From 0a4ff90bfba20ea086a859a87fae4c9a826626f1 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 8 Oct 2017 10:50:19 +0100 Subject: [PATCH] cdvdgigaherz: Detect CD track mode correctly In every CD data sector, byte 15 indicates what the CD track mode is. --- plugins/cdvdGigaherz/src/TocStuff.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/cdvdGigaherz/src/TocStuff.cpp b/plugins/cdvdGigaherz/src/TocStuff.cpp index bce5153090..6cd7c548b2 100644 --- a/plugins/cdvdGigaherz/src/TocStuff.cpp +++ b/plugins/cdvdGigaherz/src/TocStuff.cpp @@ -16,6 +16,7 @@ #include "CDVD.h" #include +#include void cdvdParseTOC() { @@ -45,10 +46,17 @@ void cdvdParseTOC() strack = std::min(strack, entry.track); etrack = std::max(etrack, entry.track); tracks[entry.track].start_lba = entry.lba; - if (!(entry.control & 0x04)) + if ((entry.control & 0x0C) == 0x04) { + std::array buffer; + // Byte 15 of a raw CD data sector determines the track mode + if (src->ReadSectors2352(entry.lba, 1, buffer.data()) && (buffer[15] & 3) == 2) { + tracks[entry.track].type = CDVD_MODE2_TRACK; + } else { + tracks[entry.track].type = CDVD_MODE1_TRACK; + } + } else { tracks[entry.track].type = CDVD_AUDIO_TRACK; - else - tracks[entry.track].type = CDVD_MODE1_TRACK; + } fprintf(stderr, "Track %u start sector: %u\n", entry.track, entry.lba); } }