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

View File

@ -1,46 +1,92 @@
/* CD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __CD_H__
#define __CD_H__
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "../PS2Edefs.h"
// Exported Functions
extern void InitCDInfo();
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 CDgetBufferOffset();
extern s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq);
extern s32 CDgetTN(cdvdTN *cdvdtn);
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 CDgetDiskType(s32 ioctldisktype);
#endif /* __CD_H__ */

View File

@ -1,29 +1,58 @@
/* CDVDiso.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CDVDISO_H
#define CDVDISO_H
// #define VERBOSE_FUNCTION_INTERFACE
#endif /* CDVDISO_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +1,90 @@
/* DVD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __DVD_H__
#define __DVD_H__
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
// Exported Functions
extern void HexDump(u8 *strptr, u8 count);
extern void InitDVDInfo();
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DVDgetTN(cdvdTN *cdvdtn);
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 DVDgetDiskType(s32 ioctldisktype);
#endif /* __DVD_H__ */

View File

@ -1,106 +1,212 @@
/* aboutbox.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new()
#include "version.h"
#include "aboutbox.h"
struct AboutBoxData aboutbox;
gint AboutBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
if(aboutbox.window != NULL) {
gtk_widget_destroy(aboutbox.window);
aboutbox.window = NULL;
} // ENDIF- Do we have an About Box still?
gtk_main_quit();
return(TRUE);
} // END AboutBoxCancelEvent()
void AboutBoxDisplay() {
GtkWidget *item;
GtkWidget *container;
GtkWidget *vbox1;
char templine[256];
aboutbox.window = NULL;
aboutbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(aboutbox.window), 5);
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_modal(GTK_WINDOW(aboutbox.window), TRUE);
gtk_window_set_resizable(GTK_WINDOW(aboutbox.window), FALSE);
g_signal_connect(G_OBJECT(aboutbox.window), "delete_event",
G_CALLBACK(AboutBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(aboutbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1);
sprintf(templine, "%s v%i.%i", libname, revision, build);
item = gtk_label_new(templine);
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item);
item = NULL;
item = gtk_label_new("Current Author: efp");
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item);
item = NULL;
item = gtk_label_new("Original code by: linuzappz & shadow");
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item);
item = NULL;
container = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), container, TRUE, TRUE, 0);
gtk_widget_show(container);
item = gtk_button_new_with_label("Ok");
gtk_container_add(GTK_CONTAINER(container), item);
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(AboutBoxCancelEvent), NULL);
item = NULL;
container = NULL;
vbox1 = NULL;
gtk_widget_show(aboutbox.window);
gtk_main();
} // END AboutDisplay()

View File

@ -1,39 +1,78 @@
/* aboutbox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef ABOUTBOX_H
#define ABOUTBOX_H
#include <gtk/gtkwidget.h>
struct AboutBoxData {
GtkWidget *window; // GtkWindow - About Box
};
extern struct AboutBoxData aboutbox;
extern void AboutBoxDisplay();
#endif /* ABOUTBOX_H */

View File

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

View File

@ -1,50 +1,100 @@
/* actualfile.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef ACTUALFILE_H
#define ACTUALFILE_H
#include <sys/types.h> // off64_t
#define ACTUALHANDLE int
#define ACTUALHANDLENULL -1
// #define VERBOSE_FUNCTION_ACTUALFILE
// #define VERBOSE_WARNING_ACTUALFILE
extern int IsActualFile(const char *filename);
extern void ActualFileDelete(const char *filename);
extern void ActualFileRename(const char *origname, const char *newname);
extern ACTUALHANDLE ActualFileOpenForRead(const char *filename);
extern off64_t ActualFileSize(ACTUALHANDLE handle);
extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position);
extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer);
extern void ActualFileClose(ACTUALHANDLE handle);
extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename);
extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer);
#endif /* ACTUALFILE_H */

View File

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

View File

@ -1,24 +1,48 @@
/* comparisondummy.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
void ConversionBoxRefocus() { return; }
void DeviceBoxRefocus() { return; }

View File

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

View File

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

View File

@ -1,47 +1,94 @@
/* conversionbox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CONVERSIONBOX_H
#define CONVERSIONBOX_H
#include <gtk/gtkwidget.h>
struct ConversionBoxData {
GtkWidget *window; // GtkWindow
GtkWidget *file; // GtkEntry
GtkWidget *selectbutton; // GtkButton
GtkWidget *filedesc; // GtkLabel
GtkWidget *compress; // GtkComboBox
GtkWidget *multi; // GtkCheckButton
GtkWidget *okbutton; // GtkButton
GtkWidget *cancelbutton; // GtkButton
};
extern struct ConversionBoxData conversionbox;
extern void ConversionBoxDestroy();
extern void ConversionBoxRefocus();
extern void ConversionBoxDisplay();
#endif /* CONVERSIONBOX_H */

View File

@ -1,69 +1,138 @@
/* device.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __DEVICE_H__
#define __DEVICE_H__
#include <time.h> // time_t
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "../PS2Edefs.h"
// #define VERBOSE_FUNCTION_DEVICE
// #define VERBOSE_WARNINGS
#define VERBOSE_DISC_TYPE
#define VERBOSE_DISC_INFO
// Device Data
extern int devicehandle;
extern s32 devicecapability; // Need to export?
extern time_t lasttime;
extern s32 traystatus;
extern s32 disctype;
extern u8 tocbuffer[];
// Device Functions
extern void DeviceInit();
extern void InitDisc();
extern s32 DiscInserted();
extern s32 DeviceOpen();
extern void DeviceClose();
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DeviceBufferOffset();
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
extern s32 DeviceGetDiskType();
extern s32 DeviceTrayStatus();
extern s32 DeviceTrayOpen();
extern s32 DeviceTrayClose();
#endif /* __DEVICE_H__ */

View File

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

View File

@ -1,50 +1,100 @@
/* devicebox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef DEVICEBOX_H
#define DEVICEBOX_H
#include <gtk/gtkwidget.h>
struct DeviceBoxData {
GtkWidget *window; // GtkWindow
GtkWidget *device; // GtkEntry
GtkWidget *devicedesc; // GtkLabel
GtkWidget *file; // GtkEntry
GtkWidget *selectbutton; // GtkButton
GtkWidget *filedesc; // GtkLabel
GtkWidget *compress; // GtkComboBox
GtkWidget *multi; // GtkCheckButton
GtkWidget *okbutton; // GtkButton
GtkWidget *cancelbutton; // GtkButton
};
extern struct DeviceBoxData devicebox;
extern void DeviceBoxDestroy();
// extern void DeviceBoxUnfocus();
extern void DeviceBoxRefocus();
extern void DeviceBoxDisplay();
#endif /* DEVICEBOX_H */

View File

@ -1,67 +1,134 @@
/* interface.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <string.h> // strcmp()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkwidget.h> // gtk_widget_show_all()
#include "logfile.h"
#include "conf.h"
#include "aboutbox.h"
#include "mainbox.h"
#include "devicebox.h"
#include "selectionbox.h"
#include "progressbox.h"
#include "messagebox.h"
#include "conversionbox.h"
#include "interface.h"
int main(int argc, char *argv[]) {
if(argc != 2) return(1);
gtk_init(NULL, NULL);
if(!strcmp(argv[1], "about")) {
AboutBoxDisplay();
return(0);
} else if (!strcmp(argv[1], "configure")) {
OpenLog();
InitConf();
LoadConf();
MainBoxDisplay();
DeviceBoxDisplay();
ConversionBoxDisplay();
ProgressBoxDisplay();
MessageBoxDisplay();
SelectionBoxDisplay();
gtk_widget_show_all(mainbox.window);
gtk_main();
CloseLog();
return(0);
} // ENDLONGIF- Which display would you like to see?
return(1); // No Displays chosen? Abort!
} // END main()

View File

@ -1,29 +1,58 @@
/* interface.h
* Copyright (C) 2002-2004 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef INTERFACE_H
#define INTERFACE_H
// Place holder... for now
#endif /* INTERFACE_H */

View File

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

View File

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

View File

@ -1,113 +1,226 @@
/* messagebox.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h> // NULL
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new()
#include "mainbox.h"
#include "devicebox.h"
#include "conversionbox.h"
#include "messagebox.h"
struct MessageBoxData messagebox;
void MessageBoxDestroy() {
if(messagebox.window != NULL) {
gtk_widget_destroy(messagebox.window);
messagebox.window = NULL;
messagebox.desc = NULL;
} // ENDIF- Do we have a Main Window still?
} // END MessageBoxDestroy()
void MessageBoxShow(char *message, int wherefrom) {
gtk_label_set_text(GTK_LABEL(messagebox.desc), message);
messagebox.wherefrom = wherefrom;
gtk_widget_show_all(messagebox.window);
gtk_window_deiconify(GTK_WINDOW(messagebox.window));
} // END MessageBox()
gint MessageBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
gtk_widget_hide(messagebox.window);
switch(messagebox.wherefrom) {
case 1:
MainBoxRefocus();
break;
case 2:
DeviceBoxRefocus();
break;
case 3:
ConversionBoxRefocus();
break;
} // ENDSWITCH- Whose window do I get to re-focus when this is done?
return(TRUE);
} // END MessageBoxCancelEvent()
void MessageBoxDisplay() {
GtkWidget *item;
GtkWidget *hbox1;
GtkWidget *vbox1;
messagebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(messagebox.window), 5);
gtk_window_set_title(GTK_WINDOW(messagebox.window), "CDVDisoEFP");
gtk_window_set_position(GTK_WINDOW(messagebox.window), GTK_WIN_POS_CENTER);
gtk_window_set_resizable(GTK_WINDOW(messagebox.window), FALSE);
g_signal_connect(G_OBJECT(messagebox.window), "delete_event",
G_CALLBACK(MessageBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(messagebox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1);
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_widget_show(messagebox.desc);
hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1);
item = gtk_button_new_with_label("Cancel");
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(MessageBoxCancelEvent), NULL);
item = NULL;
hbox1 = NULL;
vbox1 = NULL;
} // END MessageBoxDisplay()

View File

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

View File

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

View File

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

View File

@ -1,44 +1,88 @@
/* CD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CD_H
#define CD_H
#include <windows.h> // DWORD
#define CDVDdefs
#include "PS2Edefs.h"
extern DWORD cdblocksize;
extern void InitCDInfo();
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 CDgetBufferOffset();
extern s32 CDreadSubQ();
extern s32 CDgetTN(cdvdTN *cdvdtn);
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 CDgetDiskType();
#endif /* CD_H */

