mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
TimingEvents: Don't defer frame done callback
This commit is contained in:
parent
55bcf7261f
commit
fefcfc906d
|
@ -2019,9 +2019,7 @@ bool CPU::UpdateDebugDispatcherFlag()
|
|||
void CPU::ExitExecution()
|
||||
{
|
||||
// can't exit while running events without messing things up
|
||||
if (TimingEvents::IsRunningEvents())
|
||||
TimingEvents::SetFrameDone();
|
||||
else
|
||||
DebugAssert(!TimingEvents::IsRunningEvents());
|
||||
fastjmp_jmp(&s_jmp_buf, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -977,6 +977,7 @@ void GPU::CRTCTickEvent(TickCount ticks)
|
|||
Timers::AddTicks(HBLANK_TIMER_INDEX, static_cast<TickCount>(hblank_timer_ticks));
|
||||
}
|
||||
|
||||
bool frame_done = false;
|
||||
while (lines_to_draw > 0)
|
||||
{
|
||||
const u32 lines_to_draw_this_loop =
|
||||
|
@ -1007,7 +1008,7 @@ void GPU::CRTCTickEvent(TickCount ticks)
|
|||
// TODO: move present in here I guess
|
||||
FlushRender();
|
||||
UpdateDisplay();
|
||||
TimingEvents::SetFrameDone();
|
||||
frame_done = true;
|
||||
|
||||
// switch fields early. this is needed so we draw to the correct one.
|
||||
if (m_GPUSTAT.InInterleaved480iMode())
|
||||
|
@ -1068,6 +1069,9 @@ void GPU::CRTCTickEvent(TickCount ticks)
|
|||
}
|
||||
|
||||
UpdateCRTCTickEvent();
|
||||
|
||||
if (frame_done)
|
||||
System::FrameDone();
|
||||
}
|
||||
|
||||
void GPU::CommandTickEvent(TickCount ticks)
|
||||
|
|
|
@ -203,6 +203,9 @@ static u32 CompressAndWriteStateData(std::FILE* fp, std::span<const u8> src, Sav
|
|||
u32* header_type, Error* error);
|
||||
static bool DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_display, bool is_memory_state);
|
||||
|
||||
static bool IsExecutionInterrupted();
|
||||
static void ExitExecution();
|
||||
|
||||
static void SetRewinding(bool enabled);
|
||||
static bool SaveRewindState();
|
||||
static void DoRewind();
|
||||
|
@ -559,6 +562,12 @@ bool System::IsExecutionInterrupted()
|
|||
return s_state != State::Running || s_system_interrupted;
|
||||
}
|
||||
|
||||
void System::ExitExecution()
|
||||
{
|
||||
TimingEvents::CancelRunningEvent();
|
||||
CPU::ExitExecution();
|
||||
}
|
||||
|
||||
bool System::IsPaused()
|
||||
{
|
||||
return s_state == State::Paused;
|
||||
|
@ -2043,7 +2052,7 @@ void System::FrameDone()
|
|||
if (IsExecutionInterrupted())
|
||||
{
|
||||
s_system_interrupted = false;
|
||||
CPU::ExitExecution();
|
||||
ExitExecution();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2154,7 +2163,7 @@ void System::FrameDone()
|
|||
if (IsExecutionInterrupted())
|
||||
{
|
||||
s_system_interrupted = false;
|
||||
CPU::ExitExecution();
|
||||
ExitExecution();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,6 @@ std::string GetInputProfilePath(std::string_view name);
|
|||
State GetState();
|
||||
void SetState(State new_state);
|
||||
bool IsRunning();
|
||||
bool IsExecutionInterrupted();
|
||||
bool IsPaused();
|
||||
bool IsShutdown();
|
||||
bool IsValid();
|
||||
|
|
|
@ -32,7 +32,6 @@ struct TimingEventsState
|
|||
TimingEvent* active_events_tail = nullptr;
|
||||
TimingEvent* current_event = nullptr;
|
||||
u32 active_event_count = 0;
|
||||
bool frame_done = false;
|
||||
GlobalTicks current_event_next_run_time = 0;
|
||||
GlobalTicks global_tick_counter = 0;
|
||||
GlobalTicks event_run_tick_counter = 0;
|
||||
|
@ -305,20 +304,19 @@ bool TimingEvents::IsRunningEvents()
|
|||
return (s_state.current_event != nullptr);
|
||||
}
|
||||
|
||||
void TimingEvents::SetFrameDone()
|
||||
{
|
||||
s_state.frame_done = true;
|
||||
CPU::g_state.downcount = 0;
|
||||
}
|
||||
|
||||
void TimingEvents::CancelRunningEvent()
|
||||
{
|
||||
if (!s_state.current_event)
|
||||
TimingEvent* const event = s_state.current_event;
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
// Might need to sort it, since we're bailing out.
|
||||
if (s_state.current_event->IsActive())
|
||||
SortEvent(s_state.current_event);
|
||||
if (event->IsActive())
|
||||
{
|
||||
event->m_next_run_time = s_state.current_event_next_run_time;
|
||||
SortEvent(event);
|
||||
}
|
||||
|
||||
s_state.current_event = nullptr;
|
||||
}
|
||||
|
||||
|
@ -375,12 +373,6 @@ void TimingEvents::RunEvents()
|
|||
CommitGlobalTicks(new_global_ticks);
|
||||
}
|
||||
|
||||
if (s_state.frame_done)
|
||||
{
|
||||
s_state.frame_done = false;
|
||||
System::FrameDone();
|
||||
}
|
||||
|
||||
if (CPU::HasPendingInterrupt())
|
||||
CPU::DispatchInterrupt();
|
||||
|
||||
|
|
|
@ -86,7 +86,6 @@ void Shutdown();
|
|||
bool DoState(StateWrapper& sw);
|
||||
|
||||
bool IsRunningEvents();
|
||||
void SetFrameDone();
|
||||
void CancelRunningEvent();
|
||||
void RunEvents();
|
||||
void CommitLeftoverTicks();
|
||||
|
|
Loading…
Reference in a new issue