From 39d60da096c5dfa292c9261b00e680ea939ab5a8 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Fri, 8 May 2020 19:53:48 +0800 Subject: [PATCH] pcecd: don't fill FIFO before seek. --- support/pcecd/pcecd.h | 1 + support/pcecd/pcecdd.cpp | 35 ++++++++++++++++------------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/support/pcecd/pcecd.h b/support/pcecd/pcecd.h index ba1a57a..f15b16f 100644 --- a/support/pcecd/pcecd.h +++ b/support/pcecd/pcecd.h @@ -94,6 +94,7 @@ private: //uint8_t state; int CDDAStart; int CDDAEnd; + int CDDAFirst; uint8_t CDDAMode; sense_t sense; diff --git a/support/pcecd/pcecdd.cpp b/support/pcecd/pcecdd.cpp index d6c7610..ad4c3f4 100644 --- a/support/pcecd/pcecdd.cpp +++ b/support/pcecd/pcecdd.cpp @@ -390,18 +390,25 @@ void pcecdd_t::Update() { return; DISKLED_ON; - FileSeek(&this->toc.tracks[index].f, (this->lba * 2352) - this->toc.tracks[index].offset, SEEK_SET); - sec_buf[0] = 0x30; - sec_buf[1] = 0x09; - ReadCDDA(sec_buf + 2); + for (int i = 0; i <= this->CDDAFirst; i++) + { + FileSeek(&this->toc.tracks[index].f, (this->lba * 2352) - this->toc.tracks[index].offset, SEEK_SET); - if (SendData) - SendData(sec_buf, 2352 + 2, PCECD_DATA_IO_INDEX); + sec_buf[0] = 0x30; + sec_buf[1] = 0x09; + ReadCDDA(sec_buf + 2); - //printf("\x1b[32mPCECD: Audio sector send = %i, track = %i, offset = %i\n\x1b[0m", this->lba, this->index, (this->lba * 2352) - this->toc.tracks[index].offset); + if (SendData) + SendData(sec_buf, 2352 + 2, PCECD_DATA_IO_INDEX); + + //printf("\x1b[32mPCECD: Audio sector send = %i, track = %i, offset = %i\n\x1b[0m", this->lba, this->index, (this->lba * 2352) - this->toc.tracks[index].offset); + + this->lba++; + } + + this->CDDAFirst = 0; - this->lba++; if (this->lba > this->CDDAEnd) { if (this->CDDAMode == PCECD_CDDAMODE_LOOP) { @@ -604,6 +611,7 @@ void pcecdd_t::CommandExec() { this->CDDAStart = new_lba; this->CDDAEnd = this->toc.tracks[index].end; this->CDDAMode = comm[1]; + this->CDDAFirst = 1; if (this->CDDAMode == PCECD_CDDAMODE_SILENT) { this->state = PCECD_STATE_PAUSE; @@ -612,17 +620,6 @@ void pcecdd_t::CommandExec() { this->state = PCECD_STATE_PLAY; } - FileSeek(&this->toc.tracks[index].f, (this->lba * 2352) - this->toc.tracks[index].offset, SEEK_SET); - - sec_buf[0] = 0x30; - sec_buf[1] = 0x09; - ReadCDDA(sec_buf + 2); - - if (SendData) - SendData(sec_buf, 2352 + 2, PCECD_DATA_IO_INDEX); - - this->lba++; - PendStatus(PCECD_STATUS_GOOD, 0); } printf("\x1b[32mPCECD: Command SAPSP, start = %d, end = %d, [1] = %02X, [2] = %02X, [9] = %02X\n\x1b[0m", this->CDDAStart, this->CDDAEnd, comm[1], comm[2], comm[9]);