View File

@ -1,36 +1,72 @@
/* CDVDiso.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CDVDISO_H
#define CDVDISO_H
#include <windows.h> // HINSTANCE
// #define VERBOSE_FUNCTION_INTERFACE
extern HINSTANCE progmodule;
extern char isobuffer[];
#endif /* CDVDISO_H */

View File

@ -1,37 +1,74 @@
/* DVD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef DVD_H
#define DVD_H
#define CDVDdefs
#include "PS2Edefs.h"
extern void InitDVDInfo();
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DVDgetTN(cdvdTN *cdvdtn);
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 DVDgetDiskType();
#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
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <errno.h> // errno
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <stdlib.h> // getenv()
#include <string.h> // strerror()
#include <sys/stat.h> // mkdir(), stat()
#include <sys/types.h> // mkdir(), stat(), fork()
#include <unistd.h> // stat(), fork(), execlp()
#include <windows.h> // CreateProcess()
// #define CDVDdefs
// #include "../PS2Edefs.h"
#include "../PS2Etypes.h" // u8
#include "logfile.h"
#include "../ini.h"
#include "conf.h"
const char *confnames[] = { "IsoFile", "Device", "OpenOnStart", "OpenOnRestart", NULL };
const u8 defaultdevice[] = DEFAULT_DEVICE;
const char defaulthome[] = "inis";
const char defaultdirectory[] = "HideMe.PS2E";
const char defaultfile[] = "CDVDisoEFP.ini";
char confdirname[256];
char conffilename[256];
CDVDconf conf;
void InitConf() {
DWORD retval;
int i;
int pos;
char *envptr;
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: InitConf()");
#endif /* VERBOSE_FUNCTION_CONF */
conf.isoname[0] = 0; // Empty the iso name
i = 0;
while((i < 255) && defaultdevice[i] != 0) {
conf.devicename[i] = defaultdevice[i];
i++;
} // ENDWHILE- copying the default CD/DVD name in
conf.devicename[i] = 0; // 0-terminate the device name
// Locating directory and file positions
pos = 0;
envptr = NULL;
// envptr = getenv("HOME");
if(envptr == NULL) {
// = <Default Home>
retval = GetCurrentDirectory(253, confdirname);
if(retval > 0) {
pos = retval;
} else {
pos = 2;
confdirname[0] = '.';
confdirname[1] = '\\';
} // ENDIF- Did we retrieve a directory reference?
i = 0;
while(i < pos) {
conffilename[i] = confdirname[i];
i++;
} // ENDWHILE- Copying dir info (so far) into file info
if(confdirname[pos-1] != '\\') {
confdirname[pos] = '\\';
conffilename[pos] = '\\';
pos++;
} // ENDIF- No directory separator here? Add one.
i = 0;
while((pos < 253) && (defaulthome[i] != 0)) {
confdirname[pos] = defaulthome[i];
conffilename[pos] = defaulthome[i];
pos++;
i++;
} // ENDWHILE- putting an offset where to store ini data
} else {
// = <Env Home>/<Default Directory>
i = 0;
while((pos < 253) && (*(envptr + i) != 0)) {
confdirname[pos] = *(envptr + i);
conffilename[pos] = *(envptr + i);
pos++;
i++;
} // ENDWHILE- copying home directory info in
if(confdirname[pos-1] != '\\') {
confdirname[pos] = '\\';
conffilename[pos] = '\\';
pos++;
} // ENDIF- No directory separator here? Add one.
i = 0;
while((pos < 253) && (defaultdirectory[i] != 0)) {
confdirname[pos] = defaultdirectory[i];
conffilename[pos] = defaultdirectory[i];
pos++;
i++;
} // NEXT- putting a default place to store configuration data
} // ENDIF- No Home directory?
confdirname[pos] = 0; // Directory reference finished
// += /<Config File Name>
if(conffilename[pos-1] != '\\') {
conffilename[pos] = '\\';
pos++;
} // ENDIF- No directory separator here? Add one.
i = 0;
while((pos < 253) && (defaultfile[i] != 0)) {
conffilename[pos] = defaultfile[i];
pos++;
i++;
} // NEXT- putting a default place to store configuration data
conffilename[pos] = 0; // File reference finished
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: Directory: %s", confdirname);
PrintLog("CDVD config: File: %s", conffilename);
#endif /* VERBOSE_FUNCTION_CONF */
} // END InitConf()
void LoadConf() {
int retval;
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: LoadConf()");
#endif /* VERBOSE_FUNCTION_CONF */
retval = INILoadString(conffilename, "Settings", "IsoFile", conf.isoname);
if(retval < 0) {
sprintf(conf.isoname, "[Put an Image File here]");
} // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadString(conffilename, "Settings", "Device", conf.devicename);
if(retval < 0) {
sprintf(conf.devicename, "D:");
} // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadUInt(conffilename, "Settings", "OpenOnStart", &conf.startconfigure);
if(retval < 0) {
conf.startconfigure = 0; // FALSE
} // ENDIF- Couldn't find keyword? Fill in a default
retval = INILoadUInt(conffilename, "Settings", "OpenOnRestart", &conf.restartconfigure);
if(retval < 0) {
conf.restartconfigure = 1; // TRUE
} // ENDIF- Couldn't find keyword? Fill in a default
} // END LoadConf()
void SaveConf() {
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: SaveConf()");
#endif /* VERBOSE_FUNCTION_CONF */
mkdir(confdirname);
INISaveString(conffilename, "Settings", "IsoFile", conf.isoname);
INISaveString(conffilename, "Settings", "Device", conf.devicename);
INISaveUInt(conffilename, "Settings", "OpenOnStart", conf.startconfigure);
INISaveUInt(conffilename, "Settings", "OpenOnRestart", conf.restartconfigure);
} // END SaveConf()

View File

@ -1,54 +1,108 @@
/* conf.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CONF_H
#define CONF_H
#define CDVDdefs
#include "../PS2Edefs.h"
#define VERBOSE_FUNCTION_CONF
// Configuration Data
typedef struct {
u8 isoname[256];
u8 devicename[256];
unsigned int startconfigure;
unsigned int restartconfigure;
} CDVDconf;
extern CDVDconf conf;
#define DEFAULT_DEVICE "K:\\"
// Configuration Functions
extern void InitConf();
extern void LoadConf();
extern void SaveConf();
extern void ExecCfg(char *arg);
#endif /* CONF_H */

View File

@ -1,40 +1,80 @@
/* conversionbox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CONVERSIONBOX_H
#define CONVERSIONBOX_H
#include <windows.h> // HWND
extern HWND conversionboxwindow;
extern void ConversionBoxDestroy();
extern void ConversionBoxRefocus();
extern void ConversionBoxDisplay();
extern BOOL CALLBACK ConversionBoxCallback(HWND window,
UINT msg,
WPARAM param,
LPARAM param2);
#endif /* CONVERSIONBOX_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,128 @@
/* device.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __DEVICE_H__
#define __DEVICE_H__
#include <windows.h> // BOOL, DWORD
#include <time.h> // time_t
#define CDVDdefs
#include "../PS2Edefs.h"
// #define VERBOSE_FUNCTION_DEVICE
// #define VERBOSE_WARNING_DEVICE
#define VERBOSE_DISC_TYPE
#define VERBOSE_DISC_INFO
extern HANDLE devicehandle;
extern OVERLAPPED waitevent;
extern time_t lasttime;
extern s32 traystatus;
extern s32 disctype;
extern char tocbuffer[];
extern void DeviceInit();
extern void InitDisc();
extern s32 DiscInserted();
extern DWORD FinishCommand(BOOL boolresult);
extern s32 DeviceOpen();
extern void DeviceClose();
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DeviceBufferOffset();
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
extern s32 DeviceGetDiskType();
extern s32 DeviceTrayStatus();
extern s32 DeviceTrayOpen();
extern s32 DeviceTrayClose();
#endif /* __DEVICE_H__ */

View File

@ -1,41 +1,82 @@
/* devicebox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef DEVICEBOX_H
#define DEVICEBOX_H
#include <windows.h> // HWND
extern HWND deviceboxwindow;
extern void DeviceBoxDestroy();
// extern void DeviceBoxUnfocus();
extern void DeviceBoxRefocus();
extern void DeviceBoxDisplay();
extern BOOL CALLBACK DeviceBoxCallback(HWND window,
UINT msg,
WPARAM param,
LPARAM param2);
#endif /* DEVICEBOX_H */

View File

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

View File

@ -1,39 +1,78 @@
/* logfile.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef LOGFILE_H
#define LOGFILE_H
#include <windows.h> // Just for DWORD
#define VERBOSE_LOGFILE
extern void InitLog();
extern int OpenLog();
extern void CloseLog();
extern void PrintLog(const char *format, ...);
extern void PrintError(const char *header, DWORD errcode);
#endif /* LOGFILE_H */

View File

