Re-Added eol-style:native properties to the repository. The settings got lost when we merged from Playground to Official.

Added interface.cpp (plugin/pcsx2 interface) and savestate.cpp to SPU2ghz, to help clean up SPU2.cpp.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@463 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-02-09 21:15:56 +00:00
parent d2ef18113c
commit 6ebfae8ef1
1342 changed files with 489269 additions and 476563 deletions

View File

@ -1,31 +0,0 @@
CC = gcc
MKISO = mkiso.exe
OPTIMIZE = -O2 -fomit-frame-pointer -finline-functions -ffast-math -fno-strict-aliasing
CFLAGS = -Wall ${OPTIMIZE} -I.. -I. -D__WIN32__ -I../zlib -I../bzip2
OBJS = mkiso.o ../libiso.o
LIBS =
OBJS+= ../zlib/adler32.o ../zlib/compress.o ../zlib/crc32.o ../zlib/gzio.o ../zlib/uncompr.o ../zlib/deflate.o ../zlib/trees.o \
../zlib/zutil.o ../zlib/inflate.o ../zlib/infback.o ../zlib/inftrees.o ../zlib/inffast.o
OBJS+= ../bzip2/blocksort.o ../bzip2/huffman.o \
../bzip2/crctable.o ../bzip2/randtable.o \
../bzip2/compress.o ../bzip2/decompress.o \
../bzip2/bzlib.o
DEPS:= $(OBJS:.o=.d)
all: mkiso
mkiso: ${OBJS}
rm -f ${MKISO}
${CC} ${CFLAGS} ${OBJS} -o ${MKISO} ${LIBS}
strip ${MKISO}
clean:
rm -f ${OBJS} ${DEPS} ${MKISO}
%.o: %.c
${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@)
-include ${DEPS}

View File

@ -1,367 +1,734 @@
/* 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,46 +1,92 @@
/* 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

@ -1,29 +1,58 @@
/* 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,45 +1,90 @@
/* 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,106 +1,212 @@
/* 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) { gint AboutBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
if(aboutbox.window != NULL) { 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,39 +1,78 @@
/* 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,222 +1,444 @@
/* 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,50 +1,100 @@
/* 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,415 +1,830 @@
/* 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() { void MainBoxDestroy() {
if(mainbox.window != NULL) { 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,24 +1,48 @@
/* 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 ConversionBoxRefocus() { return; }
void DeviceBoxRefocus() { return; } void DeviceBoxRefocus() { return; }

View File

@ -1,204 +1,408 @@
/* 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

@ -1,388 +1,776 @@
/* 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() { void ConversionBoxDestroy() {
if(conversionbox.window != NULL) { 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,47 +1,94 @@
/* 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

@ -1,69 +1,138 @@
/* 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,443 +1,886 @@
/* 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() { void DeviceBoxDestroy() {
if(devicebox.window != NULL) { 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,50 +1,100 @@
/* 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,67 +1,134 @@
/* 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,29 +1,58 @@
/* 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,90 +1,180 @@
/* 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,324 +1,648 @@
/* 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() { void MainBoxDestroy() {
if(mainbox.window != NULL) { 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

@ -1,113 +1,226 @@
/* 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() { void MessageBoxDestroy() {
if(messagebox.window != NULL) { 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

@ -1,144 +1,288 @@
/* 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() { void ProgressBoxDestroy() {
if(progressbox.window != NULL) { 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

@ -1,102 +1,204 @@
/* 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() { void SelectionBoxDestroy() {
if(selectionbox.window != NULL) { 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

@ -1,190 +1,380 @@
/* 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

@ -1,44 +1,88 @@
/* 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

@ -1,36 +1,72 @@
/* 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,37 +1,74 @@
/* 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,59 +0,0 @@
all: plugin
PLUGIN = CDVDisoEFP.dll
CC = mingw32-gcc.exe
PLUGINOBJS = CDVDiso.o mainbox.o tablerebuild.o progressbox.o conversionbox.o \
devicebox.o device.o DVD.o CD.o
PLUGINHEADERS = CDVDiso.h mainbox.h tablerebuild.h progressbox.h conversionbox.h \
devicebox.h device.h DVD.h CD.h
PLUGINFLAGS = -Wall -O2 -D_WIN32 -D_LARGEFILE64_SOURCE -I.. -I. -I./Win32 -mwindows
PLUGINLIBS = -L./ -lcomctl32 -lwsock32 -lwinmm -lgdi32 -lcomdlg32 -lkernel32 \
-luser32 --subsystem,windows
# Note: Don't think we need all the above libs... will pare down later.
SHAREDOBJS = ..\\version.o conf.o ..\\isofile.o actualfile.o logfile.o \
..\\imagetype.o ..\\multifile.o ..\\isocompress.o ..\\convert.o \
..\\gzipv1.o ..\\blockv2.o ..\\gzipv2.o ..\\bzip2v2.o ..\\ecma119.o \
..\\toc.o ..\\ini.o ..\\bzip2v3.o \
..\\zlib\\adler32.o ..\\zlib\\compress.o ..\\zlib\\crc32.o \
..\\zlib\\gzio.o ..\\zlib\\uncompr.o ..\\zlib\\deflate.o \
..\\zlib\\trees.o ..\\zlib\\zutil.o ..\\zlib\\inflate.o \
..\\zlib\\infback.o ..\\zlib\\inftrees.o ..\\zlib\\inffast.o \
..\\bzip2\\blocksort.o ..\\bzip2\\bzlib.o ..\\bzip2\\compress.o \
..\\bzip2\\crctable.o ..\\bzip2\\decompress.o ..\\bzip2\\huffman.o \
..\\bzip2\\randtable.o
SHAREDHEADERS = ..\\version.h conf.h ..\\isofile.h actualfile.h logfile.h \
..\\imagetype.h ..\\multifile.h ..\\isocompress.h ..\\convert.h \
..\\gzipv1.h ..\\blockv2.o ..\\gzipv2.h ..\\bzip2v2.h ..\\ecma119.h \
..\\toc.h ..\\ini.h ..\\bzip2v3.o
WINDRES = windres.exe
release: plugin
copy $(PLUGIN) ..\\..
plugin: $(PLUGINOBJS) $(SHAREDOBJS) screens.res
-del $(PLUGIN)
dllwrap --def plugin.def -o $(PLUGIN) $(PLUGINOBJS) screens.res $(SHAREDOBJS) $(PLUGINLIBS)
strip --strip-unneeded --strip-debug $(PLUGIN)
$(PLUGINOBJS) $(SHAREDOBJS): %.o: %.c
$(CC) $(PLUGINFLAGS) -c $< -o $@
screens.res: screens.rc
$(WINDRES) -i screens.rc -J rc -o screens.res -O coff
.PHONY : clean allclean
clean:
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
allclean:
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
-del temp.txt err.txt ..\\temp.txt ..\\err.txt
-del ..\\..\\$(PLUGIN)

View File

@ -1,57 +0,0 @@
PLUGIN = CDVDisoEFP.dll
PLUGINOBJS = CDVDiso.o mainbox.o tablerebuild.o progressbox.o conversionbox.o \
devicebox.o device.o DVD.o CD.o
PLUGINHEADERS = CDVDiso.h mainbox.h tablerebuild.h progressbox.h conversionbox.h \
devicebox.h device.h DVD.h CD.h
PLUGINFLAGS = -Wall -O2 -D_LARGEFILE64_SOURCE -I.. -I. -I./Win32 -mwindows
PLUGINLIBS = -L./ -lcomctl32 -lwsock32 -lwinmm -lgdi32 -lcomdlg32 -lkernel32 \
-luser32 --subsystem,windows
# Note: Don't think we need all the above libs... will pare down later.
SHAREDOBJS = ..\\version.o conf.o ..\\isofile.o actualfile.o logfile.o \
..\\imagetype.o ..\\multifile.o ..\\isocompress.o ..\\convert.o \
..\\gzipv1.o ..\\blockv2.o ..\\gzipv2.o ..\\bzip2v2.o ..\\ecma119.o \
..\\toc.o ..\\ini.o ..\\bzip2v3.o \
..\\zlib\\adler32.o ..\\zlib\\compress.o ..\\zlib\\crc32.o \
..\\zlib\\gzio.o ..\\zlib\\uncompr.o ..\\zlib\\deflate.o \
..\\zlib\\trees.o ..\\zlib\\zutil.o ..\\zlib\\inflate.o \
..\\zlib\\infback.o ..\\zlib\\inftrees.o ..\\zlib\\inffast.o \
..\\bzip2\\blocksort.o ..\\bzip2\\bzlib.o ..\\bzip2\\compress.o \
..\\bzip2\\crctable.o ..\\bzip2\\decompress.o ..\\bzip2\\huffman.o \
..\\bzip2\\randtable.o
SHAREDHEADERS = ..\\version.h conf.h ..\\isofile.h actualfile.h logfile.h \
..\\imagetype.h ..\\multifile.h ..\\isocompress.h ..\\convert.h \
..\\gzipv1.h ..\\blockv2.o ..\\gzipv2.h ..\\bzip2v2.h ..\\ecma119.h \
..\\toc.h ..\\ini.h ..\\bzip2v3.o
CC = mingw32-gcc.exe
WINDRES = windres.exe
all: plugin
release: plugin
copy $(PLUGIN) ..\\..
plugin: $(PLUGINOBJS) $(SHAREDOBJS) screens.res
-del $(PLUGIN)
dllwrap --def plugin.def -o $(PLUGIN) $(PLUGINOBJS) screens.res $(SHAREDOBJS) $(PLUGINLIBS)
strip --strip-unneeded --strip-debug $(PLUGIN)
$(PLUGINOBJS) $(SHAREDOBJS): %.o: %.c
$(CC) $(PLUGINFLAGS) -c $< -o $@
screens.res: screens.rc
$(WINDRES) -i screens.rc -J rc -o screens.res -O coff
.PHONY : clean allclean
clean:
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
allclean:
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
-del temp.txt err.txt ..\\temp.txt ..\\err.txt
-del ..\\..\\$(PLUGIN)

View File

@ -1,195 +1,390 @@
/* 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,54 +1,108 @@
/* 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,40 +1,80 @@
/* 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,64 +1,128 @@
/* 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,41 +1,82 @@
/* 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,119 +1,238 @@
/* 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,39 +1,78 @@
/* 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

@ -1,43 +1,86 @@
/* 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,37 +1,74 @@
/* 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,187 +1,374 @@
/* 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,32 +1,64 @@
/* 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,59 +1,118 @@
/* 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...

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,128 @@
/* 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 */

View File

@ -1,36 +1,72 @@
/* 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,43 +1,86 @@
/* 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 */

View File

@ -1,367 +1,734 @@
/* 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,46 +1,92 @@
/* 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

@ -1,31 +1,62 @@
/* CDVDlinuz.h /* CDVDlinuz.h
* Copyright (C) 2002-2005 CDVDlinuz Team * Copyright (C) 2002-2005 CDVDlinuz 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
*/ */
#ifndef __CDVDLINUZ_H__ #ifndef __CDVDLINUZ_H__
#define __CDVDLINUZ_H__ #define __CDVDLINUZ_H__
// #define VERBOSE_WARNINGS // #define VERBOSE_WARNINGS
// #define VERBOSE_FUNCTION // #define VERBOSE_FUNCTION
#define VERBOSE_DISC_INFO #define VERBOSE_DISC_INFO
#define VERBOSE_DISC_TYPE #define VERBOSE_DISC_TYPE
#define READ_AHEAD_BUFFERS 32 #define READ_AHEAD_BUFFERS 32
#endif /* __CDVDLINUZ_H__ */ #endif /* __CDVDLINUZ_H__ */

View File

@ -1,45 +1,90 @@
/* 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,106 +1,212 @@
/* 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) { gint AboutBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
if(aboutbox.window != NULL) { 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 CDVDlinuz"); gtk_window_set_title(GTK_WINDOW(aboutbox.window), "About CDVDlinuz");
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,39 +1,78 @@
/* 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,222 +1,444 @@
/* 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,50 +1,100 @@
/* 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,57 +1,114 @@
/* 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
#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_CONF #define VERBOSE_FUNCTION_CONF
// Configuration Data // Configuration Data
typedef struct { typedef struct {
u8 devicename[256]; u8 devicename[256];
} CDVDconf; } CDVDconf;
extern CDVDconf conf; extern CDVDconf conf;
#define DEFAULT_DEVICE "/dev/cdrom" #define DEFAULT_DEVICE "/dev/cdrom"
// 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,69 +1,138 @@
/* 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,57 +1,114 @@
/* 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"
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();
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,90 +1,180 @@
/* 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,35 +1,70 @@
/* 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
#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, ...);
#endif /* LOGFILE_H */ #endif /* LOGFILE_H */

View File

@ -1,187 +1,374 @@
/* 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 <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/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/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/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 "logfile.h" // #include "logfile.h"
#include "device.h" // DeviceOpen(), DeviceClose() #include "device.h" // DeviceOpen(), DeviceClose()
#include "mainbox.h" #include "mainbox.h"
struct MainBoxData mainbox; struct MainBoxData mainbox;
void MainBoxDestroy() { void MainBoxDestroy() {
if(mainbox.window != NULL) { if(mainbox.window != NULL) {
gtk_widget_destroy(mainbox.window); gtk_widget_destroy(mainbox.window);
mainbox.window = NULL; mainbox.window = NULL;
mainbox.device = NULL; mainbox.device = NULL;
mainbox.desc = NULL; mainbox.desc = 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.device, FALSE); gtk_widget_set_sensitive(mainbox.device, FALSE);
gtk_window_iconify(GTK_WINDOW(mainbox.window)); gtk_window_iconify(GTK_WINDOW(mainbox.window));
} // END MainBoxUnfocus() } // END MainBoxUnfocus()
gint MainBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data) { gint MainBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
struct stat filestat; struct stat filestat;
int retval; int retval;
retval = stat(gtk_entry_get_text(GTK_ENTRY(mainbox.device)), &filestat); retval = stat(gtk_entry_get_text(GTK_ENTRY(mainbox.device)), &filestat);
if(retval == -1) { if(retval == -1) {
gtk_label_set_text(GTK_LABEL(mainbox.desc), "Device Type: ---"); gtk_label_set_text(GTK_LABEL(mainbox.desc), "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(mainbox.desc), "Device Type: Not a device"); gtk_label_set_text(GTK_LABEL(mainbox.desc), "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(mainbox.desc), "Device Type: Device Likely"); gtk_label_set_text(GTK_LABEL(mainbox.desc), "Device Type: Device Likely");
return(TRUE); return(TRUE);
} // END MainBoxFileEvent() } // END MainBoxFileEvent()
void MainBoxRefocus() { void MainBoxRefocus() {
GdkEvent event; GdkEvent event;
MainBoxDeviceEvent(NULL, event, NULL); MainBoxDeviceEvent(NULL, event, NULL);
gtk_widget_set_sensitive(mainbox.device, TRUE); gtk_widget_set_sensitive(mainbox.device, TRUE);
gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.device); gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.device);
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) {
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 *tempdevice; const char *tempdevice;
int retval; int retval;
MainBoxUnfocus(); MainBoxUnfocus();
tempdevice = gtk_entry_get_text(GTK_ENTRY(mainbox.device)); tempdevice = gtk_entry_get_text(GTK_ENTRY(mainbox.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;
if(*(conf.devicename) != 0) { if(*(conf.devicename) != 0) {
retval = DeviceOpen(); // Test by opening the device. retval = DeviceOpen(); // Test by opening the device.
DeviceClose(); // Failed or not, close it. DeviceClose(); // Failed or not, close it.
if(retval != 0) { if(retval != 0) {
MainBoxRefocus(); MainBoxRefocus();
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?
SaveConf(); SaveConf();
MainBoxCancelEvent(widget, event, data); MainBoxCancelEvent(widget, event, data);
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), "CDVDlinuz Configuration"); gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDlinuz 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("CD/DVD Device:"); item = gtk_label_new("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;
mainbox.device = gtk_entry_new(); mainbox.device = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.device, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), mainbox.device, TRUE, TRUE, 0);
gtk_widget_show(mainbox.device); gtk_widget_show(mainbox.device);
g_signal_connect(G_OBJECT(mainbox.device), "changed", g_signal_connect(G_OBJECT(mainbox.device), "changed",
G_CALLBACK(MainBoxDeviceEvent), NULL); G_CALLBACK(MainBoxDeviceEvent), 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_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("Ok"); item = gtk_button_new_with_label("Ok");
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(MainBoxOKEvent), NULL); G_CALLBACK(MainBoxOKEvent), 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.device), conf.devicename); gtk_entry_set_text(GTK_ENTRY(mainbox.device), conf.devicename);
} // END MainBoxDisplay() } // END MainBoxDisplay()

View File

@ -1,41 +1,82 @@
/* 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 <gtk/gtkwidget.h> #include <gtk/gtkwidget.h>
struct MainBoxData { struct MainBoxData {
GtkWidget *window; // GtkWindow GtkWidget *window; // GtkWindow
GtkWidget *device; // GtkEntry GtkWidget *device; // GtkEntry
GtkWidget *desc; // GtkLabel GtkWidget *desc; // GtkLabel
}; };
extern struct MainBoxData mainbox; extern struct MainBoxData mainbox;
// extern void MainBoxRefocus(); // extern void MainBoxRefocus();
extern void MainBoxDisplay(); extern void MainBoxDisplay();
#endif /* MAINBOX_H */ #endif /* MAINBOX_H */

View File

@ -1,43 +1,86 @@
#ifndef __PS2ETYPES_H__ #ifndef __PS2ETYPES_H__
#define __PS2ETYPES_H__ #define __PS2ETYPES_H__
// Basic types // Basic types
#if defined(__MSCW32__) #if defined(__MSCW32__)
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
#elif defined(__LINUX__) || defined(__MINGW32__) #elif defined(__LINUX__) || defined(__MINGW32__)
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 #endif
#endif
#endif /* __PS2ETYPES_H__ */ #endif /* __PS2ETYPES_H__ */

View File

