Fix for MiSTer-devel/Main-MiSTer#149 (#430)

Adjustment to head seek timing:
When seeking to audio tracks, there is a delay of between 130ms and 290ms between the status confirmation of completion and the start of audio.  80% of the time this is 220ms +/-20ms  and does not appear to be related to either seek distance or location on disc.

This fix inserts a delay between head seek arrival status confirmation and the start of audio play, without changing the total delay (ie. status is retruned earlier where appropriate).
This fixes Last Alert's excess sound, but may also fix other games' sound.
This was tested against main games which have presented issues with seektime in the past.
This commit is contained in:
David Shadoff
2021-07-19 12:41:34 -04:00
committed by GitHub
parent 62a967bb1f
commit 35639f0fb9
2 changed files with 21 additions and 1 deletions

View File

@@ -65,6 +65,7 @@ class pcecdd_t
{
public:
uint32_t latency;
uint32_t audiodelay;
uint8_t state;
uint8_t isData;
int loaded;

View File

@@ -18,6 +18,7 @@ pcecdd_t pcecdd;
pcecdd_t::pcecdd_t() {
latency = 0;
audiodelay = 0;
loaded = 0;
index = 0;
lba = 0;
@@ -315,6 +316,7 @@ void pcecdd_t::Unload()
void pcecdd_t::Reset() {
latency = 0;
audiodelay = 0;
index = 0;
lba = 0;
scanOffset = 0;
@@ -408,6 +410,12 @@ void pcecdd_t::Update() {
return;
}
if (this->audiodelay > 0)
{
this->audiodelay--;
return;
}
this->index = GetTrackByLBA(this->lba, &this->toc);
DISKLED_ON;
@@ -464,6 +472,7 @@ void pcecdd_t::CommandExec() {
msf_t msf;
int new_lba = 0;
static uint8_t buf[32];
uint32_t temp_latency;
memset(buf, 0, 32);
@@ -580,6 +589,7 @@ void pcecdd_t::CommandExec() {
else
{
this->latency = (int)(get_cd_seek_ms(this->lba, new_lba)/13.33);
this->audiodelay = 0;
}
printf("seek time ticks: %d\n", this->latency);
@@ -641,10 +651,19 @@ void pcecdd_t::CommandExec() {
if (comm[13] & 0x80) // fast seek (OSD setting)
{
this->latency = 0;
this->audiodelay = 0;
}
else
{
this->latency = (int)(get_cd_seek_ms(this->lba, new_lba) / 13.33);
temp_latency = (int)(get_cd_seek_ms(this->lba, new_lba) / 13.33);
this->audiodelay = (int)(220 / 13.33);
if (temp_latency > this->audiodelay)
this->latency = temp_latency - this->audiodelay;
else {
this->latency = temp_latency;
this->audiodelay = 0;
}
}
printf("seek time ticks: %d\n", this->latency);