@ -1,43 +1,86 @@
/* mainbox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef MAINBOX_H
#define MAINBOX_H
#include <windows.h> // HWND
extern const char fileselection[];
extern HWND mainboxwindow;
extern int mainboxstop;
extern void MainBoxRefocus();
extern void MainBoxDisplay();
extern BOOL CALLBACK MainBoxCallback(HWND window,
UINT msg,
WPARAM param,
LPARAM param2);
#endif /* MAINBOX_H */

View File

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

View File

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

View File

@ -1,32 +1,64 @@
/* tablerebuild.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef TABLEREBUILD_H
#define TABLEREBUILD_H
// #define FUNCTION_WARNING_TABLEREBUILD
extern void IsoTableRebuild(const char *filename);
#endif /* TABLEREBUILD_H */

View File

@ -1,59 +1,118 @@
/* ecma119.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h>
// #ifndef __LINUX__
// #ifdef __linux__
// #define __LINUX__
// #endif /* __linux__ */
// #endif /* No __LINUX__ */
// #define CDVDdefs
// #include "PS2Edefs.h"
#include "ecma119.h"
const char ECMA119VolumeIDstdid[] = "CD001\0";
int ValidateECMA119PrimaryVolume(struct ECMA119PrimaryVolume *volume) {
int i;
if(volume == NULL) return(-1);
// Volume ID
if(volume->id.voltype != 1) return(-1); // Incorrect volume type
if(volume->id.version != 1) return(-1); // Not a Standard Version?
i = 0;
while((ECMA119VolumeIDstdid[i] != 0) &&
(ECMA119VolumeIDstdid[i] == volume->id.stdid[i])) i++;
if(ECMA119VolumeIDstdid[i] != 0) return(-1); // "CD001" did not match?
// Looks like numblocksle might give us maximum sector count...
// Looks like blocksizele can be compared to blocksize stored in isofile...
return(0);
} // END ValidateECMA119PrimaryVolume()
// 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
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef INI_H
#define INI_H
// #ifndef __LINUX__
// #ifdef __linux__
// #define __LINUX__
// #endif /* __linux__ */
// #endif /* No __LINUX__ */
// #define CDVDdefs
// #include "PS2Edefs.h"
// File format:
// [section]
// keyword=value
// file - Name of the INI file
// section - Section within the file
// keyword - Identifier for a value
// value - value to store with a keyword in a section in the file
// buffer - place to retrieve the value of a keyword
// return values: 0 = success, -1 = failure
// #define VERBOSE_FUNCTION_INI
#define INIMAXLEN 255
extern int INISaveString(char *file, char *section, char *keyword, char *value);
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 INILoadUInt(char *file, char *section, char *keyword, unsigned int *buffer);
// NULL in the keyword below removes the whole section.
extern int INIRemove(char *file, char *section, char *keyword);
#endif /* INI_H */

View File

@ -1,36 +1,72 @@
/* version.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
char *libname = "EFP Iso CDVD Driver";
const unsigned char version = PS2E_CDVD_VERSION;
const unsigned char revision = 0;
const unsigned char build = 6;

View File

@ -1,43 +1,86 @@
/* version.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef VERSION_H
#define VERSION_H
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
extern char *libname;
extern const unsigned char version;
extern const unsigned char revision;
extern const unsigned char build;
#endif /* VERSION_H */

View File

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

View File

@ -1,46 +1,92 @@
/* CD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __CD_H__
#define __CD_H__
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "../PS2Edefs.h"
// Exported Functions
extern void InitCDInfo();
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 CDgetBufferOffset();
extern s32 CDreadSubQ(u32 lsn, cdvdSubQ *subq);
extern s32 CDgetTN(cdvdTN *cdvdtn);
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 CDgetDiskType(s32 ioctldisktype);
#endif /* __CD_H__ */

View File

@ -1,31 +1,62 @@
/* CDVDlinuz.h
* Copyright (C) 2002-2005 CDVDlinuz Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __CDVDLINUZ_H__
#define __CDVDLINUZ_H__
// #define VERBOSE_WARNINGS
// #define VERBOSE_FUNCTION
#define VERBOSE_DISC_INFO
#define VERBOSE_DISC_TYPE
#define READ_AHEAD_BUFFERS 32
#endif /* __CDVDLINUZ_H__ */

View File

@ -1,45 +1,90 @@
/* DVD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __DVD_H__
#define __DVD_H__
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
// Exported Functions
extern void HexDump(u8 *strptr, u8 count);
extern void InitDVDInfo();
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DVDgetTN(cdvdTN *cdvdtn);
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 DVDgetDiskType(s32 ioctldisktype);
#endif /* __DVD_H__ */

View File

@ -1,106 +1,212 @@
/* aboutbox.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new()
#include "version.h"
#include "aboutbox.h"
struct AboutBoxData aboutbox;
gint AboutBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
if(aboutbox.window != NULL) {
gtk_widget_destroy(aboutbox.window);
aboutbox.window = NULL;
} // ENDIF- Do we have an About Box still?
gtk_main_quit();
return(TRUE);
} // END AboutBoxCancelEvent()
void AboutBoxDisplay() {
GtkWidget *item;
GtkWidget *container;
GtkWidget *vbox1;
char templine[256];
aboutbox.window = NULL;
aboutbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(aboutbox.window), 5);
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_modal(GTK_WINDOW(aboutbox.window), TRUE);
gtk_window_set_resizable(GTK_WINDOW(aboutbox.window), FALSE);
g_signal_connect(G_OBJECT(aboutbox.window), "delete_event",
G_CALLBACK(AboutBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(aboutbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1);
sprintf(templine, "%s v%i.%i", libname, revision, build);
item = gtk_label_new(templine);
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item);
item = NULL;
item = gtk_label_new("Current Author: efp");
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item);
item = NULL;
item = gtk_label_new("Original code by: linuzappz & shadow");
gtk_box_pack_start(GTK_BOX(vbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item);
item = NULL;
container = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), container, TRUE, TRUE, 0);
gtk_widget_show(container);
item = gtk_button_new_with_label("Ok");
gtk_container_add(GTK_CONTAINER(container), item);
GTK_WIDGET_SET_FLAGS(item, GTK_CAN_DEFAULT);
gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(AboutBoxCancelEvent), NULL);
item = NULL;
container = NULL;
vbox1 = NULL;
gtk_widget_show(aboutbox.window);
gtk_main();
} // END AboutDisplay()

View File

@ -1,39 +1,78 @@
/* aboutbox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef ABOUTBOX_H
#define ABOUTBOX_H
#include <gtk/gtkwidget.h>
struct AboutBoxData {
GtkWidget *window; // GtkWindow - About Box
};
extern struct AboutBoxData aboutbox;
extern void AboutBoxDisplay();
#endif /* ABOUTBOX_H */

View File

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

View File

@ -1,50 +1,100 @@
/* actualfile.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef ACTUALFILE_H
#define ACTUALFILE_H
#include <sys/types.h> // off64_t
#define ACTUALHANDLE int
#define ACTUALHANDLENULL -1
// #define VERBOSE_FUNCTION_ACTUALFILE
// #define VERBOSE_WARNING_ACTUALFILE
extern int IsActualFile(const char *filename);
extern void ActualFileDelete(const char *filename);
extern void ActualFileRename(const char *origname, const char *newname);
extern ACTUALHANDLE ActualFileOpenForRead(const char *filename);
extern off64_t ActualFileSize(ACTUALHANDLE handle);
extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position);
extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer);
extern void ActualFileClose(ACTUALHANDLE handle);
extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename);
extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer);
#endif /* ACTUALFILE_H */

View File

@ -1,57 +1,114 @@
/* conf.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CONF_H
#define CONF_H
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "../PS2Edefs.h"
#define VERBOSE_FUNCTION_CONF
// Configuration Data
typedef struct {
u8 devicename[256];
} CDVDconf;
extern CDVDconf conf;
#define DEFAULT_DEVICE "/dev/cdrom"
// Configuration Functions
extern void InitConf();
extern void LoadConf();
extern void SaveConf();
extern void ExecCfg(char *arg);
#endif /* CONF_H */

View File

@ -1,69 +1,138 @@
/* device.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __DEVICE_H__
#define __DEVICE_H__
#include <time.h> // time_t
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "../PS2Edefs.h"
// #define VERBOSE_FUNCTION_DEVICE
// #define VERBOSE_WARNINGS
#define VERBOSE_DISC_TYPE
#define VERBOSE_DISC_INFO
// Device Data
extern int devicehandle;
extern s32 devicecapability; // Need to export?
extern time_t lasttime;
extern s32 traystatus;
extern s32 disctype;
extern u8 tocbuffer[];
// Device Functions
extern void DeviceInit();
extern void InitDisc();
extern s32 DiscInserted();
extern s32 DeviceOpen();
extern void DeviceClose();
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DeviceBufferOffset();
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
extern s32 DeviceGetDiskType();
extern s32 DeviceTrayStatus();
extern s32 DeviceTrayOpen();
extern s32 DeviceTrayClose();
#endif /* __DEVICE_H__ */

View File

@ -1,57 +1,114 @@
/* interface.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <string.h> // strcmp()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkwidget.h> // gtk_widget_show_all()
#include "logfile.h"
#include "conf.h"
#include "aboutbox.h"
#include "mainbox.h"
int main(int argc, char *argv[]) {
if(argc != 2) return(1);
gtk_init(NULL, NULL);
if(!strcmp(argv[1], "about")) {
AboutBoxDisplay();
return(0);
} else if (!strcmp(argv[1], "configure")) {
OpenLog();
InitConf();
LoadConf();
MainBoxDisplay();
gtk_widget_show_all(mainbox.window);
gtk_main();
CloseLog();
return(0);
} // ENDLONGIF- Which display would you like to see?
return(1); // No Displays chosen? Abort!
} // END main()

View File

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

View File

@ -1,35 +1,70 @@
/* logfile.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef LOGFILE_H
#define LOGFILE_H
#define VERBOSE_LOGFILE
extern void InitLog();
extern int OpenLog();
extern void CloseLog();
extern void PrintLog(const char *format, ...);
#endif /* LOGFILE_H */

