Core/FifoPlayer: Avoid global System accessor.
This commit is contained in:
parent
6725c25600
commit
443b4ae745
|
@ -228,8 +228,7 @@ public:
|
||||||
IsPlayingBackFifologWithBrokenEFBCopies = m_parent->m_File->HasBrokenEFBCopies();
|
IsPlayingBackFifologWithBrokenEFBCopies = m_parent->m_File->HasBrokenEFBCopies();
|
||||||
// Without this call, we deadlock in initialization in dual core, as the FIFO is disabled and
|
// Without this call, we deadlock in initialization in dual core, as the FIFO is disabled and
|
||||||
// thus ClearEfb()'s call to WaitForGPUInactive() never returns
|
// thus ClearEfb()'s call to WaitForGPUInactive() never returns
|
||||||
auto& system = Core::System::GetInstance();
|
m_parent->m_system.GetCPU().EnableStepping(false);
|
||||||
system.GetCPU().EnableStepping(false);
|
|
||||||
|
|
||||||
m_parent->m_CurrentFrame = m_parent->m_FrameRangeStart;
|
m_parent->m_CurrentFrame = m_parent->m_FrameRangeStart;
|
||||||
m_parent->LoadMemory();
|
m_parent->LoadMemory();
|
||||||
|
@ -251,8 +250,7 @@ public:
|
||||||
const char* GetName() const override { return "FifoPlayer"; }
|
const char* GetName() const override { return "FifoPlayer"; }
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& cpu = m_parent->m_system.GetCPU();
|
||||||
auto& cpu = system.GetCPU();
|
|
||||||
while (cpu.GetState() == CPU::State::Running)
|
while (cpu.GetState() == CPU::State::Running)
|
||||||
{
|
{
|
||||||
switch (m_parent->AdvanceFrame())
|
switch (m_parent->AdvanceFrame())
|
||||||
|
@ -404,9 +402,8 @@ void FifoPlayer::SetFrameRangeEnd(u32 end)
|
||||||
void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo& info)
|
void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo& info)
|
||||||
{
|
{
|
||||||
// Core timing information
|
// Core timing information
|
||||||
auto& system = Core::System::GetInstance();
|
auto& vi = m_system.GetVideoInterface();
|
||||||
auto& vi = system.GetVideoInterface();
|
m_CyclesPerFrame = static_cast<u64>(m_system.GetSystemTimers().GetTicksPerSecond()) *
|
||||||
m_CyclesPerFrame = static_cast<u64>(system.GetSystemTimers().GetTicksPerSecond()) *
|
|
||||||
vi.GetTargetRefreshRateDenominator() / vi.GetTargetRefreshRateNumerator();
|
vi.GetTargetRefreshRateDenominator() / vi.GetTargetRefreshRateNumerator();
|
||||||
m_ElapsedCycles = 0;
|
m_ElapsedCycles = 0;
|
||||||
m_FrameFifoSize = static_cast<u32>(frame.fifoData.size());
|
m_FrameFifoSize = static_cast<u32>(frame.fifoData.size());
|
||||||
|
@ -495,8 +492,7 @@ void FifoPlayer::WriteAllMemoryUpdates()
|
||||||
|
|
||||||
void FifoPlayer::WriteMemory(const MemoryUpdate& memUpdate)
|
void FifoPlayer::WriteMemory(const MemoryUpdate& memUpdate)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& memory = m_system.GetMemory();
|
||||||
auto& memory = system.GetMemory();
|
|
||||||
u8* mem = nullptr;
|
u8* mem = nullptr;
|
||||||
|
|
||||||
if (memUpdate.address & 0x10000000)
|
if (memUpdate.address & 0x10000000)
|
||||||
|
@ -512,11 +508,10 @@ void FifoPlayer::WriteFifo(const u8* data, u32 start, u32 end)
|
||||||
u32 written = start;
|
u32 written = start;
|
||||||
u32 lastBurstEnd = end - 1;
|
u32 lastBurstEnd = end - 1;
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
auto& cpu = m_system.GetCPU();
|
||||||
auto& cpu = system.GetCPU();
|
auto& core_timing = m_system.GetCoreTiming();
|
||||||
auto& core_timing = system.GetCoreTiming();
|
auto& gpfifo = m_system.GetGPFifo();
|
||||||
auto& gpfifo = system.GetGPFifo();
|
auto& ppc_state = m_system.GetPPCState();
|
||||||
auto& ppc_state = system.GetPPCState();
|
|
||||||
|
|
||||||
// Write up to 256 bytes at a time
|
// Write up to 256 bytes at a time
|
||||||
while (written < end)
|
while (written < end)
|
||||||
|
@ -632,8 +627,7 @@ void FifoPlayer::ClearEfb()
|
||||||
|
|
||||||
void FifoPlayer::LoadMemory()
|
void FifoPlayer::LoadMemory()
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& ppc_state = m_system.GetPPCState();
|
||||||
auto& ppc_state = system.GetPPCState();
|
|
||||||
|
|
||||||
UReg_MSR newMSR;
|
UReg_MSR newMSR;
|
||||||
newMSR.DR = 1;
|
newMSR.DR = 1;
|
||||||
|
@ -648,7 +642,7 @@ void FifoPlayer::LoadMemory()
|
||||||
|
|
||||||
PowerPC::MSRUpdated(ppc_state);
|
PowerPC::MSRUpdated(ppc_state);
|
||||||
|
|
||||||
auto& mmu = system.GetMMU();
|
auto& mmu = m_system.GetMMU();
|
||||||
mmu.DBATUpdated();
|
mmu.DBATUpdated();
|
||||||
mmu.IBATUpdated();
|
mmu.IBATUpdated();
|
||||||
|
|
||||||
|
@ -708,18 +702,17 @@ void FifoPlayer::LoadTextureMemory()
|
||||||
|
|
||||||
void FifoPlayer::WriteCP(u32 address, u16 value)
|
void FifoPlayer::WriteCP(u32 address, u16 value)
|
||||||
{
|
{
|
||||||
Core::System::GetInstance().GetMMU().Write_U16(value, 0xCC000000 | address);
|
m_system.GetMMU().Write_U16(value, 0xCC000000 | address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoPlayer::WritePI(u32 address, u32 value)
|
void FifoPlayer::WritePI(u32 address, u32 value)
|
||||||
{
|
{
|
||||||
Core::System::GetInstance().GetMMU().Write_U32(value, 0xCC003000 | address);
|
m_system.GetMMU().Write_U32(value, 0xCC003000 | address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FifoPlayer::FlushWGP()
|
void FifoPlayer::FlushWGP()
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& gpfifo = m_system.GetGPFifo();
|
||||||
auto& gpfifo = system.GetGPFifo();
|
|
||||||
|
|
||||||
// Send 31 0s through the WGP
|
// Send 31 0s through the WGP
|
||||||
for (int i = 0; i < 7; ++i)
|
for (int i = 0; i < 7; ++i)
|
||||||
|
@ -732,9 +725,8 @@ void FifoPlayer::FlushWGP()
|
||||||
|
|
||||||
void FifoPlayer::WaitForGPUInactive()
|
void FifoPlayer::WaitForGPUInactive()
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& core_timing = m_system.GetCoreTiming();
|
||||||
auto& core_timing = system.GetCoreTiming();
|
auto& cpu = m_system.GetCPU();
|
||||||
auto& cpu = system.GetCPU();
|
|
||||||
|
|
||||||
// Sleep while the GPU is active
|
// Sleep while the GPU is active
|
||||||
while (!IsIdleSet() && cpu.GetState() != CPU::State::PowerDown)
|
while (!IsIdleSet() && cpu.GetState() != CPU::State::PowerDown)
|
||||||
|
@ -746,8 +738,7 @@ void FifoPlayer::WaitForGPUInactive()
|
||||||
|
|
||||||
void FifoPlayer::LoadBPReg(u8 reg, u32 value)
|
void FifoPlayer::LoadBPReg(u8 reg, u32 value)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& gpfifo = m_system.GetGPFifo();
|
||||||
auto& gpfifo = system.GetGPFifo();
|
|
||||||
|
|
||||||
gpfifo.Write8(0x61); // load BP reg
|
gpfifo.Write8(0x61); // load BP reg
|
||||||
|
|
||||||
|
@ -758,8 +749,7 @@ void FifoPlayer::LoadBPReg(u8 reg, u32 value)
|
||||||
|
|
||||||
void FifoPlayer::LoadCPReg(u8 reg, u32 value)
|
void FifoPlayer::LoadCPReg(u8 reg, u32 value)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& gpfifo = m_system.GetGPFifo();
|
||||||
auto& gpfifo = system.GetGPFifo();
|
|
||||||
|
|
||||||
gpfifo.Write8(0x08); // load CP reg
|
gpfifo.Write8(0x08); // load CP reg
|
||||||
gpfifo.Write8(reg);
|
gpfifo.Write8(reg);
|
||||||
|
@ -768,8 +758,7 @@ void FifoPlayer::LoadCPReg(u8 reg, u32 value)
|
||||||
|
|
||||||
void FifoPlayer::LoadXFReg(u16 reg, u32 value)
|
void FifoPlayer::LoadXFReg(u16 reg, u32 value)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& gpfifo = m_system.GetGPFifo();
|
||||||
auto& gpfifo = system.GetGPFifo();
|
|
||||||
|
|
||||||
gpfifo.Write8(0x10); // load XF reg
|
gpfifo.Write8(0x10); // load XF reg
|
||||||
gpfifo.Write32((reg & 0x0fff) | 0x1000); // load 4 bytes into reg
|
gpfifo.Write32((reg & 0x0fff) | 0x1000); // load 4 bytes into reg
|
||||||
|
@ -778,8 +767,7 @@ void FifoPlayer::LoadXFReg(u16 reg, u32 value)
|
||||||
|
|
||||||
void FifoPlayer::LoadXFMem16(u16 address, const u32* data)
|
void FifoPlayer::LoadXFMem16(u16 address, const u32* data)
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& gpfifo = m_system.GetGPFifo();
|
||||||
auto& gpfifo = system.GetGPFifo();
|
|
||||||
|
|
||||||
// Loads 16 * 4 bytes in xf memory starting at address
|
// Loads 16 * 4 bytes in xf memory starting at address
|
||||||
gpfifo.Write8(0x10); // load XF reg
|
gpfifo.Write8(0x10); // load XF reg
|
||||||
|
@ -818,13 +806,13 @@ bool FifoPlayer::ShouldLoadXF(u8 reg)
|
||||||
bool FifoPlayer::IsIdleSet() const
|
bool FifoPlayer::IsIdleSet() const
|
||||||
{
|
{
|
||||||
CommandProcessor::UCPStatusReg status =
|
CommandProcessor::UCPStatusReg status =
|
||||||
Core::System::GetInstance().GetMMU().Read_U16(0xCC000000 | CommandProcessor::STATUS_REGISTER);
|
m_system.GetMMU().Read_U16(0xCC000000 | CommandProcessor::STATUS_REGISTER);
|
||||||
return status.CommandIdle;
|
return status.CommandIdle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FifoPlayer::IsHighWatermarkSet() const
|
bool FifoPlayer::IsHighWatermarkSet() const
|
||||||
{
|
{
|
||||||
CommandProcessor::UCPStatusReg status =
|
CommandProcessor::UCPStatusReg status =
|
||||||
Core::System::GetInstance().GetMMU().Read_U16(0xCC000000 | CommandProcessor::STATUS_REGISTER);
|
m_system.GetMMU().Read_U16(0xCC000000 | CommandProcessor::STATUS_REGISTER);
|
||||||
return status.OverflowHiWatermark;
|
return status.OverflowHiWatermark;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class CPUCore;
|
class CPUCore;
|
||||||
|
friend class CPUCore;
|
||||||
|
|
||||||
CPU::State AdvanceFrame();
|
CPU::State AdvanceFrame();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue