From 194e355c784ab2ec42d35875feceb978dd719dd1 Mon Sep 17 00:00:00 2001 From: Sergey Dvodnenko Date: Thu, 7 May 2020 13:39:34 +0300 Subject: [PATCH 1/2] pcecd: implement undefined commands (Steam-Heart's) and cdda pause state, cleanup --- support/pcecd/pcecdd.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/support/pcecd/pcecdd.cpp b/support/pcecd/pcecdd.cpp index 9b11c08..2d1b78c 100644 --- a/support/pcecd/pcecdd.cpp +++ b/support/pcecd/pcecdd.cpp @@ -16,7 +16,7 @@ float get_cd_seek_ms(int start_sector, int target_sector); pcecdd_t pcecdd; pcecdd_t::pcecdd_t() { - latency = 10; + latency = 0; loaded = 0; index = 0; lba = 0; @@ -284,7 +284,7 @@ void pcecdd_t::Unload() } void pcecdd_t::Reset() { - latency = 10; + latency = 0; index = 0; lba = 0; scanOffset = 0; @@ -411,7 +411,14 @@ void pcecdd_t::Update() { this->state = PCECD_STATE_IDLE; } } - + } + else if (this->state == PCECD_STATE_PAUSE) + { + if (this->latency > 0) + { + this->latency--; + return; + } } } @@ -515,10 +522,10 @@ void pcecdd_t::CommandExec() { int index = GetTrackByLBA(new_lba, &this->toc); this->index = index; - if (new_lba < this->toc.tracks[index].start) + /*if (new_lba < this->toc.tracks[index].start) { new_lba = this->toc.tracks[index].start; - } + }*/ this->latency = (int)(get_cd_seek_ms(this->lba, new_lba)/13.33); printf("seek time ticks: %d\n", this->latency); @@ -534,8 +541,6 @@ void pcecdd_t::CommandExec() { this->audioOffset = 0; - //if (this->toc.sub) fseek(this->toc.sub, lba_ * 96, SEEK_SET); - this->can_read_next = true; this->state = PCECD_STATE_READ; @@ -691,7 +696,8 @@ void pcecdd_t::CommandExec() { break; default: - //stat[0] = this->status; + CommandError(SENSEKEY_ILLEGAL_REQUEST, NSE_INVALID_COMMAND, 0, 0); + PendStatus(PCECD_STATUS_CHECK_COND, 0); printf("\x1b[32mPCECD: Command undefined, [0] = %02X, [1] = %02X, [2] = %02X, [3] = %02X, [4] = %02X, [5] = %02X\n\x1b[0m", comm[0], comm[1], comm[2], comm[3], comm[4], comm[5]); break; From d94fbe0f9286f8e9c240ef0bbaf4803c0cc1d4d2 Mon Sep 17 00:00:00 2001 From: Sergey Dvodnenko Date: Thu, 7 May 2020 15:52:17 +0300 Subject: [PATCH 2/2] pcecd: fix status sending in SAPEP command --- support/pcecd/pcecdd.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/support/pcecd/pcecdd.cpp b/support/pcecd/pcecdd.cpp index 2d1b78c..a9a19ff 100644 --- a/support/pcecd/pcecdd.cpp +++ b/support/pcecd/pcecdd.cpp @@ -410,6 +410,10 @@ void pcecdd_t::Update() { else { this->state = PCECD_STATE_IDLE; } + + if (this->CDDAMode == PCECD_CDDAMODE_INTERRUPT) { + PendStatus(PCECD_STATUS_GOOD, 0); + } } } else if (this->state == PCECD_STATE_PAUSE) @@ -641,7 +645,7 @@ void pcecdd_t::CommandExec() { int track = U8(comm[2]); if (!track) track = 1; - new_lba = (track >= toc.last) ? this->toc.end : (this->toc.tracks[track - 1].start + 150); + new_lba = (track >= toc.last) ? this->toc.end : (this->toc.tracks[track - 1].start); } break; } @@ -653,7 +657,9 @@ void pcecdd_t::CommandExec() { this->state = PCECD_STATE_PLAY; } - PendStatus(PCECD_STATUS_GOOD, 0); + if (this->CDDAMode != PCECD_CDDAMODE_INTERRUPT) { + PendStatus(PCECD_STATUS_GOOD, 0); + } } printf("\x1b[32mPCECD: Command SAPEP, end = %i, [1] = %02X, [2] = %02X, [9] = %02X\n\x1b[0m", this->CDDAEnd, comm[1], comm[2], comm[9]); break;