From eeca9f61bfadf7676243de94d9e431d77153808c Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Tue, 23 Jan 2018 19:07:25 +0000 Subject: [PATCH] cdvd: Fix writing of CD blockdumps Write the full CD sector (not including subchannels) to a blockdump instead of just a partial CD sector that isn't offset correctly. --- pcsx2/CDVD/CDVDaccess.cpp | 22 ++++++++++++++++++++-- pcsx2/CDVD/IsoFileFormats.h | 2 +- pcsx2/CDVD/OutputIsoFile.cpp | 5 +++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index 9e9d166719..128fd61081 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -439,7 +439,16 @@ s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode) if (ret == 0 && blockDumpFile.IsOpened()) { - blockDumpFile.WriteSector(buffer, lsn); + if (blockDumpFile.GetBlockSize() == CD_FRAMESIZE_RAW && mode != CDVD_MODE_2352) + { + u8 blockDumpBuffer[CD_FRAMESIZE_RAW]; + if (CDVD->readSector(blockDumpBuffer, lsn, CDVD_MODE_2352) == 0) + blockDumpFile.WriteSector(blockDumpBuffer, lsn); + } + else + { + blockDumpFile.WriteSector(buffer, lsn); + } } return ret; @@ -478,7 +487,16 @@ s32 DoCDVDgetBuffer(u8* buffer) if (ret == 0 && blockDumpFile.IsOpened()) { - blockDumpFile.WriteSector(buffer, lastLSN); + if (blockDumpFile.GetBlockSize() == CD_FRAMESIZE_RAW && lastReadSize != 2352) + { + u8 blockDumpBuffer[CD_FRAMESIZE_RAW]; + if (CDVD->readSector(blockDumpBuffer, lastLSN, CDVD_MODE_2352) == 0) + blockDumpFile.WriteSector(blockDumpBuffer, lastLSN); + } + else + { + blockDumpFile.WriteSector(buffer, lastLSN); + } } return ret; diff --git a/pcsx2/CDVD/IsoFileFormats.h b/pcsx2/CDVD/IsoFileFormats.h index 77ba8932cb..55daaeadba 100644 --- a/pcsx2/CDVD/IsoFileFormats.h +++ b/pcsx2/CDVD/IsoFileFormats.h @@ -123,7 +123,7 @@ public: virtual ~OutputIsoFile(); bool IsOpened() const; - + u32 GetBlockSize() const; const wxString& GetFilename() const { diff --git a/pcsx2/CDVD/OutputIsoFile.cpp b/pcsx2/CDVD/OutputIsoFile.cpp index 695182958b..686f667e8f 100644 --- a/pcsx2/CDVD/OutputIsoFile.cpp +++ b/pcsx2/CDVD/OutputIsoFile.cpp @@ -133,3 +133,8 @@ bool OutputIsoFile::IsOpened() const { return m_outstream && m_outstream->IsOk(); } + +u32 OutputIsoFile::GetBlockSize() const +{ + return m_blocksize; +}