diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 5ee88c34d..72c7142de 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -294,7 +294,7 @@ static_assert(sizeof(XA_ADPCMBlockHeader) == 1, "XA-ADPCM block header is one by } // namespace -static TickCount SoftReset(TickCount ticks_late); +static TickCount SoftReset(); static const CDImage::SubChannelQ& GetSectorSubQ(u32 lba, const CDImage::SubChannelQ& real_subq); static bool CanReadMedia(); @@ -315,7 +315,7 @@ static s16 SaturateVolume(s32 volume); static void SetInterrupt(Interrupt interrupt); static void SetAsyncInterrupt(Interrupt interrupt); static void ClearAsyncInterrupt(); -static void DeliverAsyncInterrupt(void*, TickCount ticks, TickCount ticks_late); +static void DeliverAsyncInterrupt(void*, TickCount ticks); static void QueueDeliverAsyncInterrupt(); static void SendACKAndStat(); static void SendErrorResponse(u8 stat_bits = STAT_ERROR, u8 reason = ERROR_REASON_NOT_READY); @@ -340,18 +340,18 @@ static bool CompleteSeek(); static void BeginCommand(Command command); // also update status register static void EndCommand(); // also updates status register -static void ExecuteCommand(void*, TickCount ticks, TickCount ticks_late); +static void ExecuteCommand(void*, TickCount ticks); static void ExecuteTestCommand(u8 subcommand); -static void ExecuteCommandSecondResponse(void*, TickCount ticks, TickCount ticks_late); +static void ExecuteCommandSecondResponse(void*, TickCount ticks); static void QueueCommandSecondResponse(Command command, TickCount ticks); static void ClearCommandSecondResponse(); static void UpdateCommandEvent(); -static void ExecuteDrive(void*, TickCount ticks, TickCount ticks_late); +static void ExecuteDrive(void*, TickCount ticks); static void ClearDriveState(); -static void BeginReading(TickCount ticks_late = 0, bool after_seek = false); -static void BeginPlaying(u8 track, TickCount ticks_late = 0, bool after_seek = false); -static void DoShellOpenComplete(TickCount ticks_late); -static void DoSeekComplete(TickCount ticks_late); +static void BeginReading(bool after_seek); +static void BeginPlaying(u8 track, bool after_seek); +static void DoShellOpenComplete(); +static void DoSeekComplete(); static void DoStatSecondResponse(); static void DoChangeSessionComplete(); static void DoSpinUpComplete(); @@ -631,7 +631,7 @@ void CDROM::Reset() SetHoldPosition(0, 0); } -TickCount CDROM::SoftReset(TickCount ticks_late) +TickCount CDROM::SoftReset() { const bool was_double_speed = s_state.mode.double_speed; @@ -672,7 +672,7 @@ TickCount CDROM::SoftReset(TickCount ticks_late) const TickCount speed_change_ticks = was_double_speed ? GetTicksForSpeedChange() : 0; const TickCount seek_ticks = (s_state.current_lba != 0) ? GetTicksForSeek(0) : 0; - total_ticks = std::max(speed_change_ticks + seek_ticks, INIT_TICKS) - ticks_late; + total_ticks = std::max(speed_change_ticks + seek_ticks, INIT_TICKS); DEV_LOG("CDROM init total disc ticks = {} (speed change = {}, seek = {})", total_ticks, speed_change_ticks, seek_ticks); @@ -693,7 +693,7 @@ TickCount CDROM::SoftReset(TickCount ticks_late) } else { - total_ticks = INIT_TICKS - ticks_late; + total_ticks = INIT_TICKS; } return total_ticks; @@ -1416,7 +1416,7 @@ void CDROM::QueueDeliverAsyncInterrupt() const u32 diff = static_cast(System::GetGlobalTickCounter() - s_state.last_interrupt_time); if (diff >= MINIMUM_INTERRUPT_DELAY) { - DeliverAsyncInterrupt(nullptr, 0, 0); + DeliverAsyncInterrupt(nullptr, 0); } else { @@ -1426,7 +1426,7 @@ void CDROM::QueueDeliverAsyncInterrupt() } } -void CDROM::DeliverAsyncInterrupt(void*, TickCount ticks, TickCount ticks_late) +void CDROM::DeliverAsyncInterrupt(void*, TickCount ticks) { if (HasPendingInterrupt()) { @@ -1832,7 +1832,7 @@ void CDROM::EndCommand() UpdateStatusRegister(); } -void CDROM::ExecuteCommand(void*, TickCount ticks, TickCount ticks_late) +void CDROM::ExecuteCommand(void*, TickCount ticks) { const CommandInfo& ci = s_command_info[static_cast(s_state.command)]; if (s_state.param_fifo.GetSize() < ci.min_parameters || s_state.param_fifo.GetSize() > ci.max_parameters) [[unlikely]] @@ -2084,7 +2084,7 @@ void CDROM::ExecuteCommand(void*, TickCount ticks, TickCount ticks_late) } else { - BeginReading(); + BeginReading(false); } } @@ -2114,7 +2114,7 @@ void CDROM::ExecuteCommand(void*, TickCount ticks, TickCount ticks_late) } else { - BeginPlaying(track); + BeginPlaying(track, false); } } @@ -2252,7 +2252,7 @@ void CDROM::ExecuteCommand(void*, TickCount ticks, TickCount ticks_late) DEV_COLOR_LOG(StrongOrange, "Init"); SendACKAndStat(); - const TickCount reset_ticks = SoftReset(ticks_late); + const TickCount reset_ticks = SoftReset(); QueueCommandSecondResponse(Command::Init, reset_ticks); EndCommand(); return; @@ -2602,7 +2602,7 @@ void CDROM::ExecuteTestCommand(u8 subcommand) } } -void CDROM::ExecuteCommandSecondResponse(void*, TickCount ticks, TickCount ticks_late) +void CDROM::ExecuteCommandSecondResponse(void*, TickCount ticks) { switch (s_state.command_second_response) { @@ -2681,17 +2681,17 @@ void CDROM::UpdateCommandEvent() } } -void CDROM::ExecuteDrive(void*, TickCount ticks, TickCount ticks_late) +void CDROM::ExecuteDrive(void*, TickCount ticks) { switch (s_state.drive_state) { case DriveState::ShellOpening: - DoShellOpenComplete(ticks_late); + DoShellOpenComplete(); break; case DriveState::SeekingPhysical: case DriveState::SeekingLogical: - DoSeekComplete(ticks_late); + DoSeekComplete(); break; case DriveState::SeekingImplicit: @@ -2759,7 +2759,7 @@ void CDROM::ClearDriveState() s_state.drive_event.Deactivate(); } -void CDROM::BeginReading(TickCount ticks_late /* = 0 */, bool after_seek /* = false */) +void CDROM::BeginReading(bool after_seek) { if (!after_seek && s_state.setloc_pending) { @@ -2786,7 +2786,7 @@ void CDROM::BeginReading(TickCount ticks_late /* = 0 */, bool after_seek /* = fa DEBUG_LOG("Starting reading @ LBA {}", s_state.current_lba); const TickCount ticks = GetTicksForRead(); - const TickCount first_sector_ticks = ticks + (after_seek ? 0 : GetTicksForSeek(s_state.current_lba)) - ticks_late; + const TickCount first_sector_ticks = ticks + (after_seek ? 0 : GetTicksForSeek(s_state.current_lba)); ClearCommandSecondResponse(); ClearAsyncInterrupt(); @@ -2808,7 +2808,7 @@ void CDROM::BeginReading(TickCount ticks_late /* = 0 */, bool after_seek /* = fa s_reader.QueueReadSector(s_state.requested_lba); } -void CDROM::BeginPlaying(u8 track, TickCount ticks_late /* = 0 */, bool after_seek /* = false */) +void CDROM::BeginPlaying(u8 track, bool after_seek) { DEBUG_LOG("Starting playing CDDA track {}", track); s_state.play_track_number_bcd = track; @@ -2835,8 +2835,7 @@ void CDROM::BeginPlaying(u8 track, TickCount ticks_late /* = 0 */, bool after_se } const TickCount ticks = GetTicksForRead(); - const TickCount first_sector_ticks = - ticks + (after_seek ? 0 : GetTicksForSeek(s_state.current_lba, true)) - ticks_late; + const TickCount first_sector_ticks = ticks + (after_seek ? 0 : GetTicksForSeek(s_state.current_lba, true)); ClearCommandSecondResponse(); ClearAsyncInterrupt(); @@ -3040,7 +3039,7 @@ void CDROM::EnsureLastSubQValid() s_state.last_subq = subq; } -void CDROM::DoShellOpenComplete(TickCount ticks_late) +void CDROM::DoShellOpenComplete() { // media is now readable (if any) ClearDriveState(); @@ -3125,7 +3124,7 @@ bool CDROM::CompleteSeek() return seek_okay; } -void CDROM::DoSeekComplete(TickCount ticks_late) +void CDROM::DoSeekComplete() { const bool logical = (s_state.drive_state == DriveState::SeekingLogical); const bool seek_okay = CompleteSeek(); @@ -3139,11 +3138,11 @@ void CDROM::DoSeekComplete(TickCount ticks_late) // INT2 is not sent on play/read if (s_state.read_after_seek) { - BeginReading(ticks_late, true); + BeginReading(true); } else if (s_state.play_after_seek) { - BeginPlaying(0, ticks_late, true); + BeginPlaying(0, true); } else { diff --git a/src/core/dma.cpp b/src/core/dma.cpp index 55d0f1afb..22e2d3188 100644 --- a/src/core/dma.cpp +++ b/src/core/dma.cpp @@ -179,7 +179,7 @@ static bool IsTransferHalted(); static void UpdateIRQ(); static void HaltTransfer(TickCount duration); -static void UnhaltTransfer(void*, TickCount ticks, TickCount ticks_late); +static void UnhaltTransfer(void*, TickCount ticks); template static bool TransferChannel(); @@ -760,9 +760,9 @@ void DMA::HaltTransfer(TickCount duration) s_state.unhalt_event.SetIntervalAndSchedule(s_state.halt_ticks_remaining); } -void DMA::UnhaltTransfer(void*, TickCount ticks, TickCount ticks_late) +void DMA::UnhaltTransfer(void*, TickCount ticks) { - DEBUG_LOG("Resuming DMA after {} ticks, {} ticks late", ticks, -(s_state.halt_ticks_remaining - ticks)); + DEBUG_LOG("Resuming DMA after {} ticks", ticks, -(s_state.halt_ticks_remaining - ticks)); s_state.halt_ticks_remaining -= ticks; s_state.unhalt_event.Deactivate(); diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 58b398a9a..ac44da6fc 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -62,14 +62,12 @@ u16 g_gpu_clut[GPU_CLUT_SIZE]; const GPU::GP0CommandHandlerTable GPU::s_GP0_command_handler_table = GPU::GenerateGP0CommandHandlerTable(); -static TimingEvent s_crtc_tick_event( - "GPU CRTC Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.CRTCTickEvent(ticks); }, - nullptr); +static TimingEvent + s_crtc_tick_event("GPU CRTC Tick", 1, 1, [](void* param, TickCount ticks) { g_gpu.CRTCTickEvent(ticks); }, nullptr); static TimingEvent s_command_tick_event( - "GPU Command Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.CommandTickEvent(ticks); }, - nullptr); -static TimingEvent s_frame_done_event( - "Frame Done", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.FrameDoneEvent(ticks); }, nullptr); + "GPU Command Tick", 1, 1, [](void* param, TickCount ticks) { g_gpu.CommandTickEvent(ticks); }, nullptr); +static TimingEvent + s_frame_done_event("Frame Done", 1, 1, [](void* param, TickCount ticks) { g_gpu.FrameDoneEvent(ticks); }, nullptr); GPU::GPU() = default; diff --git a/src/core/justifier.cpp b/src/core/justifier.cpp index e1b412d53..2f1a9d911 100644 --- a/src/core/justifier.cpp +++ b/src/core/justifier.cpp @@ -34,9 +34,9 @@ static constexpr std::array s_event_ "Justifier IRQ P5", "Justifier IRQ P6", "Justifier IRQ P7"}}; Justifier::Justifier(u32 index) - : Controller(index), m_irq_event( - s_event_names[index], 1, 1, - [](void* param, TickCount, TickCount) { static_cast(param)->IRQEvent(); }, this) + : Controller(index), + m_irq_event( + s_event_names[index], 1, 1, [](void* param, TickCount) { static_cast(param)->IRQEvent(); }, this) { } diff --git a/src/core/mdec.cpp b/src/core/mdec.cpp index 4e9f77888..258080e50 100644 --- a/src/core/mdec.cpp +++ b/src/core/mdec.cpp @@ -113,7 +113,7 @@ static void SetScaleMatrix(const u16* values); static bool DecodeMonoMacroblock(); static bool DecodeColoredMacroblock(); static void ScheduleBlockCopyOut(TickCount ticks); -static void CopyOutBlock(void* param, TickCount ticks, TickCount ticks_late); +static void CopyOutBlock(void* param, TickCount ticks); static bool DecodeRLE_Old(s16* blk, const u8* qt); static void IDCT_Old(s16* blk); @@ -650,7 +650,7 @@ void MDEC::ScheduleBlockCopyOut(TickCount ticks) s_state.block_copy_out_event.SetIntervalAndSchedule(ticks); } -void MDEC::CopyOutBlock(void* param, TickCount ticks, TickCount ticks_late) +void MDEC::CopyOutBlock(void* param, TickCount ticks) { Assert(s_state.state == State::WritingMacroblock); s_state.block_copy_out_event.Deactivate(); diff --git a/src/core/memory_card.cpp b/src/core/memory_card.cpp index 39a2b451b..97212e727 100644 --- a/src/core/memory_card.cpp +++ b/src/core/memory_card.cpp @@ -35,8 +35,7 @@ static constexpr std::array s_e MemoryCard::MemoryCard(u32 index) : m_save_event( s_event_names[index], GetSaveDelayInTicks(), GetSaveDelayInTicks(), - [](void* param, TickCount ticks, TickCount ticks_late) { static_cast(param)->SaveIfChanged(true); }, - this), + [](void* param, TickCount ticks) { static_cast(param)->SaveIfChanged(true); }, this), m_index(index) { m_FLAG.no_write_yet = true; diff --git a/src/core/pad.cpp b/src/core/pad.cpp index 146023f7a..fd6db47d8 100644 --- a/src/core/pad.cpp +++ b/src/core/pad.cpp @@ -101,9 +101,9 @@ static constexpr TickCount GetACKTicks(bool memory_card) static void SoftReset(); static void UpdateJoyStat(); -static void TransferEvent(void*, TickCount ticks, TickCount ticks_late); +static void TransferEvent(void*, TickCount ticks); static void BeginTransfer(); -static void DoTransfer(TickCount ticks_late); +static void DoTransfer(); static void DoACK(); static void EndTransfer(); static void ResetDeviceTransferState(); @@ -707,10 +707,10 @@ void Pad::UpdateJoyStat() s_state.JOY_STAT.TXRDY = !s_state.transmit_buffer_full; } -void Pad::TransferEvent(void*, TickCount ticks, TickCount ticks_late) +void Pad::TransferEvent(void*, TickCount ticks) { if (s_state.state == State::Transmitting) - DoTransfer(ticks_late); + DoTransfer(); else DoACK(); } @@ -743,7 +743,7 @@ void Pad::BeginTransfer() s_state.transfer_event.SetPeriodAndSchedule(GetTransferTicks()); } -void Pad::DoTransfer(TickCount ticks_late) +void Pad::DoTransfer() { DEBUG_LOG("Transferring slot {}", s_state.JOY_CTRL.SLOT.GetValue()); diff --git a/src/core/spu.cpp b/src/core/spu.cpp index 8fb3e5a8a..84dc70036 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -356,12 +356,12 @@ static void ReverbWrite(u32 address, s16 data); static void ProcessReverb(s32 left_in, s32 right_in, s32* left_out, s32* right_out); static void InternalGeneratePendingSamples(); -static void Execute(void* param, TickCount ticks, TickCount ticks_late); +static void Execute(void* param, TickCount ticks); static void UpdateEventInterval(); static void ExecuteFIFOWriteToRAM(TickCount& ticks); static void ExecuteFIFOReadFromRAM(TickCount& ticks); -static void ExecuteTransfer(void* param, TickCount ticks, TickCount ticks_late); +static void ExecuteTransfer(void* param, TickCount ticks); static void ManualTransferWrite(u16 value); static void UpdateTransferEvent(); static void UpdateDMARequest(); @@ -1403,7 +1403,7 @@ ALWAYS_INLINE_RELEASE void SPU::ExecuteFIFOWriteToRAM(TickCount& ticks) } } -void SPU::ExecuteTransfer(void* param, TickCount ticks, TickCount ticks_late) +void SPU::ExecuteTransfer(void* param, TickCount ticks) { const RAMTransferMode mode = s_state.SPUCNT.ram_transfer_mode; DebugAssert(mode != RAMTransferMode::Stopped); @@ -1464,7 +1464,7 @@ void SPU::ManualTransferWrite(u16 value) { WARNING_LOG("FIFO not empty on manual SPU write, draining to hopefully avoid corruption. Game is silly."); if (s_state.SPUCNT.ram_transfer_mode != RAMTransferMode::Stopped) - ExecuteTransfer(nullptr, std::numeric_limits::max(), 0); + ExecuteTransfer(nullptr, std::numeric_limits::max()); } std::memcpy(&s_ram[s_state.transfer_address], &value, sizeof(u16)); @@ -2377,7 +2377,7 @@ void SPU::ProcessReverb(s32 left_in, s32 right_in, s32* left_out, s32* right_out #endif } -void SPU::Execute(void* param, TickCount ticks, TickCount ticks_late) +void SPU::Execute(void* param, TickCount ticks) { u32 remaining_frames; if (g_settings.cpu_overclock_active) diff --git a/src/core/timers.cpp b/src/core/timers.cpp index a150c334e..a0f33166a 100644 --- a/src/core/timers.cpp +++ b/src/core/timers.cpp @@ -67,7 +67,7 @@ struct CounterState static void UpdateCountingEnabled(CounterState& cs); static void CheckForIRQ(u32 index, u32 old_counter); -static void AddSysClkTicks(void*, TickCount sysclk_ticks, TickCount ticks_late); +static void AddSysClkTicks(void*, TickCount sysclk_ticks); static TickCount GetTicksUntilNextInterrupt(); static void UpdateSysClkEvent(); @@ -274,7 +274,7 @@ void Timers::CheckForIRQ(u32 timer, u32 old_counter) } } -void Timers::AddSysClkTicks(void*, TickCount sysclk_ticks, TickCount ticks_late) +void Timers::AddSysClkTicks(void*, TickCount sysclk_ticks) { sysclk_ticks = System::UnscaleTicksToOverclock(sysclk_ticks, &s_state.sysclk_ticks_carry); diff --git a/src/core/timing_event.cpp b/src/core/timing_event.cpp index 0a56e89db..bb243f350 100644 --- a/src/core/timing_event.cpp +++ b/src/core/timing_event.cpp @@ -342,9 +342,11 @@ ALWAYS_INLINE_RELEASE void TimingEvents::CommitGlobalTicks(const GlobalTicks new s_state.current_event = event; // Factor late time into the time for the next invocation. - const TickCount ticks_late = static_cast(s_state.global_tick_counter - event->m_next_run_time); const TickCount ticks_to_execute = static_cast(s_state.global_tick_counter - event->m_last_run_time); + // Shouldn't ever be late due to the min() above. + DebugAssert(static_cast(s_state.global_tick_counter - event->m_next_run_time) == 0); + // Why don't we modify event->m_downcount directly? Because otherwise the event list won't be sorted. // Adding the interval may cause this event to have a greater downcount than the next, and a new event // may be inserted at the front, despite having a higher downcount than the next. @@ -352,7 +354,7 @@ ALWAYS_INLINE_RELEASE void TimingEvents::CommitGlobalTicks(const GlobalTicks new event->m_last_run_time = s_state.global_tick_counter; // The cycles_late is only an indicator, it doesn't modify the cycles to execute. - event->m_callback(event->m_callback_param, ticks_to_execute, ticks_late); + event->m_callback(event->m_callback_param, ticks_to_execute); if (event->m_active) { event->m_next_run_time = s_state.current_event_next_run_time; @@ -650,7 +652,7 @@ void TimingEvent::InvokeEarly(bool force /* = false */) if (s_state.active_events_head == this) UpdateCPUDowncount(); - m_callback(m_callback_param, ticks_to_execute, 0); + m_callback(m_callback_param, ticks_to_execute); } void TimingEvent::Activate() diff --git a/src/core/timing_event.h b/src/core/timing_event.h index 778287443..b8e7133b3 100644 --- a/src/core/timing_event.h +++ b/src/core/timing_event.h @@ -10,7 +10,7 @@ class StateWrapper; // Event callback type. Second parameter is the number of cycles the event was executed "late". -using TimingEventCallback = void (*)(void* param, TickCount ticks, TickCount ticks_late); +using TimingEventCallback = void (*)(void* param, TickCount ticks); class TimingEvent {