From 0341a6052b6d1147108e343f8823701bc966ae46 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 3 Sep 2017 15:02:39 +0200 Subject: [PATCH 1/2] DVDInterface: Reply to 0-length commands This regression from the chunking PR was making a few games hang. --- Source/Core/Core/HW/DVD/DVDInterface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index ffee201a97..c5db7b09d6 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -1213,7 +1213,7 @@ void ScheduleReads(u64 offset, u32 length, const DiscIO::Partition& partition, u const u32 bytes_per_chunk = partition == DiscIO::PARTITION_NONE ? DVD_ECC_BLOCK_SIZE : DiscIO::VolumeWii::BLOCK_DATA_SIZE; - while (length > 0) + do { // The length of this read - "+1" so that if this read is already // aligned to a block we'll read the entire block. @@ -1222,6 +1222,8 @@ void ScheduleReads(u64 offset, u32 length, const DiscIO::Partition& partition, u // The last chunk may be short chunk_length = std::min(chunk_length, length); + // TODO: If the emulated software requests 0 bytes of data, should we seek or not? + if (dvd_offset >= buffer_start && dvd_offset < buffer_end) { // Number of ticks it takes to transfer the data from the buffer to memory. @@ -1266,7 +1268,7 @@ void ScheduleReads(u64 offset, u32 length, const DiscIO::Partition& partition, u offset += chunk_length; length -= chunk_length; dvd_offset += DVD_ECC_BLOCK_SIZE; - } + } while (length > 0); // Update the buffer based on this read. Based on experimental testing, // we will only reuse the old buffer while reading forward. Note that the From 3528c93edf7c141eb8e1e9c85a4cc6cda499e9a0 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 3 Sep 2017 14:53:29 +0200 Subject: [PATCH 2/2] DVDThread: Don't show an error message for all 0-length reads --- Source/Core/Core/HW/DVD/DVDThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/DVD/DVDThread.cpp b/Source/Core/Core/HW/DVD/DVDThread.cpp index 33fdc279c4..221a95a451 100644 --- a/Source/Core/Core/HW/DVD/DVDThread.cpp +++ b/Source/Core/Core/HW/DVD/DVDThread.cpp @@ -326,7 +326,7 @@ static void FinishRead(u64 id, s64 cycles_late) (CoreTiming::GetTicks() - request.time_started_ticks) / (SystemTimers::GetTicksPerSecond() / 1000000)); - if (buffer.empty()) + if (buffer.size() != request.length) { PanicAlertT("The disc could not be read (at 0x%" PRIx64 " - 0x%" PRIx64 ").", request.dvd_offset, request.dvd_offset + request.length);