System: Consider pending ticks when using global ticks

This commit is contained in:
Stenzek
2024-04-07 19:01:48 +10:00
parent 1782151a7a
commit 71f50566f3
4 changed files with 23 additions and 17 deletions

View File

@ -484,7 +484,7 @@ void CDROM::Reset()
s_mode.read_raw_sector = true;
s_interrupt_enable_register = INTERRUPT_REGISTER_MASK;
s_interrupt_flag_register = 0;
s_last_interrupt_time = TimingEvents::GetGlobalTickCounter() - MINIMUM_INTERRUPT_DELAY;
s_last_interrupt_time = System::GetGlobalTickCounter() - MINIMUM_INTERRUPT_DELAY;
ClearAsyncInterrupt();
s_setloc_position = {};
s_seek_start_lba = 0;
@ -605,7 +605,7 @@ bool CDROM::DoState(StateWrapper& sw)
sw.Do(&s_interrupt_enable_register);
sw.Do(&s_interrupt_flag_register);
sw.DoEx(&s_last_interrupt_time, 57, TimingEvents::GetGlobalTickCounter() - MINIMUM_INTERRUPT_DELAY);
sw.DoEx(&s_last_interrupt_time, 57, System::GetGlobalTickCounter() - MINIMUM_INTERRUPT_DELAY);
sw.Do(&s_pending_async_interrupt);
sw.DoPOD(&s_setloc_position);
sw.Do(&s_current_lba);
@ -1097,7 +1097,7 @@ bool CDROM::HasPendingAsyncInterrupt()
void CDROM::SetInterrupt(Interrupt interrupt)
{
s_interrupt_flag_register = static_cast<u8>(interrupt);
s_last_interrupt_time = TimingEvents::GetGlobalTickCounter();
s_last_interrupt_time = System::GetGlobalTickCounter();
UpdateInterruptRequest();
}
@ -1138,7 +1138,7 @@ void CDROM::QueueDeliverAsyncInterrupt()
return;
// underflows here are okay
const u32 diff = TimingEvents::GetGlobalTickCounter() - s_last_interrupt_time;
const u32 diff = System::GetGlobalTickCounter() - s_last_interrupt_time;
if (diff >= MINIMUM_INTERRUPT_DELAY)
{
DeliverAsyncInterrupt(nullptr, 0, 0);
@ -2442,13 +2442,13 @@ void CDROM::UpdatePositionWhileSeeking()
s_current_lba = current_lba;
s_physical_lba = current_lba;
s_physical_lba_update_tick = TimingEvents::GetGlobalTickCounter();
s_physical_lba_update_tick = System::GetGlobalTickCounter();
s_physical_lba_update_carry = 0;
}
void CDROM::UpdatePhysicalPosition(bool update_logical)
{
const u32 ticks = TimingEvents::GetGlobalTickCounter();
const u32 ticks = System::GetGlobalTickCounter();
if (IsSeeking() || IsReadingOrPlaying() || !IsMotorOn())
{
// If we're seeking+reading the first sector (no stat bits set), we need to return the set/current lba, not the last
@ -2539,7 +2539,7 @@ void CDROM::SetHoldPosition(CDImage::LBA lba, bool update_subq)
s_current_lba = lba;
s_physical_lba = lba;
s_physical_lba_update_tick = TimingEvents::GetGlobalTickCounter();
s_physical_lba_update_tick = System::GetGlobalTickCounter();
s_physical_lba_update_carry = 0;
}
@ -2607,7 +2607,7 @@ bool CDROM::CompleteSeek()
}
s_physical_lba = s_current_lba;
s_physical_lba_update_tick = TimingEvents::GetGlobalTickCounter();
s_physical_lba_update_tick = System::GetGlobalTickCounter();
s_physical_lba_update_carry = 0;
return seek_okay;
}
@ -2783,7 +2783,7 @@ void CDROM::DoSectorRead()
s_current_lba = s_reader.GetLastReadSector();
s_physical_lba = s_current_lba;
s_physical_lba_update_tick = TimingEvents::GetGlobalTickCounter();
s_physical_lba_update_tick = System::GetGlobalTickCounter();
s_physical_lba_update_carry = 0;
s_secondary_status.SetReadingBits(s_drive_state == DriveState::Playing);