HW: stabilize original BootMii interaction
This commit is contained in:
1 parent
5387658e0c
commit
b85667435c
5 files changed
+57
-13
No files matched your search
@@ -320,9 +320,12 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||
return 1 + (vi.m_half_line_count) / 2;
|
||||
}),
|
||||
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
|
||||
WARN_LOG_FMT(
|
||||
VIDEOINTERFACE,
|
||||
"Changing vertical beam position to {:#06x} - not documented or implemented yet", val);
|
||||
auto& vi = system.GetVideoInterface();
|
||||
const u32 total_half_lines = vi.GetHalfLinesPerEvenField() + vi.GetHalfLinesPerOddField();
|
||||
const u32 line = val == 0 ? 0 : static_cast<u32>(val - 1);
|
||||
const u32 target_half_line = line * 2 + (vi.m_half_line_count & 1);
|
||||
vi.m_half_line_count =
|
||||
total_half_lines == 0 ? target_half_line : target_half_line % total_half_lines;
|
||||
}));
|
||||
mmio->Register(
|
||||
base | VI_HORIZONTAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
|
||||
@@ -334,10 +337,20 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||
return std::clamp<u16>(value, 1, vi.m_h_timing_0.HLW * 2);
|
||||
}),
|
||||
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
|
||||
WARN_LOG_FMT(
|
||||
VIDEOINTERFACE,
|
||||
"Changing horizontal beam position to {:#06x} - not documented or implemented yet",
|
||||
val);
|
||||
auto& vi = system.GetVideoInterface();
|
||||
const u32 half_line_width = vi.m_h_timing_0.HLW;
|
||||
if (half_line_width == 0)
|
||||
return;
|
||||
|
||||
const u32 horizontal_position =
|
||||
std::clamp<u32>(val, 1, static_cast<u32>(half_line_width) * 2);
|
||||
const u32 target_half_line = horizontal_position > half_line_width ? 1 : 0;
|
||||
vi.m_half_line_count = (vi.m_half_line_count & ~1u) | target_half_line;
|
||||
|
||||
const u64 ticks_into_line =
|
||||
static_cast<u64>(horizontal_position - 1) * vi.GetTicksPerHalfLine() / half_line_width;
|
||||
const u64 ticks = system.GetCoreTiming().GetTicks();
|
||||
vi.m_ticks_last_line_start = ticks >= ticks_into_line ? ticks - ticks_into_line : 0;
|
||||
}));
|
||||
|
||||
// The following MMIOs are interrupts related and update interrupt status
|
||||
@@ -972,9 +985,10 @@ void VideoInterfaceManager::Update(u64 ticks)
|
||||
// the beginning of a new full-line, update the timer
|
||||
|
||||
++m_half_line_count;
|
||||
if (m_half_line_count == GetHalfLinesPerEvenField() + GetHalfLinesPerOddField())
|
||||
const u32 total_half_lines = GetHalfLinesPerEvenField() + GetHalfLinesPerOddField();
|
||||
if (total_half_lines != 0 && m_half_line_count >= total_half_lines)
|
||||
{
|
||||
m_half_line_count = 0;
|
||||
m_half_line_count %= total_half_lines;
|
||||
}
|
||||
|
||||
if (!(m_half_line_count & 1))
|
||||
|
||||
Reference in new issue
Block a user