Skip to content

Commit

Permalink
VideoInterface: Cleanup and minor fix in Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-woyak committed Mar 4, 2025
1 parent 3c5da38 commit b23850f
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions Source/Core/Core/HW/VideoInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,42 +848,48 @@ void VideoInterfaceManager::EndField(FieldType field, u64 ticks)
// Run when: When a frame is scanned (progressive/interlace)
void VideoInterfaceManager::Update(u64 ticks)
{
constexpr u32 odd_field_begin = 0;
const u32 even_field_begin = GetHalfLinesPerOddField();

const bool is_at_field_boundary =
m_half_line_count == odd_field_begin || m_half_line_count == even_field_begin;

// Movie's frame counter should be updated before actually rendering the frame,
// in case frame counter display is enabled

if (m_half_line_count == 0 || m_half_line_count == GetHalfLinesPerEvenField())
if (is_at_field_boundary)
m_system.GetMovie().FrameUpdate();

// If this half-line is at some boundary of the "active video lines" in either field, we either
// need to (a) send a request to the GPU thread to actually render the XFB, or (b) increment
// the number of frames we've actually drawn

if (m_half_line_count == m_even_field_first_hl)
{
BeginField(FieldType::Even, ticks);
}
else if (m_half_line_count == m_odd_field_first_hl)
if (m_half_line_count == m_odd_field_first_hl)
{
BeginField(FieldType::Odd, ticks);
}
else if (m_half_line_count == m_even_field_last_hl)
else if (m_half_line_count == m_even_field_first_hl)
{
EndField(FieldType::Even, ticks);
BeginField(FieldType::Even, ticks);
}
else if (m_half_line_count == m_odd_field_last_hl)
{
EndField(FieldType::Odd, ticks);
}
else if (m_half_line_count == m_even_field_last_hl)
{
EndField(FieldType::Even, ticks);
}

// If this half-line is at a field boundary, deal with frame stepping before potentially
// dealing with SI polls, but after potentially sending a swap request to the GPU thread

if (m_half_line_count == 0 || m_half_line_count == GetHalfLinesPerEvenField())
if (is_at_field_boundary)
Core::Callback_NewField(m_system);

// If an SI poll is scheduled to happen on this half-line, do it!

if (m_half_line_of_next_si_poll == m_half_line_count)
if (m_half_line_count == m_half_line_of_next_si_poll)
{
Core::UpdateInputGate(!Config::Get(Config::MAIN_INPUT_BACKGROUND_INPUT),
Config::Get(Config::MAIN_LOCK_CURSOR));
Expand All @@ -895,19 +901,16 @@ void VideoInterfaceManager::Update(u64 ticks)
// If this half-line is at the actual boundary of either field, schedule an SI poll to happen
// some number of half-lines in the future

if (m_half_line_count == 0)
{
m_half_line_of_next_si_poll = NUM_HALF_LINES_FOR_SI_POLL; // first results start at vsync
}
if (m_half_line_count == GetHalfLinesPerEvenField())
if (is_at_field_boundary)
{
m_half_line_of_next_si_poll = GetHalfLinesPerEvenField() + NUM_HALF_LINES_FOR_SI_POLL;
// first results start at vsync
m_half_line_of_next_si_poll = m_half_line_count + NUM_HALF_LINES_FOR_SI_POLL;
}

// Move to the next half-line and potentially roll-over the count to zero. If we've reached
// the beginning of a new full-line, update the timer

m_half_line_count++;
++m_half_line_count;
if (m_half_line_count == GetHalfLinesPerEvenField() + GetHalfLinesPerOddField())
{
m_half_line_count = 0;
Expand Down

0 comments on commit b23850f

Please sign in to comment.