View File

@ -1,187 +1,374 @@
/* mainbox.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <string.h> // strcpy()
#include <sys/stat.h> // stat()
#include <sys/types.h> // stat()
#include <unistd.h> // stat()
#include <gtk/gtkbutton.h> // gtk_button_new_with_label()
#include <gtk/gtkcontainer.h> // gtk_container_add()
#include <gtk/gtkentry.h> // gtk_entry_new()
#include <gtk/gtkhbbox.h> // gtk_hbutton_box_new()
#include <gtk/gtkhbox.h> // gtk_hbox_new()
#include <gtk/gtklabel.h> // gtk_label_new()
#include <gtk/gtkmain.h> // gtk_init(), gtk_main(), gtk_main_quit()
#include <gtk/gtkvbox.h> // gtk_vbox_new()
#include <gtk/gtkwindow.h> // gtk_window_new()
#include "conf.h"
// #include "logfile.h"
#include "device.h" // DeviceOpen(), DeviceClose()
#include "mainbox.h"
struct MainBoxData mainbox;
void MainBoxDestroy() {
if(mainbox.window != NULL) {
gtk_widget_destroy(mainbox.window);
mainbox.window = NULL;
mainbox.device = NULL;
mainbox.desc = NULL;
} // ENDIF- Do we have a Main Window still?
} // END MainBoxDestroy()
void MainBoxUnfocus() {
gtk_widget_set_sensitive(mainbox.device, FALSE);
gtk_window_iconify(GTK_WINDOW(mainbox.window));
} // END MainBoxUnfocus()
gint MainBoxDeviceEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
struct stat filestat;
int retval;
retval = stat(gtk_entry_get_text(GTK_ENTRY(mainbox.device)), &filestat);
if(retval == -1) {
gtk_label_set_text(GTK_LABEL(mainbox.desc), "Device Type: ---");
return(TRUE);
} // ENDIF- Not a name of any sort?
if(S_ISDIR(filestat.st_mode) != 0) {
gtk_label_set_text(GTK_LABEL(mainbox.desc), "Device Type: Not a device");
return(TRUE);
} // ENDIF- Not a regular file?
gtk_label_set_text(GTK_LABEL(mainbox.desc), "Device Type: Device Likely");
return(TRUE);
} // END MainBoxFileEvent()
void MainBoxRefocus() {
GdkEvent event;
MainBoxDeviceEvent(NULL, event, NULL);
gtk_widget_set_sensitive(mainbox.device, TRUE);
gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.device);
gtk_window_deiconify(GTK_WINDOW(mainbox.window));
} // END MainBoxRefocus()
gint MainBoxCancelEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
MainBoxDestroy();
gtk_main_quit();
return(TRUE);
} // END MainBoxCancelEvent()
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data) {
const char *tempdevice;
int retval;
MainBoxUnfocus();
tempdevice = gtk_entry_get_text(GTK_ENTRY(mainbox.device));
strcpy(conf.devicename, tempdevice); // Temporarily put in new device name
tempdevice = NULL;
if(*(conf.devicename) != 0) {
retval = DeviceOpen(); // Test by opening the device.
DeviceClose(); // Failed or not, close it.
if(retval != 0) {
MainBoxRefocus();
return(TRUE);
} // ENDIF- Not an ISO file? Message and Stop here.
} // ENDIF- Is there an ISO file to check out?
SaveConf();
MainBoxCancelEvent(widget, event, data);
return(TRUE);
} // END MainBoxOKEvent()
void MainBoxDisplay() {
GtkWidget *item;
GtkWidget *hbox1;
GtkWidget *vbox1;
mainbox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(mainbox.window), 5);
gtk_window_set_title(GTK_WINDOW(mainbox.window), "CDVDlinuz Configuration");
gtk_window_set_position(GTK_WINDOW(mainbox.window), GTK_WIN_POS_CENTER);
g_signal_connect(G_OBJECT(mainbox.window), "delete_event",
G_CALLBACK(MainBoxCancelEvent), NULL);
vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(mainbox.window), vbox1);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_widget_show(vbox1);
hbox1 = gtk_hbox_new(FALSE, 10);
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1);
item = gtk_label_new("CD/DVD Device:");
gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0);
gtk_widget_show(item);
item = NULL;
mainbox.device = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox1), mainbox.device, TRUE, TRUE, 0);
gtk_widget_show(mainbox.device);
g_signal_connect(G_OBJECT(mainbox.device), "changed",
G_CALLBACK(MainBoxDeviceEvent), NULL);
hbox1 = NULL;
mainbox.desc = gtk_label_new("File Type: ---");
gtk_box_pack_start(GTK_BOX(vbox1), mainbox.desc, FALSE, FALSE, 0);
gtk_widget_show(mainbox.desc);
hbox1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0);
gtk_widget_show(hbox1);
item = gtk_button_new_with_label("Ok");
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(MainBoxOKEvent), NULL);
item = gtk_button_new_with_label("Cancel");
gtk_box_pack_start(GTK_BOX(hbox1), item, TRUE, TRUE, 0);
gtk_widget_show(item);
g_signal_connect(G_OBJECT(item), "clicked",
G_CALLBACK(MainBoxCancelEvent), NULL);
item = NULL;
hbox1 = NULL;
vbox1 = NULL;
// We held off setting the name until now... so description would show.
gtk_entry_set_text(GTK_ENTRY(mainbox.device), conf.devicename);
} // END MainBoxDisplay()

View File

@ -1,41 +1,82 @@
/* mainbox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef MAINBOX_H
#define MAINBOX_H
#include <gtk/gtkwidget.h>
struct MainBoxData {
GtkWidget *window; // GtkWindow
GtkWidget *device; // GtkEntry
GtkWidget *desc; // GtkLabel
};
extern struct MainBoxData mainbox;
// extern void MainBoxRefocus();
extern void MainBoxDisplay();
#endif /* MAINBOX_H */

View File

@ -1,43 +1,86 @@
#ifndef __PS2ETYPES_H__
#define __PS2ETYPES_H__
// Basic types
#if defined(__MSCW32__)
typedef __int8 s8;
typedef __int16 s16;
typedef __int32 s32;
typedef __int64 s64;
typedef unsigned __int8 u8;
typedef unsigned __int16 u16;
typedef unsigned __int32 u32;
typedef unsigned __int64 u64;
#if defined(__x86_64__)
typedef u64 uptr;
#else
typedef u32 uptr;
#endif
#elif defined(__LINUX__) || defined(__MINGW32__)
typedef char s8;
typedef short s16;
typedef int s32;
typedef long long s64;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
#if defined(__x86_64__)
typedef u64 uptr;
#else
typedef u32 uptr;
#endif
#endif
#endif
#endif /* __PS2ETYPES_H__ */

View File

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

View File

@ -1,44 +1,88 @@
/* CD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CD_H
#define CD_H
#include <windows.h> // DWORD
#define CDVDdefs
#include "PS2Edefs.h"
extern DWORD cdblocksize;
extern void InitCDInfo();
extern s32 CDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 CDgetBufferOffset();
extern s32 CDreadSubQ();
extern s32 CDgetTN(cdvdTN *cdvdtn);
extern s32 CDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 CDgetDiskType();
#endif /* CD_H */

View File