@ -1,387 +1,774 @@
/* 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("CDVDlinuz CD: CDreadTrack(%llu, %i)", lsn, actualcdmode); PrintLog("CDVDlinuz 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("CDVDlinuz CD: Couldn't read a sector raw!"); PrintLog("CDVDlinuz CD: Couldn't read a sector raw!");
PrintError("CDVDlinuz CD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz CD: Couldn't read a cooked sector!"); PrintLog("CDVDlinuz CD: Couldn't read a cooked sector!");
PrintError("CDVDlinuz CD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz CD: Short block! only got %u out of %u bytes", PrintLog("CDVDlinuz CD: Short block! only got %u out of %u bytes",
byteswritten, cdblocksize); byteswritten, cdblocksize);
PrintError("CDVDlinuz CD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz CD: Same mode doesn't work. Scanning..."); PrintLog("CDVDlinuz 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("CDVDlinuz CD: No modes work. Failing sector!"); PrintLog("CDVDlinuz 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("CDVDlinuz CD: CDgetTD()"); PrintLog("CDVDlinuz 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("CDVDlinuz CD: CDgetDiskType()"); PrintLog("CDVDlinuz 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("CDVDlinuz CD: ISO9660 size %llu", volumesize); PrintLog("CDVDlinuz 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("CDVDlinuz CD: Can't get TOC!"); PrintLog("CDVDlinuz CD: Can't get TOC!");
PrintError("CDVDlinuz CD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz CD: TOC First Track: %u Last Track: %u", PrintLog("CDVDlinuz 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("CDVDlinuz CD: TOC Track %u Disc Size: %u:%u.%u Data Mode %u", PrintLog("CDVDlinuz 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("CDVDlinuz CD: TOC Disc Size: %u:%u.%u", PrintLog("CDVDlinuz 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,44 +1,88 @@
/* 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

@ -1,434 +1,868 @@
/* CDVDlinuz.c /* CDVDlinuz.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> // BOOL, CALLBACK, APIENTRY #include <windows.h> // BOOL, CALLBACK, APIENTRY
#include <windef.h> // NULL #include <windef.h> // NULL
#include <time.h> // time(), time_t #include <time.h> // time(), time_t
#define CDVDdefs #define CDVDdefs
#include "../PS2Edefs.h" #include "../PS2Edefs.h"
#include "device.h" #include "device.h"
#include "CD.h" #include "CD.h"
#include "DVD.h" #include "DVD.h"
#include "../buffer.h" #include "../buffer.h"
#include "../convert.h" #include "../convert.h"
#include "conf.h" #include "conf.h"
#include "logfile.h" #include "logfile.h"
#include "../version.h" #include "../version.h"
#include "screens.h" #include "screens.h"
#include "mainbox.h" // Initialize mainboxwindow #include "mainbox.h" // Initialize mainboxwindow
#include "CDVDlinuz.h" #include "CDVDlinuz.h"
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;
return(TRUE); return(TRUE);
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
// CDVDshutdown(); // CDVDshutdown();
return(TRUE); return(TRUE);
break; break;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
return(TRUE); return(TRUE);
break; break;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
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() {
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("CDVDlinuz interface: CDVDinit()"); PrintLog("CDVDlinuz interface: CDVDinit()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
InitConf(); InitConf();
DeviceInit(); DeviceInit();
InitCDInfo(); InitCDInfo();
InitDVDInfo(); InitDVDInfo();
mainboxwindow = NULL; mainboxwindow = NULL;
return(0); return(0);
} // END CDVDinit() } // END CDVDinit()
void CALLBACK CDVDshutdown() { void CALLBACK CDVDshutdown() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDshutdown()"); PrintLog("CDVDlinuz interface: CDVDshutdown()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
DeviceClose(); DeviceClose();
// Close Windows as well? (Just in case) // Close Windows as well? (Just in case)
CloseLog(); CloseLog();
} // END CDVDshutdown() } // END CDVDshutdown()
s32 CALLBACK CDVDopen() { s32 CALLBACK CDVDopen() {
int retval; int retval;
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDopen()"); PrintLog("CDVDlinuz interface: CDVDopen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
InitBuffer(); InitBuffer();
LoadConf(); LoadConf();
retval = DeviceOpen(); retval = DeviceOpen();
if(retval == 0) { if(retval == 0) {
DeviceTrayStatus(); DeviceTrayStatus();
} // ENDIF- Did we open the device? Poll for media. } // ENDIF- Did we open the device? Poll for media.
return(retval); return(retval);
} // END CDVDopen() } // END CDVDopen()
void CALLBACK CDVDclose() { void CALLBACK CDVDclose() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDclose()"); PrintLog("CDVDlinuz interface: CDVDclose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
DeviceClose(); DeviceClose();
} // 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("CDVDlinuz interface: CDVDreadSubQ()"); PrintLog("CDVDlinuz interface: CDVDreadSubQ()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() != 0) return(-1); if(DiscInserted() != 0) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) { if((disctype == CDVD_TYPE_PS2DVD) || (disctype == 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(tocbuffer[7]); i = BCDTOHEX(tocbuffer[7]);
pos = i * 10; pos = i * 10;
pos += 30; pos += 30;
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]);
tracklsn = MSFtoLBA(temptime); tracklsn = MSFtoLBA(temptime);
while((i < BCDTOHEX(tocbuffer[17])) && (tracklsn < lsn)) { while((i < BCDTOHEX(tocbuffer[17])) && (tracklsn < lsn)) {
i++; i++;
pos = i * 10; pos = i * 10;
pos += 30; pos += 30;
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]);
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);
subq->trackIndex = HEXTOBCD(i); subq->trackIndex = HEXTOBCD(i);
LBAtoMSF(lsn - tracklsn, temptime); LBAtoMSF(lsn - tracklsn, temptime);
subq->trackM = HEXTOBCD(temptime[0]); subq->trackM = HEXTOBCD(temptime[0]);
subq->trackS = HEXTOBCD(temptime[1]); subq->trackS = HEXTOBCD(temptime[1]);
subq->trackF = HEXTOBCD(temptime[2]); subq->trackF = HEXTOBCD(temptime[2]);
subq->pad = 0; subq->pad = 0;
// lba_to_msf(lsn + (2*75), &min, &sec, &frm); // lba_to_msf(lsn + (2*75), &min, &sec, &frm);
LBAtoMSF(lsn, temptime); LBAtoMSF(lsn, temptime);
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("CDVDlinuz interface: CDVDgetTN()"); PrintLog("CDVDlinuz interface: CDVDgetTN()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() != 0) return(-1); if(DiscInserted() != 0) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) { if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
Buffer->strack = 1; Buffer->strack = 1;
Buffer->etrack = 1; Buffer->etrack = 1;
} else { } else {
Buffer->strack = BCDTOHEX(tocbuffer[7]); Buffer->strack = BCDTOHEX(tocbuffer[7]);
Buffer->etrack = BCDTOHEX(tocbuffer[17]); Buffer->etrack = BCDTOHEX(tocbuffer[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) {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetTD()"); PrintLog("CDVDlinuz interface: CDVDgetTD()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(DeviceGetTD(track, buffer)); return(DeviceGetTD(track, buffer));
} // 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("CDVDlinuz interface: CDVDgetTOC()"); PrintLog("CDVDlinuz interface: CDVDgetTOC()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() != 0) return(-1); if(DiscInserted() != 0) return(-1);
for(i = 0; i < 2048; i++) *(((char *) toc) + i) = tocbuffer[i]; for(i = 0; i < 2048; i++) *(((char *) toc) + i) = tocbuffer[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("CDVDlinuz interface: CDVDreadTrack(%u)", lsn); PrintLog("CDVDlinuz interface: CDVDreadTrack(%u)", lsn);
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() == -1) return(-1); if(DiscInserted() == -1) return(-1);
if(userbuffer < BUFFERMAX) { if(userbuffer < BUFFERMAX) {
if((bufferlist[userbuffer].lsn == lsn) && if((bufferlist[userbuffer].lsn == lsn) &&
(bufferlist[userbuffer].mode == mode)) { (bufferlist[userbuffer].mode == mode)) {
return(0); return(0);
} // ENDIF- And it's the right one? } // ENDIF- And it's the right one?
} // ENDIF- Are we already pointing at the buffer? } // ENDIF- Are we already pointing at the buffer?
userbuffer = FindListBuffer(lsn); userbuffer = FindListBuffer(lsn);
if(userbuffer < BUFFERMAX) { if(userbuffer < BUFFERMAX) {
if((bufferlist[userbuffer].lsn == lsn) && if((bufferlist[userbuffer].lsn == lsn) &&
(bufferlist[userbuffer].mode == mode)) { (bufferlist[userbuffer].mode == mode)) {
return(0); return(0);
} // ENDIF- And it was the right one? } // ENDIF- And it was the right one?
} // ENDIF- Was a buffer found in the cache? } // ENDIF- Was a buffer found in the cache?
replacebuffer++; replacebuffer++;
if(replacebuffer >= BUFFERMAX) replacebuffer = 0; if(replacebuffer >= BUFFERMAX) replacebuffer = 0;
userbuffer = replacebuffer; userbuffer = replacebuffer;
if(bufferlist[replacebuffer].upsort != 0xffff) { if(bufferlist[replacebuffer].upsort != 0xffff) {
RemoveListBuffer(replacebuffer); RemoveListBuffer(replacebuffer);
} // ENDIF- Reference already in place? Remove it. } // ENDIF- Reference already in place? Remove it.
retval = DeviceReadTrack(lsn, mode, bufferlist[replacebuffer].buffer); retval = DeviceReadTrack(lsn, mode, bufferlist[replacebuffer].buffer);
bufferlist[replacebuffer].lsn = lsn; bufferlist[replacebuffer].lsn = lsn;
bufferlist[replacebuffer].mode = mode; bufferlist[replacebuffer].mode = mode;
bufferlist[replacebuffer].offset = DeviceBufferOffset(); bufferlist[replacebuffer].offset = DeviceBufferOffset();
if(retval != 0) { if(retval != 0) {
bufferlist[replacebuffer].mode = -1; // Error! flag buffer as such. bufferlist[replacebuffer].mode = -1; // Error! flag buffer as such.
} else { } else {
if((disctype != CDVD_TYPE_PS2DVD) && (disctype != CDVD_TYPE_DVDV)) { if((disctype != CDVD_TYPE_PS2DVD) && (disctype != CDVD_TYPE_DVDV)) {
if(mode == CDVD_MODE_2352) { if(mode == CDVD_MODE_2352) {
CDreadSubQ(lsn, &bufferlist[replacebuffer].subq); CDreadSubQ(lsn, &bufferlist[replacebuffer].subq);
} // ENDIF- Read subq as well? } // ENDIF- Read subq as well?
} // ENDIF- Read a DVD buffer or a CD buffer? } // ENDIF- Read a DVD buffer or a CD buffer?
} // ENDIF-Read ok? Fill out rest of buffer info. } // ENDIF-Read ok? Fill out rest of buffer info.
AddListBuffer(replacebuffer); AddListBuffer(replacebuffer);
return(retval); return(retval);
} // END CDVDreadTrack() } // END CDVDreadTrack()
u8* CALLBACK CDVDgetBuffer() { u8* CALLBACK CDVDgetBuffer() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetBuffer()"); PrintLog("CDVDlinuz interface: CDVDgetBuffer()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() == -1) return(NULL); if(DiscInserted() == -1) return(NULL);
if(userbuffer == 0xffff) { if(userbuffer == 0xffff) {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVDlinuz interface: Not pointing to a buffer!"); PrintLog("CDVDlinuz interface: Not pointing to a buffer!");
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(NULL); // No buffer reference? return(NULL); // No buffer reference?
} // ENDIF- user buffer not pointing at anything? Abort } // ENDIF- user buffer not pointing at anything? Abort
if(bufferlist[userbuffer].mode < 0) { if(bufferlist[userbuffer].mode < 0) {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVDlinuz interface: Error retrieving sector (ReadTrack call)"); PrintLog("CDVDlinuz interface: Error retrieving sector (ReadTrack call)");
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
return(NULL); // Bad Sector? return(NULL); // Bad Sector?
} // ENDIF- Trouble reading physical sector? Tell them. } // ENDIF- Trouble reading physical sector? Tell them.
return(bufferlist[userbuffer].buffer + bufferlist[userbuffer].offset); return(bufferlist[userbuffer].buffer + bufferlist[userbuffer].offset);
} // END CDVDgetBuffer() } // END CDVDgetBuffer()
s32 CALLBACK CDVDgetDiskType() { s32 CALLBACK CDVDgetDiskType() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetDiskType()"); PrintLog("CDVDlinuz interface: CDVDgetDiskType()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if(lasttime != time(NULL)) { if(lasttime != time(NULL)) {
lasttime = time(NULL); lasttime = time(NULL);
DeviceTrayStatus(); DeviceTrayStatus();
} // ENDIF- Has enough time passed between calls? } // ENDIF- Has enough time passed between calls?
return(disctype); return(disctype);
} // END CDVDgetDiskType() } // END CDVDgetDiskType()
s32 CALLBACK CDVDgetTrayStatus() { s32 CALLBACK CDVDgetTrayStatus() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetTrayStatus()"); PrintLog("CDVDlinuz interface: CDVDgetTrayStatus()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
if(lasttime != time(NULL)) { if(lasttime != time(NULL)) {
lasttime = time(NULL); lasttime = time(NULL);
DeviceTrayStatus(); DeviceTrayStatus();
} // ENDIF- Has enough time passed between calls? } // ENDIF- Has enough time passed between calls?
return(traystatus); return(traystatus);
} // END CDVDgetTrayStatus() } // END CDVDgetTrayStatus()
s32 CALLBACK CDVDctrlTrayOpen() { s32 CALLBACK CDVDctrlTrayOpen() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDctrlTrayOpen()"); PrintLog("CDVDlinuz interface: CDVDctrlTrayOpen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(DeviceTrayOpen()); return(DeviceTrayOpen());
} // END CDVDctrlTrayOpen() } // END CDVDctrlTrayOpen()
s32 CALLBACK CDVDctrlTrayClose() { s32 CALLBACK CDVDctrlTrayClose() {
#ifdef VERBOSE_FUNCTION_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDctrlTrayClose()"); PrintLog("CDVDlinuz interface: CDVDctrlTrayClose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
return(DeviceTrayClose()); return(DeviceTrayClose());
} // END CDVDctrlTrayClose() } // END CDVDctrlTrayClose()
s32 CALLBACK CDVDtest() { s32 CALLBACK CDVDtest() {
int retval; int retval;
errno = 0; errno = 0;
if(devicehandle != NULL) { if(devicehandle != NULL) {
#ifdef VERBOSE_WARNINGS #ifdef VERBOSE_WARNINGS
PrintLog("CDVDlinuz interface: Device already open"); PrintLog("CDVDlinuz interface: Device already open");
#endif /* VERBOSE_WARNINGS */ #endif /* VERBOSE_WARNINGS */
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_INTERFACE #ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDtest()"); PrintLog("CDVDlinuz interface: CDVDtest()");
#endif /* VERBOSE_FUNCTION_INTERFACE */ #endif /* VERBOSE_FUNCTION_INTERFACE */
retval = DeviceOpen(); retval = DeviceOpen();
DeviceClose(); DeviceClose();
return(retval); return(retval);
} // 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),
lastwindow, lastwindow,
(DLGPROC)MainBoxCallback); (DLGPROC)MainBoxCallback);
SetActiveWindow(lastwindow); SetActiveWindow(lastwindow);
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),
lastwindow, lastwindow,
(DLGPROC)AboutCallback); (DLGPROC)AboutCallback);
SetActiveWindow(lastwindow); SetActiveWindow(lastwindow);
return; return;
} // END CDVDabout() } // END CDVDabout()

View File

@ -1,40 +1,80 @@
/* CDVDlinuz.h /* CDVDlinuz.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 CDVDLINUZ_H #ifndef CDVDLINUZ_H
#define CDVDLINUZ_H #define CDVDLINUZ_H
#include <windows.h> // HINSTANCE #include <windows.h> // HINSTANCE
// #define VERBOSE_WARNINGS // #define VERBOSE_WARNINGS
// #define VERBOSE_FUNCTION_INTERFACE // #define VERBOSE_FUNCTION_INTERFACE
#define VERBOSE_DISC_INFO #define VERBOSE_DISC_INFO
#define VERBOSE_DISC_TYPE #define VERBOSE_DISC_TYPE
#define READ_AHEAD_BUFFERS 32 #define READ_AHEAD_BUFFERS 32
extern HINSTANCE progmodule; extern HINSTANCE progmodule;
#endif /* CDVDLINUZ_H */ #endif /* CDVDLINUZ_H */

View File

