git-svn-id: http://pcsx2.googlecode.com/svn/trunk@429 96395faa-99c1-11dd-bbfe-3dabce05a288

This commit is contained in:
refraction
2009-02-06 20:30:49 +00:00
parent 94cc1fd329
commit 73fff124b2
55 changed files with 8946 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
Changes:
-------
CDVDlinuz v0.4 (efp):
* Moved all "threaded" code to CDVDEFP (actual directory) (efp)
* Copied mid-level (not low-level) device drivers from CDVDisoEFP (efp)
* In Windows, when newly selected from the PCSX2 configure screen, CDVDinit()
(as well as InitConf()) are not called. Fixed. (efp)
CDVDEFP v0.3 (efp):
* Protection against "Interrupted system call" errors enhanced (threading)
* Simplified ReadLoop completion detection code (threading)
* Separated buffer.c from device.c for cross-CDVD portability.
CDVDEFP v0.2 (efp):
* Separated out device command calls (for easier maintainability)
* Added a read cache (currently sized at 512kb)
* Added threading code (pthreads, because it's portable)
* With threading comes tray polling (currently at 1/sec)
* With threading comes a read-ahead function (currently set to 64kb)
CDVDEFP v0.1 (efp):
* Updated to 0.6.0 (beta) specs
+342
View File
@@ -0,0 +1,342 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
+367
View File
@@ -0,0 +1,367 @@
/* 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 */
+46
View File
@@ -0,0 +1,46 @@
/* 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__
+368
View File
@@ -0,0 +1,368 @@
/* CDVDlinuz.c
* 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
*/
#include <errno.h> // errno
#include <fcntl.h> // open()
#include <stddef.h> // NULL
#include <stdio.h> // printf()
#include <stdlib.h> // getenv(), system()
#include <string.h> // strerror(), sprintf()
#include <sys/ioctl.h> // ioctl()
#include <sys/stat.h> // stat()
#include <sys/types.h> // stat()
#include <time.h> // time_t, time(), struct timeval
#include <unistd.h> // stat()
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
// #include "PS2Etypes.h"
#include "CDVDlinuz.h"
#include "buffer.h"
#include "conf.h"
#include "logfile.h"
#include "CD.h" // InitCDInfo()
#include "DVD.h" // InitDVDInfo()
#include "device.h"
#include "../version.h"
// Globals
time_t lasttime;
// Interface Functions
u32 CALLBACK PS2EgetLibType() {
return(PS2E_LT_CDVD); // Library Type CDVD
} // END PS2EgetLibType()
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
return((version<<16)|(revision<<8)|build);
} // END PS2EgetLibVersion2()
char* CALLBACK PS2EgetLibName() {
return(libname);
} // END PS2EgetLibName()
s32 CALLBACK CDVDinit() {
errno = 0;
InitLog();
if(OpenLog() != 0) return(-1);
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDinit()");
#endif /* VERBOSE_FUNCTION */
InitConf();
devicehandle = -1;
devicecapability = 0;
lasttime = time(NULL);
// Initialize DVD.c and CD.c as well
InitDisc();
InitDVDInfo();
InitCDInfo();
return(0);
} // END CDVDinit()
void CALLBACK CDVDshutdown() {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDshutdown()");
#endif /* VERBOSE_FUNCTION */
DeviceClose();
CloseLog();
} // END CDVDshutdown()
s32 CALLBACK CDVDopen(const char* pTitleFilename) {
s32 s32result;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDopen()");
#endif /* VERBOSE_FUNCTION */
InitBuffer();
LoadConf();
errno = 0;
s32result = DeviceOpen();
if(s32result != 0) return(s32result);
if(errno != 0) return(-1);
return(0);
} // END CDVDopen();
void CALLBACK CDVDclose() {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDclose()");
#endif /* VERBOSE_FUNCTION */
DeviceClose();
} // END CDVDclose()
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode) {
s32 s32result;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDreadTrack(%i)", lsn);
#endif /* VERBOSE_FUNCTION */
s32result = 0;
errno = 0;
if(DiscInserted() == -1) return(-1);
if(userbuffer < BUFFERMAX) {
if((bufferlist[userbuffer].lsn == lsn) &&
(bufferlist[userbuffer].mode == mode)) {
return(0);
} // ENDIF- And it's the right one?
} // ENDIF- Are we already pointing at the buffer?
userbuffer = FindListBuffer(lsn);
if(userbuffer < BUFFERMAX) {
if((bufferlist[userbuffer].lsn == lsn) &&
(bufferlist[userbuffer].mode == mode)) {
return(0);
} // ENDIF- And it was the right one?
} // ENDIF- Was a buffer found in the cache?
replacebuffer++;
if(replacebuffer >= BUFFERMAX) replacebuffer = 0;
userbuffer = replacebuffer;
if(bufferlist[replacebuffer].upsort != 0xffff) {
RemoveListBuffer(replacebuffer);
} // ENDIF- Reference already in place? Remove it.
s32result = DeviceReadTrack(lsn, mode, bufferlist[replacebuffer].buffer);
bufferlist[replacebuffer].lsn = lsn;
bufferlist[replacebuffer].mode = mode;
bufferlist[replacebuffer].offset = DeviceBufferOffset();
if((s32result != 0) || (errno != 0)) {
bufferlist[replacebuffer].mode = -1; // Error! flag buffer as such.
} else {
if((disctype != CDVD_TYPE_PS2DVD) && (disctype != CDVD_TYPE_DVDV)) {
if(mode == CDVD_MODE_2352) {
CDreadSubQ(lsn, &bufferlist[replacebuffer].subq);
errno = 0;
} // ENDIF- Read subq as well?
} // ENDIF- Read a DVD buffer or a CD buffer?
} // ENDIF-Read ok? Fill out rest of buffer info.
AddListBuffer(replacebuffer);
return(s32result);
} // END CDVDreadTrack()
u8* CALLBACK CDVDgetBuffer() {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDgetBuffer()");
#endif /* VERBOSE_FUNCTION */
if(DiscInserted() == -1) return(NULL);
if(userbuffer == 0xffff) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD 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("CDVD interface: Error in buffer!");
#endif /* VERBOSE_WARNINGS */
return(NULL); // Bad Sector?
} // ENDIF- Trouble reading physical sector? Tell them.
return(bufferlist[userbuffer].buffer + bufferlist[userbuffer].offset);
} // END CDVDgetBuffer()
// Note: without the lsn, I could pull the SubQ data directly from
// the stored buffer (in buffer.h). Oh, well.
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ *subq) {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDreadSubQ(%i)", lsn);
#endif /* VERBOSE_FUNCTION */
if(DiscInserted() == -1) return(-1);
// DVDs don't have SubQ data
if(disctype == CDVD_TYPE_PS2DVD) return(-1);
if(disctype == CDVD_TYPE_DVDV) return(-1);
return(CDreadSubQ(lsn, subq));
} // END CDVDreadSubQ()
s32 CALLBACK CDVDgetTN(cdvdTN *cdvdtn) {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDgetTN()");
#endif /* VERBOSE_FUNCTION */
if(DiscInserted() == -1) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(DVDgetTN(cdvdtn));
} else {
return(CDgetTN(cdvdtn));
} // ENDIF- Are we looking at a DVD?
} // END CDVDgetTN()
s32 CALLBACK CDVDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDgetTD()");
#endif /* VERBOSE_FUNCTION */
if(DiscInserted() == -1) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(DVDgetTD(newtrack, cdvdtd));
} else {
return(CDgetTD(newtrack, cdvdtd));
} // ENDIF- Are we looking at a DVD?
} // END CDVDgetTD()
s32 CALLBACK CDVDgetTOC(void *toc) {
// A structure to fill in, or at least some documentation on what
// the PS2 expects from this call would be more helpful than a
// "void *".
union {
void *voidptr;
u8 *u8ptr;
} tocptr;
s32 i;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDgetTOC()");
#endif /* VERBOSE_FUNCTION */
if(toc == NULL) return(-1);
if(DiscInserted() == -1) return(-1);
tocptr.voidptr = toc;
for(i = 0; i < 1024; i++) *(tocptr.u8ptr + i) = tocbuffer[i];
tocptr.voidptr = NULL;
return(0);
} // END CDVDgetTOC()
s32 CALLBACK CDVDgetDiskType() {
#ifdef VERBOSE_FUNCTION
// Called way too often in boot part of bios to be left in.
// PrintLog("CDVD interface: CDVDgetDiskType()");
#endif /* VERBOSE_FUNCTION */
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
PrintLog("CDVD interface: CDVDgetTrayStatus()");
#endif /* VERBOSE_FUNCTION */
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
PrintLog("CDVD interface: CDVDctrlTrayOpen()");
#endif /* VERBOSE_FUNCTION */
return(DeviceTrayOpen());
} // END CDVDctrlTrayOpen()
s32 CALLBACK CDVDctrlTrayClose() {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD interface: CDVDctrlTrayClose()");
#endif /* VERBOSE_FUNCTION */
return(DeviceTrayClose());
} // END CDVDctrlTrayClose()
void CALLBACK CDVDconfigure() {
ExecCfg("configure");
} // END CDVDconfigure()
void CALLBACK CDVDabout() {
ExecCfg("about");
} // END CDVDabout()
s32 CALLBACK CDVDtest() {
s32 s32result;
errno = 0;
if(devicehandle != -1) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD interface: Device already open");
#endif /* VERBOSE_WARNINGS */
return(0);
} // ENDIF- Is the CD/DVD already in use? That's fine.
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDVDtest()");
#endif /* VERBOSE_FUNCTION */
s32result = DeviceOpen();
DeviceClose();
return(s32result);
} // END CDVDtest()
+31
View File
@@ -0,0 +1,31 @@
/* 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
+584
View File
@@ -0,0 +1,584 @@
/* 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 <errno.h> // errno
#include <stddef.h> // NULL
#include <stdio.h> // sprintf()
#include <string.h> // strerror(), memset(), memcpy()
#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 "logfile.h"
#include "device.h"
#include "DVD.h"
#include "../PS2Etypes.h" // u8, u32
// Constants
u8 *playstationname = "PLAYSTATION\0";
// DVD storage structures (see linux/cdrom.h for details)
dvd_struct dvdphysical;
dvd_struct dvdcopyright[DVD_LAYERS];
dvd_struct dvdbca;
dvd_struct dvdmanufact[DVD_LAYERS];
u32 dvdlastlsn;
u8 dvdtempbuffer[2064];
// Internal Functions
void InitDVDSectorInfo() {
dvdlastlsn = 0xffffffff;
} // END InitSectorInfo();
void HexDump(u8 *strptr, u8 count) {
int i;
u8 ch[2];
char hexline[81];
int hexlinepos;
ch[1] = 0;
if(count == 0) count = 16;
if((count < 1) || (count > 16)) return;
hexlinepos = 0;
hexlinepos += sprintf(&hexline[hexlinepos], "CDVD driver: ");
for(i = 0; i < count; i++) {
hexlinepos += sprintf(&hexline[hexlinepos], "%.2x ", (*(strptr + i)) * 1);
} // NEXT i- printing each new Hex number
for(i = 0; i < count; i++) {
if((*(strptr + i) < 32) || (*(strptr + i) > 127)) {
hexlinepos += sprintf(&hexline[hexlinepos], ".");
} else {
ch[0] = *(strptr + i);
hexlinepos += sprintf(&hexline[hexlinepos], "%s", ch);
} // ENDIF- Is this an unprintable character?
} // NEXT i- printing each new character
PrintLog(hexline);
} // ENDIF HexDump()
//// DVD Structure Functions
s32 DVDreadPhysical() {
s32 s32result;
u8 i;
errno = 0;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDreadPhysical()\n");
#endif /* VERBOSE_FUNCTION */
memset(&dvdphysical, 0, sizeof(dvd_struct));
dvdphysical.type = DVD_STRUCT_PHYSICAL;
i = DVD_LAYERS;
while(i > 0) {
i--;
dvdphysical.physical.layer_num = i;
errno = 0;
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdphysical);
} // ENDWHILE- reading in all physical layers...
if((s32result == -1) || (errno != 0)) {
dvdphysical.type = 0xFF;
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error getting Physical structure: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
return(-1);
} // ENDIF- Problem with reading Layer 0 of the physical data? Abort
i = 3;
while((i > 0) && (dvdphysical.physical.layer[i].end_sector == 0)) i--;
dvdphysical.physical.layer_num = i;
#ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: Physical Characteristics");
PrintLog("CDVD driver: Number of Layers: %i",
(s32) dvdphysical.physical.layer_num + 1);
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
PrintLog("CDVD driver: Layer Number %i", i);
switch(dvdphysical.physical.layer[i].book_type) {
case 0:
PrintLog("CDVD driver: Book Type: DVD-ROM");
break;
case 1:
PrintLog("CDVD driver: Book Type: DVD-RAM");
break;
case 2:
PrintLog("CDVD driver: Book Type: DVD-R");
break;
case 3:
PrintLog("CDVD driver: Book Type: DVD-RW");
break;
case 9:
PrintLog("CDVD driver: Book Type: DVD+RW");
break;
default:
PrintLog("CDVD driver: Book Type: Unknown (%i)",
dvdphysical.physical.layer[i].book_type);
break;
} // ENDSWITCH- Displaying the Book Type
PrintLog("CDVD driver: Book Version %i",
dvdphysical.physical.layer[i].book_version);
switch(dvdphysical.physical.layer[i].min_rate) {
case 0:
PrintLog("CDVD driver: Use Minimum Rate for: DVD-ROM");
break;
case 1:
PrintLog("CDVD driver: Use Minimum Rate for: DVD-RAM");
break;
case 2:
PrintLog("CDVD driver: Use Minimum Rate for: DVD-R");
break;
case 3:
PrintLog("CDVD driver: Use Minimum Rate for: DVD-RW");
break;
case 9:
PrintLog("CDVD driver: Use Minimum Rate for: DVD+RW");
break;
default:
PrintLog("CDVD driver: Use Minimum Rate for: Unknown (%i)",
dvdphysical.physical.layer[i].min_rate);
break;
} // ENDSWITCH- Displaying the Minimum (Spin?) Rate
switch(dvdphysical.physical.layer[i].disc_size) {
case 0:
PrintLog("CDVD driver: Physical Disk Size: 120mm");
break;
case 1:
PrintLog("CDVD driver: Physical Disk Size: 80mm");
break;
default:
PrintLog("CDVD driver: Physical Disk Size: Unknown (%i)",
dvdphysical.physical.layer[i].disc_size);
break;
} // ENDSWITCH- What's the Disk Size?
switch(dvdphysical.physical.layer[i].layer_type) {
case 1:
PrintLog("CDVD driver: Layer Type: Read-Only");
break;
case 2:
PrintLog("CDVD driver: Layer Type: Recordable");
break;
case 4:
PrintLog("CDVD driver: Layer Type: Rewritable");
break;
default:
PrintLog("CDVD driver: Layer Type: Unknown (%i)",
dvdphysical.physical.layer[i].layer_type);
break;
} // ENDSWITCH- Displaying the Layer Type
switch(dvdphysical.physical.layer[i].track_path) {
case 0:
PrintLog("CDVD driver: Track Path: PTP");
break;
case 1:
PrintLog("CDVD driver: Track Path: OTP");
break;
default:
PrintLog("CDVD driver: Track Path: Unknown (%i)",
dvdphysical.physical.layer[i].track_path);
break;
} // ENDSWITCH- What's Track Path Layout?
// PrintLog("CDVD driver: Disc Size %i Layer Type %i Track Path %i Nlayers %i",
// dvdphysical.physical.layer[i].nlayers);
switch(dvdphysical.physical.layer[i].track_density) {
case 0:
PrintLog("CDVD driver: Track Density: .74 m/track");
break;
case 1:
PrintLog("CDVD driver: Track Density: .8 m/track");
break;
case 2:
PrintLog("CDVD driver: Track Density: .615 m/track");
break;
default:
PrintLog("CDVD driver: Track Density: Unknown (%i)",
dvdphysical.physical.layer[i].track_density);
break;
} // ENDSWITCH- Displaying the Track Density
switch(dvdphysical.physical.layer[i].linear_density) {
case 0:
PrintLog("CDVD driver: Linear Density: .267 m/bit");
break;
case 1:
PrintLog("CDVD driver: Linear Density: .293 m/bit");
break;
case 2:
PrintLog("CDVD driver: Linear Density: .409 to .435 m/bit");
break;
case 4:
PrintLog("CDVD driver: Linear Density: .280 to .291 m/bit");
break;
case 8:
PrintLog("CDVD driver: Linear Density: .353 m/bit");
break;
default:
PrintLog("CDVD driver: Linear Density: Unknown (%i)",
dvdphysical.physical.layer[i].linear_density);
break;
} // ENDSWITCH- Displaying the Linear Density
if(dvdphysical.physical.layer[i].start_sector == 0x30000) {
PrintLog("CDVD driver: Starting Sector: %lu (DVD-ROM, DVD-R, DVD-RW)",
dvdphysical.physical.layer[i].start_sector);
} else if(dvdphysical.physical.layer[i].start_sector == 0x31000) {
PrintLog("CDVD driver: Starting Sector: %lu (DVD-RAM, DVD+RW)",
dvdphysical.physical.layer[i].start_sector);
} else {
PrintLog("CDVD driver: Starting Sector: %lu",
dvdphysical.physical.layer[i].start_sector);
} // ENDLONGIF- What does the starting sector tell us?
PrintLog("CDVD driver: End of Layer 0: %lu",
dvdphysical.physical.layer[i].end_sector_l0);
PrintLog("CDVD driver: Ending Sector: %lu",
dvdphysical.physical.layer[i].end_sector);
if(dvdphysical.physical.layer[i].bca != 0)
PrintLog("CDVD driver: BCA data present");
} // NEXT i- Work our way through each layer...
#endif /* VERBOSE_DISC_INFO */
return(0); // Success. Physical data stored for perusal.
} // END DVDreadPhysical()
s32 DVDreadCopyright() {
s32 s32result;
u8 i;
int successflag;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDreadCopyright()");
#endif /* VERBOSE_FUNCTION */
successflag = 0;
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
memset(&dvdcopyright[i], 0, sizeof(dvd_struct));
dvdcopyright[i].type = DVD_STRUCT_COPYRIGHT;
dvdcopyright[i].copyright.layer_num = i;
errno = 0;
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdcopyright[i]);
if(s32result == 0) {
successflag = 1;
} else {
dvdcopyright[i].type = 0xFF;
} // ENDIF-
} // NEXT i- Getting copyright data for every known layer
if(successflag == 0) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error getting Copyright info: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
return(-1);
} // ENDIF- Problem with read of physical data?
#ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: Copyright Information\n");
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
if(dvdcopyright[i].type != 0xFF) {
PrintLog("CDVD driver: Layer Number %i CPST %i RMI %i",
dvdcopyright[i].copyright.layer_num,
dvdcopyright[i].copyright.cpst,
dvdcopyright[i].copyright.rmi);
} // ENDIF- Were we successful reading this one?
} // NEXT i- Printing out all copyright info found...
#endif /* VERBOSE_DISC_INFO */
errno = 0;
return(0); // Success. Copyright data stored for perusal.
} // END DVDreadCopyright()
s32 DVDreadBCA() {
s32 s32result;
int i;
i = 0;
errno = 0;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDreadBCA()");
#endif /* VERBOSE_FUNCTION */
memset(&dvdbca, 0, sizeof(dvd_struct));
dvdbca.type = DVD_STRUCT_BCA;
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdbca);
if((s32result == -1) || (errno != 0)) {
dvdbca.type = 0xFF;
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error getting BCA: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
return(-1);
} // ENDIF- Problem with read of physical data?
#ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: BCA Length %i Value:",
dvdbca.bca.len);
for(i = 0; i < 188-15; i += 16) {
HexDump(dvdbca.bca.value+i, 16);
} // NEXT i- dumping whole key data
#endif /* VERBOSE_DISC_INFO */
return(0); // Success. BCA data stored for perusal.
} // END DVDreadBCA()
s32 DVDreadManufact() {
s32 s32result;
u8 i;
int successflag;
int j;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDreadManufact()");
#endif /* VERBOSE_FUNCTION */
j = 0;
successflag = 0;
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
memset(&dvdmanufact[i], 0, sizeof(dvd_struct));
dvdmanufact[i].type = DVD_STRUCT_MANUFACT;
dvdmanufact[i].manufact.layer_num = i;
errno = 0;
s32result = ioctl(devicehandle, DVD_READ_STRUCT, &dvdmanufact[i]);
if((s32result != 0) || (errno != 0)) {
dvdmanufact[i].type = 0xFF;
} else {
successflag = 1;
} // ENDIF- Did we fail to read in some manufacturer data?
} // NEXT i- Collecting manufacturer data from all layers
if(successflag == 0) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error getting Manufact: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
return(-1);
} // ENDIF- Problem with read of physical data?
#ifdef VERBOSE_DISC_INFO
PrintLog("CDVD driver: Manufact Data");
for(i = 0; i <= dvdphysical.physical.layer_num; i++) {
if(dvdmanufact[i].type != 0xFF) {
PrintLog("CDVD driver: Layer %i Length %i Value:",
dvdmanufact[i].manufact.layer_num,
dvdmanufact[i].manufact.len);
for(j = 0; j < 128-15; j += 16) {
HexDump(dvdmanufact[i].manufact.value+j, 16);
} // NEXT j- dumping whole key data
} // ENDIF- Do we have data at this layer?
} // NEXT i- Running through all the layers
#endif /* VERBOSE_DISC_INFO */
errno = 0;
return(0); // Success. Manufacturer's data stored for perusal.
} // END DVDreadManufact()
// External Functions
// Function Calls from CDVD.c
void InitDVDInfo() {
int j;
dvdphysical.type = 0xFF; // Using for empty=0xff, full!=0xff test
dvdbca.type = 0xFF;
for(j = 0; j < DVD_LAYERS; j++) {
dvdcopyright[j].type = 0xFF;
dvdmanufact[j].type = 0xFF;
} // NEXT j- Zeroing each layer of data
InitDVDSectorInfo();
} // END InitDiscType()
s32 DVDreadTrack(u32 lsn, int mode, u8 *buffer) {
s32 s32result;
off64_t offsettarget;
off64_t offsetresult;
errno = 0;
s32result = 0;
offsetresult = 0;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDreadTrack(%i)", lsn);
#endif /* VERBOSE_FUNCTION */
if(lsn != dvdlastlsn + 1) {
offsettarget = lsn;
offsettarget *= 2048;
errno = 4;
while(errno == 4) {
errno = 0;
offsetresult = lseek64(devicehandle, offsettarget, SEEK_SET);
} // ENDWHILE- waiting for the system interruptions to cease.
if((offsetresult < 0) || (errno != 0)) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: Error on seek: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
InitDVDSectorInfo();
return(-1);
} // ENDIF- trouble with seek? Reset pointer and abort
} // ENDIF- Do we have to seek a new position to read?
errno = 4;
while(errno == 4) {
errno = 0;
s32result = read(devicehandle, buffer, 2048);
} // ENDWHILE- waiting for the system interruptions to cease.
if((s32result != 2048) || (errno != 0)) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD driver: DVD Short Block, Size: %i", s32result);
PrintLog("CDVD driver: Error: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
InitDVDSectorInfo();
return(-1);
} // ENDIF- Trouble reading the data? Reset pointer and abort
dvdlastlsn = lsn;
return(0); // Call accomplished
} // END DVDreadTrack()
s32 DVDgetTN(cdvdTN *cdvdtn) {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDVDgetTN()");
#endif /* VERBOSE_FUNCTION */
// Going to treat this as one large track for now.
if(cdvdtn != NULL) {
cdvdtn->strack = 1;
cdvdtn->etrack = 1;
} // ENDIF- programmer actually WANTS this info?
return(0); // Call accomplished
} // END DVDgetTN()
s32 DVDgetTD(u8 newtrack, cdvdTD *cdvdtd) {
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: CDVDgetTD()");
#endif /* VERBOSE_FUNCTION */
if((newtrack >= 2) && (newtrack != CDROM_LEADOUT)) return(-1);
if(cdvdtd != NULL) {
cdvdtd->lsn = dvdphysical.physical.layer[0].end_sector
- dvdphysical.physical.layer[0].start_sector
+ 1;
cdvdtd->type = CDVD_MODE_2048;
} // ENDIF- Does the caller REALLY want this data?
return(0); // Call accomplished
} // END DVDgetTD()
s32 DVDgetDiskType(s32 ioctldisktype) {
s32 s32result;
int i;
s32 tempdisctype;
errno = 0;
s32result = 0;
i = 0;
tempdisctype = CDVD_TYPE_UNKNOWN;
#ifdef VERBOSE_FUNCTION
PrintLog("CDVD driver: DVDgetDiskType()");
#endif /* VERBOSE_FUNCTION */
if((ioctldisktype != CDS_DATA_1) && (ioctldisktype != CDS_MIXED)) {
return(-1);
} // ENDIF- Not a data disc we know of? Abort then
s32result = DVDreadPhysical();
if((s32result != 0) || (errno != 0)) {
return(-1);
} // ENDIF- Error reading the DVD physical structure? Not a DVD after all.
if(dvdphysical.physical.layer[0].end_sector >= (2048*1024)) {
#ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: DVD Found (Dual-Sided)");
#endif /* VERBOSE_DISC_TYPE */
disctype = CDVD_TYPE_DETCTDVDD;
} else {
#ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: DVD Found (Single-Sided)");
#endif /* VERBOSE_DISC_TYPE */
disctype = CDVD_TYPE_DETCTDVDS;
} // ENDIF- Definitely a DVD. Size Test?
// Read in the rest of the structures...
DVDreadCopyright();
DVDreadBCA();
DVDreadManufact();
// Test for "Playstation" header
s32result = DVDreadTrack(16, CDVD_MODE_2048, dvdtempbuffer);
if(s32result != 0) {
return(-1);
} else {
i = 0;
while((*(playstationname + i) != 0) &&
(*(playstationname + i) == dvdtempbuffer[8 + i])) {
i++;
} // ENDWHILE- Checking each letter of PLAYSTATION name for a match
if(*(playstationname + i) == 0) {
#ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: Detected Playstation 2 DVD");
#endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_PS2DVD;
} else {
#ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD driver: Guessing it's a Video DVD");
#endif /* VERBOSE_DISC_TYPE */
tempdisctype = CDVD_TYPE_DVDV;
} // ENDIF- Did we find the Playstation name?
} // ENDIF- Error reading disc volume information? Invalidate Disc
if(dvdphysical.physical.layer[0].end_sector >= (2048*1024)) {
tocbuffer[0] = 0x24; // Dual-Sided DVD
tocbuffer[4] = 0x41;
tocbuffer[5] = 0x95;
} else {
tocbuffer[0] = 0x04; // Single-Sided DVD
tocbuffer[4] = 0x86;
tocbuffer[5] = 0x72;
} // ENDIF- Are there too many sectors for a single-sided disc?
tocbuffer[1] = 0x02;
tocbuffer[2] = 0xF2;
tocbuffer[3] = 0x00;
tocbuffer[16] = 0x00;
tocbuffer[17] = 0x03;
tocbuffer[18] = 0x00;
tocbuffer[19] = 0x00;
disctype = tempdisctype; // Triggers the fact the other info is available
return(disctype);
} // END DVDgetDiskType()
+45
View File
@@ -0,0 +1,45 @@
/* 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__
+71
View File
@@ -0,0 +1,71 @@
PLUGIN = libCDVDlinuz.so
PLUGINOBJS = CDVDlinuz.o ../buffer.o
PLUGINHEADERS = CDVDlinuz.h ../buffer.h
PLUGINFLAGS = -fPIC -Wall -O2 -fomit-frame-pointer -D_LARGEFILE64_SOURCE \
-I.. -I. -I./Linux
PLUGINLIBS =
CFG = cfgCDVDlinuz
CFGOBJS = aboutbox.o mainbox.o interface.o
CFGHEADERS = aboutbox.h mainbox.h interface.h
CFGFLAGS = -fPIC -Wall -O2 -fomit-frame-pointer -D_LARGEFILE64_SOURCE \
-I.. -I. -I./Linux
CFGLIBS =
SHAREDOBJS = actualfile.o conf.o logfile.o \
device.o CD.o DVD.o \
../convert.o ../ini.o ../version.o
SHAREDHEADERS = actualfile.h conf.h logfile.h \
device.h CD.h DVD.h \
../convert.h ../ini.h ../version.h
CC = gcc
GTKFLAGS = $(shell pkg-config --cflags gtk+-2.0)
//GTKFLAGS += -DG_DISABLE_DEPRECATED \
// -DGDK_DISABLE_DEPRECATED \
// -DGDK_PIXBUF_DISABLE_DEPRECATED \
// -DGTK_DISABLE_DEPRECATED
GTKLIBS = $(shell pkg-config --libs gtk+-2.0)
# Do we need to remove "-rdynamic" as well? Or is that just the main program?
all: plugin cfg
install: all
release: plugin cfg
cp $(PLUGIN) ../..
cp $(CFG) ../..
plugin: $(PLUGINOBJS) $(SHAREDOBJS)
# rm -f $(PLUGIN)
$(CC) -shared -Wl,-soname,$(PLUGIN) $(PLUGINFLAGS) $(PLUGINLIBS) \
$(PLUGINOBJS) $(SHAREDOBJS) -o $(PLUGIN)
strip --strip-unneeded --strip-debug $(PLUGIN)
cfg: $(CFGOBJS) $(SHAREDOBJS)
# rm -f $(CFG)
$(CC) $(CFGFLAGS) $(GTKFLAGS) $(CFGLIBS) $(GTKLIBS) \
$(CFGOBJS) $(SHAREDOBJS) -o $(CFG)
strip $(CFG)
$(PLUGINOBJS) $(SHAREDOBJS): %.o: %.c
$(CC) $(PLUGINFLAGS) -c $< -o $@
$(CFGOBJS): %.o: %.c
$(CC) $(CFGFLAGS) $(GTKFLAGS) -c $< -o $@
.PHONY : clean allclean
clean:
-rm -f $(PLUGINOBJS) $(PLUGIN) $(CFGOBJS) $(CFG) $(SHAREDOBJS)
-rm -f *~ temp.txt ../*~ ../temp.txt ../../*~
allclean:
-rm -f $(PLUGINOBJS) $(PLUGIN) $(CFGOBJS) $(CFG) $(SHAREDOBJS)
-rm -f *~ temp.txt ../*~ ../temp.txt ../../*~
-rm -f ../../$(PLUGIN) ../../$(CFG)
+106
View File
@@ -0,0 +1,106 @@
/* 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;
+39
View File
@@ -0,0 +1,39 @@
/* 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.
*/
+222
View File
@@ -0,0 +1,222 @@
/* 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);
+50
View File
@@ -0,0 +1,50 @@
/* 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
+184
View File
@@ -0,0 +1,184 @@
/* 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/cfgCDVDlinuz", \
"../cfg/cfgCDVDlinuz", \
"./plugins/cfgCDVDlinuz", \
"../plugins/cfgCDVDlinuz", \
"./cfgCDVDlinuz", \
"../cfgCDVDlinuz", \
NULL };
const char *confnames[] = { "Device", NULL };
const u8 defaultdevice[] = DEFAULT_DEVICE;
const char defaulthome[] = "../inis";
const char defaultdirectory[] = ".PS2E";
const char defaultfile[] = "CDVDlinuz.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 */
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", "Device", conf.devicename);
if(retval < 0) {
sprintf(conf.devicename, "/dev/dvd");
} // 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", "Device", conf.devicename);
} // END SaveConf()
+57
View File
@@ -0,0 +1,57 @@
/* 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__ */
+420
View File
@@ -0,0 +1,420 @@
/* device.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 <stddef.h> // NULL
#include <stdlib.h> // getenv()
#include <string.h> // strerror()
#include <sys/ioctl.h> // ioctl()
#include <sys/stat.h> // open()
#include <sys/types.h> // open()
#include <time.h> // time_t, time(), struct timeval
#include <unistd.h> // close(), select()
#include <linux/cdrom.h> // CD/DVD based ioctl() and defines.
// missing on some files for some reason.........
#ifndef CDC_IOCTLS
#define CDC_IOCTLS 0x400
#endif
#include "logfile.h"
#include "conf.h"
#include "CD.h"
#include "DVD.h"
#include "device.h"
#include "../PS2Etypes.h" // u32, u8, s32
// Globals
int devicehandle; // File Handle for the device/drive
s32 devicecapability; // Capability Flags
time_t lasttime; // Time marker (in case something gets called too often)
s32 traystatus; // Is the CD/DVD tray open?
s32 disctype; // Type of disc in drive (Video DVD, PSX CD, etc.)
u8 tocbuffer[2048];
void DeviceInit() {
devicehandle = -1;
devicecapability = 0;
lasttime = time(NULL);
InitDisc();
} // END DeviceInit()
// Called by DeviceOpen(), DeviceGetDiskType()
void InitDisc() {
int i;
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: InitDisc()");
#endif /* VERBOSE_FUNCTION_DEVICE */
if((disctype == CDVD_TYPE_PS2DVD) ||
(disctype == CDVD_TYPE_DVDV)) {
InitDVDInfo();
} // ENDIF- Clean out DVD Disc Info?
if((disctype == CDVD_TYPE_PS2CD) ||
(disctype == CDVD_TYPE_PS2CDDA) ||
(disctype == CDVD_TYPE_PSCD) ||
(disctype == CDVD_TYPE_PSCDDA) ||
(disctype == CDVD_TYPE_CDDA)) {
InitCDInfo();
} // ENDIF- Clean out DVD Disc Info?
disctype = CDVD_TYPE_NODISC;
for(i = 0; i > sizeof(tocbuffer); i++) tocbuffer[i] = 0x00;
} // END InitDisc()
s32 DiscInserted() {
if(devicehandle == -1) return(-1);
if(traystatus == CDVD_TRAY_OPEN) return(-1);
if(disctype == CDVD_TYPE_ILLEGAL) return(-1);
// if(disctype == CDVD_TYPE_UNKNOWN) return(-1); // Hmm. Let this one through?
if(disctype == CDVD_TYPE_DETCTDVDD) return(-1);
if(disctype == CDVD_TYPE_DETCTDVDS) return(-1);
if(disctype == CDVD_TYPE_DETCTCD) return(-1);
if(disctype == CDVD_TYPE_DETCT) return(-1);
if(disctype == CDVD_TYPE_NODISC) return(-1);
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DiscInserted()");
#endif /* VERBOSE_FUNCTION_DEVICE */
return(0);
} // END DiscInserted()
// Called by DeviceTrayStatus() and CDVDopen()
s32 DeviceOpen() {
// s32 s32result;
errno = 0;
if(devicehandle != -1) {
#ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVD device: Device already open!");
#endif /* VERBOSE_WARNING_DEVICE */
return(0);
} // ENDIF- Is the CD/DVD already in use? That's fine.
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceOpen()");
#endif /* VERBOSE_FUNCTION_DEVICE */
// InitConf();
// LoadConf(); // Should be done once before making this call
devicehandle = open(conf.devicename, O_RDONLY | O_NONBLOCK);
if(devicehandle == -1) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Error opening device: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
return(-1);
} // ENDIF- Failed to open device? Abort
// Note: Hmm. Need a minimum capability in case this fails?
devicecapability = ioctl(devicehandle, CDROM_GET_CAPABILITY);
if(errno != 0) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Error getting device capabilities: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
close(devicehandle);
devicehandle = -1;
devicecapability = 0;
return(-1);
} // ENDIF- Can't read drive capabilities? Close and Abort.
#ifdef VERBOSE_DISC_TYPE
PrintLog("CDVD device: Device Type(s)");
if(devicecapability < CDC_CD_R) PrintLog("CDVD device: CD");
if(devicecapability & CDC_CD_R) PrintLog("CDVD device: CD-R");
if(devicecapability & CDC_CD_RW) PrintLog("CDVD device: CD-RW");
if(devicecapability & CDC_DVD) PrintLog("CDVD device: DVD");
if(devicecapability & CDC_DVD_R) PrintLog("CDVD device: DVD-R");
if(devicecapability & CDC_DVD_RAM) PrintLog("CDVD device: DVD-RAM");
#endif /* VERBOSE_DISC_TYPE */
#ifdef VERBOSE_DISC_INFO
PrintLog("CDVD device: Device Capabilities:");
if(devicecapability & CDC_CLOSE_TRAY) PrintLog("CDVD device: Can close a tray");
if(devicecapability & CDC_OPEN_TRAY) PrintLog("CDVD device: Can open a tray");
// if(devicecapability & CDC_LOCK) PrintLog("CDVD device: Can lock the drive door");
if(devicecapability & CDC_SELECT_SPEED) PrintLog("CDVD device: Can change spin speed");
// if(devicecapability & CDC_SELECT_DISC) PrintLog("CDVD device: Can change disks (multi-disk tray)");
// if(devicecapability & CDC_MULTI_SESSION) PrintLog("CDVD device: Can read multi-session disks");
// if(devicecapability & CDC_MCN) PrintLog("CDVD device: Can read Medium Catalog Numbers (maybe)");
if(devicecapability & CDC_MEDIA_CHANGED) PrintLog("CDVD device: Can tell if the disc was changed");
if(devicecapability & CDC_PLAY_AUDIO) PrintLog("CDVD device: Can play audio disks");
// if(devicecapability & CDC_RESET) PrintLog("CDVD device: Can reset the device");
if(devicecapability & CDC_IOCTLS) PrintLog("CDVD device: Odd IOCTLs. Not sure of compatability");
if(devicecapability & CDC_DRIVE_STATUS) PrintLog("CDVD device: Can monitor the drive tray");
#endif /* VERBOSE_DISC_INFO */
////// Should be called after an open (instead of inside of one)
// InitDisc();
// traystatus = CDVD_TRAY_OPEN; // Start with Tray Open
// DeviceTrayStatus(); // Now find out for sure.
return(0); // Device opened and ready for use.
} // END DeviceOpen()
// Called by DeviceTrayStatus(), CDVDclose(), and CDVDshutdown()
void DeviceClose() {
if(devicehandle == -1) {
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: Device already closed");
#endif /* VERBOSE_FUNCTION_DEVICE */
return;
} // ENDIF- Device already closed? Ok.
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceClose()");
#endif /* VERBOSE_FUNCTION_DEVICE */
InitDisc();
close(devicehandle);
devicehandle = -1;
devicecapability = 0;
return;
} // END CDVDclose()
s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer) {
s32 s32result;
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceReadTrack(%i)", lsn);
#endif /* VERBOSE_FUNCTION_DEVICE */
if(DiscInserted() == -1) return(-1);
// Get that data
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
s32result = DVDreadTrack(lsn, mode, buffer);
} else {
s32result = CDreadTrack(lsn, mode, buffer);
} //ENDIF- Read a DVD sector or a CD sector?
return(s32result);
} // END DeviceReadTrack()
s32 DeviceBufferOffset() {
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceBufferOffset()");
#endif /* VERBOSE_FUNCTION_DEVICE */
if(DiscInserted() == -1) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(0);
} else {
return(CDgetBufferOffset());
} // ENDIF- Is this a DVD?
} // END DeviceBufferOffset()
s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd) {
if(DiscInserted() == -1) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(DVDgetTD(track, cdvdtd));
} else {
return(CDgetTD(track, cdvdtd));
} // ENDIF- Is this a DVD?
} // END DeviceGetTD()
// Called by DeviceTrayStatus()
s32 DeviceGetDiskType() {
s32 s32result;
s32 ioctldisktype;
errno = 0;
if(devicehandle == -1) {
return(-1);
} // ENDIF- Someone forget to open the device?
if(traystatus == CDVD_TRAY_OPEN) {
return(disctype);
} // ENDIF- Is the device tray open? No disc to check yet.
if(disctype != CDVD_TYPE_NODISC) {
return(disctype);
} // ENDIF- Already checked? Drive still closed? Disc hasn't changed.
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceGetDiskType()");
#endif /* VERBOSE_FUNCTION_DEVICE */
disctype = CDVD_TYPE_DETCT;
ioctldisktype = ioctl(devicehandle, CDROM_DISC_STATUS);
if(errno != 0) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Trouble reading Disc Type!");
PrintLog("CDVD device: Error: %i:%s", errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
disctype = CDVD_TYPE_UNKNOWN;
return(disctype);
} // ENDIF- Trouble probing for a disc?
s32result = DVDgetDiskType(ioctldisktype);
if(s32result != -1) {
return(disctype);
} // ENDIF- Did we find a disc type?
s32result = CDgetDiskType(ioctldisktype);
if(s32result != -1) {
return(disctype);
} // ENDIF- Did we find a disc type?
disctype = CDVD_TYPE_UNKNOWN; // Not a CD? Not a DVD? Is is peanut butter?
return(disctype);
} // END CDVDgetDiskType()
// Called by PollLoop() and CDVDgetTrayStatus()
s32 DeviceTrayStatus() {
s32 s32result;
errno = 0;
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceTrayStatus()");
#endif /* VERBOSE_FUNCTION_DEVICE */
if(devicehandle == -1) {
return(-1);
} // ENDIF- Someone forget to open the device?
if((devicecapability & CDC_DRIVE_STATUS) != 0) {
s32result = ioctl(devicehandle, CDROM_DRIVE_STATUS);
if(s32result < 0) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Trouble reading Drive Status!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
s32result = CDS_TRAY_OPEN;
} // ENDIF- Failure to get status? Assume it's open.
errno = 0;
} else {
s32result = ioctl(devicehandle, CDROM_DISC_STATUS);
if(errno != 0) {
#ifdef VERBOSE_WARNINGS
PrintLog("CDVD device: Trouble detecting Disc Status presense!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
#endif /* VERBOSE_WARNINGS */
s32result = CDS_TRAY_OPEN;
errno = 0;
} // ENDIF- Trouble?
if(s32result == CDS_NO_DISC) {
s32result = CDS_TRAY_OPEN;
} // ENDIF- Is there no disc in the device? Guess the tray is open
} // ENDIF- Can we poll the tray directly? (Or look at disc status instead?)
if(s32result == CDS_TRAY_OPEN) {
traystatus = CDVD_TRAY_OPEN;
if(disctype != CDVD_TYPE_NODISC) {
DeviceClose(); // Kind of severe way of flushing all buffers.
DeviceOpen();
InitDisc();
} // ENDIF- Tray just opened... clear disc info
} else {
traystatus = CDVD_TRAY_CLOSE;
if(disctype == CDVD_TYPE_NODISC) {
DeviceGetDiskType();
} // ENDIF- Tray just closed? Get disc information
} // ENDIF- Do we detect an open tray?
return(traystatus);
} // END CDVD_getTrayStatus()
s32 DeviceTrayOpen() {
s32 s32result;
errno = 0;
if(devicehandle == -1) {
return(-1);
} // ENDIF- Someone forget to open the device?
if((devicecapability & CDC_OPEN_TRAY) == 0) {
return(-1);
} // ENDIF- Don't have open capability? Error out.
// Tray already open? Exit.
if(traystatus == CDVD_TRAY_OPEN) return(0);
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceTrayOpen()");
#endif /* VERBOSE_FUNCTION_DEVICE */
s32result = ioctl(devicehandle, CDROMEJECT);
#ifdef VERBOSE_WARNINGS
if((s32result != 0) || (errno != 0)) {
PrintLog("CDVD device: Could not open the tray!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
} // ENDIF- Trouble?
#endif /* VERBOSE_WARNINGS */
return(s32result);
} // END DeviceTrayOpen()
s32 DeviceTrayClose() {
s32 s32result;
errno = 0;
if(devicehandle == -1) {
return(-1);
} // ENDIF- Someone forget to open the device?
if((devicecapability & CDC_CLOSE_TRAY) == 0) {
return(-1);
} // ENDIF- Don't have close capability? Error out.
// Tray already closed? Exit.
if(traystatus == CDVD_TRAY_CLOSE) return(0);
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVD device: DeviceTrayClose()");
#endif /* VERBOSE_FUNCTION_DEVICE */
s32result = ioctl(devicehandle, CDROMCLOSETRAY);
#ifdef VERBOSE_WARNINGS
if((s32result != 0) || (errno != 0)) {
PrintLog("CDVD device: Could not close the tray!");
PrintLog("CDVD device: Error: (%i) %i:%s", s32result, errno, strerror(errno));
} // ENDIF- Trouble?
#endif /* VERBOSE_WARNINGS */
return(s32result);
} // END DeviceTrayClose()
+69
View File
@@ -0,0 +1,69 @@
/* 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"
+57
View File
@@ -0,0 +1,57 @@
/* 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"
+90
View File
@@ -0,0 +1,90 @@
/* 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();
+35
View File
@@ -0,0 +1,35 @@
/* 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.
+187
View File
@@ -0,0 +1,187 @@
/* 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()
+41
View File
@@ -0,0 +1,41 @@
/* 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.
*/
+812
View File
@@ -0,0 +1,812 @@
#ifndef __PS2EDEFS_H__
#define __PS2EDEFS_H__
/*
* PS2E Definitions v0.6.2 (beta)
*
* Author: linuzappz@hotmail.com
* shadowpcsx2@yahoo.gr
* florinsasu@hotmail.com
*/
/*
Notes:
* Since this is still beta things may change.
* OSflags:
__LINUX__ (linux OS)
_WIN32 (win32 OS)
* common return values (for ie. GSinit):
0 - success
-1 - error
* reserved keys:
F1 to F10 are reserved for the emulator
* plugins should NOT change the current
working directory.
(on win32, add flag OFN_NOCHANGEDIR for
GetOpenFileName)
*/
#include "PS2Etypes.h"
#ifdef __LINUX__
#define CALLBACK
#else
#include <windows.h>
#endif
/* common defines */
#ifndef C_ASSERT
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
#endif
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
defined(USBdefs) || defined(FWdefs)
#define COMMONdefs
#endif
// PS2EgetLibType returns (may be OR'd)
#define PS2E_LT_GS 0x01
#define PS2E_LT_PAD 0x02 // -=[ OBSOLETE ]=-
#define PS2E_LT_SPU2 0x04
#define PS2E_LT_CDVD 0x08
#define PS2E_LT_DEV9 0x10
#define PS2E_LT_USB 0x20
#define PS2E_LT_FW 0x40
#define PS2E_LT_SIO 0x80
// PS2EgetLibVersion2 (high 16 bits)
#define PS2E_GS_VERSION 0x0006
#define PS2E_PAD_VERSION 0x0002 // -=[ OBSOLETE ]=-
#define PS2E_SPU2_VERSION 0x0005
#define PS2E_CDVD_VERSION 0x0005
#define PS2E_DEV9_VERSION 0x0003
#define PS2E_USB_VERSION 0x0003
#define PS2E_FW_VERSION 0x0002
#define PS2E_SIO_VERSION 0x0001
#ifdef COMMONdefs
u32 CALLBACK PS2EgetLibType(void);
u32 CALLBACK PS2EgetLibVersion2(u32 type);
char* CALLBACK PS2EgetLibName(void);
#endif
// key values:
/* key values must be OS dependant:
win32: the VK_XXX will be used (WinUser)
linux: the XK_XXX will be used (XFree86)
*/
// event values:
#define KEYPRESS 1
#define KEYRELEASE 2
typedef struct {
u32 key;
u32 event;
} keyEvent;
// for 64bit compilers
typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8)?1:-1];
// plugin types
#define SIO_TYPE_PAD 0x00000001
#define SIO_TYPE_MTAP 0x00000004
#define SIO_TYPE_RM 0x00000040
#define SIO_TYPE_MC 0x00000100
typedef int (CALLBACK * SIOchangeSlotCB)(int slot);
typedef struct {
u8 ctrl:4; // control and mode bits
u8 mode:4; // control and mode bits
u8 trackNum; // current track number (1 to 99)
u8 trackIndex; // current index within track (0 to 99)
u8 trackM; // current minute location on the disc (BCD encoded)
u8 trackS; // current sector location on the disc (BCD encoded)
u8 trackF; // current frame location on the disc (BCD encoded)
u8 pad; // unused
u8 discM; // current minute offset from first track (BCD encoded)
u8 discS; // current sector offset from first track (BCD encoded)
u8 discF; // current frame offset from first track (BCD encoded)
} cdvdSubQ;
typedef struct { // NOT bcd coded
u32 lsn;
u8 type;
} cdvdTD;
typedef struct {
u8 strack; //number of the first track (usually 1)
u8 etrack; //number of the last track
} cdvdTN;
// CDVDreadTrack mode values:
#define CDVD_MODE_2352 0 // full 2352 bytes
#define CDVD_MODE_2340 1 // skip sync (12) bytes
#define CDVD_MODE_2328 2 // skip sync+head+sub (24) bytes
#define CDVD_MODE_2048 3 // skip sync+head+sub (24) bytes
#define CDVD_MODE_2368 4 // full 2352 bytes + 16 subq
// CDVDgetDiskType returns:
#define CDVD_TYPE_ILLEGAL 0xff // Illegal Disc
#define CDVD_TYPE_DVDV 0xfe // DVD Video
#define CDVD_TYPE_CDDA 0xfd // Audio CD
#define CDVD_TYPE_PS2DVD 0x14 // PS2 DVD
#define CDVD_TYPE_PS2CDDA 0x13 // PS2 CD (with audio)
#define CDVD_TYPE_PS2CD 0x12 // PS2 CD
#define CDVD_TYPE_PSCDDA 0x11 // PS CD (with audio)
#define CDVD_TYPE_PSCD 0x10 // PS CD
#define CDVD_TYPE_UNKNOWN 0x05 // Unknown
#define CDVD_TYPE_DETCTDVDD 0x04 // Detecting Dvd Dual Sided
#define CDVD_TYPE_DETCTDVDS 0x03 // Detecting Dvd Single Sided
#define CDVD_TYPE_DETCTCD 0x02 // Detecting Cd
#define CDVD_TYPE_DETCT 0x01 // Detecting
#define CDVD_TYPE_NODISC 0x00 // No Disc
// CDVDgetTrayStatus returns:
#define CDVD_TRAY_CLOSE 0x00
#define CDVD_TRAY_OPEN 0x01
// cdvdTD.type (track types for cds)
#define CDVD_AUDIO_TRACK 0x01
#define CDVD_MODE1_TRACK 0x41
#define CDVD_MODE2_TRACK 0x61
#define CDVD_AUDIO_MASK 0x00
#define CDVD_DATA_MASK 0x40
// CDROM_DATA_TRACK 0x04 //do not enable this! (from linux kernel)
typedef void (*DEV9callback)(int cycles);
typedef int (*DEV9handler)(void);
typedef void (*USBcallback)(int cycles);
typedef int (*USBhandler)(void);
// freeze modes:
#define FREEZE_LOAD 0
#define FREEZE_SAVE 1
#define FREEZE_SIZE 2
typedef struct {
char name[8];
void *common;
} GSdriverInfo;
#ifdef _WIN32
typedef struct { // unsupported values must be set to zero
HWND hWnd;
HMENU hMenu;
HWND hStatusWnd;
} winInfo;
#endif
/* GS plugin API */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef GSdefs
// basic funcs
s32 CALLBACK GSinit();
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread);
void CALLBACK GSclose();
void CALLBACK GSshutdown();
void CALLBACK GSvsync(int field);
void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr);
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size);
void CALLBACK GSgifTransfer3(u32 *pMem, u32 size);
void CALLBACK GSgifSoftReset(u32 mask);
void CALLBACK GSreadFIFO(u64 *mem);
void CALLBACK GSreadFIFO2(u64 *mem, int qwc);
// extended funcs
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
void CALLBACK GSkeyEvent(keyEvent *ev);
void CALLBACK GSchangeSaveState(int, const char* filename);
void CALLBACK GSmakeSnapshot(char *path);
void CALLBACK GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg);
void CALLBACK GSirqCallback(void (*callback)());
void CALLBACK GSprintf(int timeout, char *fmt, ...);
void CALLBACK GSsetBaseMem(void*);
void CALLBACK GSsetGameCRC(int);
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
void CALLBACK GSsetFrameSkip(int frameskip);
void CALLBACK GSreset();
void CALLBACK GSwriteCSR(u32 value);
void CALLBACK GSgetDriverInfo(GSdriverInfo *info);
#ifdef _WIN32
s32 CALLBACK GSsetWindowInfo(winInfo *info);
#endif
s32 CALLBACK GSfreeze(int mode, freezeData *data);
void CALLBACK GSconfigure();
void CALLBACK GSabout();
s32 CALLBACK GStest();
#endif
/* PAD plugin API -=[ OBSOLETE ]=- */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef PADdefs
// basic funcs
s32 CALLBACK PADinit(u32 flags);
s32 CALLBACK PADopen(void *pDsp);
void CALLBACK PADclose();
void CALLBACK PADshutdown();
// PADkeyEvent is called every vsync (return NULL if no event)
keyEvent* CALLBACK PADkeyEvent();
u8 CALLBACK PADstartPoll(int pad);
u8 CALLBACK PADpoll(u8 value);
// returns: 1 if supported pad1
// 2 if supported pad2
// 3 if both are supported
u32 CALLBACK PADquery();
// extended funcs
void CALLBACK PADgsDriverInfo(GSdriverInfo *info);
void CALLBACK PADconfigure();
void CALLBACK PADabout();
s32 CALLBACK PADtest();
#endif
/* SIO plugin API */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef SIOdefs
// basic funcs
s32 CALLBACK SIOinit(u32 port, u32 slot, SIOchangeSlotCB f);
s32 CALLBACK SIOopen(void *pDsp);
void CALLBACK SIOclose();
void CALLBACK SIOshutdown();
u8 CALLBACK SIOstartPoll(u8 value);
u8 CALLBACK SIOpoll(u8 value);
// returns: SIO_TYPE_{PAD,MTAP,RM,MC}
u32 CALLBACK SIOquery();
// extended funcs
void CALLBACK SIOconfigure();
void CALLBACK SIOabout();
s32 CALLBACK SIOtest();
#endif
/* SPU2 plugin API */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef SPU2defs
// basic funcs
s32 CALLBACK SPU2init();
s32 CALLBACK SPU2open(void *pDsp);
void CALLBACK SPU2close();
void CALLBACK SPU2shutdown();
void CALLBACK SPU2write(u32 mem, u16 value);
u16 CALLBACK SPU2read(u32 mem);
void CALLBACK SPU2readDMA4Mem(u16 *pMem, int size);
void CALLBACK SPU2writeDMA4Mem(u16 *pMem, int size);
void CALLBACK SPU2interruptDMA4();
void CALLBACK SPU2readDMA7Mem(u16* pMem, int size);
void CALLBACK SPU2writeDMA7Mem(u16 *pMem, int size);
void CALLBACK SPU2interruptDMA7();
u32 CALLBACK SPU2ReadMemAddr(int core);
void CALLBACK SPU2WriteMemAddr(int core,u32 value);
void CALLBACK SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
// extended funcs
void CALLBACK SPU2async(u32 cycles);
s32 CALLBACK SPU2freeze(int mode, freezeData *data);
void CALLBACK SPU2configure();
void CALLBACK SPU2about();
s32 CALLBACK SPU2test();
#endif
/* CDVD plugin API */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef CDVDdefs
// basic funcs
s32 CALLBACK CDVDinit();
s32 CALLBACK CDVDopen(const char* pTitleFilename);
void CALLBACK CDVDclose();
void CALLBACK CDVDshutdown();
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
// return can be NULL (for async modes)
u8* CALLBACK CDVDgetBuffer();
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq);//read subq from disc (only cds have subq data)
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer); //disk information
s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
s32 CALLBACK CDVDgetTOC(void* toc); //gets ps2 style toc from disc
s32 CALLBACK CDVDgetDiskType(); //CDVD_TYPE_xxxx
s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
s32 CALLBACK CDVDctrlTrayOpen(); //open disc tray
s32 CALLBACK CDVDctrlTrayClose(); //close disc tray
// extended funcs
void CALLBACK CDVDconfigure();
void CALLBACK CDVDabout();
s32 CALLBACK CDVDtest();
void CALLBACK CDVDnewDiskCB(void (*callback)());
#endif
/* DEV9 plugin API */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef DEV9defs
// basic funcs
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
s32 CALLBACK DEV9init();
s32 CALLBACK DEV9open(void *pDsp);
void CALLBACK DEV9close();
void CALLBACK DEV9shutdown();
u8 CALLBACK DEV9read8(u32 addr);
u16 CALLBACK DEV9read16(u32 addr);
u32 CALLBACK DEV9read32(u32 addr);
void CALLBACK DEV9write8(u32 addr, u8 value);
void CALLBACK DEV9write16(u32 addr, u16 value);
void CALLBACK DEV9write32(u32 addr, u32 value);
void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size);
void CALLBACK DEV9writeDMA8Mem(u32 *pMem, int size);
// cycles = IOP cycles before calling callback,
// if callback returns 1 the irq is triggered, else not
void CALLBACK DEV9irqCallback(DEV9callback callback);
DEV9handler CALLBACK DEV9irqHandler(void);
// extended funcs
s32 CALLBACK DEV9freeze(int mode, freezeData *data);
void CALLBACK DEV9configure();
void CALLBACK DEV9about();
s32 CALLBACK DEV9test();
#endif
/* USB plugin API */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef USBdefs
// basic funcs
s32 CALLBACK USBinit();
s32 CALLBACK USBopen(void *pDsp);
void CALLBACK USBclose();
void CALLBACK USBshutdown();
u8 CALLBACK USBread8(u32 addr);
u16 CALLBACK USBread16(u32 addr);
u32 CALLBACK USBread32(u32 addr);
void CALLBACK USBwrite8(u32 addr, u8 value);
void CALLBACK USBwrite16(u32 addr, u16 value);
void CALLBACK USBwrite32(u32 addr, u32 value);
// cycles = IOP cycles before calling callback,
// if callback returns 1 the irq is triggered, else not
void CALLBACK USBirqCallback(USBcallback callback);
USBhandler CALLBACK USBirqHandler(void);
void CALLBACK USBsetRAM(void *mem);
// extended funcs
s32 CALLBACK USBfreeze(int mode, freezeData *data);
void CALLBACK USBconfigure();
void CALLBACK USBabout();
s32 CALLBACK USBtest();
#endif
/* FW plugin API */
// if this file is included with this define
// the next api will not be skipped by the compiler
#ifdef FWdefs
// basic funcs
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
s32 CALLBACK FWinit();
s32 CALLBACK FWopen(void *pDsp);
void CALLBACK FWclose();
void CALLBACK FWshutdown();
u32 CALLBACK FWread32(u32 addr);
void CALLBACK FWwrite32(u32 addr, u32 value);
void CALLBACK FWirqCallback(void (*callback)());
// extended funcs
s32 CALLBACK FWfreeze(int mode, freezeData *data);
void CALLBACK FWconfigure();
void CALLBACK FWabout();
s32 CALLBACK FWtest();
#endif
// might be useful for emulators
#ifdef PLUGINtypedefs
typedef u32 (CALLBACK* _PS2EgetLibType)(void);
typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type);
typedef char*(CALLBACK* _PS2EgetLibName)(void);
// GS
// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
typedef s32 (CALLBACK* _GSinit)();
typedef s32 (CALLBACK* _GSopen)(void *pDsp, char *Title, int multithread);
typedef void (CALLBACK* _GSclose)();
typedef void (CALLBACK* _GSshutdown)();
typedef void (CALLBACK* _GSvsync)(int field);
typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem, u32 addr);
typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size);
typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size);
typedef void (CALLBACK* _GSgifSoftReset)(u32 mask);
typedef void (CALLBACK* _GSreadFIFO)(u64 *pMem);
typedef void (CALLBACK* _GSreadFIFO2)(u64 *pMem, int qwc);
typedef void (CALLBACK* _GSkeyEvent)(keyEvent* ev);
typedef void (CALLBACK* _GSchangeSaveState)(int, const char* filename);
typedef void (CALLBACK* _GSirqCallback)(void (*callback)());
typedef void (CALLBACK* _GSprintf)(int timeout, char *fmt, ...);
typedef void (CALLBACK* _GSsetBaseMem)(void*);
typedef void (CALLBACK* _GSsetGameCRC)(int);
typedef void (CALLBACK* _GSsetFrameSkip)(int frameskip);
typedef void (CALLBACK* _GSreset)();
typedef void (CALLBACK* _GSwriteCSR)(u32 value);
typedef void (CALLBACK* _GSgetDriverInfo)(GSdriverInfo *info);
#ifdef _WIN32
typedef s32 (CALLBACK* _GSsetWindowInfo)(winInfo *info);
#endif
typedef void (CALLBACK* _GSmakeSnapshot)(char *path);
typedef void (CALLBACK* _GSmakeSnapshot2)(char *path, int*, int);
typedef s32 (CALLBACK* _GSfreeze)(int mode, freezeData *data);
typedef void (CALLBACK* _GSconfigure)();
typedef s32 (CALLBACK* _GStest)();
typedef void (CALLBACK* _GSabout)();
// PAD
typedef s32 (CALLBACK* _PADinit)(u32 flags);
typedef s32 (CALLBACK* _PADopen)(void *pDsp);
typedef void (CALLBACK* _PADclose)();
typedef void (CALLBACK* _PADshutdown)();
typedef keyEvent* (CALLBACK* _PADkeyEvent)();
typedef u8 (CALLBACK* _PADstartPoll)(int pad);
typedef u8 (CALLBACK* _PADpoll)(u8 value);
typedef u32 (CALLBACK* _PADquery)();
typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
typedef void (CALLBACK* _PADconfigure)();
typedef s32 (CALLBACK* _PADtest)();
typedef void (CALLBACK* _PADabout)();
// SIO
typedef s32 (CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f);
typedef s32 (CALLBACK* _SIOopen)(void *pDsp);
typedef void (CALLBACK* _SIOclose)();
typedef void (CALLBACK* _SIOshutdown)();
typedef u8 (CALLBACK* _SIOstartPoll)(u8 value);
typedef u8 (CALLBACK* _SIOpoll)(u8 value);
typedef u32 (CALLBACK* _SIOquery)();
typedef void (CALLBACK* _SIOconfigure)();
typedef s32 (CALLBACK* _SIOtest)();
typedef void (CALLBACK* _SIOabout)();
// SPU2
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
typedef s32 (CALLBACK* _SPU2init)();
typedef s32 (CALLBACK* _SPU2open)(void *pDsp);
typedef void (CALLBACK* _SPU2close)();
typedef void (CALLBACK* _SPU2shutdown)();
typedef void (CALLBACK* _SPU2write)(u32 mem, u16 value);
typedef u16 (CALLBACK* _SPU2read)(u32 mem);
typedef void (CALLBACK* _SPU2readDMA4Mem)(u16 *pMem, int size);
typedef void (CALLBACK* _SPU2writeDMA4Mem)(u16 *pMem, int size);
typedef void (CALLBACK* _SPU2interruptDMA4)();
typedef void (CALLBACK* _SPU2readDMA7Mem)(u16 *pMem, int size);
typedef void (CALLBACK* _SPU2writeDMA7Mem)(u16 *pMem, int size);
typedef void (CALLBACK* _SPU2interruptDMA7)();
typedef void (CALLBACK* _SPU2irqCallback)(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
typedef u32 (CALLBACK* _SPU2ReadMemAddr)(int core);
typedef void (CALLBACK* _SPU2WriteMemAddr)(int core,u32 value);
typedef void (CALLBACK* _SPU2async)(u32 cycles);
typedef s32 (CALLBACK* _SPU2freeze)(int mode, freezeData *data);
typedef void (CALLBACK* _SPU2configure)();
typedef s32 (CALLBACK* _SPU2test)();
typedef void (CALLBACK* _SPU2about)();
// CDVD
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
typedef s32 (CALLBACK* _CDVDinit)();
typedef s32 (CALLBACK* _CDVDopen)(const char* pTitleFilename);
typedef void (CALLBACK* _CDVDclose)();
typedef void (CALLBACK* _CDVDshutdown)();
typedef s32 (CALLBACK* _CDVDreadTrack)(u32 lsn, int mode);
typedef u8* (CALLBACK* _CDVDgetBuffer)();
typedef s32 (CALLBACK* _CDVDreadSubQ)(u32 lsn, cdvdSubQ* subq);
typedef s32 (CALLBACK* _CDVDgetTN)(cdvdTN *Buffer);
typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer);
typedef s32 (CALLBACK* _CDVDgetTOC)(void* toc);
typedef s32 (CALLBACK* _CDVDgetDiskType)();
typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
typedef s32 (CALLBACK* _CDVDctrlTrayOpen)();
typedef s32 (CALLBACK* _CDVDctrlTrayClose)();
typedef void (CALLBACK* _CDVDconfigure)();
typedef s32 (CALLBACK* _CDVDtest)();
typedef void (CALLBACK* _CDVDabout)();
typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)());
// DEV9
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
typedef s32 (CALLBACK* _DEV9init)();
typedef s32 (CALLBACK* _DEV9open)(void *pDsp);
typedef void (CALLBACK* _DEV9close)();
typedef void (CALLBACK* _DEV9shutdown)();
typedef u8 (CALLBACK* _DEV9read8)(u32 mem);
typedef u16 (CALLBACK* _DEV9read16)(u32 mem);
typedef u32 (CALLBACK* _DEV9read32)(u32 mem);
typedef void (CALLBACK* _DEV9write8)(u32 mem, u8 value);
typedef void (CALLBACK* _DEV9write16)(u32 mem, u16 value);
typedef void (CALLBACK* _DEV9write32)(u32 mem, u32 value);
typedef void (CALLBACK* _DEV9readDMA8Mem)(u32 *pMem, int size);
typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size);
typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback);
typedef DEV9handler (CALLBACK* _DEV9irqHandler)(void);
typedef s32 (CALLBACK* _DEV9freeze)(int mode, freezeData *data);
typedef void (CALLBACK* _DEV9configure)();
typedef s32 (CALLBACK* _DEV9test)();
typedef void (CALLBACK* _DEV9about)();
// USB
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
typedef s32 (CALLBACK* _USBinit)();
typedef s32 (CALLBACK* _USBopen)(void *pDsp);
typedef void (CALLBACK* _USBclose)();
typedef void (CALLBACK* _USBshutdown)();
typedef u8 (CALLBACK* _USBread8)(u32 mem);
typedef u16 (CALLBACK* _USBread16)(u32 mem);
typedef u32 (CALLBACK* _USBread32)(u32 mem);
typedef void (CALLBACK* _USBwrite8)(u32 mem, u8 value);
typedef void (CALLBACK* _USBwrite16)(u32 mem, u16 value);
typedef void (CALLBACK* _USBwrite32)(u32 mem, u32 value);
typedef void (CALLBACK* _USBirqCallback)(USBcallback callback);
typedef USBhandler (CALLBACK* _USBirqHandler)(void);
typedef void (CALLBACK* _USBsetRAM)(void *mem);
typedef s32 (CALLBACK* _USBfreeze)(int mode, freezeData *data);
typedef void (CALLBACK* _USBconfigure)();
typedef s32 (CALLBACK* _USBtest)();
typedef void (CALLBACK* _USBabout)();
//FW
typedef s32 (CALLBACK* _FWinit)();
typedef s32 (CALLBACK* _FWopen)(void *pDsp);
typedef void (CALLBACK* _FWclose)();
typedef void (CALLBACK* _FWshutdown)();
typedef u32 (CALLBACK* _FWread32)(u32 mem);
typedef void (CALLBACK* _FWwrite32)(u32 mem, u32 value);
typedef void (CALLBACK* _FWirqCallback)(void (*callback)());
typedef s32 (CALLBACK* _FWfreeze)(int mode, freezeData *data);
typedef void (CALLBACK* _FWconfigure)();
typedef s32 (CALLBACK* _FWtest)();
typedef void (CALLBACK* _FWabout)();
#endif
#ifdef PLUGINfuncs
// GS
_GSinit GSinit;
_GSopen GSopen;
_GSclose GSclose;
_GSshutdown GSshutdown;
_GSvsync GSvsync;
_GSgifTransfer1 GSgifTransfer1;
_GSgifTransfer2 GSgifTransfer2;
_GSgifTransfer3 GSgifTransfer3;
_GSgifSoftReset GSgifSoftReset;
_GSreadFIFO GSreadFIFO;
_GSreadFIFO2 GSreadFIFO2;
_GSkeyEvent GSkeyEvent;
_GSchangeSaveState GSchangeSaveState;
_GSmakeSnapshot GSmakeSnapshot;
_GSmakeSnapshot2 GSmakeSnapshot2;
_GSirqCallback GSirqCallback;
_GSprintf GSprintf;
_GSsetBaseMem GSsetBaseMem;
_GSsetGameCRC GSsetGameCRC;
_GSsetFrameSkip GSsetFrameSkip;
_GSreset GSreset;
_GSwriteCSR GSwriteCSR;
_GSgetDriverInfo GSgetDriverInfo;
#ifdef _WIN32
_GSsetWindowInfo GSsetWindowInfo;
#endif
_GSfreeze GSfreeze;
_GSconfigure GSconfigure;
_GStest GStest;
_GSabout GSabout;
// PAD1
_PADinit PAD1init;
_PADopen PAD1open;
_PADclose PAD1close;
_PADshutdown PAD1shutdown;
_PADkeyEvent PAD1keyEvent;
_PADstartPoll PAD1startPoll;
_PADpoll PAD1poll;
_PADquery PAD1query;
_PADgsDriverInfo PAD1gsDriverInfo;
_PADconfigure PAD1configure;
_PADtest PAD1test;
_PADabout PAD1about;
// PAD2
_PADinit PAD2init;
_PADopen PAD2open;
_PADclose PAD2close;
_PADshutdown PAD2shutdown;
_PADkeyEvent PAD2keyEvent;
_PADstartPoll PAD2startPoll;
_PADpoll PAD2poll;
_PADquery PAD2query;
_PADgsDriverInfo PAD2gsDriverInfo;
_PADconfigure PAD2configure;
_PADtest PAD2test;
_PADabout PAD2about;
// SIO[2]
_SIOinit SIOinit[2][9];
_SIOopen SIOopen[2][9];
_SIOclose SIOclose[2][9];
_SIOshutdown SIOshutdown[2][9];
_SIOstartPoll SIOstartPoll[2][9];
_SIOpoll SIOpoll[2][9];
_SIOquery SIOquery[2][9];
_SIOconfigure SIOconfigure[2][9];
_SIOtest SIOtest[2][9];
_SIOabout SIOabout[2][9];
// SPU2
_SPU2init SPU2init;
_SPU2open SPU2open;
_SPU2close SPU2close;
_SPU2shutdown SPU2shutdown;
_SPU2write SPU2write;
_SPU2read SPU2read;
_SPU2readDMA4Mem SPU2readDMA4Mem;
_SPU2writeDMA4Mem SPU2writeDMA4Mem;
_SPU2interruptDMA4 SPU2interruptDMA4;
_SPU2readDMA7Mem SPU2readDMA7Mem;
_SPU2writeDMA7Mem SPU2writeDMA7Mem;
_SPU2interruptDMA7 SPU2interruptDMA7;
_SPU2ReadMemAddr SPU2ReadMemAddr;
_SPU2WriteMemAddr SPU2WriteMemAddr;
_SPU2irqCallback SPU2irqCallback;
_SPU2async SPU2async;
_SPU2freeze SPU2freeze;
_SPU2configure SPU2configure;
_SPU2test SPU2test;
_SPU2about SPU2about;
// CDVD
_CDVDinit CDVDinit;
_CDVDopen CDVDopen;
_CDVDclose CDVDclose;
_CDVDshutdown CDVDshutdown;
_CDVDreadTrack CDVDreadTrack;
_CDVDgetBuffer CDVDgetBuffer;
_CDVDreadSubQ CDVDreadSubQ;
_CDVDgetTN CDVDgetTN;
_CDVDgetTD CDVDgetTD;
_CDVDgetTOC CDVDgetTOC;
_CDVDgetDiskType CDVDgetDiskType;
_CDVDgetTrayStatus CDVDgetTrayStatus;
_CDVDctrlTrayOpen CDVDctrlTrayOpen;
_CDVDctrlTrayClose CDVDctrlTrayClose;
_CDVDconfigure CDVDconfigure;
_CDVDtest CDVDtest;
_CDVDabout CDVDabout;
_CDVDnewDiskCB CDVDnewDiskCB;
// DEV9
_DEV9init DEV9init;
_DEV9open DEV9open;
_DEV9close DEV9close;
_DEV9shutdown DEV9shutdown;
_DEV9read8 DEV9read8;
_DEV9read16 DEV9read16;
_DEV9read32 DEV9read32;
_DEV9write8 DEV9write8;
_DEV9write16 DEV9write16;
_DEV9write32 DEV9write32;
_DEV9readDMA8Mem DEV9readDMA8Mem;
_DEV9writeDMA8Mem DEV9writeDMA8Mem;
_DEV9irqCallback DEV9irqCallback;
_DEV9irqHandler DEV9irqHandler;
_DEV9configure DEV9configure;
_DEV9freeze DEV9freeze;
_DEV9test DEV9test;
_DEV9about DEV9about;
// USB
_USBinit USBinit;
_USBopen USBopen;
_USBclose USBclose;
_USBshutdown USBshutdown;
_USBread8 USBread8;
_USBread16 USBread16;
_USBread32 USBread32;
_USBwrite8 USBwrite8;
_USBwrite16 USBwrite16;
_USBwrite32 USBwrite32;
_USBirqCallback USBirqCallback;
_USBirqHandler USBirqHandler;
_USBsetRAM USBsetRAM;
_USBconfigure USBconfigure;
_USBfreeze USBfreeze;
_USBtest USBtest;
_USBabout USBabout;
// FW
_FWinit FWinit;
_FWopen FWopen;
_FWclose FWclose;
_FWshutdown FWshutdown;
_FWread32 FWread32;
_FWwrite32 FWwrite32;
_FWirqCallback FWirqCallback;
_FWconfigure FWconfigure;
_FWfreeze FWfreeze;
_FWtest FWtest;
_FWabout FWabout;
#endif
#endif /* __PS2EDEFS_H__ */
+43
View File
@@ -0,0 +1,43 @@
#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
+387
View File
@@ -0,0 +1,387 @@
/* 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
+44
View File
@@ -0,0 +1,44 @@
/* 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
+434
View File
@@ -0,0 +1,434 @@
/* 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]);
+40
View File
@@ -0,0 +1,40 @@
/* 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.
*/
+398
View File
@@ -0,0 +1,398 @@
/* 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");
+37
View File
@@ -0,0 +1,37 @@
/* 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.
*/
@@ -0,0 +1,43 @@
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) ..\\..
+253
View File
@@ -0,0 +1,253 @@
/* 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 */
+52
View File
@@ -0,0 +1,52 @@
/* 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>
+175
View File
@@ -0,0 +1,175 @@
/* 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
+49
View File
@@ -0,0 +1,49 @@
/* 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
+583
View File
@@ -0,0 +1,583 @@
/* device.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..., IOCTL_STORAGE...
#include <ddk/ntdddisk.h> // IOCTL_DISK...
#include <stdio.h> // sprintf()
#include <time.h> // time_t
#define CDVDdefs
#include "PS2Edefs.h"
#include "logfile.h"
#include "conf.h"
#include "CD.h"
#include "DVD.h"
#include "device.h"
HANDLE devicehandle;
OVERLAPPED waitevent;
time_t lasttime;
s32 traystatus;
int traystatusmethod;
s32 disctype;
char tocbuffer[2048];
void DeviceInit() {
devicehandle = NULL;
waitevent.hEvent = NULL;
waitevent.Internal = 0;
waitevent.InternalHigh = 0;
waitevent.Offset = 0;
waitevent.OffsetHigh = 0;
lasttime = 0;
InitDisc();
} // END DeviceInit()
void InitDisc() {
int i;
InitCDInfo();
InitDVDInfo();
traystatus = CDVD_TRAY_OPEN;
traystatusmethod = 0; // Poll all until one works
disctype = CDVD_TYPE_NODISC;
for(i = 0; i < 2048; i++) tocbuffer[i] = 0;
} // END InitDisc()
s32 DiscInserted() {
if(traystatus != CDVD_TRAY_CLOSE) return(-1);
if(disctype == CDVD_TYPE_ILLEGAL) return(-1);
// if(disctype == CDVD_TYPE_UNKNOWN) return(-1); // Hmm. Let this one through?
if(disctype == CDVD_TYPE_DETCTDVDD) return(-1);
if(disctype == CDVD_TYPE_DETCTDVDS) return(-1);
if(disctype == CDVD_TYPE_DETCTCD) return(-1);
if(disctype == CDVD_TYPE_DETCT) return(-1);
if(disctype == CDVD_TYPE_NODISC) return(-1);
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDlinuz device: DiscInserted()");
#endif /* VERBOSE_FUNCTION_DEVICE */
return(0);
} // END DiscInserted()
// Returns errcode (or 0 if successful)
DWORD FinishCommand(BOOL boolresult) {
DWORD errcode;
DWORD waitcode;
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDlinuz device: FinishCommand()");
#endif /* VERBOSE_FUNCTION_DEVICE */
if(boolresult == TRUE) {
ResetEvent(waitevent.hEvent);
return(0);
} // ENDIF- Device is ready? Say so.
errcode = GetLastError();
if(errcode == ERROR_IO_PENDING) {
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDlinuz device: Waiting for completion.");
#endif /* VERBOSE_FUNCTION_DEVICE */
waitcode = WaitForSingleObject(waitevent.hEvent, 10 * 1000); // 10 sec wait
if((waitcode == WAIT_FAILED) || (waitcode == WAIT_ABANDONED)) {
errcode = GetLastError();
} else if(waitcode == WAIT_TIMEOUT) {
errcode = 21;
CancelIo(devicehandle); // Speculative Line
} else {
ResetEvent(waitevent.hEvent);
return(0); // Success!
} // ENDIF- Trouble waiting? (Or doesn't finish in 5 seconds?)
} // ENDIF- Should we wait for the call to finish?
ResetEvent(waitevent.hEvent);
return(errcode);
} // END DeviceCommand()
s32 DeviceOpen() {
char tempname[256];
UINT drivetype;
DWORD errcode;
if(conf.devicename[0] == 0) return(-1);
if(devicehandle != NULL) return(0);
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDlinuz device: DeviceOpen()");
#endif /* VERBOSE_FUNCTION_DEVICE */
// InitConf();
// LoadConf(); // Should be done at least once before this call
// Root Directory reference
if(conf.devicename[1] == 0) {
sprintf(tempname, "%s:\\", conf.devicename);
} else if((conf.devicename[1] == ':') && (conf.devicename[2] == 0)) {
sprintf(tempname, "%s\\", conf.devicename);
} else {
sprintf(tempname, "%s", conf.devicename);
} // ENDIF- Not a single drive letter? (or a letter/colon?) Copy the name in.
drivetype = GetDriveType(tempname);
if(drivetype != DRIVE_CDROM) {
#ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDlinuz device: Not a CD-ROM!");
PrintLog("CDVDlinuz device: (Came back: %u)", drivetype);
errcode = GetLastError();
if(errcode > 0) PrintError("CDVDlinuz device", errcode);
#endif /* VERBOSE_WARNING_DEVICE */
return(-1);
} // ENDIF- Not a CD-ROM? Say so!
// Hmm. Do we want to include DRIVE_REMOVABLE... just in case?
// Device Reference
if(conf.devicename[1] == 0) {
sprintf(tempname, "\\\\.\\%s:", conf.devicename);
} else if((conf.devicename[1] == ':') && (conf.devicename[2] == 0)) {
sprintf(tempname, "\\\\.\\%s", conf.devicename);
} else {
sprintf(tempname, "%s", conf.devicename);
} // ENDIF- Not a single drive letter? (or a letter/colon?) Copy the name in.
devicehandle = CreateFile(tempname,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if(devicehandle == INVALID_HANDLE_VALUE) {
#ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDlinuz device: Couldn't open device read-only! Read-Write perhaps?");
errcode = GetLastError();
PrintError("CDVDlinuz device", errcode);
#endif /* VERBOSE_WARNING_DEVICE */
devicehandle = CreateFile(tempname,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
} // ENDIF- Couldn't open for read? Try read/write (for those drives that insist)
if(devicehandle == INVALID_HANDLE_VALUE) {
#ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDlinuz device: Couldn't open device!");
errcode = GetLastError();
PrintError("CDVDlinuz device", errcode);
#endif /* VERBOSE_WARNING_DEVICE */
devicehandle = NULL;
return(-1);
} // ENDIF- Couldn't open that way either? Abort.
waitevent.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if(waitevent.hEvent == INVALID_HANDLE_VALUE) {
#ifdef VERBOSE_WARNING_DEVICE
PrintLog("CDVDlinuz device: Couldn't open event handler!");
errcode = GetLastError();
PrintError("CDVDlinuz device", errcode);
#endif /* VERBOSE_WARNING_DEVICE */
waitevent.hEvent = NULL;
CloseHandle(devicehandle);
devicehandle = NULL;
} // ENDIF- Couldn't create an "Wait for I/O" handle? Abort.
// More here... DeviceIoControl? for Drive Capabilities
// DEVICE_CAPABILITIES?
////// Should be done just after the first DeviceOpen();
// InitDisc(); // ?
// DeviceTrayStatus();
return(0);
} // END DeviceOpen()
void DeviceClose() {
if(devicehandle == NULL) return;
if(devicehandle == INVALID_HANDLE_VALUE) {
devicehandle = NULL;
return;
} // ENDIF- Bad value? Just clear the value.
#ifdef VERBOSE_FUNCTION_DEVICE
PrintLog("CDVDlinuz device: DeviceClose()");
#endif /* VERBOSE_FUNCTION_DEVICE */
if(waitevent.hEvent != NULL) {
if(waitevent.hEvent != INVALID_HANDLE_VALUE) {
CancelIo(devicehandle);
CloseHandle(waitevent.hEvent);
} // ENDIF- Is this handle actually open?
waitevent.hEvent = NULL;
waitevent.Offset = 0;
waitevent.OffsetHigh = 0;
} // ENDIF- Reset the event handle?
CloseHandle(devicehandle);
devicehandle = NULL;
return;
} // END DeviceClose()
s32 DeviceReadTrack(u32 lsn, int mode, u8 *buffer) {
if(DiscInserted() == -1) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(DVDreadTrack(lsn, mode, buffer));
} else {
return(CDreadTrack(lsn, mode, buffer));
} // ENDIF- Is this a DVD?
} // END DeviceReadTrack()
s32 DeviceBufferOffset() {
if(DiscInserted() == -1) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(0);
} else {
return(CDgetBufferOffset());
} // ENDIF- Is this a DVD?
return(-1);
} // END DeviceBufferOffset()
s32 DeviceGetTD(u8 track, cdvdTD *cdvdtd) {
if(DiscInserted() == -1) return(-1);
if((disctype == CDVD_TYPE_PS2DVD) || (disctype == CDVD_TYPE_DVDV)) {
return(DVDgetTD(track, cdvdtd));
} else {
return(CDgetTD(track, cdvdtd));
} // ENDIF- Is this a DVD?
return(-1);
} // END DeviceGetTD()
+64
View File
@@ -0,0 +1,64 @@
/* 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"
+119
View File
@@ -0,0 +1,119 @@
/* 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) {
+39
View File
@@ -0,0 +1,39 @@
/* 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.
*/
+173
View File
@@ -0,0 +1,173 @@
/* 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);
+42
View File
@@ -0,0 +1,42 @@
/* 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.
*/
+1
View File
@@ -0,0 +1 @@
mingw32-make -f Makefile.MinGW32 %1
+21
View File
@@ -0,0 +1,21 @@
EXPORTS
PS2EgetLibType = PS2EgetLibType@0 @2
PS2EgetLibName = PS2EgetLibName@0 @3
PS2EgetLibVersion2 = PS2EgetLibVersion2@4 @4
CDVDinit = CDVDinit@0 @5
CDVDshutdown = CDVDshutdown@0 @6
CDVDopen = CDVDopen@0 @7
CDVDclose = CDVDclose@0 @8
CDVDreadTrack = CDVDreadTrack@8 @9
CDVDgetBuffer = CDVDgetBuffer@0 @10
CDVDreadSubQ = CDVDreadSubQ@8 @11
+9
View File
@@ -0,0 +1,9 @@
/* Weditres generated include file. Do NOT edit */
#include <windows.h>
#define DLG_0100 100
#define IDC_0104 104
#define DLG_0200 200
+29
View File
@@ -0,0 +1,29 @@
/* Wedit generated resource file */
#ifdef __LCC__
#include <windows.h>
#endif
#include "screens.h"
DLG_0100 DIALOG 2, 2, 140, 59
STYLE DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "About CDVDlinuz"
FONT 8, "MS Sans Serif"
BEGIN
CTEXT "EFP polling CDVD Driver v0.4", 101, 11, 6, 118, 12
CTEXT "Current Author: efp", 102, 12, 16, 118, 12
CTEXT "Original code by: linuzappz && shadow", 103, 12, 26, 118, 12
+525
View File
@@ -0,0 +1,525 @@
/* buffer.c
* 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
*/
#include <errno.h> // errno
#include <stddef.h> // NULL
#include <stdio.h> // printf()
#include <string.h> // strerror()
#ifndef __LINUX__
#ifdef __linux__
#define __LINUX__
#endif /* __linux__ */
#endif /* No __LINUX__ */
#define CDVDdefs
#include "PS2Edefs.h"
#include "logfile.h"
#include "buffer.h"
// Globals
struct BufferSortEmpty {
u16 sortptr;
};
struct BufferSort {
u16 upptr;
u16 uppos;
u32 mask;
u32 divisor;
struct {
u8 isdata;
u16 ptr;
} lower[256];
u16 ptrcount;
u16 firstptr;
};
struct BufferSortEmpty buffersortempty[BUFFERMAX];
u16 buffersortemptystart;
u16 buffersortemptyend;
struct BufferSort buffersort[BUFFERMAX];
u8 buffersortstartisdata;
u16 buffersortstart;
struct BufferList bufferlist[BUFFERMAX];
u16 userbuffer;
u16 replacebuffer;
void InitBuffer() {
u16 i;
u16 j;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: InitBuffer()");
#endif /* VERBOSE_FUNCTION_BUFFER */
buffersortemptystart = 0;
buffersortemptyend = 0;
for(i = 0; i < BUFFERMAX; i++) {
buffersortempty[i].sortptr = i;
} // NEXT i- Saying all buffersort[] entries are open.
buffersortstart = 0xffff;
buffersortstartisdata = 2;
for(i = 0; i < BUFFERMAX; i++) {
for(j = 0; j < 256; j++) buffersort[i].lower[j].isdata = 2;
// buffersort[i].ptrcount = 0;
} // NEXT i- Saying all buffersort[] entries are open.
for(i = 0; i < BUFFERMAX; i++) {
bufferlist[i].upsort = 0xffff;
} // NEXT i- Clearing out the buffer pointers
userbuffer = 0xffff;
replacebuffer = BUFFERMAX - 1;
} // END InitBuffer();
u16 AllocSortBuffer() {
u16 newbuffer;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: AllocSortBuffer()");
#endif /* VERBOSE_FUNCTION_BUFFER */
newbuffer = buffersortempty[buffersortemptyend].sortptr;
buffersortempty[buffersortemptyend].sortptr = BUFFERMAX;
buffersortemptyend++;
if(buffersortemptyend > BUFFERMAX - 1) buffersortemptyend = 0;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: Sort Buffer %u", newbuffer);
#endif /* VERBOSE_FUNCTION_BUFFER */
#ifdef VERBOSE_WARNINGS_BUFFER
if(buffersortemptyend == buffersortemptystart) {
PrintLog("Completely out of Sort Buffers to allocate now!");
} // ENDIF- Out of Sort Buffers? Say so!
#endif /* VERBOSE_WARNINGS_BUFFER */
return(newbuffer);
} // END AllocSortBuffer()
void ReleaseSortBuffer(u16 oldbuffer) {
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: ReleaseSortBuffer(%u)", oldbuffer);
#endif /* VERBOSE_FUNCTION_BUFFER */
buffersortempty[buffersortemptystart].sortptr = oldbuffer;
buffersortemptystart++;
if(buffersortemptystart > BUFFERMAX - 1) buffersortemptystart = 0;
} // END ReleaseSortBuffer()
// Returns either index in buffersort... or closest insertion point.
// Make lsn == buffersort[int].lsn test for exact match
u16 FindListBuffer(u32 lsn) {
u16 current;
u8 isdata;
u32 index;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: FindListBuffer(%u)", lsn);
#endif /* VERBOSE_FUNCTION_BUFFER */
if(buffersortstart == 0xffff) return(0xffff); // Buffer empty? Exit
if(buffersortstartisdata == 1) {
if(bufferlist[buffersortstart].lsn != lsn) return(0xffff);
return(buffersortstart);
} // ENDIF- Only one Record in Buffer?
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: Searching...");
#endif /* VERBOSE_FUNCTION_BUFFER */
current = buffersortstart;
isdata = 0;
while(isdata == 0) {
index = lsn;
index &= buffersort[current].mask;
index /= buffersort[current].divisor;
isdata = buffersort[current].lower[index].isdata;
current = buffersort[current].lower[index].ptr;
} // ENDWHILE- still haven't found data
if(isdata == 2) return(0xffff); // Pointing at empty entry?
if(bufferlist[current].lsn != lsn) return(0xffff); // LSNs don't match?
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: Found.");
#endif /* VERBOSE_FUNCTION_BUFFER */
return(current);
} // END FindListBuffer()
// Removes buffer from the buffersort list
// bufnum = The bufferlist pointer
void RemoveListBuffer(u16 bufnum) {
u16 current;
u16 currentpos;
u16 upperlink;
u16 upperindex;
u16 lowerlink;
u8 lowerisdata;
u32 index;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: RemoveListBuffer(%u)", bufnum);
#endif /* VERBOSE_FUNCTION_BUFFER */
if(bufferlist[bufnum].upsort == 0xffff) return; // No link to break.
current = bufferlist[bufnum].upsort;
currentpos = bufferlist[bufnum].uppos;
bufferlist[bufnum].upsort = 0xffff;
if(current == 0xfffe) {
buffersortstart = 0xffff;
buffersortstartisdata = 2;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: Buffer emptied");
#endif /* VERBOSE_FUNCTION_BUFFER */
return;
} // ENDIF- Last link broken... empty buffer now.
lowerlink = 0xffff;
lowerisdata = 2;
// Remove Lower Pointer
buffersort[current].lower[currentpos].isdata = 2;
if(currentpos == buffersort[current].firstptr) {
index = currentpos + 1;
while((index < 256) && (buffersort[current].lower[index].isdata == 2)) index++;
buffersort[current].firstptr = index;
} // ENDIF- Do we need to move firstptr to an active entry?
buffersort[current].ptrcount--;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: Pointer count for sort buffer %u: %u",
current, buffersort[current].ptrcount);
#endif /* VERBOSE_FUNCTION_BUFFER */
if(buffersort[current].ptrcount > 1) return; // Still 2+ branches left
// Find Lower Link
index = buffersort[current].firstptr;
lowerlink = buffersort[current].lower[index].ptr;
lowerisdata = buffersort[current].lower[index].isdata;
buffersort[current].lower[index].isdata = 2;
// Find and Break Upper Link
upperlink = buffersort[current].upptr;
upperindex = buffersort[current].uppos;
if(upperlink == 0xffff) {
buffersortstart = lowerlink;
buffersortstartisdata = lowerisdata;
} else {
buffersort[upperlink].lower[upperindex].ptr = lowerlink;
buffersort[upperlink].lower[upperindex].isdata = lowerisdata;
} // ENDIF- Did we hit the top of the web?
// Break Lower Link
if(lowerisdata == 1) {
if(upperlink == 0xffff) {
bufferlist[lowerlink].upsort = 0xfffe;
#ifdef VERBOSE_FUNCTION_BUFFER
PrintLog("CDVD buffer: Buffer down to 1 record now");
#endif /* VERBOSE_FUNCTION_BUFFER */
} else {
bufferlist[lowerlink].upsort = upperlink;
bufferlist[lowerlink].uppos = upperindex;
} // ENDIF- Is this the last active buffersort?
} else {
buffersort[lowerlink].upptr = upperlink;
buffersort[lowerlink].uppos = upperindex;
} // ENDIF- Was this a BufferList link?
+67
View File
@@ -0,0 +1,67 @@
/* 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
+118
View File
@@ -0,0 +1,118 @@
/* 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);
+50
View File
@@ -0,0 +1,50 @@
/* 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
+689
View File
@@ -0,0 +1,689 @@
/* ini.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 "logfile.h"
#include "actualfile.h"
#include "ini.h"
const char INIext[] = ".ini";
const char INInewext[] = ".new";
// Returns: position where new extensions should be added.
int INIRemoveExt(char *argname, char *tempname) {
int i;
int j;
int k;
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: RemoveExt(%s)", argname);
#endif /* VERBOSE_FUNCTION_INI */
i = 0;
while((i <= INIMAXLEN) && (*(argname + i) != 0)) {
*(tempname + i) = *(argname + i);
i++;
} // ENDWHILE- Copying the argument name into a temporary area;
*(tempname + i) = 0; // And 0-terminate
k = i;
k--;
j = 0;
while((j <= INIMAXLEN) && (INIext[j] != 0)) j++;
j--;
while((j >= 0) && (*(tempname + k) == INIext[j])) {
k--;
j--;
} // ENDWHILE- Comparing the ending characters to the INI ext.
if(j < 0) {
k++;
i = k;
*(tempname + i) = 0; // 0-terminate, cutting off ".ini"
} // ENDIF- Do we have a match? Then remove the end chars.
return(i);
} // END INIRemoveExt()
void INIAddInExt(char *tempname, int temppos) {
int i;
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: AddInExt(%s, %i)", tempname, temppos);
#endif /* VERBOSE_FUNCTION_INI */
i = 0;
while((i + temppos < INIMAXLEN) && (INIext[i] != 0)) {
*(tempname + temppos + i) = INIext[i];
i++;
} // ENDWHILE- Attaching extenstion to filename
*(tempname + temppos + i) = 0; // And 0-terminate
} // END INIAddInExt()
void INIAddOutExt(char *tempname, int temppos) {
int i;
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: AddOutExt(%s, %i)", tempname, temppos);
#endif /* VERBOSE_FUNCTION_INI */
i = 0;
while((i + temppos < INIMAXLEN) && (INInewext[i] != 0)) {
*(tempname + temppos + i) = INInewext[i];
i++;
} // ENDWHILE- Attaching extenstion to filename
*(tempname + temppos + i) = 0; // And 0-terminate
} // END INIAddInExt()
// Returns number of bytes read to get line (0 means end-of-file)
int INIReadLine(ACTUALHANDLE infile, char *buffer) {
int charcount;
int i;
char tempin[2];
int retflag;
int retval;
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: ReadLine()");
#endif /* VERBOSE_FUNCTION_INI */
charcount = 0;
i = 0;
tempin[1] = 0;
retflag = 0;
while((i < INIMAXLEN) && (retflag < 2)) {
retval = ActualFileRead(infile, 1, tempin);
charcount++;
if(retval != 1) {
retflag = 2;
charcount--;
} else if(tempin[0] == '\n') {
retflag = 2;
} else if(tempin[0] >= ' ') {
*(buffer + i) = tempin[0];
i++;
} // ENDLONGIF- How do we react to the next character?
} // ENDWHILE- Loading up on characters until an End-of-Line appears
*(buffer + i) = 0; // And 0-terminate
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: Line: %s", buffer);
#endif /* VERBOSE_FUNCTION_INI */
return(charcount);
} // END INIReadLine()
// Note: Do we need to back-skip a char if something other \n follows \r?
// Returns: number of bytes to get to start of section (or -1)
int INIFindSection(ACTUALHANDLE infile, char *section) {
int charcount;
int i;
int retflag;
int retval;
char scanbuffer[INIMAXLEN+1];
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: FindSection(%s)", section);
#endif /* VERBOSE_FUNCTION_INI */
charcount = 0;
retflag = 0;
while(retflag == 0) {
retval = INIReadLine(infile, scanbuffer);
if(retval == 0) return(-1); // EOF? Stop here.
if(scanbuffer[0] == '[') {
i = 0;
while((i < INIMAXLEN) &&
(*(section + i) != 0) &&
(*(section + i) == scanbuffer[i + 1])) i++;
if((i < INIMAXLEN - 2) && (*(section + i) == 0)) {
if((scanbuffer[i + 1] == ']') && (scanbuffer[i + 2] == 0)) {
retflag = 1;
} // ENDIF- End marks look good? Return successful.
} // ENDIF- Do we have a section match?
} // ENDIF- Does this look like a section header?
if(retflag == 0) charcount += retval;
} // ENDWHILE- Scanning lines for the correct [Section] header.
return(charcount);
} // END INIFindSection()
// Returns: number of bytes to get to start of keyword (or -1)
int INIFindKeyword(ACTUALHANDLE infile, char *keyword, char *buffer) {
int charcount;
int i;
int j;
int retflag;
int retval;
char scanbuffer[INIMAXLEN+1];
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: FindKeyword(%s)", keyword);
#endif /* VERBOSE_FUNCTION_INI */
charcount = 0;
retflag = 0;
while(retflag == 0) {
retval = INIReadLine(infile, scanbuffer);
if(retval == 0) return(-1); // EOF? Stop here.
if(scanbuffer[0] == '[') return(-1); // New section? Stop here.
i = 0;
while((i < INIMAXLEN) &&
(*(keyword + i) != 0) &&
(*(keyword + i) == scanbuffer[i])) i++;
if((i < INIMAXLEN - 2) && (*(keyword + i) == 0)) {
if(scanbuffer[i] == '=') {
retflag = 1;
if(buffer != NULL) {
i++;
j = 0;
while((i < INIMAXLEN) && (scanbuffer[i] != 0)) {
*(buffer + j) = scanbuffer[i];
i++;
j++;
} // ENDWHILE- Copying the value out to the outbound buffer.
*(buffer + j) = 0; // And 0-terminate.
} // ENDIF- Return the value as well?
} // ENDIF- End marks look good? Return successful.
} // ENDIF- Do we have a section match?
if(retflag == 0) charcount += retval;
} // ENDWHILE- Scanning lines for the correct [Section] header.
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: Value: %s", buffer);
#endif /* VERBOSE_FUNCTION_INI */
return(charcount);
} // END INIFindKeyWord()
// Returns: number of bytes left to write... (from charcount back)
int INICopy(ACTUALHANDLE infile, ACTUALHANDLE outfile, int charcount) {
char buffer[4096];
int i;
int chunk;
int retval;
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: Copy(%i)", charcount);
#endif /* VERBOSE_FUNCTION_INI */
i = charcount;
chunk = 4096;
if(i < chunk) chunk = i;
while(chunk > 0) {
retval = ActualFileRead(infile, chunk, buffer);
if(retval <= 0) return(i); // Trouble? Stop here.
if(retval < chunk) chunk = retval; // Short block? Note it.
retval = ActualFileWrite(outfile, chunk, buffer);
if(retval <= 0) return(i); // Trouble? Stop here.
i -= retval;
if(retval < chunk) return(i); // Short block written? Stop here.
chunk = 4096;
if(i < chunk) chunk = i;
} // ENDWHILE- Copying a section of file across, one chunk at a time.
return(0);
} // END INICopyToPos()
int INISaveString(char *file, char *section, char *keyword, char *value) {
char inname[INIMAXLEN+1];
char outname[INIMAXLEN+1];
int filepos;
ACTUALHANDLE infile;
ACTUALHANDLE outfile;
int i;
int retval;
char templine[INIMAXLEN+1];
if(file == NULL) return(-1);
if(section == NULL) return(-1);
if(keyword == NULL) return(-1);
if(value == NULL) return(-1);
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: SaveString(%s, %s, %s, %s)",
file, section, keyword, value);
#endif /* VERBOSE_FUNCTION_INI */
filepos = INIRemoveExt(file, inname);
for(i = 0; i <= filepos; i++) outname[i] = inname[i];
INIAddInExt(inname, filepos);
INIAddOutExt(outname, filepos);
filepos = 0;
infile = ActualFileOpenForRead(inname);
if(infile == ACTUALHANDLENULL) {
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: creating new file");
#endif /* VERBOSE_FUNCTION_INI */
outfile = ActualFileOpenForWrite(inname);
if(outfile == ACTUALHANDLENULL) return(-1); // Just a bad name? Abort.
sprintf(templine, "[%s]\r\n", section);
i = 0;
while((i < INIMAXLEN) && (templine[i] != 0)) i++;
retval = ActualFileWrite(outfile, i, templine);
if(retval < i) {
ActualFileClose(outfile);
outfile = ACTUALHANDLENULL;
ActualFileDelete(inname);
return(-1);
} // ENDIF- Trouble writing it out? Abort.
sprintf(templine, "%s=%s\r\n", keyword, value);
i = 0;
while((i < INIMAXLEN) && (templine[i] != 0)) i++;
retval = ActualFileWrite(outfile, i, templine);
ActualFileClose(outfile);
outfile = ACTUALHANDLENULL;
if(retval < i) {
ActualFileDelete(inname);
return(-1);
} // ENDIF- Trouble writing it out? Abort.
return(0);
} // ENDIF- No input file? Create a brand new .ini file then.
retval = INIFindSection(infile, section);
if(retval < 0) {
#ifdef VERBOSE_FUNCTION_INI
PrintLog("CDVDiso ini: creating new section");
#endif /* VERBOSE_FUNCTION_INI */
outfile = ActualFileOpenForWrite(outname);
if(outfile == ACTUALHANDLENULL) {
ActualFileClose(infile);
infile = ACTUALHANDLENULL;
return(-1);
} // ENDIF- Couldn't open a temp file? Abort
ActualFileSeek(infile, 0); // Move ini to beginning of file...
INICopy(infile, outfile, 0x0FFFFFFF); // Copy the whole file out...
sprintf(templine, "\r\n[%s]\r\n", section);
i = 0;
while((i < INIMAXLEN) && (templine[i] != 0)) i++;
retval = ActualFileWrite(outfile, i, templine);
if(retval < i) {
+64
View File
@@ -0,0 +1,64 @@
/* 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
+36
View File
@@ -0,0 +1,36 @@
/* 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.
+43
View File
@@ -0,0 +1,43 @@
/* 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
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
curdir=`pwd`
echo ------------------
echo Building CDVDlinuz
echo ------------------
cd ${curdir}/Src/Linux
make $@
if [ -s cfgCDVDlinuz ] && [ -s libCDVDlinuz.so ]
then
# copy the files
cp cfgCDVDlinuz libCDVDlinuz.so ${PCSX2PLUGINS}
fi
+37
View File
@@ -0,0 +1,37 @@
CDVDlinuz v0.4
--------------
This is an extension to use with play station2 emulators
as PCSX2 (only one right now).
The plugin is free open source code.
Modified by efp to work with DVDs as well
To install in Windows:
-----
Place the file "CDVDlinuz.dll" in the "plugins" directory.
To install in Linux:
-----
Place the file "libCDVDlinuz.so" in the "plugins/" directory.
Place the file "cfgCDVDlinuz" in the "cfg/" directory.
To activate in PCSX2: