Skip to content

Commit

Permalink
HW/VideoInterface: Refactor to class.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiralCurtiss committed Mar 11, 2023
1 parent 2102e64 commit 069280d
Show file tree
Hide file tree
Showing 13 changed files with 461 additions and 474 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/Boot/Boot.cpp
Expand Up @@ -496,8 +496,8 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
}

// PAL Wii uses NTSC framerate and linecount in 60Hz modes
VideoInterface::Preset(DiscIO::IsNTSC(config.m_region) ||
(config.bWii && Config::Get(Config::SYSCONF_PAL60)));
system.GetVideoInterface().Preset(DiscIO::IsNTSC(config.m_region) ||
(config.bWii && Config::Get(Config::SYSCONF_PAL60)));

struct BootTitle
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/FifoPlayer/FifoPlayer.cpp
Expand Up @@ -414,9 +414,9 @@ FifoPlayer& FifoPlayer::GetInstance()
void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo& info)
{
// Core timing information
auto& vi = Core::System::GetInstance().GetVideoInterface();
m_CyclesPerFrame = static_cast<u64>(SystemTimers::GetTicksPerSecond()) *
VideoInterface::GetTargetRefreshRateDenominator() /
VideoInterface::GetTargetRefreshRateNumerator();
vi.GetTargetRefreshRateDenominator() / vi.GetTargetRefreshRateNumerator();
m_ElapsedCycles = 0;
m_FrameFifoSize = static_cast<u32>(frame.fifoData.size());

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/HW.cpp
Expand Up @@ -41,7 +41,7 @@ void Init(const Sram* override_sram)

// Init the whole Hardware
system.GetAudioInterface().Init();
VideoInterface::Init();
system.GetVideoInterface().Init();
SerialInterface::Init();
system.GetProcessorInterface().Init();
system.GetExpansionInterface().Init(override_sram); // Needs to be initialized before Memory
Expand Down Expand Up @@ -93,7 +93,7 @@ void DoState(PointerWrap& p)
p.DoMarker("Memory");
system.GetMemoryInterface().DoState(p);
p.DoMarker("MemoryInterface");
VideoInterface::DoState(p);
system.GetVideoInterface().DoState(p);
p.DoMarker("VideoInterface");
SerialInterface::DoState(p);
p.DoMarker("SerialInterface");
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/Memmap.cpp
Expand Up @@ -51,7 +51,7 @@ void MemoryManager::InitMMIO(bool is_wii)
auto& system = Core::System::GetInstance();
system.GetCommandProcessor().RegisterMMIO(system, m_mmio_mapping.get(), 0x0C000000);
system.GetPixelEngine().RegisterMMIO(m_mmio_mapping.get(), 0x0C001000);
VideoInterface::RegisterMMIO(m_mmio_mapping.get(), 0x0C002000);
system.GetVideoInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C002000);
system.GetProcessorInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C003000);
system.GetMemoryInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C004000);
system.GetDSP().RegisterMMIO(m_mmio_mapping.get(), 0x0C005000);
Expand Down
12 changes: 7 additions & 5 deletions Source/Core/Core/HW/SystemTimers.cpp
Expand Up @@ -149,8 +149,9 @@ void PerfTrackerCallback(Core::System& system, u64 userdata, s64 cyclesLate)
void VICallback(Core::System& system, u64 userdata, s64 cyclesLate)
{
auto& core_timing = system.GetCoreTiming();
VideoInterface::Update(core_timing.GetTicks() - cyclesLate);
core_timing.ScheduleEvent(VideoInterface::GetTicksPerHalfLine() - cyclesLate, et_VI);
auto& vi = system.GetVideoInterface();
vi.Update(core_timing.GetTicks() - cyclesLate);
core_timing.ScheduleEvent(vi.GetTicksPerHalfLine() - cyclesLate, et_VI);
}

void DecrementerCallback(Core::System& system, u64 userdata, s64 cyclesLate)
Expand All @@ -164,7 +165,7 @@ void PatchEngineCallback(Core::System& system, u64 userdata, s64 cycles_late)
{
// We have 2 periods, a 1000 cycle error period and the VI period.
// We have to carefully combine these together so that we stay on the VI period without drifting.
u32 vi_interval = VideoInterface::GetTicksPerField();
u32 vi_interval = system.GetVideoInterface().GetTicksPerField();
s64 cycles_pruned = (userdata + cycles_late) % vi_interval;
s64 next_schedule = 0;

Expand Down Expand Up @@ -282,6 +283,7 @@ void Init()

auto& system = Core::System::GetInstance();
auto& core_timing = system.GetCoreTiming();
auto& vi = system.GetVideoInterface();

core_timing.SetFakeTBStartValue(static_cast<u64>(s_cpu_core_clock / TIMER_RATIO) *
static_cast<u64>(ExpansionInterface::CEXIIPL::GetEmulatedTime(
Expand All @@ -303,11 +305,11 @@ void Init()

core_timing.ScheduleEvent(0, et_perf_tracker);
core_timing.ScheduleEvent(0, et_GPU_sleeper);
core_timing.ScheduleEvent(VideoInterface::GetTicksPerHalfLine(), et_VI);
core_timing.ScheduleEvent(vi.GetTicksPerHalfLine(), et_VI);
core_timing.ScheduleEvent(0, et_DSP);
core_timing.ScheduleEvent(GetAudioDMACallbackPeriod(), et_AudioDMA);

core_timing.ScheduleEvent(VideoInterface::GetTicksPerField(), et_PatchEngine);
core_timing.ScheduleEvent(vi.GetTicksPerField(), et_PatchEngine);

if (SConfig::GetInstance().bWii)
core_timing.ScheduleEvent(s_ipc_hle_period, et_IPC_HLE);
Expand Down

0 comments on commit 069280d

Please sign in to comment.