@ -1,398 +1,796 @@
/* 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("CDVDlinuz DVD: DVDgetStructures()"); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Couldn't start session!"); PrintLog("CDVDlinuz DVD: Couldn't start session!");
PrintError("CDVDlinuz DVD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz DVD: Couldn't get layer data!"); PrintLog("CDVDlinuz DVD: Couldn't get layer data!");
PrintError("CDVDlinuz DVD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz DVD: Book Type: DVD-ROM"); PrintLog("CDVDlinuz DVD: Book Type: DVD-ROM");
break; break;
case 1: case 1:
PrintLog("CDVDlinuz DVD: Book Type: DVD-RAM"); PrintLog("CDVDlinuz DVD: Book Type: DVD-RAM");
break; break;
case 2: case 2:
PrintLog("CDVDlinuz DVD: Book Type: DVD-R"); PrintLog("CDVDlinuz DVD: Book Type: DVD-R");
break; break;
case 3: case 3:
PrintLog("CDVDlinuz DVD: Book Type: DVD-RW"); PrintLog("CDVDlinuz DVD: Book Type: DVD-RW");
break; break;
case 9: case 9:
PrintLog("CDVDlinuz DVD: Book Type: DVD+RW"); PrintLog("CDVDlinuz DVD: Book Type: DVD+RW");
break; break;
default: default:
PrintLog("CDVDlinuz DVD: Book Type: Unknown (%i)", layer.d.BookType); PrintLog("CDVDlinuz DVD: Book Type: Unknown (%i)", layer.d.BookType);
break; break;
} // ENDSWITCH- Displaying the Book Type } // ENDSWITCH- Displaying the Book Type
PrintLog("CDVDlinuz DVD: Book Version %i", layer.d.BookVersion); PrintLog("CDVDlinuz DVD: Book Version %i", layer.d.BookVersion);
switch(layer.d.MinimumRate) { switch(layer.d.MinimumRate) {
case 0: case 0:
PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-ROM"); PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-ROM");
break; break;
case 1: case 1:
PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-RAM"); PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-RAM");
break; break;
case 2: case 2:
PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-R"); PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-R");
break; break;
case 3: case 3:
PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-RW"); PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD-RW");
break; break;
case 9: case 9:
PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD+RW"); PrintLog("CDVDlinuz DVD: Use Minimum Rate for: DVD+RW");
break; break;
default: default:
PrintLog("CDVDlinuz DVD: Use Minimum Rate for: Unknown (%i)", layer.d.MinimumRate); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Physical Disk Size: 120mm"); PrintLog("CDVDlinuz DVD: Physical Disk Size: 120mm");
break; break;
case 1: case 1:
PrintLog("CDVDlinuz DVD: Physical Disk Size: 80mm"); PrintLog("CDVDlinuz DVD: Physical Disk Size: 80mm");
break; break;
default: default:
PrintLog("CDVDlinuz DVD: Physical Disk Size: Unknown (%i)", layer.d.DiskSize); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Layer Type: Read-Only"); PrintLog("CDVDlinuz DVD: Layer Type: Read-Only");
break; break;
case 2: case 2:
PrintLog("CDVDlinuz DVD: Layer Type: Recordable"); PrintLog("CDVDlinuz DVD: Layer Type: Recordable");
break; break;
case 4: case 4:
PrintLog("CDVDlinuz DVD: Layer Type: Rewritable"); PrintLog("CDVDlinuz DVD: Layer Type: Rewritable");
break; break;
default: default:
PrintLog("CDVDlinuz DVD: Layer Type: Unknown (%i)", layer.d.LayerType); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Track Path: PTP"); PrintLog("CDVDlinuz DVD: Track Path: PTP");
break; break;
case 1: case 1:
PrintLog("CDVDlinuz DVD: Track Path: OTP"); PrintLog("CDVDlinuz DVD: Track Path: OTP");
break; break;
default: default:
PrintLog("CDVDlinuz DVD: Track Path: Unknown (%i)", layer.d.TrackPath); PrintLog("CDVDlinuz DVD: Track Path: Unknown (%i)", layer.d.TrackPath);
break; break;
} // ENDSWITCH- What's Track Path Layout? } // ENDSWITCH- What's Track Path Layout?
PrintLog("CDVDlinuz DVD: Number of Layers: %i", layer.d.NumberOfLayers + 1); PrintLog("CDVDlinuz DVD: Number of Layers: %i", layer.d.NumberOfLayers + 1);
switch(layer.d.TrackDensity) { switch(layer.d.TrackDensity) {
case 0: case 0:
PrintLog("CDVDlinuz DVD: Track Density: .74 m/track"); PrintLog("CDVDlinuz DVD: Track Density: .74 m/track");
break; break;
case 1: case 1:
PrintLog("CDVDlinuz DVD: Track Density: .8 m/track"); PrintLog("CDVDlinuz DVD: Track Density: .8 m/track");
break; break;
case 2: case 2:
PrintLog("CDVDlinuz DVD: Track Density: .615 m/track"); PrintLog("CDVDlinuz DVD: Track Density: .615 m/track");
break; break;
default: default:
PrintLog("CDVDlinuz DVD: Track Density: Unknown (%i)", layer.d.TrackDensity); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Linear Density: .267 m/bit"); PrintLog("CDVDlinuz DVD: Linear Density: .267 m/bit");
break; break;
case 1: case 1:
PrintLog("CDVDlinuz DVD: Linear Density: .293 m/bit"); PrintLog("CDVDlinuz DVD: Linear Density: .293 m/bit");
break; break;
case 2: case 2:
PrintLog("CDVDlinuz DVD: Linear Density: .409 to .435 m/bit"); PrintLog("CDVDlinuz DVD: Linear Density: .409 to .435 m/bit");
break; break;
case 4: case 4:
PrintLog("CDVDlinuz DVD: Linear Density: .280 to .291 m/bit"); PrintLog("CDVDlinuz DVD: Linear Density: .280 to .291 m/bit");
break; break;
case 8: case 8:
PrintLog("CDVDlinuz DVD: Linear Density: .353 m/bit"); PrintLog("CDVDlinuz DVD: Linear Density: .353 m/bit");
break; break;
default: default:
PrintLog("CDVDlinuz DVD: Linear Density: Unknown (%i)", layer.d.LinearDensity); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Starting Sector: %lu (DVD-ROM, DVD-R, DVD-RW)", PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Starting Sector: %lu (DVD-RAM, DVD+RW)", PrintLog("CDVDlinuz DVD: Starting Sector: %lu (DVD-RAM, DVD+RW)",
layer.d.StartingDataSector); layer.d.StartingDataSector);
} else { } else {
PrintLog("CDVDlinuz DVD: Starting Sector: %lu", layer.d.StartingDataSector); PrintLog("CDVDlinuz DVD: Starting Sector: %lu", layer.d.StartingDataSector);
} // ENDLONGIF- What does the starting sector tell us? } // ENDLONGIF- What does the starting sector tell us?
PrintLog("CDVDlinuz DVD: End of Layer 0: %lu", layer.d.EndLayerZeroSector); PrintLog("CDVDlinuz DVD: End of Layer 0: %lu", layer.d.EndLayerZeroSector);
PrintLog("CDVDlinuz DVD: Ending Sector: %lu", layer.d.EndDataSector); PrintLog("CDVDlinuz DVD: Ending Sector: %lu", layer.d.EndDataSector);
if(layer.d.BCAFlag != 0) PrintLog("CDVDlinuz DVD: BCA data present"); if(layer.d.BCAFlag != 0) PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Couldn't end the session!"); PrintLog("CDVDlinuz DVD: Couldn't end the session!");
PrintError("CDVDlinuz DVD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz DVD: DVDreadTrack(%lu)", lsn); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Couldn't read sector!"); PrintLog("CDVDlinuz DVD: Couldn't read sector!");
PrintError("CDVDlinuz DVD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz CD: Short block! only got %u out of %u bytes", PrintLog("CDVDlinuz CD: Short block! only got %u out of %u bytes",
byteswritten, 2048); byteswritten, 2048);
PrintError("CDVDlinuz CD", errcode); PrintError("CDVDlinuz 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("CDVDlinuz DVD: DVDgetTN()"); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: DVDgetTD()"); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: DVDgetDiskType()"); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Found Single-Sided DVD."); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Found Dual-Sided DVD."); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Found Playstation 2 DVD."); PrintLog("CDVDlinuz 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("CDVDlinuz DVD: Guessing it's a Video DVD."); PrintLog("CDVDlinuz 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,37 +1,74 @@
/* 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,43 +0,0 @@
PLUGIN = CDVDlinuz.dll
PLUGINOBJS = CDVDlinuz.o mainbox.o
PLUGINHEADERS = CDVDlinuz.h mainbox.h
PLUGINFLAGS = -Wall -O2 -D_LARGEFILE64_SOURCE -I.. -I. -I.\\Win32
PLUGINLIBS =
# In this case, SHARED marks files that don't need Windows Display components
SHAREDOBJS = device.o CD.o DVD.o logfile.o actualfile.o conf.o \
..\\ini.o ..\\buffer.o ..\\version.o ..\\convert.o
SHAREDHEADERS = device.h CD.h DVD.h logfile.h actualfile.h conf.h \
..\\ini.h ..\\buffer.h ..\\version.h ..\\convert.h
CC = mingw32-gcc.exe
WINDRES = windres.exe
all: plugin
release: plugin
copy $(PLUGIN) ..\\..
plugin: $(PLUGINOBJS) $(SHAREDOBJS) screens.res
-del $(PLUGIN)
dllwrap --def plugin.def -o $(PLUGIN) $(PLUGINOBJS) screens.res $(SHAREDOBJS) $(PLUGINLIBS)
strip --strip-unneeded --strip-debug $(PLUGIN)
$(PLUGINOBJS) $(SHAREDOBJS): %.o: %.c
$(CC) $(PLUGINFLAGS) -c $< -o $@
screens.res: screens.rc
$(WINDRES) -i screens.rc -J rc -o screens.res -O coff
.PHONY : clean allclean
clean:
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
allclean:
-del $(PLUGINOBJS) $(PLUGIN) $(SHAREDOBJS) screens.res
-del temp.txt err.txt ..\\temp.txt ..\\err.txt
-del ..\\..\\$(PLUGIN)

View File

@ -1,253 +1,506 @@
/* 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
if(bytesread < bytes) {
#ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Short Block! Only read %i out of %i bytes", bytesread, bytes);
#endif /* VERBOSE_WARNING_ACTUALFILE */
} // ENDIF- Error? Abort } // ENDIF- Error? Abort
if(bytesread < bytes) {
#ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Short Block! Only read %i out of %i bytes", bytesread, bytes);
#endif /* VERBOSE_WARNING_ACTUALFILE */
} // 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,52 +1,104 @@
/* 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
#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,175 +1,350 @@
/* 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[] = { "Device", NULL }; const char *confnames[] = { "Device", 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[] = "CDVDlinuz.ini"; const char defaultfile[] = "CDVDlinuz.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 */
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", "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
} // 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", "Device", conf.devicename); INISaveString(conffilename, "Settings", "Device", conf.devicename);
} // END SaveConf() } // END SaveConf()

View File

@ -1,49 +1,98 @@
/* 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 devicename[256]; u8 devicename[256];
} 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();
#endif /* CONF_H */ #endif /* CONF_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,128 @@
/* 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,119 +1,238 @@
/* 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,39 +1,78 @@
/* 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

@ -1,173 +1,346 @@
/* 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 <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 <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 "conf.h" #include "conf.h"
#include "device.h" #include "device.h"
// #include "imagetype.h" // imagedata[].name // #include "imagetype.h" // imagedata[].name
#include "screens.h" // DLG_, IDC_ #include "screens.h" // DLG_, IDC_
#include "CDVDlinuz.h" // progmodule #include "CDVDlinuz.h" // progmodule
#include "mainbox.h" #include "mainbox.h"
HWND mainboxwindow; HWND mainboxwindow;
void MainBoxDestroy() { void MainBoxDestroy() {
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.device, FALSE); // gtk_widget_set_sensitive(mainbox.device, FALSE);
ShowWindow(mainboxwindow, SW_HIDE); ShowWindow(mainboxwindow, SW_HIDE);
} // END MainBoxUnfocus() } // END MainBoxUnfocus()
void MainBoxDeviceEvent() { void MainBoxDeviceEvent() {
char tempdevice[256]; char tempdevice[256];
struct stat filestat; struct stat filestat;
int returnval; int returnval;
GetDlgItemText(mainboxwindow, IDC_0202, tempdevice, 256); GetDlgItemText(mainboxwindow, IDC_0202, tempdevice, 256);
returnval = stat(tempdevice, &filestat); returnval = stat(tempdevice, &filestat);
if(returnval == -1) { if(returnval == -1) {
SetDlgItemText(mainboxwindow, IDC_0203, "Device Type: ---"); SetDlgItemText(mainboxwindow, IDC_0203, "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(mainboxwindow, IDC_0203, "Device Type: Not a device"); SetDlgItemText(mainboxwindow, IDC_0203, "Device Type: Not a device");
return; return;
} // ENDIF- Not a regular file? } // ENDIF- Not a regular file?
SetDlgItemText(mainboxwindow, IDC_0203, "Device Type: Device Likely"); SetDlgItemText(mainboxwindow, IDC_0203, "Device Type: Device Likely");
return; return;
} // END MainBoxFileEvent() } // END MainBoxFileEvent()
void MainBoxRefocus() { void MainBoxRefocus() {
MainBoxDeviceEvent(); MainBoxDeviceEvent();
// gtk_widget_set_sensitive(mainbox.device, TRUE); // gtk_widget_set_sensitive(mainbox.device, TRUE);
// gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.device); // gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.device);
// ShowWindow(mainboxwindow, SW_RESTORE); // and/or, SW_SHOW? SW_SHOWNORMAL? // ShowWindow(mainboxwindow, SW_RESTORE); // and/or, SW_SHOW? SW_SHOWNORMAL?
ShowWindow(mainboxwindow, SW_SHOW); ShowWindow(mainboxwindow, SW_SHOW);
SetActiveWindow(mainboxwindow); SetActiveWindow(mainboxwindow);
} // END MainBoxRefocus() } // END MainBoxRefocus()
void MainBoxCancelEvent() { void MainBoxCancelEvent() {
MainBoxDestroy(); MainBoxDestroy();
return; return;
} // END MainBoxCancelEvent() } // END MainBoxCancelEvent()
void MainBoxOKEvent() { void MainBoxOKEvent() {
int retval; int retval;
MainBoxUnfocus(); MainBoxUnfocus();
GetDlgItemText(mainboxwindow, IDC_0202, conf.devicename, 256); GetDlgItemText(mainboxwindow, IDC_0202, conf.devicename, 256);
retval = DeviceOpen(); retval = DeviceOpen();
DeviceClose(); DeviceClose();
if(retval != 0) { if(retval != 0) {
MainBoxRefocus(); MainBoxRefocus();
MessageBox(mainboxwindow, MessageBox(mainboxwindow,
"Could not open the device", "Could not open the device",
"CDVDlinuz Message", "CDVDlinuz 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.
SaveConf(); SaveConf();
MainBoxCancelEvent(); MainBoxCancelEvent();
return; return;
} // END MainBoxOKEvent() } // END MainBoxOKEvent()
void MainBoxDisplay() { void MainBoxDisplay() {
InitConf(); // Man, am I boiling mad! CDVDinit() should have been called first! InitConf(); // Man, am I boiling mad! CDVDinit() should have been called first!
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.devicename); SetDlgItemText(mainboxwindow, IDC_0202, conf.devicename);
// 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.
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: // Devicename Edit Box case IDC_0202: // Devicename Edit Box
MainBoxDeviceEvent(); // Describe the File's type... MainBoxDeviceEvent(); // 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_0204: // "Ok" Button case IDC_0204: // "Ok" Button
MainBoxOKEvent(); MainBoxOKEvent();
return(TRUE); return(TRUE);
break; break;
case IDC_0205: // "Cancel" Button case IDC_0205: // "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,42 +1,84 @@
/* 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 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,9 +1,18 @@
/* 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

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +1,134 @@
/* buffer.h /* buffer.h
* Copyright (C) 2002-2005 CDVDlinuz Team * Copyright (C) 2002-2005 CDVDlinuz 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
*/ */
#ifndef __BUFFER_H__ #ifndef __BUFFER_H__
#define __BUFFER_H__ #define __BUFFER_H__
#define CDVDdefs #define CDVDdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
// #define VERBOSE_FUNCTION_BUFFER // #define VERBOSE_FUNCTION_BUFFER
// #define VERBOSE_WARNINGS_BUFFER // #define VERBOSE_WARNINGS_BUFFER
// Remember, each buffer set is about 5k (packed. might be 4x that in-memory) // Remember, each buffer set is about 5k (packed. might be 4x that in-memory)
// Minimum: 16 Maximum: 32760 // Minimum: 16 Maximum: 32760
#define BUFFERMAX 256 #define BUFFERMAX 256
// Buffer Structures // Buffer Structures
struct BufferList { struct BufferList {
u16 upsort; // Don't alter this variable u16 upsort; // Don't alter this variable
u16 uppos; // Don't alter this variable u16 uppos; // Don't alter this variable
u32 lsn; u32 lsn;
int mode; // -1 means error int mode; // -1 means error
u8 buffer[2368]; u8 buffer[2368];
u8 offset; u8 offset;
cdvdSubQ subq; cdvdSubQ subq;
}; };
// Exported Variables // Exported Variables
extern struct BufferList bufferlist[]; extern struct BufferList bufferlist[];
extern u16 userbuffer; extern u16 userbuffer;
extern u16 replacebuffer; extern u16 replacebuffer;
// Exported Functions // Exported Functions
extern void InitBuffer(); extern void InitBuffer();
extern u16 FindListBuffer(u32 lsn); extern u16 FindListBuffer(u32 lsn);
extern void RemoveListBuffer(u16 oldbuffer); extern void RemoveListBuffer(u16 oldbuffer);
extern void AddListBuffer(u16 newbuffer); extern void AddListBuffer(u16 newbuffer);
#ifdef VERBOSE_WARNINGS_BUFFER #ifdef VERBOSE_WARNINGS_BUFFER
extern void PrintSortBuffers(); extern void PrintSortBuffers();
#endif /* VERBOSE_WARNINGS_BUFFER */ #endif /* VERBOSE_WARNINGS_BUFFER */
#endif /* __BUFFER_H__ */ #endif /* __BUFFER_H__ */

View File

@ -1,118 +1,236 @@
/* convert.c /* convert.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>
#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];
return(newnumber.n); return(newnumber.n);
#else #else
return(number); return(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;
int i; int i;
oldnumber.n = number; oldnumber.n = number;
for(i = 0; i < sizeof(unsigned int); i++) for(i = 0; i < sizeof(unsigned int); i++)
newnumber.c[i] = oldnumber.c[sizeof(unsigned int) - 1 - i]; newnumber.c[i] = oldnumber.c[sizeof(unsigned int) - 1 - i];
return(newnumber.n); return(newnumber.n);
#else #else
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];
return(newnumber.n); return(newnumber.n);
#else #else
return(number); return(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;
} // ENDIF- Out of range? } // ENDIF- Out of range?
templsn = lsn; templsn = lsn;
templsn += 150; // 2 second offset (75 Frames * 2 Seconds) templsn += 150; // 2 second offset (75 Frames * 2 Seconds)
*(buffer + 2) = templsn % 75; // Remainder in frames *(buffer + 2) = templsn % 75; // Remainder in frames
templsn -= *(buffer + 2); templsn -= *(buffer + 2);
templsn /= 75; templsn /= 75;
*(buffer + 1) = templsn % 60; // Remainder in seconds *(buffer + 1) = templsn % 60; // Remainder in seconds
templsn -= *(buffer + 1); templsn -= *(buffer + 1);
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
templsn *= 75; templsn *= 75;
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

@ -1,50 +1,100 @@
/* convert.h /* convert.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 CONVERT_H #ifndef CONVERT_H
#define CONVERT_H #define CONVERT_H
#include <sys/types.h> // off64_t #include <sys/types.h> // off64_t
#ifdef __linux__ #ifdef __linux__
#include "endian.h" #include "endian.h"
#if __BYTE_ORDER == __LITTLE_ENDIAN #if __BYTE_ORDER == __LITTLE_ENDIAN
#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);
#endif /* CONVERT_H */ #endif /* CONVERT_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,128 @@
/* 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 */

