From 77e9cb4eaa0085238adc49aff69aa85abe4ef775 Mon Sep 17 00:00:00 2001 From: David Shadoff <46657586+dshadoff@users.noreply.github.com> Date: Sun, 20 Jun 2021 02:57:46 -0400 Subject: [PATCH] PC Engine CDROM timing corrections (#412) 1) Fix for Issue 120 broke timing for cut-scene videos. Restoring delay for SAPSP-type seeks (issue #145) 2) fixes for issues #120 & #145: a) PAUSE placed head just outside of minimum-seektime area -> when playback was restored, it was late, contributing to hangs (i.e. Bomberman Panic Bomber). Increase minimum seektime region, so as to include this case. b) Moved logging printf to AFTER SendStatus on SAPEP transactions; may help reduce hangs (i.e. Bomberman Panic Bomber). 3) Minor adjustment to improve timing on Sherlock Holmes games' video playback. --- support/pcecd/pcecd.cpp | 2 +- support/pcecd/pcecdd.cpp | 10 ++++++++-- support/pcecd/seektime.cpp | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/support/pcecd/pcecd.cpp b/support/pcecd/pcecd.cpp index 4b22b45..de7f55f 100644 --- a/support/pcecd/pcecd.cpp +++ b/support/pcecd/pcecd.cpp @@ -34,7 +34,7 @@ void pcecd_poll() if (--adj <= 0) adj = 3; } - if (pcecdd.has_status ) { + if (pcecdd.has_status && !pcecdd.latency) { pcecdd.SendStatus(pcecdd.GetStatus()); pcecdd.has_status = 0; diff --git a/support/pcecd/pcecdd.cpp b/support/pcecd/pcecdd.cpp index c52d3de..04a3caf 100644 --- a/support/pcecd/pcecdd.cpp +++ b/support/pcecd/pcecdd.cpp @@ -567,6 +567,12 @@ void pcecdd_t::CommandExec() { { this->latency = 0; } + /* Sherlock Holmes streams by fetching 252 sectors at a time, and suffers + * from slight pauses at each seek */ + else if ((this->lba == new_lba) && (cnt_ == 252)) + { + this->latency = 5; + } else if (comm[13] & 0x80) // fast seek (OSD setting) { this->latency = 0; @@ -697,11 +703,11 @@ void pcecdd_t::CommandExec() { this->state = PCECD_STATE_PLAY; } - printf("\x1b[32mPCECD: Command SAPEP, end = %i, [1] = %02X, [2] = %02X, [9] = %02X\n\x1b[0m", this->CDDAEnd, comm[1], comm[2], comm[9]); - if (this->CDDAMode != PCECD_CDDAMODE_INTERRUPT) { SendStatus(MAKE_STATUS(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; diff --git a/support/pcecd/seektime.cpp b/support/pcecd/seektime.cpp index adfe96d..cef316e 100644 --- a/support/pcecd/seektime.cpp +++ b/support/pcecd/seektime.cpp @@ -91,11 +91,11 @@ float get_cd_seek_ms(int start_sector, int target_sector) } // Now, we use the algorithm to determine how long to wait - if (abs(target_sector - start_sector) < 2) + if (abs(target_sector - start_sector) <= 3) { milliseconds = (2 * 1000 / 60); } - else if (abs(target_sector - start_sector) < 5) + else if (abs(target_sector - start_sector) < 7) { milliseconds = (9 * 1000 / 60) + (float)(sector_list[target_index].rotation_ms * 0.75); }