From f910d26c6e027d6c4f00c088d428b5e91daeb5d2 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Wed, 15 Jul 2009 04:31:14 +0000 Subject: [PATCH] Some fixes and cleanups. Now the File->Run* options won't reset the emulation, so it might be possible to swap discs properly from nodisc, iso or whatever cdvd plugin has been selected (to switch between iso/cdvdplugin/nodisc, it's necessary to use the file menu options, as run->execute will not update the active cdvd interface). git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1514 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD/CDVD.cpp | 17 +++----------- pcsx2/CDVD/CDVDisoReader.cpp | 11 +++++++-- pcsx2/CDVD/CdRom.cpp | 6 ++--- pcsx2/CDVD/IsoFStools.cpp | 10 ++++---- pcsx2/Plugins.cpp | 44 ++++++++++++++++-------------------- pcsx2/windows/WinMain.cpp | 13 +++++++---- 6 files changed, 46 insertions(+), 55 deletions(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 05fb15129a..0331bd2745 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -28,8 +28,6 @@ static cdvdStruct cdvd; -static u8 tempbuf[2352]; - static __forceinline void SetResultSize(u8 size) { cdvd.ResultC = size; @@ -522,18 +520,10 @@ void SaveState::cdvdFreeze() void cdvdNewDiskCB() { DoCDVDresetDiskTypeCache(); - cdvd.Type = CDVD.getDiskType(); + cdvd.Type = DoCDVDdetectDiskType(); - char str[g_MaxPath]; int result = GetPS2ElfName(str); - - if (cdvd.Type == CDVD_TYPE_PS2CD) - { - - // Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then. - if(result == 1) cdvd.Type = CDVD_TYPE_PSCD; - } // Now's a good time to reload the ELF info... if( ElfCRC == 0 ) @@ -542,7 +532,6 @@ void cdvdNewDiskCB() ElfApplyPatches(); GSsetGameCRC( ElfCRC, 0 ); } - } void mechaDecryptBytes( u32 madr, int size ) @@ -725,8 +714,8 @@ __forceinline void cdvdReadInterrupt() if (cdvd.RErr == 0) { - cdr.RErr = DoCDVDgetBuffer(tempbuf); - cdr.pTransfer = tempbuf; + cdr.RErr = DoCDVDgetBuffer(cdr.Transfer); + cdr.pTransfer = cdr.Transfer; } else cdr.pTransfer = NULL; diff --git a/pcsx2/CDVD/CDVDisoReader.cpp b/pcsx2/CDVD/CDVDisoReader.cpp index e6c56b6b94..95b2aa6dcb 100644 --- a/pcsx2/CDVD/CDVDisoReader.cpp +++ b/pcsx2/CDVD/CDVDisoReader.cpp @@ -185,7 +185,7 @@ static void FindLayer1Start() int off = iso->blockofs; u8* tempbuffer; - Console::Status("CDVD: searching for layer1..."); + Console::Status("CDVD ISO: searching for layer1..."); tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW); for (layer1start = (iso->blocks / 2 - 0x10) & ~0xf; layer1start < 0x200010; layer1start += 16) { @@ -409,6 +409,8 @@ s32 CALLBACK ISOreadTrack(u32 lsn, int mode) break; } + DevCon::Status("* ISO: Reading Track %d mode %d\n", params lsn, psize); + return 0; } @@ -418,6 +420,11 @@ s32 CALLBACK ISOgetBuffer2(u8* buffer) return 0; } +u8* CALLBACK ISOgetBuffer() +{ + return pbuffer; +} + s32 CALLBACK ISOgetTrayStatus() { return CDVD_TRAY_CLOSE; @@ -451,7 +458,7 @@ CDVDplugin ISO = { ISOclose, ISOshutdown, ISOreadTrack, - NULL, // emu shouldn't try to use this one. + ISOgetBuffer, // emu shouldn't use this one. ISOreadSubQ, ISOgetTN, ISOgetTD, diff --git a/pcsx2/CDVD/CdRom.cpp b/pcsx2/CDVD/CdRom.cpp index bf2ce8d187..459b0b6102 100644 --- a/pcsx2/CDVD/CdRom.cpp +++ b/pcsx2/CDVD/CdRom.cpp @@ -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 = DoCDVDreadTrack(MSFtoLSN(cdr.SetSector), CDVD_MODE_2352); + cdr.RErr = DoCDVDreadTrack(MSFtoLSN(cdr.SetSector), CDVD_MODE_2340); } // cdr.Stat: @@ -514,8 +514,7 @@ void cdrReadInterrupt() { cdr.Result[0] = cdr.StatP; SysPrintf("Reading From CDR"); - cdr.RErr = DoCDVDgetBuffer(buf); - + cdr.RErr = DoCDVDgetBuffer(cdr.Transfer); if (cdr.RErr == -1) { CDR_LOG(" err\n"); @@ -526,7 +525,6 @@ void cdrReadInterrupt() { CDREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime); return; } - memcpy_fast(cdr.Transfer, buf+12, 2340); cdr.Stat = DataReady; CDR_LOG(" %x:%x:%x", cdr.Transfer[0], cdr.Transfer[1], cdr.Transfer[2]); diff --git a/pcsx2/CDVD/IsoFStools.cpp b/pcsx2/CDVD/IsoFStools.cpp index 743a83a4c1..830e25f23c 100644 --- a/pcsx2/CDVD/IsoFStools.cpp +++ b/pcsx2/CDVD/IsoFStools.cpp @@ -193,7 +193,7 @@ int IsoFS_getVolumeDescriptor(void) cdVolDesc localVolDesc; - DbgCon::WriteLn("CDVD_GetVolumeDescriptor called"); + DbgCon::WriteLn("IsoFS_GetVolumeDescriptor called"); for (volDescSector = 16; volDescSector<20; volDescSector++) { @@ -241,7 +241,7 @@ int IsoFS_findFile(const char* fname, TocEntry* tocEntry){ dirTocEntry* tocEntryPointer; - DbgCon::WriteLn("CDVD_findfile called"); + DbgCon::WriteLn("IsoFS_findfile(\"%s\" called", params fname); _splitpath2(fname, pathname, filename); @@ -351,7 +351,7 @@ int IsoFS_findFile(const char* fname, TocEntry* tocEntry){ // If we havent found the directory name we wanted then fail if (found_dir != TRUE) { - Console::Notice( "CDVD_findfile: could not find dir" ); + Console::Notice( "IsoFS_findfile: could not find dir" ); return -1; } @@ -406,7 +406,7 @@ int IsoFS_findFile(const char* fname, TocEntry* tocEntry){ strcpy(tocEntry->filename, localTocEntry.filename); memcpy(tocEntry->date, localTocEntry.date, 7); - DbgCon::WriteLn("CDVD_findfile: found file"); + DbgCon::WriteLn("IsoFS_findfile: found file"); return TRUE; } @@ -430,7 +430,7 @@ int IsoFS_findFile(const char* fname, TocEntry* tocEntry){ } } - DbgCon::Notice("CDVD_findfile: could not find file"); + DbgCon::Notice("IsoFS_findfile: could not find file"); return FALSE; } diff --git a/pcsx2/Plugins.cpp b/pcsx2/Plugins.cpp index 91900027e4..0c9d766951 100644 --- a/pcsx2/Plugins.cpp +++ b/pcsx2/Plugins.cpp @@ -479,11 +479,11 @@ void CALLBACK CDVD_about() {} s32 CALLBACK CDVD_test() { return 0; } void CALLBACK CDVD_newDiskCB(void (*callback)()) {} +extern int lastReadSize; s32 CALLBACK CDVD_getBuffer2(u8* buffer) { int ret; - extern int lastReadSize; // TEMP: until I fix all the plugins to use this function style u8* pb = CDVD.getBuffer(); @@ -500,32 +500,26 @@ s32 CALLBACK CDVD_getBuffer2(u8* buffer) s32 CALLBACK CDVD_readSector(u8* buffer, u32 lsn, int mode) { - int ret; - - CDVD.readTrack(lsn,mode); - void* pbuffer = CDVD.getBuffer(); - if(pbuffer!=NULL) + if(CDVD.readTrack(lsn,mode)<0) + return -1; + + // TEMP: until all the plugins use the new CDVDgetBuffer style + switch (mode) { - switch(mode) - { - case CDVD_MODE_2048: - memcpy(buffer,pbuffer,2048); - break; - case CDVD_MODE_2328: - memcpy(buffer,pbuffer,2328); - break; - case CDVD_MODE_2340: - memcpy(buffer,pbuffer,2340); - break; - case CDVD_MODE_2352: - memcpy(buffer,pbuffer,2352); - break; - } - ret = 0; + case CDVD_MODE_2352: + lastReadSize = 2352; + break; + case CDVD_MODE_2340: + lastReadSize = 2340; + break; + case CDVD_MODE_2328: + lastReadSize = 2328; + break; + case CDVD_MODE_2048: + lastReadSize = 2048; + break; } - else ret = -1; - - return ret; + return CDVD.getBuffer2(buffer); } s32 CALLBACK CDVD_getDualInfo(s32* dualType, u32* layer1Start) diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index abccd5404d..0fd7714488 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -677,19 +677,21 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) string outstr; if( Open_Iso_File_Proc( outstr ) ) { - CDVD = ISO; - strcpy(isoFileName,outstr.c_str()); - SysReset(); + //SysReset(); + + // SysReset shuts down plugins so it's best in here + CDVD = ISO; SysPrepareExecution( NULL ); } } break; case ID_FILE_RUNBIOS: + //SysReset(); + // SysReset shuts down plugins so it's best in here CDVD = NODISC; - SysReset(); SysPrepareExecution( NULL, true ); break; @@ -700,8 +702,9 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case ID_FILE_RUNCD: + //SysReset(); + // SysReset shuts down plugins so it's best in here CDVD = CDVD_plugin; - SysReset(); SysPrepareExecution( NULL ); break;