View File

@ -1,36 +1,72 @@
/* 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 polling CDVD Driver"; char *libname = "EFP polling 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 = 4; const unsigned char build = 4;

View File

@ -1,43 +1,86 @@
/* 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 */

View File

@ -62,6 +62,7 @@ void CALLBACK SPU2configure() {
MAKEINTRESOURCE(IDD_CONFIG), MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(), GetActiveWindow(),
(DLGPROC)ConfigureDlgProc); (DLGPROC)ConfigureDlgProc);
} }
void CALLBACK SPU2about() { void CALLBACK SPU2about() {

View File

@ -62,6 +62,7 @@ void CALLBACK USBconfigure() {
MAKEINTRESOURCE(IDD_CONFIG), MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(), GetActiveWindow(),
(DLGPROC)ConfigureDlgProc); (DLGPROC)ConfigureDlgProc);
} }
void CALLBACK USBabout() { void CALLBACK USBabout() {

View File

@ -1,51 +0,0 @@
#
# Makefile for MINGW32
#
all: dev9null
PLUGIN = DEV9null.dll
CC = gcc
NASM = nasmw
RM = rm -f
AR = ar
STRIP = strip
RC = windres
OPTIMIZE = -O2 -fomit-frame-pointer -finline-functions -ffast-math -fno-strict-aliasing
FLAGS = -D__WIN32__ -D__MINGW32__ # -DENABLE_NLS -DPACKAGE=\"pcsx2\"
RC1FLAGS = -d__MINGW32__
LIBS = -L./ -lcomctl32 -lwinmm -lgdi32 -lcomdlg32 #-lintl -lwsock32
RESOBJ = dev9nullrc.o
OBJS = dev9null.o
DEPS:= $(OBJS:.o=.d)
CFLAGS = -Wall ${OPTIMIZE} -I. -I/usr/local/include ${FLAGS}
dev9null: ${OBJS}
dllwrap --def plugin.def -o ${PLUGIN} ${OBJS} ${LIBS}
# ${CC} -shared -Wl,--kill-at,--output-def,plugin.def ${CFLAGS} ${OBJS} -o ${PLUGIN} ${LIBS}
${STRIP} ${PLUGIN}
.PHONY: clean dev9null
clean:
${RM} ${OBJS} ${DEPS} ${PCSX2}
%.o: %.asm
${NASM} ${ASMFLAGS} -o $@ $<
%.o: %.c
${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@)
${RESOBJ}: DEV9null.rc
${RC} -D__MINGW32__ -I rc -O coff -o $@ -i $<
-include ${DEPS}

View File

@ -473,7 +473,6 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
AssemblerOutput="4"
BrowseInformation="1" BrowseInformation="1"
CompileAs="0" CompileAs="0"
/> />
@ -619,7 +618,6 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
AssemblerOutput="4"
BrowseInformation="1" BrowseInformation="1"
CompileAs="0" CompileAs="0"
/> />
@ -852,14 +850,26 @@
RelativePath="..\defs.h" RelativePath="..\defs.h"
> >
</File> </File>
<File
RelativePath="..\interface.cpp"
>
</File>
<File <File
RelativePath="..\regs.h" RelativePath="..\regs.h"
> >
</File> </File>
<File
RelativePath="..\regtable.cpp"
>
</File>
<File <File
RelativePath="..\regtable.h" RelativePath="..\regtable.h"
> >
</File> </File>
<File
RelativePath="..\savestate.cpp"
>
</File>
<File <File
RelativePath="..\spu2.cpp" RelativePath="..\spu2.cpp"
> >
@ -888,7 +898,6 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
AssemblerOutput="4"
BrowseInformation="1" BrowseInformation="1"
CompileAs="0" CompileAs="0"
/> />

View File

@ -0,0 +1,760 @@
//GiGaHeRz's SPU2 Driver
//Copyright (c) 2003-2008, David Quintana <gigaherz@gmail.com>
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "spu2.h"
#include "regtable.h"
#include "svnrev.h"
// [Air]: Adding the spu2init boolean wasn't necessary except to help me in
// debugging the spu2 suspend/resume behavior (when user hits escape).
static bool spu2open=false; // has spu2open plugin interface been called?
static bool spu2init=false; // has spu2init plugin interface been called?
static s32 logvolume[16384];
static u32 pClocks=0;
static const u8 version = PS2E_SPU2_VERSION;
static const u8 revision = 1;
static const u8 build = 9; // increase that with each version
static char libraryName[256];
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD dwReason,LPVOID lpvReserved)
{
if(dwReason==DLL_PROCESS_ATTACH) hInstance=hinstDLL;
return TRUE;
}
static void InitLibraryName()
{
#ifdef PUBLIC
// Public Release!
// Output a simplified string that's just our name:
strcpy( libraryName, "SPU2ghz" );
#elif defined( SVN_REV_UNKNOWN )
// Unknown revision.
// Output a name that includes devbuild status but not
// subversion revision tags:
strcpy( libraryName, "SPU2ghz"
# ifdef _DEBUG_FAST
"-Debug"
# elif defined( DEBUG )
"-Debug/Strict" // strict debugging is slow!
# else
"-Dev"
# endif
);
#else
// Use TortoiseSVN's SubWCRev utility's output
// to label the specific revision:
sprintf_s( libraryName, "SPU2ghz r%d%s"
# ifdef _DEBUG_FAST
"-Debug"
# elif defined( _DEBUG )
"-Debug/Strict" // strict debugging is slow!
# else
"-Dev"
# endif
,SVN_REV,
SVN_MODS ? "m" : ""
);
#endif
}
EXPORT_C_(u32) PS2EgetLibType()
{
return PS2E_LT_SPU2;
}
EXPORT_C_(char*) PS2EgetLibName()
{
InitLibraryName();
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
{
return (version<<16)|(revision<<8)|build;
}
EXPORT_C_(void) SPU2configure() {
configure();
}
EXPORT_C_(void) SPU2about() {
InitLibraryName();
SysMessage( libraryName );
}
EXPORT_C_(s32) SPU2test() {
return SndTest();
}
EXPORT_C_(s32) SPU2init()
{
#define MAKESURE(a,b) \
/*fprintf(stderr,"%08p: %08p == %08p\n",&(regtable[a>>1]),regtable[a>>1],U16P(b));*/ \
assert(regtable[(a)>>1]==U16P(b))
MAKESURE(0x800,zero);
s32 c=0,v=0;
ReadSettings();
#ifdef SPU2_LOG
if(AccessLog())
{
spu2Log = fopen(AccessLogFileName, "w");
setvbuf(spu2Log, NULL, _IONBF, 0);
FileLog("SPU2init\n");
}
#endif
srand((unsigned)time(NULL));
disableFreezes=false;
if (spu2init)
{
ConLog( " * SPU2: Already initialized - Ignoring SPU2init signal." );
return 0;
}
spu2init=true;
spu2regs = (short*)malloc(0x010000);
_spu2mem = (short*)malloc(0x200000);
// adpcm decoder cache:
// the cache data size is determined by taking the number of adpcm blocks
// (2MB / 16) and multiplying it by the decoded block size (28 samples).
// Thus: pcm_cache_data = 7,340,032 bytes (ouch!)
// Expanded: 16 bytes expands to 56 bytes [3.5:1 ratio]
// Resulting in 2MB * 3.5.
pcm_cache_data = (PcmCacheEntry*)calloc( pcm_BlockCount, sizeof(PcmCacheEntry) );
if( (spu2regs == NULL) || (_spu2mem == NULL) ||
(pcm_cache_data == NULL) )
{
SysMessage("SPU2: Error allocating Memory\n"); return -1;
}
for(int mem=0;mem<0x800;mem++)
{
u16 *ptr=regtable[mem>>1];
if(!ptr) {
regtable[mem>>1] = &(spu2Ru16(mem));
}
}
memset(spu2regs,0,0x010000);
memset(_spu2mem,0,0x200000);
memset(&Cores,0,(sizeof(V_Core) * 2));
CoreReset(0);
CoreReset(1);
DMALogOpen();
if(WaveLog())
{
if(!wavedump_open())
{
SysMessage("Can't open '%s'.\nWave Log disabled.",WaveLogFileName);
}
}
for(v=0;v<16384;v++)
{
logvolume[v]=(s32)(s32)floor(log((double)(v+1))*3376.7);
}
LowPassFilterInit();
InitADSR();
#ifdef STREAM_DUMP
il0=fopen("logs/spu2input0.pcm","wb");
il1=fopen("logs/spu2input1.pcm","wb");
#endif
#ifdef EFFECTS_DUMP
el0=fopen("logs/spu2fx0.pcm","wb");
el1=fopen("logs/spu2fx1.pcm","wb");
#endif
#ifdef S2R_ENABLE
if(!replay_mode)
s2r_open("replay_dump.s2r");
#endif
return 0;
}
EXPORT_C_(s32) SPU2open(void *pDsp)
{
if( spu2open ) return 0;
FileLog("[%10d] SPU2 Open\n",Cycles);
/*
if(debugDialogOpen==0)
{
hDebugDialog = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_DEBUG),0,DebugProc,0);
ShowWindow(hDebugDialog,SW_SHOWNORMAL);
debugDialogOpen=1;
}*/
spu2open=true;
if (!SndInit())
{
srate_pv=(double)SampleRate/48000.0;
spdif_init();
DspLoadLibrary(dspPlugin,dspPluginModule);
return 0;
}
else
{
SPU2close();
return -1;
};
}
EXPORT_C_(void) SPU2close()
{
if( !spu2open ) return;
FileLog("[%10d] SPU2 Close\n",Cycles);
DspCloseLibrary();
spdif_shutdown();
SndClose();
spu2open = false;
}
EXPORT_C_(void) SPU2shutdown()
{
if(!spu2init) return;
ConLog( " * SPU2: Shutting down.\n" );
SPU2close();
#ifdef S2R_ENABLE
if(!replay_mode)
s2r_close();
#endif
DoFullDump();
#ifdef STREAM_DUMP
fclose(il0);
fclose(il1);
#endif
#ifdef EFFECTS_DUMP
fclose(el0);
fclose(el1);
#endif
if(WaveLog() && wavedump_ok) wavedump_close();
DMALogClose();
spu2init = false;
SAFE_FREE(spu2regs);
SAFE_FREE(_spu2mem);
SAFE_FREE( pcm_cache_data );
spu2regs = NULL;
_spu2mem = NULL;
pcm_cache_data = NULL;
#ifdef SPU2_LOG
if(!AccessLog()) return;
FileLog("[%10d] SPU2shutdown\n",Cycles);
if(spu2Log) fclose(spu2Log);
#endif
}
EXPORT_C_(void) SPU2setClockPtr(u32 *ptr)
{
cPtr=ptr;
hasPtr=(cPtr!=NULL);
}
bool numpad_minus_old=false;
bool numpad_minus = false;
bool numpad_plus = false, numpad_plus_old = false;
EXPORT_C_(void) SPU2async(u32 cycles)
{
#ifndef PUBLIC
u32 oldClocks = lClocks;
static u32 timer=0,time1=0,time2=0;
timer++;
if (timer == 1){
time1=timeGetTime();
}
if (timer == 3000){
time2 = timeGetTime()-time1 ;
timer=0;
}
#endif
DspUpdate();
if(LimiterToggleEnabled)
{
numpad_minus = (GetAsyncKeyState(VK_SUBTRACT)&0x8000)!=0;
if(numpad_minus && !numpad_minus_old)
{
if(LimitMode) LimitMode=0;
else LimitMode=1;
SndUpdateLimitMode();
}
numpad_minus_old = numpad_minus;
}
#ifndef PUBLIC
/*numpad_plus = (GetAsyncKeyState(VK_ADD)&0x8000)!=0;
if(numpad_plus && !numpad_plus_old)
{
DoFullDump();
}
numpad_plus_old = numpad_plus;*/
#endif
if(hasPtr)
{
TimeUpdate(*cPtr);
}
else
{
pClocks+=cycles;
TimeUpdate(pClocks);
}
}
EXPORT_C_(void) SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)())
{
_irqcallback=SPU2callback;
dma4callback=DMA4callback;
dma7callback=DMA7callback;
}
EXPORT_C_(u16) SPU2read(u32 rmem)
{
// if(!replay_mode)
// s2r_readreg(Cycles,rmem);
if(hasPtr) TimeUpdate(*cPtr);
u16 ret=0xDEAD; u32 core=0, mem=rmem&0xFFFF, omem=mem;
if (mem & 0x400) { omem^=0x400; core=1; }
if(rmem==0x1f9001AC)
{
ret = DmaRead(core);
}
else if (rmem>>16 == 0x1f80)
{
ret = SPU_ps1_read(rmem);
}
else if ((mem&0xFFFF)>=0x800)
{
ret=spu2Ru16(mem);
ConLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret);
FileLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret);
}
else
{
ret = *(regtable[(mem>>1)]);
FileLog("[%10d] SPU2 read mem %x (core %d, register %x): %x\n",Cycles, mem, core, (omem & 0x7ff), ret);
}
return ret;
}
static __forceinline void SPU2_FastWrite( u32 rmem, u16 value )
{
u32 vx=0, vc=0, core=0, omem, mem;
omem=mem=rmem & 0x7FF; //FFFF;
if (mem & 0x400) { omem^=0x400; core=1; }
//else if ((omem >= 0x0000) && (omem < 0x0180)) { // Voice Params
if (omem < 0x0180) { // Voice Params
u32 voice=(omem & 0x1F0) >> 4;
u32 param=(omem & 0xF)>>1;
//FileLog("[%10d] SPU2 write mem %08x (Core %d Voice %d Param %s) value %x\n",Cycles,rmem,core,voice,ParamNames[param],value);
switch (param) {
case 0: //VOLL (Volume L)
if (value & 0x8000) { // +Lin/-Lin/+Exp/-Exp
Cores[core].Voices[voice].VolumeL.Mode=(value & 0xF000)>>12;
Cores[core].Voices[voice].VolumeL.Increment=(value & 0x3F);
}
else {
Cores[core].Voices[voice].VolumeL.Mode=0;
Cores[core].Voices[voice].VolumeL.Increment=0;
if(value&0x4000)
value=0x3fff - (value&0x3fff);
Cores[core].Voices[voice].VolumeL.Value=value<<1;
}
Cores[core].Voices[voice].VolumeL.Reg_VOL = value; break;
case 1: //VOLR (Volume R)
if (value & 0x8000) {
Cores[core].Voices[voice].VolumeR.Mode=(value & 0xF000)>>12;
Cores[core].Voices[voice].VolumeR.Increment=(value & 0x3F);
}
else {
Cores[core].Voices[voice].VolumeR.Mode=0;
Cores[core].Voices[voice].VolumeR.Increment=0;
Cores[core].Voices[voice].VolumeR.Value=value<<1;
}
Cores[core].Voices[voice].VolumeR.Reg_VOL = value; break;
case 2: Cores[core].Voices[voice].Pitch=value; break;
case 3: // ADSR1 (Envelope)
Cores[core].Voices[voice].ADSR.Am=(value & 0x8000)>>15;
Cores[core].Voices[voice].ADSR.Ar=(value & 0x7F00)>>8;
Cores[core].Voices[voice].ADSR.Dr=(value & 0xF0)>>4;
Cores[core].Voices[voice].ADSR.Sl=(value & 0xF);
Cores[core].Voices[voice].ADSR.Reg_ADSR1 = value; break;
case 4: // ADSR2 (Envelope)
Cores[core].Voices[voice].ADSR.Sm=(value & 0xE000)>>13;
Cores[core].Voices[voice].ADSR.Sr=(value & 0x1FC0)>>6;
Cores[core].Voices[voice].ADSR.Rm=(value & 0x20)>>5;
Cores[core].Voices[voice].ADSR.Rr=(value & 0x1F);
Cores[core].Voices[voice].ADSR.Reg_ADSR2 = value; break;
case 5:
// [Air] : Mysterious volume set code. Too bad none of my games ever use it.
// (as usual... )
Cores[core].Voices[voice].ADSR.Value = value << 15;
ConLog( "* SPU2: Mysterious ADSR Volume Set to 0x%x", value );
break;
case 6: Cores[core].Voices[voice].VolumeL.Value=value; break;
case 7: Cores[core].Voices[voice].VolumeR.Value=value; break;
jNO_DEFAULT;
}
}
else if ((omem >= 0x01C0) && (omem < 0x02DE)) {
u32 voice =((omem-0x01C0) / 12);
u32 address =((omem-0x01C0) % 12)>>1;
//FileLog("[%10d] SPU2 write mem %08x (Core %d Voice %d Address %s) value %x\n",Cycles,rmem,core,voice,AddressNames[address],value);
switch (address) {
case 0: Cores[core].Voices[voice].StartA=((value & 0x0F) << 16) | (Cores[core].Voices[voice].StartA & 0xFFF8);
#ifndef PUBLIC
DebugCores[core].Voices[voice].lastSetStartA = Cores[core].Voices[voice].StartA;
#endif
break;
case 1: Cores[core].Voices[voice].StartA=(Cores[core].Voices[voice].StartA & 0x0F0000) | (value & 0xFFF8);
#ifndef PUBLIC
DebugCores[core].Voices[voice].lastSetStartA = Cores[core].Voices[voice].StartA;
#endif
//if(core==1) printf(" *** StartA for C%dV%02d set to 0x%05x\n",core,voice,Cores[core].Voices[voice].StartA);
break;
case 2: Cores[core].Voices[voice].LoopStartA=((value & 0x0F) << 16) | (Cores[core].Voices[voice].LoopStartA & 0xFFF8);
Cores[core].Voices[voice].LoopMode=3; break;
case 3: Cores[core].Voices[voice].LoopStartA=(Cores[core].Voices[voice].LoopStartA & 0x0F0000) | (value & 0xFFF8);break;
Cores[core].Voices[voice].LoopMode=3; break;
case 4: Cores[core].Voices[voice].NextA=((value & 0x0F) << 16) | (Cores[core].Voices[voice].NextA & 0xFFF8);
//printf(" *** Warning: C%dV%02d NextA MODIFIED EXTERNALLY!\n",core,voice);
break;
case 5: Cores[core].Voices[voice].NextA=(Cores[core].Voices[voice].NextA & 0x0F0000) | (value & 0xFFF8);
//printf(" *** Warning: C%dV%02d NextA MODIFIED EXTERNALLY!\n",core,voice);
break;
}
}
else
switch(omem) {
case REG_C_ATTR:
RegLog(4,"ATTR",rmem,core,value);
{
int irqe=Cores[core].IRQEnable;
int bit0=Cores[core].AttrBit0;
int bit4=Cores[core].AttrBit4;
if(((value>>15)&1)&&(!Cores[core].CoreEnabled)&&(Cores[core].InitDelay==0)) // on init/reset
{
if(hasPtr)
{
Cores[core].InitDelay=1;
Cores[core].Regs.STATX=0;
}
else
{
CoreReset(core);
}
}
Cores[core].AttrBit0 =(value>> 0) & 0x01; //1 bit
Cores[core].DMABits =(value>> 1) & 0x07; //3 bits
Cores[core].AttrBit4 =(value>> 4) & 0x01; //1 bit
Cores[core].AttrBit5 =(value>> 5) & 0x01; //1 bit
Cores[core].IRQEnable =(value>> 6) & 0x01; //1 bit
Cores[core].FxEnable =(value>> 7) & 0x01; //1 bit
Cores[core].NoiseClk =(value>> 8) & 0x3f; //6 bits
//Cores[core].Mute =(value>>14) & 0x01; //1 bit
Cores[core].Mute=0;
Cores[core].CoreEnabled=(value>>15) & 0x01; //1 bit
Cores[core].Regs.ATTR =value&0x7fff;
if(value&0x000E)
{
ConLog(" * SPU2: Core %d ATTR unknown bits SET! value=%04x\n",core,value);
}
if(Cores[core].AttrBit0!=bit0)
{
ConLog(" * SPU2: ATTR bit 0 set to %d\n",Cores[core].AttrBit0);
}
if(Cores[core].IRQEnable!=irqe)
{
ConLog(" * SPU2: IRQ %s\n",((Cores[core].IRQEnable==0)?"disabled":"enabled"));
if(!Cores[core].IRQEnable)
Spdif.Info=0;
}
}
break;
case REG_S_PMON:
RegLog(1,"PMON0",rmem,core,value);
vx=2; for (vc=1;vc<16;vc++) { Cores[core].Voices[vc].Modulated=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.PMON = (Cores[core].Regs.PMON & 0xFFFF0000) | value;
break;
case (REG_S_PMON + 2):
RegLog(1,"PMON1",rmem,core,value);
vx=1; for (vc=16;vc<24;vc++) { Cores[core].Voices[vc].Modulated=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.PMON = (Cores[core].Regs.PMON & 0xFFFF) | (value << 16);
break;
case REG_S_NON:
RegLog(1,"NON0",rmem,core,value);
vx=1; for (vc=0;vc<16;vc++) { Cores[core].Voices[vc].Noise=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.NON = (Cores[core].Regs.NON & 0xFFFF0000) | value;
break;
case (REG_S_NON + 2):
RegLog(1,"NON1",rmem,core,value);
vx=1; for (vc=16;vc<24;vc++) { Cores[core].Voices[vc].Noise=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.NON = (Cores[core].Regs.NON & 0xFFFF) | (value << 16);
break;
case REG_S_VMIXL:
RegLog(1,"VMIXL0",rmem,core,value);
vx=1; for (vc=0;vc<16;vc++) { Cores[core].Voices[vc].DryL=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXL = (Cores[core].Regs.VMIXL & 0xFFFF0000) | value;
case (REG_S_VMIXL + 2):
RegLog(1,"VMIXL1",rmem,core,value);
vx=1; for (vc=16;vc<24;vc++) { Cores[core].Voices[vc].DryL=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXL = (Cores[core].Regs.VMIXL & 0xFFFF) | (value << 16);
case REG_S_VMIXEL:
RegLog(1,"VMIXEL0",rmem,core,value);
vx=1; for (vc=0;vc<16;vc++) { Cores[core].Voices[vc].WetL=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXEL = (Cores[core].Regs.VMIXEL & 0xFFFF0000) | value;
break;
case (REG_S_VMIXEL + 2):
RegLog(1,"VMIXEL1",rmem,core,value);
vx=1; for (vc=16;vc<24;vc++) { Cores[core].Voices[vc].WetL=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXEL = (Cores[core].Regs.VMIXEL & 0xFFFF) | (value << 16);
break;
case REG_S_VMIXR:
RegLog(1,"VMIXR0",rmem,core,value);
vx=1; for (vc=0;vc<16;vc++) { Cores[core].Voices[vc].DryR=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXR = (Cores[core].Regs.VMIXR & 0xFFFF0000) | value;
break;
case (REG_S_VMIXR + 2):
RegLog(1,"VMIXR1",rmem,core,value);
vx=1; for (vc=16;vc<24;vc++) { Cores[core].Voices[vc].DryR=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXR = (Cores[core].Regs.VMIXR & 0xFFFF) | (value << 16);
break;
case REG_S_VMIXER:
RegLog(1,"VMIXER0",rmem,core,value);
vx=1; for (vc=0;vc<16;vc++) { Cores[core].Voices[vc].WetR=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXER = (Cores[core].Regs.VMIXER & 0xFFFF0000) | value;
break;
case (REG_S_VMIXER + 2):
RegLog(1,"VMIXER1",rmem,core,value);
vx=1; for (vc=16;vc<24;vc++) { Cores[core].Voices[vc].WetR=(s8)((value & vx)/vx); vx<<=1; }
Cores[core].Regs.VMIXER = (Cores[core].Regs.VMIXER & 0xFFFF) | (value << 16);
break;
case REG_P_MMIX:
RegLog(1,"MMIX",rmem,core,value);
vx=value;
if (core == 0) vx&=0xFF0;
Cores[core].ExtWetR=(vx & 0x001);
Cores[core].ExtWetL=(vx & 0x002)>>1;
Cores[core].ExtDryR=(vx & 0x004)>>2;
Cores[core].ExtDryL=(vx & 0x008)>>3;
Cores[core].InpWetR=(vx & 0x010)>>4;
Cores[core].InpWetL=(vx & 0x020)>>5;
Cores[core].InpDryR=(vx & 0x040)>>6;
Cores[core].InpDryL=(vx & 0x080)>>7;
Cores[core].SndWetR=(vx & 0x100)>>8;
Cores[core].SndWetL=(vx & 0x200)>>9;
Cores[core].SndDryR=(vx & 0x400)>>10;
Cores[core].SndDryL=(vx & 0x800)>>11;
Cores[core].Regs.MMIX = value;
break;
case (REG_S_KON + 2):
RegLog(2,"KON1",rmem,core,value);
StartVoices(core,((u32)value)<<16);
break;
case REG_S_KON:
RegLog(2,"KON0",rmem,core,value);
StartVoices(core,((u32)value));
break;
case (REG_S_KOFF + 2):
RegLog(2,"KOFF1",rmem,core,value);
StopVoices(core,((u32)value)<<16);
break;
case REG_S_KOFF:
RegLog(2,"KOFF0",rmem,core,value);
StopVoices(core,((u32)value));
break;
case REG_S_ENDX:
//ConLog(" * SPU2: Core %d ENDX cleared!\n",core);
RegLog(2,"ENDX0",rmem,core,value);
Cores[core].Regs.ENDX&=0x00FF0000; break;
case (REG_S_ENDX + 2):
//ConLog(" * SPU2: Core %d ENDX cleared!\n",core);
RegLog(2,"ENDX1",rmem,core,value);
Cores[core].Regs.ENDX&=0xFFFF; break;
case REG_P_MVOLL:
RegLog(1,"MVOLL",rmem,core,value);
if (value & 0x8000) { // +Lin/-Lin/+Exp/-Exp
Cores[core].MasterL.Mode=(value & 0xE000)/0x2000;
Cores[core].MasterL.Increment=(value & 0x3F) | ((value & 0x800)/0x10);
}
else {
Cores[core].MasterL.Mode=0;
Cores[core].MasterL.Increment=0;
Cores[core].MasterL.Value=value;
}
Cores[core].MasterL.Reg_VOL=value;
break;
case REG_P_MVOLR:
RegLog(1,"MVOLR",rmem,core,value);
if (value & 0x8000) { // +Lin/-Lin/+Exp/-Exp
Cores[core].MasterR.Mode=(value & 0xE000)/0x2000;
Cores[core].MasterR.Increment=(value & 0x3F) | ((value & 0x800)/0x10);
}
else {
Cores[core].MasterR.Mode=0;
Cores[core].MasterR.Increment=0;
Cores[core].MasterR.Value=value;
}
Cores[core].MasterR.Reg_VOL=value;
break;
case REG_S_ADMAS:
RegLog(3,"ADMAS",rmem,core,value);
//ConLog(" * SPU2: Core %d AutoDMAControl set to %d (%d)\n",core,value, Cycles);
Cores[core].AutoDMACtrl=value;
if(value==0)
{
Cores[core].AdmaInProgress=0;
}
break;
default:
*(regtable[mem>>1])=value;
break;
}
SPU2writeLog(mem,value);
if ((mem>=0x07C0) && (mem<0x07CE))
{
UpdateSpdifMode();
}
}
EXPORT_C_(void) SPU2write(u32 rmem, u16 value)
{
#ifdef S2R_ENABLE
if(!replay_mode)
s2r_writereg(Cycles,rmem,value);
#endif
if(rmem==0x1f9001ac)
{
//RegWriteLog(0,value);
if((Cores[0].IRQEnable)&&(Cores[0].TSA==Cores[0].IRQA))
{
Spdif.Info=4;
SetIrqCall();
}
spu2M_Write( Cores[0].TSA++, value );
Cores[0].TSA&=0xfffff;
}
else if(rmem==0x1f9005ac)
{
//RegWriteLog(1,value);
if((Cores[0].IRQEnable)&&(Cores[0].TSA==Cores[0].IRQA))
{
Spdif.Info=4;
SetIrqCall();
}
spu2M_Write( Cores[1].TSA++, value );
Cores[1].TSA&=0xfffff;
}
else
{
if(hasPtr) TimeUpdate(*cPtr);
if (rmem>>16 == 0x1f80)
SPU_ps1_write(rmem,value);
else
SPU2_FastWrite( rmem, value );
}
}
// if start is 1, starts recording spu2 data, else stops
// returns a non zero value if successful
// for now, pData is not used
EXPORT_C_(int) SPU2setupRecording(int start, void* pData)
{
// Don't record if we have a bogus state.
if( disableFreezes ) return 0;
if(start==0)
{
//stop recording
RecordStop();
if(recording==0)
return 1;
}
else if(start==1)
{
//start recording
RecordStart();
if(recording!=0)
return 1;
}
return 0;
}

View File

@ -89,12 +89,10 @@ void InitADSR() // INIT ADSR
int shift=(i-32)>>2; int shift=(i-32)>>2;
s64 rate=(i&3)+4; s64 rate=(i&3)+4;
if (shift<0) if (shift<0)
{
rate>>=-shift; rate>>=-shift;
} else else
{
rate<<=shift; rate<<=shift;
}
PsxRates[i]=(int)min(rate,0x3fffffff); PsxRates[i]=(int)min(rate,0x3fffffff);
} }
} }

View File

@ -0,0 +1,276 @@
//GiGaHeRz's SPU2 Driver
//Copyright (c) 2003-2008, David Quintana <gigaherz@gmail.com>
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "spu2.h"
#include "regtable.h"
u16* regtable[] =
{
// Voice Params: 8 params, 24 voices = 0x180 bytes
PVC(0, 0),PVC(0, 1),PVC(0, 2),PVC(0, 3),PVC(0, 4),PVC(0, 5),
PVC(0, 6),PVC(0, 7),PVC(0, 8),PVC(0, 9),PVC(0,10),PVC(0,11),
PVC(0,12),PVC(0,13),PVC(0,14),PVC(0,15),PVC(0,16),PVC(0,17),
PVC(0,18),PVC(0,19),PVC(0,20),PVC(0,21),PVC(0,22),PVC(0,23),
PCORE(0,Regs.PMON),
PCORE(0,Regs.PMON)+1,
PCORE(0,Regs.NON),
PCORE(0,Regs.NON)+1,
PCORE(0,Regs.VMIXL),
PCORE(0,Regs.VMIXL)+1,
PCORE(0,Regs.VMIXEL),
PCORE(0,Regs.VMIXEL)+1,
PCORE(0,Regs.VMIXR),
PCORE(0,Regs.VMIXR)+1,
PCORE(0,Regs.VMIXER),
PCORE(0,Regs.VMIXER)+1,
PCORE(0,Regs.MMIX),
PCORE(0,Regs.ATTR),
PCORE(0,IRQA)+1,
PCORE(0,IRQA),
U16P(zero),
U16P(zero),
U16P(zero),
U16P(zero),
PCORE(0,TSA)+1,
PCORE(0,TSA),
PRAW(0x1ac), PRAW(0x1ae),
PCORE(0,AutoDMACtrl),
PRAW(0x1b2), PRAW(0x1b4), PRAW(0x1b6), PRAW(0x1b8), PRAW(0x1ba), PRAW(0x1bc), PRAW(0x1be), // unknown
// Voice Addresses
PVCA(0, 0),PVCA(0, 1),PVCA(0, 2),PVCA(0, 3),PVCA(0, 4),PVCA(0, 5),
PVCA(0, 6),PVCA(0, 7),PVCA(0, 8),PVCA(0, 9),PVCA(0,10),PVCA(0,11),
PVCA(0,12),PVCA(0,13),PVCA(0,14),PVCA(0,15),PVCA(0,16),PVCA(0,17),
PVCA(0,18),PVCA(0,19),PVCA(0,20),PVCA(0,21),PVCA(0,22),PVCA(0,23),
PCORE(0,EffectsStartA)+1,
PCORE(0,EffectsStartA),
PREVB_REG(0,FB_SRC_A),
PREVB_REG(0,FB_SRC_B),
PREVB_REG(0,IIR_SRC_A0),
PREVB_REG(0,IIR_SRC_A1),
PREVB_REG(0,IIR_SRC_B1),
PREVB_REG(0,IIR_SRC_B0),
PREVB_REG(0,IIR_DEST_A0),
PREVB_REG(0,IIR_DEST_A1),
PREVB_REG(0,IIR_DEST_B0),
PREVB_REG(0,IIR_DEST_B1),
PREVB_REG(0,ACC_SRC_A0),
PREVB_REG(0,ACC_SRC_A1),
PREVB_REG(0,ACC_SRC_B0),
PREVB_REG(0,ACC_SRC_B1),
PREVB_REG(0,ACC_SRC_C0),
PREVB_REG(0,ACC_SRC_C1),
PREVB_REG(0,ACC_SRC_D0),
PREVB_REG(0,ACC_SRC_D1),
PREVB_REG(0,MIX_DEST_A0),
PREVB_REG(0,MIX_DEST_A1),
PREVB_REG(0,MIX_DEST_B0),
PREVB_REG(0,MIX_DEST_B1),
PCORE(0,EffectsEndA)+1,
U16P(zero),
PCORE(0,Regs.ENDX),
PCORE(0,Regs.ENDX)+1,
PCORE(0,Regs.STATX),
//0x346 here
PRAW(0x346),
PRAW(0x348),PRAW(0x34A),PRAW(0x34C),PRAW(0x34E),
PRAW(0x350),PRAW(0x352),PRAW(0x354),PRAW(0x356),
PRAW(0x358),PRAW(0x35A),PRAW(0x35C),PRAW(0x35E),
PRAW(0x360),PRAW(0x362),PRAW(0x364),PRAW(0x366),
PRAW(0x368),PRAW(0x36A),PRAW(0x36C),PRAW(0x36E),
PRAW(0x370),PRAW(0x372),PRAW(0x374),PRAW(0x376),
PRAW(0x378),PRAW(0x37A),PRAW(0x37C),PRAW(0x37E),
PRAW(0x380),PRAW(0x382),PRAW(0x384),PRAW(0x386),
PRAW(0x388),PRAW(0x38A),PRAW(0x38C),PRAW(0x38E),
PRAW(0x390),PRAW(0x392),PRAW(0x394),PRAW(0x396),
PRAW(0x398),PRAW(0x39A),PRAW(0x39C),PRAW(0x39E),
PRAW(0x3A0),PRAW(0x3A2),PRAW(0x3A4),PRAW(0x3A6),
PRAW(0x3A8),PRAW(0x3AA),PRAW(0x3AC),PRAW(0x3AE),
PRAW(0x3B0),PRAW(0x3B2),PRAW(0x3B4),PRAW(0x3B6),
PRAW(0x3B8),PRAW(0x3BA),PRAW(0x3BC),PRAW(0x3BE),
PRAW(0x3C0),PRAW(0x3C2),PRAW(0x3C4),PRAW(0x3C6),
PRAW(0x3C8),PRAW(0x3CA),PRAW(0x3CC),PRAW(0x3CE),
PRAW(0x3D0),PRAW(0x3D2),PRAW(0x3D4),PRAW(0x3D6),
PRAW(0x3D8),PRAW(0x3DA),PRAW(0x3DC),PRAW(0x3DE),
PRAW(0x3E0),PRAW(0x3E2),PRAW(0x3E4),PRAW(0x3E6),
PRAW(0x3E8),PRAW(0x3EA),PRAW(0x3EC),PRAW(0x3EE),
PRAW(0x3F0),PRAW(0x3F2),PRAW(0x3F4),PRAW(0x3F6),
PRAW(0x3F8),PRAW(0x3FA),PRAW(0x3FC),PRAW(0x3FE),
//AND... we reached 0x400!
// Voice Params: 8 params, 24 voices = 0x180 bytes
PVC(1, 0),PVC(1, 1),PVC(1, 2),PVC(1, 3),PVC(1, 4),PVC(1, 5),
PVC(1, 6),PVC(1, 7),PVC(1, 8),PVC(1, 9),PVC(1,10),PVC(1,11),
PVC(1,12),PVC(1,13),PVC(1,14),PVC(1,15),PVC(1,16),PVC(1,17),
PVC(1,18),PVC(1,19),PVC(1,20),PVC(1,21),PVC(1,22),PVC(1,23),
PCORE(1,Regs.PMON),
PCORE(1,Regs.PMON)+1,
PCORE(1,Regs.NON),
PCORE(1,Regs.NON)+1,
PCORE(1,Regs.VMIXL),
PCORE(1,Regs.VMIXL)+1,
PCORE(1,Regs.VMIXEL),
PCORE(1,Regs.VMIXEL)+1,
PCORE(1,Regs.VMIXR),
PCORE(1,Regs.VMIXR)+1,
PCORE(1,Regs.VMIXER),
PCORE(1,Regs.VMIXER)+1,
PCORE(1,Regs.MMIX),
PCORE(1,Regs.ATTR),
PCORE(1,IRQA)+1,
PCORE(1,IRQA),
U16P(zero),
U16P(zero),
U16P(zero),
U16P(zero),
PCORE(1,TSA)+1,
PCORE(1,TSA),
PRAW(0x5ac), PRAW(0x5ae),
PCORE(1,AutoDMACtrl),
PRAW(0x5b2), PRAW(0x5b4), PRAW(0x5b6), PRAW(0x5b8), PRAW(0x5ba), PRAW(0x5bc), PRAW(0x5be), // unknown
// Voice Addresses
PVCA(1, 0),PVCA(1, 1),PVCA(1, 2),PVCA(1, 3),PVCA(1, 4),PVCA(1, 5),
PVCA(1, 6),PVCA(1, 7),PVCA(1, 8),PVCA(1, 9),PVCA(1,10),PVCA(1,11),
PVCA(1,12),PVCA(1,13),PVCA(1,14),PVCA(1,15),PVCA(1,16),PVCA(1,17),
PVCA(1,18),PVCA(1,19),PVCA(1,20),PVCA(1,21),PVCA(1,22),PVCA(1,23),
PCORE(1,EffectsStartA)+1,
PCORE(1,EffectsStartA),
PREVB_REG(1,FB_SRC_A),
PREVB_REG(1,FB_SRC_B),
PREVB_REG(1,IIR_SRC_A0),
PREVB_REG(1,IIR_SRC_A1),
PREVB_REG(1,IIR_SRC_B1),
PREVB_REG(1,IIR_SRC_B0),
PREVB_REG(1,IIR_DEST_A0),
PREVB_REG(1,IIR_DEST_A1),
PREVB_REG(1,IIR_DEST_B0),
PREVB_REG(1,IIR_DEST_B1),
PREVB_REG(1,ACC_SRC_A0),
PREVB_REG(1,ACC_SRC_A1),
PREVB_REG(1,ACC_SRC_B0),
PREVB_REG(1,ACC_SRC_B1),
PREVB_REG(1,ACC_SRC_C0),
PREVB_REG(1,ACC_SRC_C1),
PREVB_REG(1,ACC_SRC_D0),
PREVB_REG(1,ACC_SRC_D1),
PREVB_REG(1,MIX_DEST_A0),
PREVB_REG(1,MIX_DEST_A1),
PREVB_REG(1,MIX_DEST_B0),
PREVB_REG(1,MIX_DEST_B1),
PCORE(1,EffectsEndA)+1,
U16P(zero),
PCORE(1,Regs.ENDX),
PCORE(1,Regs.ENDX)+1,
PCORE(1,Regs.STATX),
PRAW(0x746),
PRAW(0x748),PRAW(0x74A),PRAW(0x74C),PRAW(0x74E),
PRAW(0x750),PRAW(0x752),PRAW(0x754),PRAW(0x756),
PRAW(0x758),PRAW(0x75A),PRAW(0x75C),PRAW(0x75E),
//0x760: weird area
PCORE(0,MasterL.Reg_VOL),
PCORE(0,MasterR.Reg_VOL),
PCORE(0,FxL),
PCORE(0,FxR),
PCORE(0,ExtL),
PCORE(0,ExtR),
PCORE(0,InpL),
PCORE(0,InpR),
PCORE(0,MasterL.Value),
PCORE(0,MasterR.Value),
PCORE(0,Revb.IIR_ALPHA),
PCORE(0,Revb.ACC_COEF_A),
PCORE(0,Revb.ACC_COEF_B),
PCORE(0,Revb.ACC_COEF_C),
PCORE(0,Revb.ACC_COEF_D),
PCORE(0,Revb.IIR_COEF),
PCORE(0,Revb.FB_ALPHA),
PCORE(0,Revb.FB_X),
PCORE(0,Revb.IN_COEF_L),
PCORE(0,Revb.IN_COEF_R),
PCORE(1,MasterL.Reg_VOL),
PCORE(1,MasterR.Reg_VOL),
PCORE(1,FxL),
PCORE(1,FxR),
PCORE(1,ExtL),
PCORE(1,ExtR),
PCORE(1,InpL),
PCORE(1,InpR),
PCORE(1,MasterL.Value),
PCORE(1,MasterR.Value),
PCORE(1,Revb.IIR_ALPHA),
PCORE(1,Revb.ACC_COEF_A),
PCORE(1,Revb.ACC_COEF_B),
PCORE(1,Revb.ACC_COEF_C),
PCORE(1,Revb.ACC_COEF_D),
PCORE(1,Revb.IIR_COEF),
PCORE(1,Revb.FB_ALPHA),
PCORE(1,Revb.FB_X),
PCORE(1,Revb.IN_COEF_L),
PCORE(1,Revb.IN_COEF_R),
PRAW(0x7B0),PRAW(0x7B2),PRAW(0x7B4),PRAW(0x7B6),
PRAW(0x7B8),PRAW(0x7BA),PRAW(0x7BC),PRAW(0x7BE),
// SPDIF interface
U16P(Spdif.Out),
U16P(Spdif.Info),
U16P(Spdif.Unknown1),
U16P(Spdif.Mode),
U16P(Spdif.Media),
U16P(Spdif.Unknown2),
U16P(Spdif.Protection),
PRAW(0x7CE),
PRAW(0x7D0),PRAW(0x7D2),PRAW(0x7D4),PRAW(0x7D6),
PRAW(0x7D8),PRAW(0x7DA),PRAW(0x7DC),PRAW(0x7DE),
PRAW(0x7E0),PRAW(0x7E2),PRAW(0x7E4),PRAW(0x7E6),
PRAW(0x7E8),PRAW(0x7EA),PRAW(0x7EC),PRAW(0x7EE),
PRAW(0x7F0),PRAW(0x7F2),PRAW(0x7F4),PRAW(0x7F6),
PRAW(0x7F8),PRAW(0x7FA),PRAW(0x7FC),PRAW(0x7FE),
U16P(zero)
};

View File

@ -16,6 +16,9 @@
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
#ifndef _REGTABLE_H_
#define _REGTABLE_H_
#define U16P(x) ((u16*)&(x)) #define U16P(x) ((u16*)&(x))
#define PCORE(c,p) \ #define PCORE(c,p) \
@ -49,260 +52,9 @@
PCORE(c,Revb.##n)+1, \ PCORE(c,Revb.##n)+1, \
PCORE(c,Revb.##n) PCORE(c,Revb.##n)
const u16 zero=0; // Yay! Global namespace pollution 101!
static const u16 zero=0;
#pragma pack(push,1) extern u16* regtable[];
u16* /*const*/ regtable[] = {
// Voice Params: 8 params, 24 voices = 0x180 bytes
PVC(0, 0),PVC(0, 1),PVC(0, 2),PVC(0, 3),PVC(0, 4),PVC(0, 5),
PVC(0, 6),PVC(0, 7),PVC(0, 8),PVC(0, 9),PVC(0,10),PVC(0,11),
PVC(0,12),PVC(0,13),PVC(0,14),PVC(0,15),PVC(0,16),PVC(0,17),
PVC(0,18),PVC(0,19),PVC(0,20),PVC(0,21),PVC(0,22),PVC(0,23),
PCORE(0,Regs.PMON), #endif
PCORE(0,Regs.PMON)+1,
PCORE(0,Regs.NON),
PCORE(0,Regs.NON)+1,
PCORE(0,Regs.VMIXL),
PCORE(0,Regs.VMIXL)+1,
PCORE(0,Regs.VMIXEL),
PCORE(0,Regs.VMIXEL)+1,
PCORE(0,Regs.VMIXR),
PCORE(0,Regs.VMIXR)+1,
PCORE(0,Regs.VMIXER),
PCORE(0,Regs.VMIXER)+1,
PCORE(0,Regs.MMIX),
PCORE(0,Regs.ATTR),
PCORE(0,IRQA)+1,
PCORE(0,IRQA),
U16P(zero),
U16P(zero),
U16P(zero),
U16P(zero),
PCORE(0,TSA)+1,
PCORE(0,TSA),
PRAW(0x1ac), PRAW(0x1ae),
PCORE(0,AutoDMACtrl),
PRAW(0x1b2), PRAW(0x1b4), PRAW(0x1b6), PRAW(0x1b8), PRAW(0x1ba), PRAW(0x1bc), PRAW(0x1be), // unknown
// Voice Addresses
PVCA(0, 0),PVCA(0, 1),PVCA(0, 2),PVCA(0, 3),PVCA(0, 4),PVCA(0, 5),
PVCA(0, 6),PVCA(0, 7),PVCA(0, 8),PVCA(0, 9),PVCA(0,10),PVCA(0,11),
PVCA(0,12),PVCA(0,13),PVCA(0,14),PVCA(0,15),PVCA(0,16),PVCA(0,17),
PVCA(0,18),PVCA(0,19),PVCA(0,20),PVCA(0,21),PVCA(0,22),PVCA(0,23),
PCORE(0,EffectsStartA)+1,
PCORE(0,EffectsStartA),
PREVB_REG(0,FB_SRC_A),
PREVB_REG(0,FB_SRC_B),
PREVB_REG(0,IIR_SRC_A0),
PREVB_REG(0,IIR_SRC_A1),
PREVB_REG(0,IIR_SRC_B1),
PREVB_REG(0,IIR_SRC_B0),
PREVB_REG(0,IIR_DEST_A0),
PREVB_REG(0,IIR_DEST_A1),
PREVB_REG(0,IIR_DEST_B0),
PREVB_REG(0,IIR_DEST_B1),
PREVB_REG(0,ACC_SRC_A0),
PREVB_REG(0,ACC_SRC_A1),
PREVB_REG(0,ACC_SRC_B0),
PREVB_REG(0,ACC_SRC_B1),
PREVB_REG(0,ACC_SRC_C0),
PREVB_REG(0,ACC_SRC_C1),
PREVB_REG(0,ACC_SRC_D0),
PREVB_REG(0,ACC_SRC_D1),
PREVB_REG(0,MIX_DEST_A0),
PREVB_REG(0,MIX_DEST_A1),
PREVB_REG(0,MIX_DEST_B0),
PREVB_REG(0,MIX_DEST_B1),
PCORE(0,EffectsEndA)+1,
U16P(zero),
PCORE(0,Regs.ENDX),
PCORE(0,Regs.ENDX)+1,
PCORE(0,Regs.STATX),
//0x346 here
PRAW(0x346),
PRAW(0x348),PRAW(0x34A),PRAW(0x34C),PRAW(0x34E),
PRAW(0x350),PRAW(0x352),PRAW(0x354),PRAW(0x356),
PRAW(0x358),PRAW(0x35A),PRAW(0x35C),PRAW(0x35E),
PRAW(0x360),PRAW(0x362),PRAW(0x364),PRAW(0x366),
PRAW(0x368),PRAW(0x36A),PRAW(0x36C),PRAW(0x36E),
PRAW(0x370),PRAW(0x372),PRAW(0x374),PRAW(0x376),
PRAW(0x378),PRAW(0x37A),PRAW(0x37C),PRAW(0x37E),
PRAW(0x380),PRAW(0x382),PRAW(0x384),PRAW(0x386),
PRAW(0x388),PRAW(0x38A),PRAW(0x38C),PRAW(0x38E),
PRAW(0x390),PRAW(0x392),PRAW(0x394),PRAW(0x396),
PRAW(0x398),PRAW(0x39A),PRAW(0x39C),PRAW(0x39E),
PRAW(0x3A0),PRAW(0x3A2),PRAW(0x3A4),PRAW(0x3A6),
PRAW(0x3A8),PRAW(0x3AA),PRAW(0x3AC),PRAW(0x3AE),
PRAW(0x3B0),PRAW(0x3B2),PRAW(0x3B4),PRAW(0x3B6),
PRAW(0x3B8),PRAW(0x3BA),PRAW(0x3BC),PRAW(0x3BE),
PRAW(0x3C0),PRAW(0x3C2),PRAW(0x3C4),PRAW(0x3C6),
PRAW(0x3C8),PRAW(0x3CA),PRAW(0x3CC),PRAW(0x3CE),
PRAW(0x3D0),PRAW(0x3D2),PRAW(0x3D4),PRAW(0x3D6),
PRAW(0x3D8),PRAW(0x3DA),PRAW(0x3DC),PRAW(0x3DE),
PRAW(0x3E0),PRAW(0x3E2),PRAW(0x3E4),PRAW(0x3E6),
PRAW(0x3E8),PRAW(0x3EA),PRAW(0x3EC),PRAW(0x3EE),
PRAW(0x3F0),PRAW(0x3F2),PRAW(0x3F4),PRAW(0x3F6),
PRAW(0x3F8),PRAW(0x3FA),PRAW(0x3FC),PRAW(0x3FE),
//AND... we reached 0x400!
// Voice Params: 8 params, 24 voices = 0x180 bytes
PVC(1, 0),PVC(1, 1),PVC(1, 2),PVC(1, 3),PVC(1, 4),PVC(1, 5),
PVC(1, 6),PVC(1, 7),PVC(1, 8),PVC(1, 9),PVC(1,10),PVC(1,11),
PVC(1,12),PVC(1,13),PVC(1,14),PVC(1,15),PVC(1,16),PVC(1,17),
PVC(1,18),PVC(1,19),PVC(1,20),PVC(1,21),PVC(1,22),PVC(1,23),
PCORE(1,Regs.PMON),
PCORE(1,Regs.PMON)+1,
PCORE(1,Regs.NON),
PCORE(1,Regs.NON)+1,
PCORE(1,Regs.VMIXL),
PCORE(1,Regs.VMIXL)+1,
PCORE(1,Regs.VMIXEL),
PCORE(1,Regs.VMIXEL)+1,
PCORE(1,Regs.VMIXR),
PCORE(1,Regs.VMIXR)+1,
PCORE(1,Regs.VMIXER),
PCORE(1,Regs.VMIXER)+1,
PCORE(1,Regs.MMIX),
PCORE(1,Regs.ATTR),
PCORE(1,IRQA)+1,
PCORE(1,IRQA),
U16P(zero),
U16P(zero),
U16P(zero),
U16P(zero),
PCORE(1,TSA)+1,
PCORE(1,TSA),
PRAW(0x5ac), PRAW(0x5ae),
PCORE(1,AutoDMACtrl),
PRAW(0x5b2), PRAW(0x5b4), PRAW(0x5b6), PRAW(0x5b8), PRAW(0x5ba), PRAW(0x5bc), PRAW(0x5be), // unknown
// Voice Addresses
PVCA(1, 0),PVCA(1, 1),PVCA(1, 2),PVCA(1, 3),PVCA(1, 4),PVCA(1, 5),
PVCA(1, 6),PVCA(1, 7),PVCA(1, 8),PVCA(1, 9),PVCA(1,10),PVCA(1,11),
PVCA(1,12),PVCA(1,13),PVCA(1,14),PVCA(1,15),PVCA(1,16),PVCA(1,17),
PVCA(1,18),PVCA(1,19),PVCA(1,20),PVCA(1,21),PVCA(1,22),PVCA(1,23),
PCORE(1,EffectsStartA)+1,
PCORE(1,EffectsStartA),
PREVB_REG(1,FB_SRC_A),
PREVB_REG(1,FB_SRC_B),
PREVB_REG(1,IIR_SRC_A0),
PREVB_REG(1,IIR_SRC_A1),
PREVB_REG(1,IIR_SRC_B1),
PREVB_REG(1,IIR_SRC_B0),
PREVB_REG(1,IIR_DEST_A0),
PREVB_REG(1,IIR_DEST_A1),
PREVB_REG(1,IIR_DEST_B0),
PREVB_REG(1,IIR_DEST_B1),
PREVB_REG(1,ACC_SRC_A0),
PREVB_REG(1,ACC_SRC_A1),
PREVB_REG(1,ACC_SRC_B0),
PREVB_REG(1,ACC_SRC_B1),
PREVB_REG(1,ACC_SRC_C0),
PREVB_REG(1,ACC_SRC_C1),
PREVB_REG(1,ACC_SRC_D0),
PREVB_REG(1,ACC_SRC_D1),
PREVB_REG(1,MIX_DEST_A0),
PREVB_REG(1,MIX_DEST_A1),
PREVB_REG(1,MIX_DEST_B0),
PREVB_REG(1,MIX_DEST_B1),
PCORE(1,EffectsEndA)+1,
U16P(zero),
PCORE(1,Regs.ENDX),
PCORE(1,Regs.ENDX)+1,
PCORE(1,Regs.STATX),
PRAW(0x746),
PRAW(0x748),PRAW(0x74A),PRAW(0x74C),PRAW(0x74E),
PRAW(0x750),PRAW(0x752),PRAW(0x754),PRAW(0x756),
PRAW(0x758),PRAW(0x75A),PRAW(0x75C),PRAW(0x75E),
//0x760: weird area
PCORE(0,MasterL.Reg_VOL),
PCORE(0,MasterR.Reg_VOL),
PCORE(0,FxL),
PCORE(0,FxR),
PCORE(0,ExtL),
PCORE(0,ExtR),
PCORE(0,InpL),
PCORE(0,InpR),
PCORE(0,MasterL.Value),
PCORE(0,MasterR.Value),
PCORE(0,Revb.IIR_ALPHA),
PCORE(0,Revb.ACC_COEF_A),
PCORE(0,Revb.ACC_COEF_B),
PCORE(0,Revb.ACC_COEF_C),
PCORE(0,Revb.ACC_COEF_D),
PCORE(0,Revb.IIR_COEF),
PCORE(0,Revb.FB_ALPHA),
PCORE(0,Revb.FB_X),
PCORE(0,Revb.IN_COEF_L),
PCORE(0,Revb.IN_COEF_R),
PCORE(1,MasterL.Reg_VOL),
PCORE(1,MasterR.Reg_VOL),
PCORE(1,FxL),
PCORE(1,FxR),
PCORE(1,ExtL),
PCORE(1,ExtR),
PCORE(1,InpL),
PCORE(1,InpR),
PCORE(1,MasterL.Value),
PCORE(1,MasterR.Value),
PCORE(1,Revb.IIR_ALPHA),
PCORE(1,Revb.ACC_COEF_A),
PCORE(1,Revb.ACC_COEF_B),
PCORE(1,Revb.ACC_COEF_C),
PCORE(1,Revb.ACC_COEF_D),
PCORE(1,Revb.IIR_COEF),
PCORE(1,Revb.FB_ALPHA),
PCORE(1,Revb.FB_X),
PCORE(1,Revb.IN_COEF_L),
PCORE(1,Revb.IN_COEF_R),
PRAW(0x7B0),PRAW(0x7B2),PRAW(0x7B4),PRAW(0x7B6),
PRAW(0x7B8),PRAW(0x7BA),PRAW(0x7BC),PRAW(0x7BE),
// SPDIF interface
U16P(Spdif.Out),
U16P(Spdif.Info),
U16P(Spdif.Unknown1),
U16P(Spdif.Mode),
U16P(Spdif.Media),
U16P(Spdif.Unknown2),
U16P(Spdif.Protection),
PRAW(0x7CE),
PRAW(0x7D0),PRAW(0x7D2),PRAW(0x7D4),PRAW(0x7D6),
PRAW(0x7D8),PRAW(0x7DA),PRAW(0x7DC),PRAW(0x7DE),
PRAW(0x7E0),PRAW(0x7E2),PRAW(0x7E4),PRAW(0x7E6),
PRAW(0x7E8),PRAW(0x7EA),PRAW(0x7EC),PRAW(0x7EE),
PRAW(0x7F0),PRAW(0x7F2),PRAW(0x7F4),PRAW(0x7F6),
PRAW(0x7F8),PRAW(0x7FA),PRAW(0x7FC),PRAW(0x7FE),
U16P(zero)
};

View File

@ -0,0 +1,244 @@
//GiGaHeRz's SPU2 Driver
//Copyright (c) 2003-2008, David Quintana <gigaherz@gmail.com>
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "SPU2.h"
struct SPU2freezeData
{
u32 version;
u8 unkregs[0x10000];
u8 mem[0x200000];
u32 id;
V_Core Cores[2];
V_SPDIF Spdif;
s16 OutPos;
s16 InputPos;
u8 InpBuff;
u32 Cycles;
s32 uTicks;
double srate_pv;
double opitch;
int osps;
int PlayMode;
int lClocks;
PcmCacheEntry cacheData;
};
#define SAVE_ID 0x73326701
// versioning for saves.
// Increment this if changes to V_Core or V_Voice structs are made.
// Chances are we'll never explicitly support older save versions,
// but might as well version them anyway. Could come in handly someday!
#define SAVE_VERSION 0x0101
static int getFreezeSize()
{
if( disableFreezes ) return 8; // length of the string id "invalid" (plus a zero!)
int size = sizeof(SPU2freezeData);
// calculate the amount of memory consumed by our cache:
for( int bidx=0; bidx<pcm_BlockCount; bidx++ )
{
if( pcm_cache_data[bidx].Validated )
size += pcm_DecodedSamplesPerBlock*sizeof(PcmCacheEntry);
}
return size;
}
static void wipe_the_cache()
{
memset( pcm_cache_data, 0, pcm_BlockCount * sizeof(PcmCacheEntry) );
}
static s16 old_state_sBuffer[pcm_DecodedSamplesPerBlock] = {0};
EXPORT_C_(s32) SPU2freeze(int mode, freezeData *data)
{
if (mode == FREEZE_LOAD)
{
const SPU2freezeData *spud = (SPU2freezeData*)data->data;
if( spud->id != SAVE_ID || spud->version < 0x100 )
{
printf("\n*** SPU2Ghz Warning:\n");
printf(" The savestate you are trying to load was not made with this plugin.\n");
printf(" The emulator will not be stable! Find a memorycard savespot to save your\n");
printf(" game, reset, and then continue from there.\n\n");
disableFreezes=true;
lClocks = 0;
resetClock = true;
// Do *not* reset the cores.
// We'll need some "hints" as to how the cores should be initialized,
// and the only way to get that is to use the game's existing core settings
// and hope they kinda match the settings for the savestate (IRQ enables and such).
//
//CoreReset( 0 );
//CoreReset( 1 );
// adpcm cache : Clear all the cache flags and buffers.
wipe_the_cache();
}
else
{
disableFreezes=false;
// base stuff
memcpy(spu2regs, spud->unkregs, 0x010000);
memcpy(_spu2mem, spud->mem, 0x200000);
memcpy(Cores, spud->Cores, sizeof(Cores));
memcpy(&Spdif, &spud->Spdif, sizeof(Spdif));
OutPos = spud->OutPos;
InputPos = spud->InputPos;
InpBuff = spud->InpBuff;
Cycles = spud->Cycles;
uTicks = spud->uTicks;
srate_pv = spud->srate_pv;
PlayMode = spud->PlayMode;
lClocks = spud->lClocks;
// Load the ADPCM cache:
wipe_the_cache();
if( spud->version == 0x100 ) // don't support 0x100 cache anymore.
{
printf("\n*** SPU2Ghz Warning:\n");
printf("\tSavestate version is from an older version of this plugin.\n");
printf("\tAudio may not recover correctly.");
const PcmCacheEntry* pcmSrc = &spud->cacheData;
int blksLoaded=0;
for( int bidx=0; bidx<pcm_BlockCount; bidx++ )
{
if( pcm_cache_data[bidx].Validated )
{
// load a cache block!
memcpy( &pcm_cache_data[bidx], pcmSrc, sizeof(PcmCacheEntry) );
pcmSrc++;
blksLoaded++;
}
}
// Go through the V_Voice structs and recalculate SBuffer pointer from
// the NextA setting.
for( int c=0; c<2; c++ )
{
for( int v=0; v<24; v++ )
{
const int cacheIdx = Cores[c].Voices[v].NextA / pcm_WordsPerBlock;
Cores[c].Voices[v].SBuffer = pcm_cache_data[cacheIdx].Sampledata;
}
}
}
else
{
// We don't support the cache, so make sure the SBuffer pointers
// are safe (don't want any GPFs reading bad data)
for( int c=0; c<2; c++ )
{
for( int v=0; v<24; v++ )
Cores[c].Voices[v].SBuffer = old_state_sBuffer;
}
}
//printf( " * SPU2 > FreezeLoad > Loaded %d cache blocks.\n", blksLoaded++ );
}
} else if (mode == FREEZE_SAVE)
{
if (data->data == NULL) return -1;
if( disableFreezes )
{
// No point in making a save state since the SPU2
// state is completely bogus anyway... Let's just
// give this some random ID that no one will recognize.
strcpy( data->data, "invalid" );
return 0;
}
SPU2freezeData *spud = (SPU2freezeData*)data->data;
spud->id=SAVE_ID;
spud->version=SAVE_VERSION;//ZEROSPU_VERSION; //Zero compat working bad, better not save that
memcpy(spud->unkregs, spu2regs, 0x010000);
memcpy(spud->mem, _spu2mem, 0x200000);
memcpy(spud->Cores, Cores, sizeof(Cores));
memcpy(&spud->Spdif, &Spdif, sizeof(Spdif));
spud->OutPos = OutPos;
spud->InputPos = InputPos;
spud->InpBuff = InpBuff;
spud->Cycles = Cycles;
spud->uTicks = uTicks;
spud->srate_pv = srate_pv;
spud->PlayMode = PlayMode;
spud->lClocks = lClocks;
// Save our cache:
// We could just force the user to rebuild the cache when loading
// from stavestates, but for most games the cache is pretty
// small and compresses well.
//
// Potential Alternative:
// If the cache is not saved then it is necessary to save the
// decoded blocks currently in use by active voices. This allows
// voices to resume seamlessly on load.
PcmCacheEntry* pcmDst = &spud->cacheData;
int blksSaved=0;
for( int bidx=0; bidx<pcm_BlockCount; bidx++ )
{
if( pcm_cache_data[bidx].Validated )
{
// save a cache block!
memcpy( pcmDst, &pcm_cache_data[bidx], sizeof(PcmCacheEntry) );
pcmDst++;
blksSaved++;
}
}
//printf( " * SPU2 > FreezeSave > Saved %d cache blocks.\n", blksSaved++ );
}
else if (mode == FREEZE_SIZE)
{
data->size = getFreezeSize();
}
return 0;
}

View File

@ -20,35 +20,20 @@
#include <assert.h> #include <assert.h>
#include "regtable.h" #include "regtable.h"
#include "svnrev.h"
void StartVoices(int core, u32 value); void StartVoices(int core, u32 value);
void StopVoices(int core, u32 value); void StopVoices(int core, u32 value);
void InitADSR(); void InitADSR();
const unsigned char version = PS2E_SPU2_VERSION;
const unsigned char revision = 1;
const unsigned char build = 9; // increase that with each version
static __forceinline void SPU2_FastWrite( u32 rmem, u16 value );
static void SPU2writeLog(u32 rmem, u16 value);
DWORD CALLBACK TimeThread(PVOID /* unused param */); DWORD CALLBACK TimeThread(PVOID /* unused param */);
const char *ParamNames[8]={"VOLL","VOLR","PITCH","ADSR1","ADSR2","ENVX","VOLXL","VOLXR"}; const char *ParamNames[8]={"VOLL","VOLR","PITCH","ADSR1","ADSR2","ENVX","VOLXL","VOLXR"};
const char *AddressNames[6]={"SSAH","SSAL","LSAH","LSAL","NAXH","NAXL"}; const char *AddressNames[6]={"SSAH","SSAL","LSAH","LSAL","NAXH","NAXL"};
double opitch;
int osps;
// [Air]: Adding the spu2init boolean wasn't necessary except to help me in
// debugging the spu2 suspend/resume behavior (when user hits escape).
static bool spu2open=false; // has spu2open plugin interface been called?
static bool spu2init=false; // has spu2init plugin interface been called?
// [Air]: fixed the hacky part of UpdateTimer with this: // [Air]: fixed the hacky part of UpdateTimer with this:
static bool resetClock = true; bool resetClock = true;
// Used to make spu2 more robust at loading incompatible saves. // Used to make spu2 more robust at loading incompatible saves.
// Disables re-freezing of save state data. // Disables re-freezing of save state data.
@ -78,11 +63,9 @@ s16 InputPos;
u8 InpBuff; u8 InpBuff;
u32 Cycles; u32 Cycles;
u32 Num; u32 Num;
u32 acumCycles;
u32* cPtr=NULL; u32* cPtr=NULL;
u32 lClocks=0; u32 lClocks=0;
u32 pClocks=0;
bool hasPtr=false; bool hasPtr=false;
@ -95,12 +78,8 @@ HINSTANCE hInstance;
bool debugDialogOpen=false; bool debugDialogOpen=false;
HWND hDebugDialog=NULL; HWND hDebugDialog=NULL;
static char libraryName[256];
CRITICAL_SECTION threadSync; CRITICAL_SECTION threadSync;
s32 logvolume[16384];
bool has_to_call_irq=false; bool has_to_call_irq=false;
void SetIrqCall() void SetIrqCall()
@ -108,12 +87,6 @@ void SetIrqCall()
has_to_call_irq=true; has_to_call_irq=true;
} }
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD dwReason,LPVOID lpvReserved)
{
if(dwReason==DLL_PROCESS_ATTACH) hInstance=hinstDLL;
return TRUE;
}
void SysMessage(const char *fmt, ...) void SysMessage(const char *fmt, ...)
{ {
va_list list; va_list list;
@ -125,80 +98,6 @@ void SysMessage(const char *fmt, ...)
MessageBox(0, tmp, "SPU2ghz Msg", 0); MessageBox(0, tmp, "SPU2ghz Msg", 0);
} }
static void InitLibraryName()
{
#ifdef PUBLIC
// Public Release!
// Output a simplified string that's just our name:
strcpy( libraryName, "SPU2ghz" );
#elif defined( SVN_REV_UNKNOWN )
// Unknown revision.
// Output a name that includes devbuild status but not
// subversion revision tags:
strcpy( libraryName, "SPU2ghz"
# ifdef _DEBUG_FAST
"-Debug"
# elif defined( DEBUG )
"-Debug/Strict" // strict debugging is slow!
# else
"-Dev"
# endif
);
#else
// Use TortoiseSVN's SubWCRev utility's output
// to label the specific revision:
sprintf_s( libraryName, "SPU2ghz r%d%s"
# ifdef _DEBUG_FAST
"-Debug"
# elif defined( _DEBUG )
"-Debug/Strict" // strict debugging is slow!
# else
"-Dev"
# endif
,SVN_REV,
SVN_MODS ? "m" : ""
);
#endif
}
EXPORT_C_(u32) PS2EgetLibType()
{
return PS2E_LT_SPU2;
}
EXPORT_C_(char*) PS2EgetLibName()
{
InitLibraryName();
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
{
return (version<<16)|(revision<<8)|build;
}
EXPORT_C_(void) SPU2configure() {
configure();
}
EXPORT_C_(void) SPU2about() {
InitLibraryName();
SysMessage( libraryName );
}
EXPORT_C_(s32) SPU2test() {
return SndTest();
}
__forceinline s16 * __fastcall GetMemPtr(u32 addr) __forceinline s16 * __fastcall GetMemPtr(u32 addr)
{ {
#ifndef _DEBUG_FAST #ifndef _DEBUG_FAST
@ -240,6 +139,12 @@ __inline void __fastcall spu2M_Write( u32 addr, u16 value )
spu2M_Write( addr, (s16)value ); spu2M_Write( addr, (s16)value );
} }
__forceinline void RegLog(int level, char *RName,u32 mem,u32 core,u16 value)
{
if( level > 1 )
FileLog("[%10d] SPU2 write mem %08x (core %d, register %s) value %04x\n",Cycles,mem,core,RName,value);
}
void AssignVolume(V_Volume& vol, s16 value) void AssignVolume(V_Volume& vol, s16 value)
{ {
vol.Reg_VOL = value; vol.Reg_VOL = value;
@ -324,109 +229,6 @@ void CoreReset(int c)
ConLog("done.\n"); ConLog("done.\n");
} }
extern void LowPassFilterInit();
EXPORT_C_(s32) SPU2init()
{
#define MAKESURE(a,b) \
/*fprintf(stderr,"%08p: %08p == %08p\n",&(regtable[a>>1]),regtable[a>>1],U16P(b));*/ \
assert(regtable[(a)>>1]==U16P(b))
MAKESURE(0x800,zero);
s32 c=0,v=0;
ReadSettings();
acumCycles=0;
#ifdef SPU2_LOG
if(AccessLog())
{
spu2Log = fopen(AccessLogFileName, "w");
setvbuf(spu2Log, NULL, _IONBF, 0);
FileLog("SPU2init\n");
}
#endif
srand((unsigned)time(NULL));
disableFreezes=false;
if (spu2init)
{
ConLog( " * SPU2: Already initialized - Ignoring SPU2init signal." );
return 0;
}
spu2init=true;
spu2regs = (short*)malloc(0x010000);
_spu2mem = (short*)malloc(0x200000);
// adpcm decoder cache:
// the cache data size is determined by taking the number of adpcm blocks
// (2MB / 16) and multiplying it by the decoded block size (28 samples).
// Thus: pcm_cache_data = 7,340,032 bytes (ouch!)
// Expanded: 16 bytes expands to 56 bytes [3.5:1 ratio]
// Resulting in 2MB * 3.5.
pcm_cache_data = (PcmCacheEntry*)calloc( pcm_BlockCount, sizeof(PcmCacheEntry) );
if( (spu2regs == NULL) || (_spu2mem == NULL) ||
(pcm_cache_data == NULL) )
{
SysMessage("SPU2: Error allocating Memory\n"); return -1;
}
for(int mem=0;mem<0x800;mem++)
{
u16 *ptr=regtable[mem>>1];
if(!ptr) {
regtable[mem>>1] = &(spu2Ru16(mem));
}
}
memset(spu2regs,0,0x010000);
memset(_spu2mem,0,0x200000);
memset(&Cores,0,(sizeof(V_Core) * 2));
CoreReset(0);
CoreReset(1);
DMALogOpen();
if(WaveLog())
{
if(!wavedump_open())
{
SysMessage("Can't open '%s'.\nWave Log disabled.",WaveLogFileName);
}
}
for(v=0;v<16384;v++)
{
logvolume[v]=(s32)(s32)floor(log((double)(v+1))*3376.7);
}
LowPassFilterInit();
InitADSR();
#ifdef STREAM_DUMP
il0=fopen("logs/spu2input0.pcm","wb");
il1=fopen("logs/spu2input1.pcm","wb");
#endif
#ifdef EFFECTS_DUMP
el0=fopen("logs/spu2fx0.pcm","wb");
el1=fopen("logs/spu2fx1.pcm","wb");
#endif
#ifdef S2R_ENABLE
if(!replay_mode)
s2r_open("replay_dump.s2r");
#endif
return 0;
}
static BOOL CALLBACK DebugProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) static BOOL CALLBACK DebugProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{ {
int wmId,wmEvent; int wmId,wmEvent;
@ -461,99 +263,7 @@ static BOOL CALLBACK DebugProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
return TRUE; return TRUE;
} }
EXPORT_C_(s32) SPU2open(void *pDsp) #ifndef PUBLIC
{
if( spu2open ) return 0;
FileLog("[%10d] SPU2 Open\n",Cycles);
/*
if(debugDialogOpen==0)
{
hDebugDialog = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_DEBUG),0,DebugProc,0);
ShowWindow(hDebugDialog,SW_SHOWNORMAL);
debugDialogOpen=1;
}*/
spu2open=true;
if (!SndInit())
{
srate_pv=(double)SampleRate/48000.0;
spdif_init();
DspLoadLibrary(dspPlugin,dspPluginModule);
return 0;
}
else
{
SPU2close();
return -1;
};
}
EXPORT_C_(void) SPU2close()
{
if( !spu2open ) return;
FileLog("[%10d] SPU2 Close\n",Cycles);
DspCloseLibrary();
spdif_shutdown();
SndClose();
spu2open = false;
}
EXPORT_C_(void) SPU2shutdown()
{
if(!spu2init) return;
ConLog( " * SPU2: Shutting down.\n" );
SPU2close();
#ifdef S2R_ENABLE
if(!replay_mode)
s2r_close();
#endif
DoFullDump();
#ifdef STREAM_DUMP
fclose(il0);
fclose(il1);
#endif
#ifdef EFFECTS_DUMP
fclose(el0);
fclose(el1);
#endif
if(WaveLog() && wavedump_ok) wavedump_close();
DMALogClose();
spu2init = false;
SAFE_FREE(spu2regs);
SAFE_FREE(_spu2mem);
SAFE_FREE( pcm_cache_data );
spu2regs = NULL;
_spu2mem = NULL;
pcm_cache_data = NULL;
#ifdef SPU2_LOG
if(!AccessLog()) return;
FileLog("[%10d] SPU2shutdown\n",Cycles);
if(spu2Log) fclose(spu2Log);
#endif
}
EXPORT_C_(void) SPU2setClockPtr(u32 *ptr)
{
cPtr=ptr;
hasPtr=(cPtr!=NULL);
}
int FillRectangle(HDC dc, int left, int top, int width, int height) int FillRectangle(HDC dc, int left, int top, int width, int height)
{ {
@ -577,7 +287,7 @@ BOOL DrawRectangle(HDC dc, int left, int top, int width, int height)
return Polyline(dc, p, 5); return Polyline(dc, p, 5);
} }
#ifndef PUBLIC
HFONT hf = NULL; HFONT hf = NULL;
int lCount=0; int lCount=0;
void UpdateDebugDialog() void UpdateDebugDialog()
@ -689,27 +399,6 @@ void UpdateDebugDialog()
u32 TicksCore=0; u32 TicksCore=0;
u32 TicksThread=0; u32 TicksThread=0;
static DWORD CALLBACK TimeThread(PVOID /* unused param */)
{
while(spu2open)
{
if(TicksThread>=(TicksCore+320))
{
Sleep(1);
}
else if(TicksThread>=TicksCore)
{
Sleep(0);
}
else
{
Mix();
TicksThread++;
}
}
return 0;
}
void __fastcall TimeUpdate(u32 cClocks) void __fastcall TimeUpdate(u32 cClocks)
{ {
u32 dClocks = cClocks-lClocks; u32 dClocks = cClocks-lClocks;
@ -794,69 +483,7 @@ void __fastcall TimeUpdate(u32 cClocks)
} }
} }
bool numpad_minus_old=false; static u16 mask = 0xFFFF;
bool numpad_minus = false;
bool numpad_plus = false, numpad_plus_old = false;
EXPORT_C_(void) SPU2async(u32 cycles)
{
#ifndef PUBLIC
u32 oldClocks = lClocks;
static u32 timer=0,time1=0,time2=0;
timer++;
if (timer == 1){
time1=timeGetTime();
}
if (timer == 3000){
time2 = timeGetTime()-time1 ;
timer=0;
}
#endif
DspUpdate();
if(LimiterToggleEnabled)
{
numpad_minus = (GetAsyncKeyState(VK_SUBTRACT)&0x8000)!=0;
if(numpad_minus && !numpad_minus_old)
{
if(LimitMode) LimitMode=0;
else LimitMode=1;
SndUpdateLimitMode();
}
numpad_minus_old = numpad_minus;
}
#ifndef PUBLIC
/*numpad_plus = (GetAsyncKeyState(VK_ADD)&0x8000)!=0;
if(numpad_plus && !numpad_plus_old)
{
DoFullDump();
}
numpad_plus_old = numpad_plus;*/
#endif
if(hasPtr)
{
TimeUpdate(*cPtr);
}
else
{
pClocks+=cycles;
TimeUpdate(pClocks);
}
}
EXPORT_C_(void) SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)())
{
_irqcallback=SPU2callback;
dma4callback=DMA4callback;
dma7callback=DMA7callback;
}
u16 mask = 0xFFFF;
void UpdateSpdifMode() void UpdateSpdifMode()
{ {
@ -896,13 +523,7 @@ void UpdateSpdifMode()
} }
} }
__forceinline void RegLog(int level, char *RName,u32 mem,u32 core,u16 value) void SPU_ps1_write(u32 mem, u16 value)
{
if( level > 1 )
FileLog("[%10d] SPU2 write mem %08x (core %d, register %s) value %04x\n",Cycles,mem,core,RName,value);
}
static void SPU_ps1_write(u32 mem, u16 value)
{ {
bool show=true; bool show=true;
@ -1043,7 +664,7 @@ static void SPU_ps1_write(u32 mem, u16 value)
spu2Ru16(mem)=value; spu2Ru16(mem)=value;
} }
static u16 SPU_ps1_read(u32 mem) u16 SPU_ps1_read(u32 mem)
{ {
bool show=true; bool show=true;
u16 value = spu2Ru16(mem); u16 value = spu2Ru16(mem);
@ -1120,7 +741,7 @@ static u16 SPU_ps1_read(u32 mem)
void RegWriteLog(u32 core,u16 value); void RegWriteLog(u32 core,u16 value);
static void SPU2writeLog(u32 rmem, u16 value) void SPU2writeLog(u32 rmem, u16 value)
{ {
#ifndef PUBLIC #ifndef PUBLIC
u32 vx=0, vc=0, core=0, omem=rmem, mem=rmem&0x7FF; u32 vx=0, vc=0, core=0, omem=rmem, mem=rmem&0x7FF;
@ -1329,8 +950,7 @@ static void SPU2writeLog(u32 rmem, u16 value)
#endif #endif
} }
__forceinline void SPU2_FastWrite( u32 rmem, u16 value )
static __forceinline void SPU2_FastWrite( u32 rmem, u16 value )
{ {
u32 vx=0, vc=0, core=0, omem, mem; u32 vx=0, vc=0, core=0, omem, mem;
omem=mem=rmem & 0x7FF; //FFFF; omem=mem=rmem & 0x7FF; //FFFF;
@ -1622,315 +1242,6 @@ static __forceinline void SPU2_FastWrite( u32 rmem, u16 value )
} }
EXPORT_C_(void) SPU2write(u32 rmem, u16 value)
{
#ifdef S2R_ENABLE
if(!replay_mode)
s2r_writereg(Cycles,rmem,value);
#endif
if(rmem==0x1f9001ac)
{
//RegWriteLog(0,value);
if((Cores[0].IRQEnable)&&(Cores[0].TSA==Cores[0].IRQA))
{
Spdif.Info=4;
SetIrqCall();
}
spu2M_Write( Cores[0].TSA++, value );
Cores[0].TSA&=0xfffff;
}
else if(rmem==0x1f9005ac)
{
//RegWriteLog(1,value);
if((Cores[0].IRQEnable)&&(Cores[0].TSA==Cores[0].IRQA))
{
Spdif.Info=4;
SetIrqCall();
}
spu2M_Write( Cores[1].TSA++, value );
Cores[1].TSA&=0xfffff;
}
else
{
if(hasPtr) TimeUpdate(*cPtr);
if (rmem>>16 == 0x1f80)
SPU_ps1_write(rmem,value);
else
SPU2_FastWrite( rmem, value );
}
}
EXPORT_C_(u16) SPU2read(u32 rmem)
{
// if(!replay_mode)
// s2r_readreg(Cycles,rmem);
if(hasPtr) TimeUpdate(*cPtr);
u16 ret=0xDEAD; u32 core=0, mem=rmem&0xFFFF, omem=mem;
if (mem & 0x400) { omem^=0x400; core=1; }
if(rmem==0x1f9001AC)
{
ret = DmaRead(core);
}
else if (rmem>>16 == 0x1f80)
{
ret = SPU_ps1_read(rmem);
}
else if ((mem&0xFFFF)>=0x800)
{
ret=spu2Ru16(mem);
ConLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret);
FileLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret);
}
else
{
ret = *(regtable[(mem>>1)]);
FileLog("[%10d] SPU2 read mem %x (core %d, register %x): %x\n",Cycles, mem, core, (omem & 0x7ff), ret);
}
return ret;
}
typedef struct
{
// compatibility with zerospu2 removed...
u32 version;
u8 unkregs[0x10000];
u8 mem[0x200000];
u32 id;
V_Core Cores[2];
V_SPDIF Spdif;
s16 OutPos;
s16 InputPos;
u8 InpBuff;
u32 Cycles;
s32 uTicks;
double srate_pv;
double opitch;
int osps;
int PlayMode;
int lClocks;
PcmCacheEntry cacheData;
} SPU2freezeData;
// No more ZeroSPU compatibility...
//#define ZEROSPU_VERSION 0x70000001
#define SAVE_ID 0x73326701
// versioning for saves.
// Increment this if changes to V_Core or V_Voice structs are made.
// Chances are we'll never explicitly support older save versions,
// but might as well version them anyway. Could come in handly someday!
#define SAVE_VERSION 0x0101
static int getFreezeSize()
{
if( disableFreezes ) return 8; // length of the string id "invalid" (plus a zero!)
int size = sizeof(SPU2freezeData);
// calculate the amount of memory consumed by our cache:
for( int bidx=0; bidx<pcm_BlockCount; bidx++ )
{
if( pcm_cache_data[bidx].Validated )
size += pcm_DecodedSamplesPerBlock*sizeof(PcmCacheEntry);
}
return size;
}
static void wipe_the_cache()
{
memset( pcm_cache_data, 0, pcm_BlockCount * sizeof(PcmCacheEntry) );
}
static s16 old_state_sBuffer[pcm_DecodedSamplesPerBlock] = {0};
EXPORT_C_(s32) SPU2freeze(int mode, freezeData *data)
{
if (mode == FREEZE_LOAD)
{
const SPU2freezeData *spud = (SPU2freezeData*)data->data;
if( spud->id != SAVE_ID || spud->version < 0x100 )
{
printf("\n*** SPU2Ghz Warning:\n");
printf(" The savestate you are trying to load was not made with this plugin.\n");
printf(" The emulator will not be stable! Find a memorycard savespot to save your\n");
printf(" game, reset, and then continue from there.\n\n");
disableFreezes=true;
lClocks = 0;
resetClock = true;
// Do *not* reset the cores.
// We'll need some "hints" as to how the cores should be initialized,
// and the only way to get that is to use the game's existing core settings
// and hope they kinda match the settings for the savestate (IRQ enables and such).
//
//CoreReset( 0 );
//CoreReset( 1 );
// adpcm cache : Clear all the cache flags and buffers.
wipe_the_cache();
}
else
{
disableFreezes=false;
// base stuff
memcpy(spu2regs, spud->unkregs, 0x010000);
memcpy(_spu2mem, spud->mem, 0x200000);
memcpy(Cores, spud->Cores, sizeof(Cores));
memcpy(&Spdif, &spud->Spdif, sizeof(Spdif));
OutPos = spud->OutPos;
InputPos = spud->InputPos;
InpBuff = spud->InpBuff;
Cycles = spud->Cycles;
uTicks = spud->uTicks;
srate_pv = spud->srate_pv;
opitch = spud->opitch;
osps = spud->osps;
PlayMode = spud->PlayMode;
lClocks = spud->lClocks;
// Load the ADPCM cache:
wipe_the_cache();
if( spud->version == 0x100 ) // don't support 0x100 cache anymore.
{
printf("\n*** SPU2Ghz Warning:\n");
printf("\tSavestate version is from an older version of this plugin.\n");
printf("\tAudio may not recover correctly.");
const PcmCacheEntry* pcmSrc = &spud->cacheData;
int blksLoaded=0;
for( int bidx=0; bidx<pcm_BlockCount; bidx++ )
{
if( pcm_cache_data[bidx].Validated )
{
// load a cache block!
memcpy( &pcm_cache_data[bidx], pcmSrc, sizeof(PcmCacheEntry) );
pcmSrc++;
blksLoaded++;
}
}
// Go through the V_Voice structs and recalculate SBuffer pointer from
// the NextA setting.
for( int c=0; c<2; c++ )
{
for( int v=0; v<24; v++ )
{
const int cacheIdx = Cores[c].Voices[v].NextA / pcm_WordsPerBlock;
Cores[c].Voices[v].SBuffer = pcm_cache_data[cacheIdx].Sampledata;
}
}
}
else
{
// We don't support the cache, so make sure the SBuffer pointers
// are safe (don't want any GPFs reading bad data)
for( int c=0; c<2; c++ )
{
for( int v=0; v<24; v++ )
Cores[c].Voices[v].SBuffer = old_state_sBuffer;
}
}
//printf( " * SPU2 > FreezeLoad > Loaded %d cache blocks.\n", blksLoaded++ );
}
} else if (mode == FREEZE_SAVE)
{
if (data->data == NULL) return -1;
if( disableFreezes )
{
// No point in making a save state since the SPU2
// state is completely bogus anyway... Let's just
// give this some random ID that no one will recognize.
strcpy( data->data, "invalid" );
return 0;
}
SPU2freezeData *spud = (SPU2freezeData*)data->data;
spud->id=SAVE_ID;
spud->version=SAVE_VERSION;//ZEROSPU_VERSION; //Zero compat working bad, better not save that
memcpy(spud->unkregs, spu2regs, 0x010000);
memcpy(spud->mem, _spu2mem, 0x200000);
memcpy(spud->Cores, Cores, sizeof(Cores));
memcpy(&spud->Spdif, &Spdif, sizeof(Spdif));
spud->OutPos = OutPos;
spud->InputPos = InputPos;
spud->InpBuff = InpBuff;
spud->Cycles = Cycles;
spud->uTicks = uTicks;
spud->srate_pv = srate_pv;
spud->opitch = opitch;
spud->osps = osps;
spud->PlayMode = PlayMode;
spud->lClocks = lClocks;
// Save our cache:
// We could just force the user to rebuild the cache when loading
// from stavestates, but for most games the cache is pretty
// small and compresses well.
//
// Potential Alternative:
// If the cache is not saved then it is necessary to save the
// decoded blocks currently in use by active voices. This allows
// voices to resume seamlessly on load.
PcmCacheEntry* pcmDst = &spud->cacheData;
int blksSaved=0;
for( int bidx=0; bidx<pcm_BlockCount; bidx++ )
{
if( pcm_cache_data[bidx].Validated )
{
// save a cache block!
memcpy( pcmDst, &pcm_cache_data[bidx], sizeof(PcmCacheEntry) );
pcmDst++;
blksSaved++;
}
}
//printf( " * SPU2 > FreezeSave > Saved %d cache blocks.\n", blksSaved++ );
}
else if (mode == FREEZE_SIZE)
{
data->size = getFreezeSize();
}
return 0;
}
void VoiceStart(int core,int vc) void VoiceStart(int core,int vc)
{ {
if((Cycles-Cores[core].Voices[vc].PlayCycle)>=4) if((Cycles-Cores[core].Voices[vc].PlayCycle)>=4)
@ -1958,7 +1269,7 @@ void VoiceStart(int core,int vc)
Cores[core].Regs.ENDX&=~(1<<vc); Cores[core].Regs.ENDX&=~(1<<vc);
#ifndef PUBLIC #ifndef PUBLIC
DebugCores[core].Voices[vc].FirstBlock=1; DebugCores[core].Voices[vc].FirstBlock=1;
if(core==1) if(core==1)
{ {
@ -1971,7 +1282,7 @@ void VoiceStart(int core,int vc)
Cores[core].Voices[vc].VolumeL.Value,Cores[core].Voices[vc].VolumeR.Value, Cores[core].Voices[vc].VolumeL.Value,Cores[core].Voices[vc].VolumeR.Value,
Cores[core].Voices[vc].ADSR.Reg_ADSR1,Cores[core].Voices[vc].ADSR.Reg_ADSR2); Cores[core].Voices[vc].ADSR.Reg_ADSR1,Cores[core].Voices[vc].ADSR.Reg_ADSR2);
} }
#endif #endif
} }
else else
{ {
@ -2010,28 +1321,3 @@ void StopVoices(int core, u32 value)
} }
} }
// if start is 1, starts recording spu2 data, else stops
// returns a non zero value if successful
// for now, pData is not used
EXPORT_C_(int) SPU2setupRecording(int start, void* pData)
{
// Don't record if we have a bogus state.
if( disableFreezes ) return 0;
if(start==0)
{
//stop recording
RecordStop();
if(recording==0)
return 1;
}
else if(start==1)
{
//start recording
RecordStart();
if(recording!=0)
return 1;
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More