@ -1,434 +1,868 @@
/* CDVDlinuz.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <windows.h> // BOOL, CALLBACK, APIENTRY
#include <windef.h> // NULL
#include <time.h> // time(), time_t
#define CDVDdefs
#include "../PS2Edefs.h"
#include "device.h"
#include "CD.h"
#include "DVD.h"
#include "../buffer.h"
#include "../convert.h"
#include "conf.h"
#include "logfile.h"
#include "../version.h"
#include "screens.h"
#include "mainbox.h" // Initialize mainboxwindow
#include "CDVDlinuz.h"
HINSTANCE progmodule;
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD param,
LPVOID reserved) {
switch(param) {
case DLL_PROCESS_ATTACH:
progmodule = hModule;
// mainboxwindow = NULL;
return(TRUE);
break;
case DLL_PROCESS_DETACH:
// CDVDshutdown();
return(TRUE);
break;
case DLL_THREAD_ATTACH:
return(TRUE);
break;
case DLL_THREAD_DETACH:
return(TRUE);
break;
} // ENDSWITCH param- What does the OS want with us?
return(FALSE); // Wasn't on list? Wasn't handled.
} // END DllMain()
char* CALLBACK PS2EgetLibName() {
return(libname);
} // END PS2EgetLibName()
u32 CALLBACK PS2EgetLibType() {
return(PS2E_LT_CDVD);
} // END PS2getLibType()
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
return((version << 16) | (revision << 8) | build);
} // END PS2EgetLibVersion2()
s32 CALLBACK CDVDinit() {
InitLog();
if(OpenLog() != 0) return(-1); // Couldn't open Log File? Abort.
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDinit()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
InitConf();
DeviceInit();
InitCDInfo();
InitDVDInfo();
mainboxwindow = NULL;
return(0);
} // END CDVDinit()
void CALLBACK CDVDshutdown() {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDshutdown()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
DeviceClose();
// Close Windows as well? (Just in case)
CloseLog();
} // END CDVDshutdown()
s32 CALLBACK CDVDopen() {
int retval;
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDopen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
InitBuffer();
LoadConf();
retval = DeviceOpen();
if(retval == 0) {
DeviceTrayStatus();
} // ENDIF- Did we open the device? Poll for media.
return(retval);
} // END CDVDopen()
void CALLBACK CDVDclose() {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDclose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
DeviceClose();
} // END CDVDclose()
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq) {
char temptime[3];
int i;
int pos;
u32 tracklsn;
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDreadSubQ()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() != 0) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(-1); // DVDs don't have SubQ data
} // ENDIF- Trying to get a SubQ from a DVD?
// fake it
i = BCDTOHEX(tocbuffer[7]);
pos = i * 10;
pos += 30;
temptime[0] = BCDTOHEX(tocbuffer[pos + 7]);
temptime[1] = BCDTOHEX(tocbuffer[pos + 8]);
temptime[2] = BCDTOHEX(tocbuffer[pos + 9]);
tracklsn = MSFtoLBA(temptime);
while((i < BCDTOHEX(tocbuffer[17])) && (tracklsn < lsn)) {
i++;
pos = i * 10;
pos += 30;
temptime[0] = BCDTOHEX(tocbuffer[pos + 7]);
temptime[1] = BCDTOHEX(tocbuffer[pos + 8]);
temptime[2] = BCDTOHEX(tocbuffer[pos + 9]);
tracklsn = MSFtoLBA(temptime);
} // ENDIF- Loop through tracks searching for lsn track
i--;
subq->ctrl = 4;
subq->mode = 1;
subq->trackNum = HEXTOBCD(i);
subq->trackIndex = HEXTOBCD(i);
LBAtoMSF(lsn - tracklsn, temptime);
subq->trackM = HEXTOBCD(temptime[0]);
subq->trackS = HEXTOBCD(temptime[1]);
subq->trackF = HEXTOBCD(temptime[2]);
subq->pad = 0;
// lba_to_msf(lsn + (2*75), &min, &sec, &frm);
LBAtoMSF(lsn, temptime);
subq->discM = HEXTOBCD(temptime[0]);
subq->discS = HEXTOBCD(temptime[1]);
subq->discF = HEXTOBCD(temptime[2]);
return(0);
} // END CDVDreadSubQ()
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer) {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetTN()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() != 0) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
Buffer->strack = 1;
Buffer->etrack = 1;
} else {
Buffer->strack = BCDTOHEX(tocbuffer[7]);
Buffer->etrack = BCDTOHEX(tocbuffer[17]);
} // ENDIF- Retrieve track info from a DVD? (or a CD?)
return(0);
} // END CDVDgetTN()
s32 CALLBACK CDVDgetTD(u8 track, cdvdTD *buffer) {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetTD()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
return(DeviceGetTD(track, buffer));
} // END CDVDgetTD()
s32 CALLBACK CDVDgetTOC(void* toc) {
int i;
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetTOC()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() != 0) return(-1);
for(i = 0; i < 2048; i++) *(((char *) toc) + i) = tocbuffer[i];
return(0);
} // END CDVDgetTOC()
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) {
int retval;
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDreadTrack(%u)", lsn);
#endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() == -1) return(-1);
if(userbuffer < BUFFERMAX) {
if((bufferlist[userbuffer].lsn == lsn) &&
(bufferlist[userbuffer].mode == mode)) {
return(0);
} // ENDIF- And it's the right one?
} // ENDIF- Are we already pointing at the buffer?
userbuffer = FindListBuffer(lsn);
if(userbuffer < BUFFERMAX) {
if((bufferlist[userbuffer].lsn == lsn) &&
(bufferlist[userbuffer].mode == mode)) {
return(0);
} // ENDIF- And it was the right one?
} // ENDIF- Was a buffer found in the cache?
replacebuffer++;
if(replacebuffer >= BUFFERMAX) replacebuffer = 0;
userbuffer = replacebuffer;
if(bufferlist[replacebuffer].upsort != 0xffff) {
RemoveListBuffer(replacebuffer);
} // ENDIF- Reference already in place? Remove it.
retval = DeviceReadTrack(lsn, mode, bufferlist[replacebuffer].buffer);
bufferlist[replacebuffer].lsn = lsn;
bufferlist[replacebuffer].mode = mode;
bufferlist[replacebuffer].offset = DeviceBufferOffset();
if(retval != 0) {
bufferlist[replacebuffer].mode = -1; // Error! flag buffer as such.
} else {
if((disctype != CDVD_TYPE_PS2DVD) && (disctype != CDVD_TYPE_DVDV)) {
if(mode == CDVD_MODE_2352) {
CDreadSubQ(lsn, &bufferlist[replacebuffer].subq);
} // ENDIF- Read subq as well?
} // ENDIF- Read a DVD buffer or a CD buffer?
} // ENDIF-Read ok? Fill out rest of buffer info.
AddListBuffer(replacebuffer);
return(retval);
} // END CDVDreadTrack()
u8* CALLBACK CDVDgetBuffer() {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetBuffer()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
if(DiscInserted() == -1) return(NULL);
if(userbuffer == 0xffff) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVDlinuz interface: Not pointing to a buffer!");
#endif /* VERBOSE_WARNINGS */
return(NULL); // No buffer reference?
} // ENDIF- user buffer not pointing at anything? Abort
if(bufferlist[userbuffer].mode < 0) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVDlinuz interface: Error retrieving sector (ReadTrack call)");
#endif /* VERBOSE_WARNINGS */
return(NULL); // Bad Sector?
} // ENDIF- Trouble reading physical sector? Tell them.
return(bufferlist[userbuffer].buffer + bufferlist[userbuffer].offset);
} // END CDVDgetBuffer()
s32 CALLBACK CDVDgetDiskType() {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetDiskType()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
if(lasttime != time(NULL)) {
lasttime = time(NULL);
DeviceTrayStatus();
} // ENDIF- Has enough time passed between calls?
return(disctype);
} // END CDVDgetDiskType()
s32 CALLBACK CDVDgetTrayStatus() {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDgetTrayStatus()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
if(lasttime != time(NULL)) {
lasttime = time(NULL);
DeviceTrayStatus();
} // ENDIF- Has enough time passed between calls?
return(traystatus);
} // END CDVDgetTrayStatus()
s32 CALLBACK CDVDctrlTrayOpen() {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDctrlTrayOpen()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
return(DeviceTrayOpen());
} // END CDVDctrlTrayOpen()
s32 CALLBACK CDVDctrlTrayClose() {
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDctrlTrayClose()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
return(DeviceTrayClose());
} // END CDVDctrlTrayClose()
s32 CALLBACK CDVDtest() {
int retval;
errno = 0;
if(devicehandle != NULL) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVDlinuz interface: Device already open");
#endif /* VERBOSE_WARNINGS */
return(0);
} // ENDIF- Is the CD/DVD already in use? That's fine.
#ifdef VERBOSE_FUNCTION_INTERFACE
PrintLog("CDVDlinuz interface: CDVDtest()");
#endif /* VERBOSE_FUNCTION_INTERFACE */
retval = DeviceOpen();
DeviceClose();
return(retval);
} // END CDVDtest()
void CALLBACK CDVDconfigure() {
HWND lastwindow;
lastwindow = GetActiveWindow();
DialogBox(progmodule,
MAKEINTRESOURCE(DLG_0200),
lastwindow,
(DLGPROC)MainBoxCallback);
SetActiveWindow(lastwindow);
lastwindow = NULL;
return;
} // END CDVDconfigure()
BOOL CALLBACK AboutCallback(HWND window, UINT msg, WPARAM param, LPARAM param2) {
switch(msg) {
case WM_COMMAND:
switch(LOWORD(param)) {
case IDC_0104: // "Ok" Button
EndDialog(window, FALSE);
return(TRUE);
break;
} // ENDSWITCH param- Which Windows Message Command?
case WM_CLOSE:
EndDialog(window, FALSE);
return(TRUE);
break;
} // ENDSWITCH msg- what message has been sent to this window?
return(FALSE); // Not a recognisable message. Pass it back to the OS.
} // END AboutCallback()
void CALLBACK CDVDabout() {
HWND lastwindow;
lastwindow = GetActiveWindow();
DialogBox(progmodule,
MAKEINTRESOURCE(DLG_0100),
lastwindow,
(DLGPROC)AboutCallback);
SetActiveWindow(lastwindow);
return;
} // END CDVDabout()

View File

@ -1,40 +1,80 @@
/* CDVDlinuz.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CDVDLINUZ_H
#define CDVDLINUZ_H
#include <windows.h> // HINSTANCE
// #define VERBOSE_WARNINGS
// #define VERBOSE_FUNCTION_INTERFACE
#define VERBOSE_DISC_INFO
#define VERBOSE_DISC_TYPE
#define READ_AHEAD_BUFFERS 32
extern HINSTANCE progmodule;
#endif /* CDVDLINUZ_H */

View File

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

View File

