Implemented WIP code to run a ISO image from within pcsx2, ignoring the currently selected cdvd plugin.

I tried it and it seems to work, but I can't assure it's bugfree.
Next step is to implement internal blockdump creation and loading, and fix any problems ppl might have with this.
(And sorry for breaking linux on every commit I do. :P)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1496 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gigaherz 2009-07-12 17:17:57 +00:00
parent aa438a6b73
commit 43f8746906
14 changed files with 584 additions and 126 deletions

View File

@ -185,6 +185,8 @@ public:
u32 sseVUMXCSR;
u32 eeOptions;
u32 vuOptions;
int Blockdump;
};
extern PcsxConfig Config;

View File

@ -24,6 +24,7 @@
#include "IopCommon.h"
#include "IsoFStools.h"
#include "CDVD_internal.h"
#include "CDVDisoReader.h"
static cdvdStruct cdvd;
@ -400,28 +401,28 @@ void cdvdReadKey(u8 arg0, u16 arg1, u32 arg2, u8* key) {
s32 cdvdGetToc(void* toc)
{
s32 ret = CDVDgetTOC(toc);
s32 ret = DoCDVDgetTOC(toc);
if (ret == -1) ret = 0x80;
return ret;
}
s32 cdvdReadSubQ(s32 lsn, cdvdSubQ* subq)
{
s32 ret = CDVDreadSubQ(lsn, subq);
s32 ret = DoCDVDreadSubQ(lsn, subq);
if (ret == -1) ret = 0x80;
return ret;
}
s32 cdvdCtrlTrayOpen()
{
s32 ret = CDVDctrlTrayOpen();
s32 ret = DoCDVDctrlTrayOpen();
if (ret == -1) ret = 0x80;
return ret;
}
s32 cdvdCtrlTrayClose()
{
s32 ret = CDVDctrlTrayClose();
s32 ret = DoCDVDctrlTrayClose();
if (ret == -1) ret = 0x80;
return ret;
}
@ -430,7 +431,7 @@ s32 cdvdCtrlTrayClose()
// checks if tray was opened since last call to this func
s32 cdvdGetTrayStatus()
{
s32 ret = CDVDgetTrayStatus();
s32 ret = DoCDVDgetTrayStatus();
if (ret == -1)
return(CDVD_TRAY_CLOSE);
@ -444,29 +445,7 @@ s32 cdvdGetTrayStatus()
// Modified by (efp) - 16/01/2006
static __forceinline void cdvdGetDiskType()
{
// defs 0.9.0
if (CDVDnewDiskCB || (cdvd.Type != CDVD_TYPE_NODISC)) return;
// defs.0.8.1
if (cdvdGetTrayStatus() == CDVD_TRAY_OPEN)
{
cdvd.Type = CDVD_TYPE_NODISC;
return;
}
cdvd.Type = CDVDgetDiskType();
// Is the type listed as a PS2 CD?
if (cdvd.Type == CDVD_TYPE_PS2CD) // && needReset == 1)
{
char str[g_MaxPath];
if (GetPS2ElfName(str) == 1)
{
// Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then.
cdvd.Type = CDVD_TYPE_PSCD;
}
}
cdvd.Type = DoCDVDdetectDiskType();
}
// check whether disc is single or dual layer
@ -559,14 +538,16 @@ void SaveState::cdvdFreeze()
// seek is in progress!)
if( cdvd.Reading )
cdvd.RErr = CDVDreadTrack( cdvd.Readed ? cdvd.Sector : cdvd.SeekToSector, cdvd.ReadMode);
cdvd.RErr = DoCDVDreadTrack( cdvd.Readed ? cdvd.Sector : cdvd.SeekToSector, cdvd.ReadMode);
}
}
// Modified by (efp) - 16/01/2006
void cdvdNewDiskCB()
{
DoCDVDresetDiskTypeCache();
cdvd.Type = CDVDgetDiskType();
char str[g_MaxPath];
int result = GetPS2ElfName(str);
@ -766,7 +747,7 @@ __forceinline void cdvdReadInterrupt()
else
{
if (cdvd.RErr == 0)
cdr.pTransfer = CDVDgetBuffer();
cdr.pTransfer = DoCDVDgetBuffer();
else
cdr.pTransfer = NULL;
@ -777,7 +758,7 @@ __forceinline void cdvdReadInterrupt()
if (cdvd.RetryCntP <= cdvd.RetryCnt)
{
cdvd.RErr = CDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
cdvd.RErr = DoCDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
CDVDREAD_INT(cdvd.ReadTime);
return;
}
@ -811,7 +792,7 @@ __forceinline void cdvdReadInterrupt()
cdvd.RetryCntP = 0;
cdvd.Reading = 1;
cdr.RErr = CDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
cdr.RErr = DoCDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
CDVDREAD_INT(cdvd.ReadTime);
return;
@ -1142,7 +1123,7 @@ static void cdvdWrite04(u8 rt) { // NCOMMAND
// Read-ahead by telling the plugin about the track now.
// This helps improve performance on actual from-cd emulation
// (ie, not using the hard drive)
cdvd.RErr = CDVDreadTrack( cdvd.SeekToSector, cdvd.ReadMode );
cdvd.RErr = DoCDVDreadTrack( cdvd.SeekToSector, cdvd.ReadMode );
// Set the reading block flag. If a seek is pending then Readed will
// take priority in the handler anyway. If the read is contiguous then
@ -1189,7 +1170,7 @@ static void cdvdWrite04(u8 rt) { // NCOMMAND
// Read-ahead by telling the plugin about the track now.
// This helps improve performance on actual from-cd emulation
// (ie, not using the hard drive)
cdvd.RErr = CDVDreadTrack( cdvd.SeekToSector, cdvd.ReadMode );
cdvd.RErr = DoCDVDreadTrack( cdvd.SeekToSector, cdvd.ReadMode );
// Set the reading block flag. If a seek is pending then Readed will
// take priority in the handler anyway. If the read is contiguous then
@ -1224,7 +1205,7 @@ static void cdvdWrite04(u8 rt) { // NCOMMAND
// Read-ahead by telling the plugin about the track now.
// This helps improve performance on actual from-cd emulation
// (ie, not using the hard drive)
cdvd.RErr = CDVDreadTrack( cdvd.SeekToSector, cdvd.ReadMode );
cdvd.RErr = DoCDVDreadTrack( cdvd.SeekToSector, cdvd.ReadMode );
// Set the reading block flag. If a seek is pending then Readed will
// take priority in the handler anyway. If the read is contiguous then

View File

@ -20,6 +20,10 @@
#define __CDVD_H__
#include "IopCommon.h"
#include "CDVD/CDVDaccess.h"
extern bool loadFromISO;
extern char isoFileName[];
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */

352
pcsx2/CDVD/CDVDaccess.cpp Normal file
View File

@ -0,0 +1,352 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "PrecompiledHeader.h"
#include <ctype.h>
#include <time.h>
#include "IopCommon.h"
#include "IsoFStools.h"
#include "IsoFSdrv.h"
#include "CDVDisoReader.h"
static int diskTypeCached=-1;
/////////////////////////////////////////////////
//
// Disk Type detection stuff (from cdvdGigaherz)
//
int CheckDiskTypeFS(int baseType)
{
int f;
char buffer[256];//if a file is longer...it should be shorter :D
char *pos;
static struct TocEntry tocEntry;
IsoFS_init();
// check if the file exists
if (IsoFS_findFile("SYSTEM.CNF;1", &tocEntry) == TRUE)
{
f=IsoFS_open("SYSTEM.CNF;1", 1);
IsoFS_read(f, buffer, 256);
IsoFS_close(f);
buffer[tocEntry.fileSize]='\0';
pos=strstr(buffer, "BOOT2");
if (pos==NULL){
pos=strstr(buffer, "BOOT");
if (pos==NULL) {
return CDVD_TYPE_ILLEGAL;
}
return CDVD_TYPE_PSCD;
}
return (baseType==CDVD_TYPE_DETCTCD)?CDVD_TYPE_PS2CD:CDVD_TYPE_PS2DVD;
}
if (IsoFS_findFile("PSX.EXE;1", &tocEntry) == TRUE)
{
return CDVD_TYPE_PSCD;
}
if (IsoFS_findFile("VIDEO_TS/VIDEO_TS.IFO;1", &tocEntry) == TRUE)
{
return CDVD_TYPE_DVDV;
}
return CDVD_TYPE_ILLEGAL; // << Only for discs which aren't ps2 at all.
}
static char bleh[2352];
int FindDiskType(int mType)
{
int dataTracks=0;
int audioTracks=0;
int iCDType = CDVD_TYPE_DETCTDVDS;
s32 mt=mType;
cdvdTN tn;
DoCDVDgetTN(&tn);
if((mt<0) || ((mt == CDVD_TYPE_DETCTDVDS) && (tn.strack != tn.etrack)))
{
cdvdTD td;
DoCDVDgetTD(0,&td);
if(td.lsn>452849)
{
iCDType = CDVD_TYPE_DETCTDVDS;
}
else if(DoCDVDreadSector((u8*)bleh,16)==0)
{
struct cdVolDesc* volDesc=(struct cdVolDesc *)bleh;
if(volDesc)
{
if(volDesc->rootToc.tocSize==2048) iCDType = CDVD_TYPE_DETCTCD;
else iCDType = CDVD_TYPE_DETCTDVDS;
}
}
}
fprintf(stderr," * CDVD Disk Open: %d tracks (%d to %d):\n",tn.etrack-tn.strack+1,tn.strack,tn.etrack);
audioTracks=dataTracks=0;
for(int i=tn.strack;i<=tn.etrack;i++)
{
cdvdTD td,td2;
DoCDVDgetTD(i,&td);
DoCDVDgetTD(i+1,&td2);
int tlength = td2.lsn - td.lsn;
if(td.type==CDVD_AUDIO_TRACK)
{
audioTracks++;
fprintf(stderr," * * Track %d: Audio (%d sectors)\n",i,tlength);
}
else
{
dataTracks++;
fprintf(stderr," * * Track %d: Data (Mode %d) (%d sectors)\n",i,((td.type==CDVD_MODE1_TRACK)?1:2),tlength);
}
}
if(dataTracks>0)
{
iCDType=CheckDiskTypeFS(iCDType);
}
if(audioTracks>0)
{
if(iCDType==CDVD_TYPE_PS2CD)
{
iCDType=CDVD_TYPE_PS2CDDA;
}
else if(iCDType==CDVD_TYPE_PSCD)
{
iCDType=CDVD_TYPE_PSCDDA;
}
else
{
iCDType=CDVD_TYPE_CDDA;
}
}
return iCDType;
}
void DetectDiskType()
{
if (DoCDVDgetTrayStatus() == CDVD_TRAY_OPEN)
{
diskTypeCached = CDVD_TYPE_NODISC;
return;
}
int baseMediaType = DoCDVDgetDiskType();
int mType = -1;
switch(baseMediaType) // Paranoid mode: do not trust the plugin's detection system to work correctly.
{
case CDVD_TYPE_CDDA:
case CDVD_TYPE_PSCD:
case CDVD_TYPE_PS2CD:
case CDVD_TYPE_PSCDDA:
case CDVD_TYPE_PS2CDDA:
mType=CDVD_TYPE_DETCTCD;
break;
case CDVD_TYPE_DVDV:
case CDVD_TYPE_PS2DVD:
mType=CDVD_TYPE_DETCTDVDS;
break;
case CDVD_TYPE_DETCTDVDS:
case CDVD_TYPE_DETCTDVDD:
case CDVD_TYPE_DETCTCD:
mType=baseMediaType;
break;
case CDVD_TYPE_NODISC:
diskTypeCached = CDVD_TYPE_NODISC;
return;
}
diskTypeCached = FindDiskType(mType);
}
//
/////////////////////////////////////////////////
s32 DoCDVDinit()
{
if(!loadFromISO)
return CDVDinit();
diskTypeCached=-1;
return 0;
}
s32 DoCDVDopen(const char* pTitleFilename)
{
if(loadFromISO)
return ISOopen(pTitleFilename);
else
return CDVDopen(pTitleFilename);
}
void DoCDVDclose()
{
if(loadFromISO)
ISOclose();
else
CDVDclose();
}
void DoCDVDshutdown()
{
if(!loadFromISO)
{
if (CDVDshutdown != NULL) CDVDshutdown();
}
}
s32 DoCDVDreadSector(u8* buffer, u32 lsn)
{
if(loadFromISO)
return ISOreadSector(buffer,lsn);
else
{
CDVDreadTrack(lsn,CDVD_MODE_2048);
void* pbuffer = CDVDgetBuffer();
if(pbuffer!=NULL)
{
memcpy(buffer,pbuffer,2048);
return 0;
}
return -1;
}
}
s32 DoCDVDreadTrack(u32 lsn, int mode)
{
if(loadFromISO)
return ISOreadTrack(lsn, mode);
else
return CDVDreadTrack(lsn, mode);
}
// return can be NULL (for async modes)
u8* DoCDVDgetBuffer()
{
if(loadFromISO)
return ISOgetBuffer();
else
return CDVDgetBuffer();
}
s32 DoCDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
{
if(loadFromISO)
return ISOreadSubQ(lsn,subq);
else
return CDVDreadSubQ(lsn,subq);
}
s32 DoCDVDgetTN(cdvdTN *Buffer)
{
if(loadFromISO)
return ISOgetTN(Buffer);
else
return CDVDgetTN(Buffer);
}
s32 DoCDVDgetTD(u8 Track, cdvdTD *Buffer)
{
if(loadFromISO)
return ISOgetTD(Track,Buffer);
else
return CDVDgetTD(Track,Buffer);
}
s32 DoCDVDgetTOC(void* toc)
{
if(loadFromISO)
return ISOgetTOC(toc);
else
return CDVDgetTOC(toc);
}
s32 DoCDVDgetDiskType()
{
if(loadFromISO)
return ISOgetDiskType();
else
return CDVDgetDiskType();
}
s32 DoCDVDdetectDiskType()
{
if(diskTypeCached<0)
DetectDiskType();
return diskTypeCached;
}
void DoCDVDresetDiskTypeCache()
{
diskTypeCached=-1;
}
s32 DoCDVDgetTrayStatus()
{
if(loadFromISO)
return ISOgetTrayStatus();
else
return CDVDgetTrayStatus();
}
s32 DoCDVDctrlTrayOpen()
{
if(loadFromISO)
return ISOctrlTrayOpen();
else
return CDVDctrlTrayOpen();
}
s32 DoCDVDctrlTrayClose()
{
if(loadFromISO)
return ISOctrlTrayClose();
else
return CDVDctrlTrayClose();
}
void DoCDVDnewDiskCB(void (*callback)())
{
if(!loadFromISO)
{
if (CDVDnewDiskCB) CDVDnewDiskCB(callback);
}
}

40
pcsx2/CDVD/CDVDaccess.h Normal file
View File

@ -0,0 +1,40 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __CDVD_ACCESS_H__
#define __CDVD_ACCESS_H__
s32 DoCDVDinit();
s32 DoCDVDopen(const char* pTitleFilename);
void DoCDVDclose();
void DoCDVDshutdown();
s32 DoCDVDreadSector(u8* buffer, u32 lsn);
s32 DoCDVDreadTrack(u32 lsn, int mode);
u8* DoCDVDgetBuffer();
s32 DoCDVDreadSubQ(u32 lsn, cdvdSubQ* subq);
s32 DoCDVDgetTN(cdvdTN *Buffer);
s32 DoCDVDgetTD(u8 Track, cdvdTD *Buffer);
s32 DoCDVDgetTOC(void* toc);
s32 DoCDVDgetDiskType();
s32 DoCDVDgetTrayStatus();
s32 DoCDVDctrlTrayOpen();
s32 DoCDVDctrlTrayClose();
void DoCDVDnewDiskCB(void (*callback)());
s32 DoCDVDdetectDiskType();
void DoCDVDresetDiskTypeCache();
#endif /* __CDVD_H__ */

View File

@ -20,25 +20,26 @@
* Modified by Florin for PCSX2 emu
* Fixed CdRead by linuzappz
*/
#include "PrecompiledHeader.h"
#ifdef __LINUX__
#ifdef __LINUX__
// Just in case.
#define __USE_LARGEFILE64
#define __USE_FILE_OFFSET64
#define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
# define __USE_LARGEFILE64
# define __USE_FILE_OFFSET64
# define _FILE_OFFSET_BITS 64
# define _LARGEFILE_SOURCE
# define _LARGEFILE64_SOURCE
#endif
#include "PrecompiledHeader.h"
#include "CDVDisoReader.h"
#ifndef MAX_PATH
#define MAX_PATH 255
#endif
char IsoFile[256];
bool loadFromISO;
char isoFileName[256];
u8 *pbuffer;
@ -63,10 +64,6 @@ int isoSectorOffset = 0;
#define _fseeki64 fseeko64
#endif
// This var is used to detect resume-style behavior of the Pcsx2 emulator,
// and skip prompting the user for a new CD when it's likely they want to run the existing one.
static char cdvdCurrentIso[MAX_PATH];
u8 cdbuffer[CD_FRAMESIZE_RAW * 10] = {0};
s32 msf_to_lba(u8 m, u8 s, u8 f)
@ -106,7 +103,7 @@ void __Log(char *fmt, ...)
#endif
s32 ISOinit()
s32 CALLBACK ISOinit()
{
#ifdef PCSX2_DEBUG
cdvdLog = fopen("logs/cdvdLog.txt", "w");
@ -123,39 +120,24 @@ s32 ISOinit()
CDVD_LOG("ISOinit\n");
#endif
cdvdCurrentIso[0] = 0;
return 0;
}
void ISOshutdown()
void CALLBACK ISOshutdown()
{
cdvdCurrentIso[0] = 0;
#ifdef CDVD_LOG
if (cdvdLog != NULL) fclose(cdvdLog);
#endif
}
s32 ISOopen(const char* pTitle)
s32 CALLBACK ISOopen(const char* pTitle)
{
if (pTitle != NULL) strcpy(IsoFile, pTitle);
//if (pTitle != NULL) strcpy(isoFileName, pTitle);
if (*IsoFile == 0) strcpy(IsoFile, cdvdCurrentIso);
if (*IsoFile == 0)
{
char temp[256];
//CfgOpenFile();
strcpy(temp, IsoFile);
*IsoFile = 0;
strcpy(IsoFile, temp);
}
isoFile = fopen(IsoFile,"rb");
isoFile = fopen(isoFileName,"rb");
if (isoFile == NULL)
{
Console::Error("Error loading %s\n", params IsoFile);
Console::Error("Error loading %s\n", params isoFileName);
return -1;
}
@ -165,8 +147,9 @@ s32 ISOopen(const char* pTitle)
isoSectorSize = 2048;
isoSectorOffset = 0;
// probably vc++ only, CBA to find the unix equivalent
_fseeki64(isoFile,0,SEEK_END);
isoNumSectors = (int)(_ftelli64(isoFile)/isoSectorSize);
_fseeki64(isoFile,0,SEEK_SET);
if (BlockDump)
{
@ -174,12 +157,12 @@ s32 ISOopen(const char* pTitle)
#ifdef _WIN32
char fname[MAX_PATH], ext[MAX_PATH];
_splitpath(IsoFile, NULL, NULL, fname, ext);
_splitpath(isoFileName, NULL, NULL, fname, ext);
_makepath(fname_only, NULL, NULL, fname, NULL);
#else
char* p, *plast;
plast = p = strchr(IsoFile, '/');
plast = p = strchr(isoFileName, '/');
while (p != NULL)
{
plast = p;
@ -191,7 +174,7 @@ s32 ISOopen(const char* pTitle)
if (plast != NULL)
strcat(fname_only, plast + 1);
else
strcat(fname_only, IsoFile);
strcat(fname_only, isoFileName);
plast = p = strchr(fname_only, '.');
@ -240,15 +223,13 @@ s32 ISOopen(const char* pTitle)
return 0;
}
void ISOclose()
void CALLBACK ISOclose()
{
strcpy(cdvdCurrentIso, IsoFile);
fclose(isoFile);
if (fdump != NULL) fclose(fdump);
}
s32 ISOreadSubQ(u32 lsn, cdvdSubQ* subq)
s32 CALLBACK ISOreadSubQ(u32 lsn, cdvdSubQ* subq)
{
// fake it, until some kind of support for clonecd .sub files is implemented
u8 min, sec, frm;
@ -271,7 +252,7 @@ s32 ISOreadSubQ(u32 lsn, cdvdSubQ* subq)
return 0;
}
s32 ISOgetTN(cdvdTN *Buffer)
s32 CALLBACK ISOgetTN(cdvdTN *Buffer)
{
Buffer->strack = 1;
Buffer->etrack = 1;
@ -279,7 +260,7 @@ s32 ISOgetTN(cdvdTN *Buffer)
return 0;
}
s32 ISOgetTD(int tn, cdvdTD *Buffer)
s32 CALLBACK ISOgetTD(u8 tn, cdvdTD *Buffer)
{
if(tn==1)
{
@ -294,26 +275,26 @@ s32 ISOgetTD(int tn, cdvdTD *Buffer)
return 0;
}
s32 ISOgetDiskType()
s32 CALLBACK ISOgetDiskType()
{
return isoType;
}
s32 ISOgetTrayStatus()
s32 CALLBACK ISOgetTrayStatus()
{
return CDVD_TRAY_CLOSE;
}
s32 ISOctrlTrayOpen()
s32 CALLBACK ISOctrlTrayOpen()
{
return 0;
}
s32 ISOctrlTrayClose()
s32 CALLBACK ISOctrlTrayClose()
{
return 0;
}
s32 ISOreadSector(u8* tempbuffer, u32 lsn)
s32 CALLBACK ISOreadSector(u8* tempbuffer, u32 lsn)
{
// dummy function, doesn't create valid info for the data surrounding the userdata bytes!
@ -323,7 +304,7 @@ s32 ISOreadSector(u8* tempbuffer, u32 lsn)
}
static s32 layer1start = -1;
s32 ISOgetTOC(void* toc)
s32 CALLBACK ISOgetTOC(void* toc)
{
u8 type = ISOgetDiskType();
u8* tocBuff = (u8*)toc;
@ -465,7 +446,7 @@ s32 ISOgetTOC(void* toc)
return 0;
}
s32 ISOreadTrack(u32 lsn, int mode)
s32 CALLBACK ISOreadTrack(u32 lsn, int mode)
{
int _lsn = lsn;
@ -503,7 +484,7 @@ s32 ISOreadTrack(u32 lsn, int mode)
return 0;
}
u8* ISOgetBuffer()
u8* CALLBACK ISOgetBuffer()
{
return pbuffer;
}

View File

@ -1,23 +1,23 @@
/* CDVDiso
* Copyright (C) 2002-2004 CDVDiso 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 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __CDVD_ISO_H__
#define __CDVD_ISO_H__
#ifndef __CDVD_ISO_READER_H__
#define __CDVD_ISO_READER_H__
#ifdef _MSC_VER
#pragma warning(disable:4018)
@ -27,7 +27,6 @@
#include "IopCommon.h"
#include "IsoFStools.h"
#include "CDVD_internal.h"
#define CD_FRAMESIZE_RAW 2352
#define DATA_SIZE (CD_FRAMESIZE_RAW-12)
@ -37,7 +36,9 @@
#define MSF2SECT(m,s,f) (((m)*60+(s)-2)*75+(f))
extern char IsoFile[256];
extern bool loadFromISO;
extern char isoFileName[256];
extern int BlockDump;
extern FILE* fdump;
@ -47,4 +48,20 @@ extern int isoType;
extern u8 cdbuffer[];
extern u8 *pbuffer;
s32 CALLBACK ISOinit();
void CALLBACK ISOshutdown();
s32 CALLBACK ISOopen(const char* pTitle);
void CALLBACK ISOclose();
s32 CALLBACK ISOreadSubQ(u32 lsn, cdvdSubQ* subq);
s32 CALLBACK ISOgetTN(cdvdTN *Buffer);
s32 CALLBACK ISOgetTD(u8 tn, cdvdTD *Buffer);
s32 CALLBACK ISOgetDiskType();
s32 CALLBACK ISOgetTrayStatus();
s32 CALLBACK ISOctrlTrayOpen();
s32 CALLBACK ISOctrlTrayClose();
s32 CALLBACK ISOreadSector(u8* tempbuffer, u32 lsn);
s32 CALLBACK ISOgetTOC(void* toc);
s32 CALLBACK ISOreadTrack(u32 lsn, int mode);
u8* CALLBACK ISOgetBuffer();
#endif

View File

@ -141,7 +141,7 @@ static void ReadTrack() {
cdr.Prev[2] = itob(cdr.SetSector[2]);
CDR_LOG("KEY *** %x:%x:%x", cdr.Prev[0], cdr.Prev[1], cdr.Prev[2]);
cdr.RErr = CDVDreadTrack(MSFtoLSN(cdr.SetSector), CDVD_MODE_2352);
cdr.RErr = DoCDVDreadTrack(MSFtoLSN(cdr.SetSector), CDVD_MODE_2352);
}
// cdr.Stat:
@ -332,7 +332,7 @@ void cdrInterrupt() {
SetResultSize(3);
cdr.StatP|= 0x2;
cdr.Result[0] = cdr.StatP;
if (CDVDgetTN(&cdr.ResultTN) == -1) {
if (DoCDVDgetTN(&cdr.ResultTN) == -1) {
cdr.Stat = DiskError;
cdr.Result[0]|= 0x01;
} else {
@ -347,7 +347,7 @@ void cdrInterrupt() {
cdr.Track = btoi(cdr.Param[0]);
SetResultSize(4);
cdr.StatP|= 0x2;
if (CDVDgetTD(cdr.Track, &trackInfo) == -1) {
if (DoCDVDgetTD(cdr.Track, &trackInfo) == -1) {
cdr.Stat = DiskError;
cdr.Result[0]|= 0x01;
} else {
@ -514,7 +514,7 @@ void cdrReadInterrupt() {
cdr.Result[0] = cdr.StatP;
SysPrintf("Reading From CDR");
buf = CDVDgetBuffer();
buf = DoCDVDgetBuffer();
if (buf == NULL) cdr.RErr = -1;
if (cdr.RErr == -1) {

View File

@ -26,6 +26,7 @@
#include "IsoFStools.h"
#include "IsoFSdrv.h"
#include "CDVDaccess.h"
struct dir_toc_data
{
@ -175,9 +176,9 @@ int IsoFS_readSectors(u32 lsn, u32 sectors, void *buf)
for (i=0; i<sectors; i++)
{
if (CDVDreadTrack(lsn+i, CDVD_MODE_2048) == -1) return 0;
if (DoCDVDreadTrack(lsn+i, CDVD_MODE_2048) == -1) return 0;
buff = CDVDgetBuffer();
buff = DoCDVDgetBuffer();
if (buff == NULL) return 0;

View File

@ -22,6 +22,7 @@
#include "IopCommon.h"
#include "GS.h"
#include "HostGui.h"
#include "CDVD/CDVDisoReader.h"
_GSinit GSinit;
_GSopen GSopen;
@ -486,6 +487,7 @@ void *CDVDplugin;
void CALLBACK CDVD_configure() {}
void CALLBACK CDVD_about() {}
s32 CALLBACK CDVD_test() { return 0; }
void CALLBACK CDVD_newDiskCB(void (*callback)()) {}
int LoadCDVDplugin(const string& filename) {
void *drv;
@ -691,7 +693,9 @@ int InitPlugins()
if (ReportError(PAD1init(1), "PAD1init")) return -1;
if (ReportError(PAD2init(2), "PAD2init")) return -1;
if (ReportError(SPU2init(), "SPU2init")) return -1;
if (ReportError(CDVDinit(), "CDVDinit")) return -1;
if (ReportError(DoCDVDinit(), "CDVDinit")) return -1;
if (ReportError(DEV9init(), "DEV9init")) return -1;
if (ReportError(USBinit(), "USBinit")) return -1;
if (ReportError(FWinit(), "FWinit")) return -1;
@ -714,7 +718,10 @@ void ShutdownPlugins()
if (PAD2shutdown != NULL) PAD2shutdown();
if (SPU2shutdown != NULL) SPU2shutdown();
if (CDVDshutdown != NULL) CDVDshutdown();
//if (CDVDshutdown != NULL) CDVDshutdown();
DoCDVDshutdown();
if (DEV9shutdown != NULL) DEV9shutdown();
if (USBshutdown != NULL) USBshutdown();
if (FWshutdown != NULL) FWshutdown();
@ -757,9 +764,9 @@ bool OpenCDVD(const char* pTitleFilename)
if (!OpenStatus.CDVD && !only_loading_elf)
{
//First, we need the data.
if (CDVDnewDiskCB) CDVDnewDiskCB(cdvdNewDiskCB);
DoCDVDnewDiskCB(cdvdNewDiskCB);
if (CDVDopen(pTitleFilename) != 0)
if (DoCDVDopen(pTitleFilename) != 0)
{
if (g_Startup.BootMode != BootMode_Elf)
{

View File

@ -1529,16 +1529,17 @@
RelativePath="..\..\CDVD\CDVD_internal.h"
>
</File>
<File
RelativePath="..\..\CDVD\CDVDaccess.cpp"
>
</File>
<File
RelativePath="..\..\CDVD\CDVDaccess.h"
>
</File>
<File
RelativePath="..\..\CDVD\CDVDisoReader.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\CDVD\CDVDisoReader.h"

View File

@ -38,6 +38,8 @@
#include "implement.h" // pthreads-win32 defines for startup/shutdown
#include "CDVD/CDVDisoReader.h"
unsigned int langsMax;
static bool m_RestartGui = false; // used to signal a GUI restart after DestroyWindow()
static HBITMAP hbitmap_background = NULL;
@ -447,6 +449,45 @@ BOOL Open_File_Proc( std::string& outstr )
return FALSE;
}
BOOL Open_Iso_File_Proc( std::string& outstr )
{
OPENFILENAME ofn;
char szFileName[ g_MaxPath ];
char szFileTitle[ g_MaxPath ];
char * filter = "ISO Files (*.ISO)\0*.ISO\0ALL Files (*.*)\0*.*\0";
memzero_obj( szFileName );
memzero_obj( szFileTitle );
ofn.lStructSize = sizeof( OPENFILENAME );
ofn.hwndOwner = gApp.hWnd;
ofn.lpstrFilter = filter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = g_MaxPath;
ofn.lpstrInitialDir = NULL;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = g_MaxPath;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "ELF";
ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER;
if (GetOpenFileName(&ofn)) {
struct stat buf;
if (stat(szFileName, &buf) != 0) {
return FALSE;
}
outstr = szFileName;
return TRUE;
}
return FALSE;
}
//2002-09-20 (Florin)
BOOL APIENTRY CmdlineProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
@ -630,6 +671,21 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
case ID_FILE_RUNISO:
{
string outstr;
if( Open_Iso_File_Proc( outstr ) )
{
loadFromISO = true;
strcpy(isoFileName,outstr.c_str());
SysReset();
SysPrepareExecution( NULL );
}
}
break;
case ID_RUN_EXECUTE:
// Execute without reset -- resumes existing states or runs the BIOS if
// the state is cleared/reset.
@ -637,10 +693,13 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case ID_FILE_RUNCD:
loadFromISO = false;
SysReset();
SysPrepareExecution( NULL );
break;
case ID_RUN_RESET:
SysReset();
break;
@ -791,6 +850,12 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
SaveConfig();
break;
case ID_BLOCKDUMP:
Config.Blockdump = !Config.Blockdump;
CheckMenuItem(gApp.hMenu, ID_BLOCKDUMP, Config.Blockdump ? MF_CHECKED : MF_UNCHECKED);
SaveConfig();
break;
case ID_CDVDPRINT:
Config.cdvdPrint = !Config.cdvdPrint;
CheckMenuItem(gApp.hMenu, ID_CDVDPRINT, Config.cdvdPrint ? MF_CHECKED : MF_UNCHECKED);
@ -926,6 +991,7 @@ void CreateMainMenu() {
ADDSUBMENUS(0, 1, _("&States"));
ADDSEPARATOR(0);
ADDMENUITEM(0, _("&Open ELF File"), ID_FILEOPEN);
ADDMENUITEM(0, _("Run from &ISO Image"), ID_FILE_RUNISO);
ADDMENUITEM(0, _("&Run CD/DVD"), ID_FILE_RUNCD);
ADDSUBMENUS(1, 3, _("&Save"));
ADDSUBMENUS(1, 2, _("&Load"));
@ -993,6 +1059,8 @@ void CreateMainMenu() {
ADDMENUITEM(0,_("Enable &Profiler"), ID_PROFILER);
ADDMENUITEM(0,_("Enable &Patches"), ID_PATCHES);
ADDMENUITEM(0,_("Enable &Console"), ID_CONSOLE);
//TODO
//ADDMENUITEM(0,_("Enable &Block Dumping"), ID_BLOCKDUMP);
ADDSEPARATOR(0);
ADDMENUITEM(0,_("Patch &Finder..."), ID_CHEAT_FINDER_SHOW);
ADDMENUITEM(0,_("Patch &Browser..."), ID_CHEAT_BROWSER_SHOW);

View File

@ -175,6 +175,8 @@ void IniFile::DoConfig( PcsxConfig& Conf )
{
SetCurrentSection( "Misc" );
Entry( "Blockdump", Conf.Blockdump, false );
Entry( "Patching", Conf.Patch, false );
Entry( "GameFixes", Conf.GameFixes);
#ifdef PCSX2_DEVBUILD

View File

@ -410,6 +410,8 @@
#define ID_HACKS 40102
#define ID_GAMEFIXES 40103
#define ID_ADVANCED_OPTIONS 40104
#define ID_FILE_RUNISO 40105
#define ID_BLOCKDUMP 40106
#define ID_LANGS 50000
// Next default values for new objects
@ -417,7 +419,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 182
#define _APS_NEXT_COMMAND_VALUE 40018
#define _APS_NEXT_COMMAND_VALUE 40107
#define _APS_NEXT_CONTROL_VALUE 1331
#define _APS_NEXT_SYMED_VALUE 104
#endif