@ -1,37 +1,74 @@
/* DVD.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef DVD_H
#define DVD_H
#define CDVDdefs
#include "PS2Edefs.h"
extern void InitDVDInfo();
extern s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DVDgetTN(cdvdTN *cdvdtn);
extern s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd);
extern s32 DVDgetDiskType();
#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
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <windows.h>
#include <stddef.h> // NULL
#include "logfile.h"
#include "actualfile.h"
int IsActualFile(const char *filename) {
DWORD retval;
if(filename == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: IsActualFile(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = GetFileAttributes(filename);
if(retval == INVALID_FILE_ATTRIBUTES) return(-1); // Name doesn't exist.
if((retval & FILE_ATTRIBUTE_DIRECTORY) != 0) return(-2);
return(0); // Yep, that's a file.
} // END IsActualFile()
void ActualFileDelete(const char *filename) {
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileDelete(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
DeleteFile(filename);
} // END ActualFileDelete()
void ActualFileRename(const char *origname, const char *newname) {
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileDelete(%s->%s)", origname, newname);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
MoveFile(origname, newname);
return;
} // END ActualFileRename()
ACTUALHANDLE ActualFileOpenForRead(const char *filename) {
HANDLE newhandle;
if(filename == NULL) return(NULL);
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileOpenForRead(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
newhandle = CreateFile(filename,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS,
NULL);
if(newhandle == INVALID_HANDLE_VALUE) {
#ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error opening file %s", filename);
#endif /* VERBOSE_WARNING_ACTUALFILE */
return(NULL);
} // ENDIF- Error? Abort
return(newhandle);
} // END ActualFileOpenForRead()
off64_t ActualFileSize(ACTUALHANDLE handle) {
int retval;
BY_HANDLE_FILE_INFORMATION info;
off64_t retsize;
if(handle == NULL) return(-1);
if(handle == INVALID_HANDLE_VALUE) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileSize()");
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = GetFileInformationByHandle(handle, &info);
if(retval == 0) return(-1); // Handle doesn't exist...
retsize = info.nFileSizeHigh;
retsize *= 0x10000;
retsize *= 0x10000;
retsize += info.nFileSizeLow;
return(retsize);
} // END ActualFileSize()
int ActualFileSeek(ACTUALHANDLE handle, off64_t position) {
// int retval;
LARGE_INTEGER realpos;
DWORD errcode;
if(handle == NULL) return(-1);
if(handle == INVALID_HANDLE_VALUE) return(-1);
if(position < 0) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileSeek(%llu)", position);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
realpos.QuadPart = position;
////// WinXP code for seek
// retval = SetFilePointerEx(handle,
// realpos,
// NULL,
// FILE_BEGIN);
// if(retval == 0) {
////// Win98 code for seek
realpos.LowPart = SetFilePointer(handle,
realpos.LowPart,
&realpos.HighPart,
FILE_BEGIN);
errcode = GetLastError();
if((realpos.LowPart == 0xFFFFFFFF) && (errcode != NO_ERROR)) {
#ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error on seek (%llu)", position);
PrintError("CDVDiso file", errcode);
#endif /* VERBOSE_WARNING_ACTUALFILE */
return(-1);
} // ENDIF- Error? Abort
return(0);
} // END ActualFileSeek()
int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {
int retval;
DWORD bytesread;
#ifdef VERBOSE_WARNING_ACTUALFILE
DWORD errcode;
#endif /* VERBOSE_WARNING_ACTUALFILE */
if(handle == NULL) return(-1);
if(handle == INVALID_HANDLE_VALUE) return(-1);
if(bytes < 1) return(-1);
if(buffer == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileRead(%i)", bytes);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = ReadFile(handle, buffer, bytes, &bytesread, NULL);
if(retval == 0) {
#ifdef VERBOSE_WARNING_ACTUALFILE
errcode = GetLastError();
PrintLog("CDVDiso file: Error reading from file");
PrintError("CDVDiso file", errcode);
#endif /* VERBOSE_WARNING_ACTUALFILE */
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
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
} // END ActualFileRead()
void ActualFileClose(ACTUALHANDLE handle) {
if(handle == NULL) return;
if(handle == INVALID_HANDLE_VALUE) return;
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileClose()");
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
CloseHandle(handle);
return;
} // END ActualFileClose()
ACTUALHANDLE ActualFileOpenForWrite(const char *filename) {
HANDLE newhandle;
if(filename == NULL) return(NULL);
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileOpenForWrite(%s)", filename);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
newhandle = CreateFile(filename,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if(newhandle == INVALID_HANDLE_VALUE) {
#ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error opening file %s", filename);
#endif /* VERBOSE_WARNING_ACTUALFILE */
return(NULL);
} // ENDIF- Error? Abort
return(newhandle);
} // END ActualFileOpenForWrite()
int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer) {
int retval;
DWORD byteswritten;
if(handle == NULL) return(-1);
if(handle == INVALID_HANDLE_VALUE) return(-1);
if(bytes < 1) return(-1);
if(buffer == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_ACTUALFILE
PrintLog("CDVDiso file: ActualFileWrite(%i)", bytes);
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
retval = WriteFile(handle, buffer, bytes, &byteswritten, NULL);
if(retval == 0) {
#ifdef VERBOSE_WARNING_ACTUALFILE
PrintLog("CDVDiso file: Error writing to file!");
#endif /* VERBOSE_WARNING_ACTUALFILE */
// return(-1);
} // ENDIF- Error? Abort
return(byteswritten); // Send back how many bytes written
} // END ActualFileWrite()

View File

@ -1,52 +1,104 @@
/* actualfile.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef ACTUALFILE_H
#define ACTUALFILE_H
#include <windows.h>
#include <sys/types.h> // off64_t
#define ACTUALHANDLE HANDLE
#define ACTUALHANDLENULL NULL
// #define VERBOSE_FUNCTION_ACTUALFILE
// #define VERBOSE_WARNING_ACTUALFILE
extern int IsActualFile(const char *filename);
extern void ActualFileDelete(const char *filename);
extern void ActualFileRename(const char *origname, const char *newname);
extern ACTUALHANDLE ActualFileOpenForRead(const char *filename);
extern off64_t ActualFileSize(ACTUALHANDLE handle);
extern int ActualFileSeek(ACTUALHANDLE handle, off64_t position);
extern int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer);
extern void ActualFileClose(ACTUALHANDLE handle);
extern ACTUALHANDLE ActualFileOpenForWrite(const char *filename);
extern int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer);
#endif /* ACTUALFILE_H */

View File

@ -1,175 +1,350 @@
/* conf.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <errno.h> // errno
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <stdlib.h> // getenv()
#include <string.h> // strerror()
#include <sys/stat.h> // mkdir(), stat()
#include <sys/types.h> // mkdir(), stat(), fork()
#include <unistd.h> // stat(), fork(), execlp()
#include <windows.h> // CreateProcess()
// #define CDVDdefs
// #include "../PS2Edefs.h"
#include "../PS2Etypes.h" // u8
#include "logfile.h"
#include "../ini.h"
#include "conf.h"
const char *confnames[] = { "Device", NULL };
const u8 defaultdevice[] = DEFAULT_DEVICE;
const char defaulthome[] = "inis";
const char defaultdirectory[] = "HideMe.PS2E";
const char defaultfile[] = "CDVDlinuz.ini";
char confdirname[256];
char conffilename[256];
CDVDconf conf;
void InitConf() {
DWORD retval;
int i;
int pos;
char *envptr;
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: InitConf()");
#endif /* VERBOSE_FUNCTION_CONF */
i = 0;
while((i < 255) && defaultdevice[i] != 0) {
conf.devicename[i] = defaultdevice[i];
i++;
} // ENDWHILE- copying the default CD/DVD name in
conf.devicename[i] = 0; // 0-terminate the device name
// Locating directory and file positions
pos = 0;
envptr = NULL;
// envptr = getenv("HOME");
if(envptr == NULL) {
// = <Default Home>
retval = GetCurrentDirectory(253, confdirname);
if(retval > 0) {
pos = retval;
} else {
pos = 2;
confdirname[0] = '.';
confdirname[1] = '\\';
} // ENDIF- Did we retrieve a directory reference?
i = 0;
while(i < pos) {
conffilename[i] = confdirname[i];
i++;
} // ENDWHILE- Copying dir info (so far) into file info
if(confdirname[pos-1] != '\\') {
confdirname[pos] = '\\';
conffilename[pos] = '\\';
pos++;
} // ENDIF- No directory separator here? Add one.
i = 0;
while((pos < 253) && (defaulthome[i] != 0)) {
confdirname[pos] = defaulthome[i];
conffilename[pos] = defaulthome[i];
pos++;
i++;
} // ENDWHILE- putting an offset where to store ini data
} else {
// = <Env Home>/<Default Directory>
i = 0;
while((pos < 253) && (*(envptr + i) != 0)) {
confdirname[pos] = *(envptr + i);
conffilename[pos] = *(envptr + i);
pos++;
i++;
} // ENDWHILE- copying home directory info in
if(confdirname[pos-1] != '\\') {
confdirname[pos] = '\\';
conffilename[pos] = '\\';
pos++;
} // ENDIF- No directory separator here? Add one.
i = 0;
while((pos < 253) && (defaultdirectory[i] != 0)) {
confdirname[pos] = defaultdirectory[i];
conffilename[pos] = defaultdirectory[i];
pos++;
i++;
} // NEXT- putting a default place to store configuration data
} // ENDIF- No Home directory?
confdirname[pos] = 0; // Directory reference finished
// += /<Config File Name>
if(conffilename[pos-1] != '\\') {
conffilename[pos] = '\\';
pos++;
} // ENDIF- No directory separator here? Add one.
i = 0;
while((pos < 253) && (defaultfile[i] != 0)) {
conffilename[pos] = defaultfile[i];
pos++;
i++;
} // NEXT- putting a default place to store configuration data
conffilename[pos] = 0; // File reference finished
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: Directory: %s", confdirname);
PrintLog("CDVD config: File: %s", conffilename);
#endif /* VERBOSE_FUNCTION_CONF */
} // END InitConf()
void LoadConf() {
int retval;
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: LoadConf()");
#endif /* VERBOSE_FUNCTION_CONF */
retval = INILoadString(conffilename, "Settings", "Device", conf.devicename);
if(retval < 0) {
sprintf(conf.devicename, "D:");
} // ENDIF- Couldn't find keyword? Fill in a default
} // END LoadConf()
void SaveConf() {
#ifdef VERBOSE_FUNCTION_CONF
PrintLog("CDVD config: SaveConf()");
#endif /* VERBOSE_FUNCTION_CONF */
mkdir(confdirname);
INISaveString(conffilename, "Settings", "Device", conf.devicename);
} // END SaveConf()

View File

@ -1,49 +1,98 @@
/* conf.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CONF_H
#define CONF_H
#define CDVDdefs
#include "../PS2Edefs.h"
#define VERBOSE_FUNCTION_CONF
// Configuration Data
typedef struct {
u8 devicename[256];
} CDVDconf;
extern CDVDconf conf;
#define DEFAULT_DEVICE "K:\\"
// Configuration Functions
extern void InitConf();
extern void LoadConf();
extern void SaveConf();
#endif /* CONF_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,128 @@
/* device.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __DEVICE_H__
#define __DEVICE_H__
#include <windows.h> // BOOL, DWORD
#include <time.h> // time_t
#define CDVDdefs
#include "../PS2Edefs.h"
// #define VERBOSE_FUNCTION_DEVICE
// #define VERBOSE_WARNING_DEVICE
#define VERBOSE_DISC_TYPE
#define VERBOSE_DISC_INFO
extern HANDLE devicehandle;
extern OVERLAPPED waitevent;
extern time_t lasttime;
extern s32 traystatus;
extern s32 disctype;
extern char tocbuffer[];
extern void DeviceInit();
extern void InitDisc();
extern s32 DiscInserted();
extern DWORD FinishCommand(BOOL boolresult);
extern s32 DeviceOpen();
extern void DeviceClose();
extern s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer);
extern s32 DeviceBufferOffset();
extern s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd);
extern s32 DeviceGetDiskType();
extern s32 DeviceTrayStatus();
extern s32 DeviceTrayOpen();
extern s32 DeviceTrayClose();
#endif /* __DEVICE_H__ */

View File

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

View File

@ -1,39 +1,78 @@
/* logfile.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef LOGFILE_H
#define LOGFILE_H
#include <windows.h> // Just for DWORD
#define VERBOSE_LOGFILE
extern void InitLog();
extern int OpenLog();
extern void CloseLog();
extern void PrintLog(const char *format, ...);
extern void PrintError(const char *header, DWORD errcode);
#endif /* LOGFILE_H */

View File

@ -1,173 +1,346 @@
/* mainbox.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <windows.h>
// #include <windowsx.h> // Button_
#include <windef.h> // NULL
#include <stdio.h> // sprintf()
#include <string.h> // strcpy()
#include <sys/stat.h> // stat()
#include <sys/types.h> // stat()
#include <unistd.h> // stat()
#include "conf.h"
#include "device.h"
// #include "imagetype.h" // imagedata[].name
#include "screens.h" // DLG_, IDC_
#include "CDVDlinuz.h" // progmodule
#include "mainbox.h"
HWND mainboxwindow;
void MainBoxDestroy() {
if(mainboxwindow != NULL) {
EndDialog(mainboxwindow, FALSE);
mainboxwindow = NULL;
} // ENDIF- Do we have a Main Window still?
} // END MainBoxDestroy()
void MainBoxUnfocus() {
// EnableWindow(?)
// gtk_widget_set_sensitive(mainbox.device, FALSE);
ShowWindow(mainboxwindow, SW_HIDE);
} // END MainBoxUnfocus()
void MainBoxDeviceEvent() {
char tempdevice[256];
struct stat filestat;
int returnval;
GetDlgItemText(mainboxwindow, IDC_0202, tempdevice, 256);
returnval = stat(tempdevice, &filestat);
if(returnval == -1) {
SetDlgItemText(mainboxwindow, IDC_0203, "Device Type: ---");
return;
} // ENDIF- Not a name of any sort?
if(S_ISDIR(filestat.st_mode) != 0) {
SetDlgItemText(mainboxwindow, IDC_0203, "Device Type: Not a device");
return;
} // ENDIF- Not a regular file?
SetDlgItemText(mainboxwindow, IDC_0203, "Device Type: Device Likely");
return;
} // END MainBoxFileEvent()
void MainBoxRefocus() {
MainBoxDeviceEvent();
// gtk_widget_set_sensitive(mainbox.device, TRUE);
// gtk_window_set_focus(GTK_WINDOW(mainbox.window), mainbox.device);
// ShowWindow(mainboxwindow, SW_RESTORE); // and/or, SW_SHOW? SW_SHOWNORMAL?
ShowWindow(mainboxwindow, SW_SHOW);
SetActiveWindow(mainboxwindow);
} // END MainBoxRefocus()
void MainBoxCancelEvent() {
MainBoxDestroy();
return;
} // END MainBoxCancelEvent()
void MainBoxOKEvent() {
int retval;
MainBoxUnfocus();
GetDlgItemText(mainboxwindow, IDC_0202, conf.devicename, 256);
retval = DeviceOpen();
DeviceClose();
if(retval != 0) {
MainBoxRefocus();
MessageBox(mainboxwindow,
"Could not open the device",
"CDVDlinuz Message",
MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
return;
} // ENDIF- Trouble opening device? Abort here.
SaveConf();
MainBoxCancelEvent();
return;
} // END MainBoxOKEvent()
void MainBoxDisplay() {
InitConf(); // Man, am I boiling mad! CDVDinit() should have been called first!
LoadConf();
// Adjust window position?
// We held off setting the name until now... so description would show.
SetDlgItemText(mainboxwindow, IDC_0202, conf.devicename);
// First Time - Show the window
ShowWindow(mainboxwindow, SW_SHOWNORMAL);
} // END MainBoxDisplay()
BOOL CALLBACK MainBoxCallback(HWND window,
UINT msg,
WPARAM param,
LPARAM param2) {
switch(msg) {
case WM_INITDIALOG:
mainboxwindow = window;
MainBoxDisplay(); // In this case, final touches to this window.
return(FALSE); // And let Windows display this window.
break;
case WM_CLOSE: // The "X" in the upper right corner was hit.
MainBoxCancelEvent();
return(TRUE);
break;
case WM_COMMAND:
// Do we wish to capture 'ENTER/RETURN' and/or 'ESC' here?
switch(LOWORD(param)) {
case IDC_0202: // Devicename Edit Box
MainBoxDeviceEvent(); // Describe the File's type...
return(FALSE); // Let Windows handle the actual 'edit' processing...
break;
case IDC_0204: // "Ok" Button
MainBoxOKEvent();
return(TRUE);
break;
case IDC_0205: // "Cancel" Button
MainBoxCancelEvent();
return(TRUE);
break;
} // ENDSWITCH param- Which object got the message?
} // ENDSWITCH msg- what message has been sent to this window?
return(FALSE); // Not a recognized message? Tell Windows to handle it.
} // END MainBoxEventLoop()

View File

@ -1,42 +1,84 @@
/* mainbox.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef MAINBOX_H
#define MAINBOX_H
#include <windows.h> // HWND
extern const char fileselection[];
extern HWND mainboxwindow;
extern void MainBoxRefocus();
extern void MainBoxDisplay();
extern BOOL CALLBACK MainBoxCallback(HWND window,
UINT msg,
WPARAM param,
LPARAM param2);
#endif /* MAINBOX_H */

View File

@ -1,9 +1,18 @@
/* Weditres generated include file. Do NOT edit */
#include <windows.h>
#define DLG_0100 100
#define IDC_0104 104
#define DLG_0200 200
#define IDC_0202 202
#define IDC_0203 203
#define IDC_0204 204
#define IDC_0205 205

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +1,134 @@
/* buffer.h
* Copyright (C) 2002-2005 CDVDlinuz Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __BUFFER_H__
#define __BUFFER_H__
#define CDVDdefs
#include "PS2Edefs.h"
// #define VERBOSE_FUNCTION_BUFFER
// #define VERBOSE_WARNINGS_BUFFER
// Remember, each buffer set is about 5k (packed. might be 4x that in-memory)
// Minimum: 16 Maximum: 32760
#define BUFFERMAX 256
// Buffer Structures
struct BufferList {
u16 upsort; // Don't alter this variable
u16 uppos; // Don't alter this variable
u32 lsn;
int mode; // -1 means error
u8 buffer[2368];
u8 offset;
cdvdSubQ subq;
};
// Exported Variables
extern struct BufferList bufferlist[];
extern u16 userbuffer;
extern u16 replacebuffer;
// Exported Functions
extern void InitBuffer();
extern u16 FindListBuffer(u32 lsn);
extern void RemoveListBuffer(u16 oldbuffer);
extern void AddListBuffer(u16 newbuffer);
#ifdef VERBOSE_WARNINGS_BUFFER
extern void PrintSortBuffers();
#endif /* VERBOSE_WARNINGS_BUFFER */
#endif /* __BUFFER_H__ */

View File

@ -1,118 +1,236 @@
/* convert.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#include <stddef.h>
#include <sys/types.h>
#include "convert.h"
off64_t ConvertEndianOffset(off64_t number) {
#ifndef CONVERTLITTLEENDIAN
union {
off64_t n;
char c[sizeof(off64_t)];
} oldnumber, newnumber;
int i;
oldnumber.n = number;
for(i = 0; i < sizeof(off64_t); i++)
newnumber.c[i] = oldnumber.c[sizeof(off64_t) - 1 - i];
return(newnumber.n);
#else
return(number);
#endif /* CONVERTLITTLEENDIAN */
} // END ConvertEndianOffset()
unsigned int ConvertEndianUInt(unsigned int number) {
#ifndef CONVERTLITTLEENDIAN
union {
unsigned int n;
char c[sizeof(unsigned int)];
} oldnumber, newnumber;
int i;
oldnumber.n = number;
for(i = 0; i < sizeof(unsigned int); i++)
newnumber.c[i] = oldnumber.c[sizeof(unsigned int) - 1 - i];
return(newnumber.n);
#else
return(number);
#endif /* CONVERTLITTLEENDIAN */
} // END ConvertEndianUInt()
unsigned short ConvertEndianUShort(unsigned short number) {
#ifndef CONVERTLITTLEENDIAN
union {
unsigned short n;
char c[sizeof(unsigned short)];
} oldnumber, newnumber;
int i;
oldnumber.n = number;
for(i = 0; i < sizeof(unsigned short); i++)
newnumber.c[i] = oldnumber.c[sizeof(unsigned short) - 1 - i];
return(newnumber.n);
#else
return(number);
#endif /* CONVERTLITTLEENDIAN */
} // END ConvertEndianUShort()
// Note: deposits M/S/F data in buffer[0]/[1]/[2] respectively.
void LBAtoMSF(unsigned long lsn, char *buffer) {
unsigned long templsn;
if(lsn >= 0xFFFFFFFF - 150) {
*(buffer + 2) = 75-1;
*(buffer + 1) = 60-1;
*(buffer) = 100-1;
} // ENDIF- Out of range?
templsn = lsn;
templsn += 150; // 2 second offset (75 Frames * 2 Seconds)
*(buffer + 2) = templsn % 75; // Remainder in frames
templsn -= *(buffer + 2);
templsn /= 75;
*(buffer + 1) = templsn % 60; // Remainder in seconds
templsn -= *(buffer + 1);
templsn /= 60;
*(buffer) = templsn; // Leftover quotient in minutes
} // END LBAtoMSF()
unsigned long MSFtoLBA(char *buffer) {
unsigned long templsn;
if(buffer == NULL) return(0xFFFFFFFF);
templsn = *(buffer); // Minutes
templsn *= 60;
templsn += *(buffer + 1); // Seconds
templsn *= 75;
templsn += *(buffer + 2); // Frames
if(templsn < 150) return(0xFFFFFFFF);
templsn -= 150; // Offset
return(templsn);
} // END MSFtoLBA()

View File

@ -1,50 +1,100 @@
/* convert.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef CONVERT_H
#define CONVERT_H
#include <sys/types.h> // off64_t
#ifdef __linux__
#include "endian.h"
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define CONVERTLITTLEENDIAN
#endif /* __BYTE_ORDER */
#endif /* __linux__ */
#ifdef __WIN32__
#define CONVERTLITTLEENDIAN
#endif /* __WIN32__ */
#define HEXTOBCD(i) (((i)/10*16) + ((i)%10))
#define BCDTOHEX(i) (((i)/16*10) + ((i)%16))
extern off64_t ConvertEndianOffset(off64_t number);
extern unsigned int ConvertEndianUInt(unsigned int number);
extern unsigned short ConvertEndianUShort(unsigned short number);
extern void LBAtoMSF(unsigned long lsn, char *buffer);
extern unsigned long MSFtoLBA(char *buffer);
#endif /* CONVERT_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,128 @@
/* ini.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef INI_H
#define INI_H
// #ifndef __LINUX__
// #ifdef __linux__
// #define __LINUX__
// #endif /* __linux__ */
// #endif /* No __LINUX__ */
// #define CDVDdefs
// #include "PS2Edefs.h"
// File format:
// [section]
// keyword=value
// file - Name of the INI file
// section - Section within the file
// keyword - Identifier for a value
// value - value to store with a keyword in a section in the file
// buffer - place to retrieve the value of a keyword
// return values: 0 = success, -1 = failure
// #define VERBOSE_FUNCTION_INI
#define INIMAXLEN 255
extern int INISaveString(char *file, char *section, char *keyword, char *value);
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 INILoadUInt(char *file, char *section, char *keyword, unsigned int *buffer);
// NULL in the keyword below removes the whole section.
extern int INIRemove(char *file, char *section, char *keyword);
#endif /* INI_H */

View File

@ -1,36 +1,72 @@
/* version.c
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
char *libname = "EFP polling CDVD Driver";
const unsigned char version = PS2E_CDVD_VERSION;
const unsigned char revision = 0;
const unsigned char build = 4;

View File

@ -1,43 +1,86 @@
/* version.h
* Copyright (C) 2002-2005 PCSX2 Team
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* PCSX2 members can be contacted through their website at www.pcsx2.net.
*/
#ifndef VERSION_H
#define VERSION_H
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
extern char *libname;
extern const unsigned char version;
extern const unsigned char revision;
extern const unsigned char build;
#endif /* VERSION_H */

View File

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

View File

@ -62,6 +62,7 @@ void CALLBACK USBconfigure() {
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
}
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
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
AssemblerOutput="4"
BrowseInformation="1"
CompileAs="0"
/>
@ -619,7 +618,6 @@
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
AssemblerOutput="4"
BrowseInformation="1"
CompileAs="0"
/>
@ -852,14 +850,26 @@
RelativePath="..\defs.h"
>
</File>
<File
RelativePath="..\interface.cpp"
>
</File>
<File
RelativePath="..\regs.h"
>
</File>
<File
RelativePath="..\regtable.cpp"
>
</File>
<File
RelativePath="..\regtable.h"
>
</File>
<File
RelativePath="..\savestate.cpp"
>
</File>
<File
RelativePath="..\spu2.cpp"
>
@ -888,7 +898,6 @@
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
AssemblerOutput="4"
BrowseInformation="1"
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;
s64 rate=(i&3)+4;
if (shift<0)
{
rate>>=-shift;
} else
{
else
rate<<=shift;
}
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
//
#ifndef _REGTABLE_H_
#define _REGTABLE_H_
#define U16P(x) ((u16*)&(x))
#define PCORE(c,p) \
@ -49,260 +52,9 @@
PCORE(c,Revb.##n)+1, \
PCORE(c,Revb.##n)
const u16 zero=0;
// Yay! Global namespace pollution 101!
static const u16 zero=0;
#pragma pack(push,1)
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),
extern u16* regtable[];
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)
};
#endif

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 "regtable.h"
#include "svnrev.h"
void StartVoices(int core, u32 value);
void StopVoices(int core, u32 value);
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 */);
const char *ParamNames[8]={"VOLL","VOLR","PITCH","ADSR1","ADSR2","ENVX","VOLXL","VOLXR"};
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:
static bool resetClock = true;
bool resetClock = true;
// Used to make spu2 more robust at loading incompatible saves.
// Disables re-freezing of save state data.
@ -78,11 +63,9 @@ s16 InputPos;
u8 InpBuff;
u32 Cycles;
u32 Num;
u32 acumCycles;
u32* cPtr=NULL;
u32 lClocks=0;
u32 pClocks=0;
bool hasPtr=false;
@ -95,12 +78,8 @@ HINSTANCE hInstance;
bool debugDialogOpen=false;
HWND hDebugDialog=NULL;
static char libraryName[256];
CRITICAL_SECTION threadSync;
s32 logvolume[16384];
bool has_to_call_irq=false;
void SetIrqCall()
@ -108,12 +87,6 @@ void SetIrqCall()
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, ...)
{
va_list list;
@ -125,80 +98,6 @@ void SysMessage(const char *fmt, ...)
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)
{
#ifndef _DEBUG_FAST
@ -240,6 +139,12 @@ __inline void __fastcall spu2M_Write( u32 addr, u16 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)
{
vol.Reg_VOL = value;
@ -324,109 +229,6 @@ void CoreReset(int c)
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)
{
int wmId,wmEvent;
@ -461,99 +263,7 @@ static BOOL CALLBACK DebugProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
return TRUE;
}
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);
}
#ifndef PUBLIC
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);
}
#ifndef PUBLIC
HFONT hf = NULL;
int lCount=0;
void UpdateDebugDialog()
@ -689,27 +399,6 @@ void UpdateDebugDialog()
u32 TicksCore=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)
{
u32 dClocks = cClocks-lClocks;
@ -794,69 +483,7 @@ void __fastcall TimeUpdate(u32 cClocks)
}
}
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;
}
u16 mask = 0xFFFF;
static u16 mask = 0xFFFF;
void UpdateSpdifMode()
{
@ -896,13 +523,7 @@ void UpdateSpdifMode()
}
}
__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);
}
static void SPU_ps1_write(u32 mem, u16 value)
void SPU_ps1_write(u32 mem, u16 value)
{
bool show=true;
@ -1043,7 +664,7 @@ static void SPU_ps1_write(u32 mem, u16 value)
spu2Ru16(mem)=value;
}
static u16 SPU_ps1_read(u32 mem)
u16 SPU_ps1_read(u32 mem)
{
bool show=true;
u16 value = spu2Ru16(mem);
@ -1120,7 +741,7 @@ static u16 SPU_ps1_read(u32 mem)
void RegWriteLog(u32 core,u16 value);
static void SPU2writeLog(u32 rmem, u16 value)
void SPU2writeLog(u32 rmem, u16 value)
{
#ifndef PUBLIC
u32 vx=0, vc=0, core=0, omem=rmem, mem=rmem&0x7FF;
@ -1329,8 +950,7 @@ static void SPU2writeLog(u32 rmem, u16 value)
#endif
}
static __forceinline void SPU2_FastWrite( u32 rmem, u16 value )
__forceinline void SPU2_FastWrite( u32 rmem, u16 value )
{
u32 vx=0, vc=0, core=0, omem, mem;
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)
{
if((Cycles-Cores[core].Voices[vc].PlayCycle)>=4)
@ -1958,7 +1269,7 @@ void VoiceStart(int core,int vc)
Cores[core].Regs.ENDX&=~(1<<vc);
#ifndef PUBLIC
#ifndef PUBLIC
DebugCores[core].Voices[vc].FirstBlock=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].ADSR.Reg_ADSR1,Cores[core].Voices[vc].ADSR.Reg_ADSR2);
}
#endif
#endif
}
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