diff --git a/Source/Core/Common/Src/VideoBackendBase.h b/Source/Core/Common/Src/VideoBackendBase.h index 2d2b71b79d..798750ca73 100644 --- a/Source/Core/Common/Src/VideoBackendBase.h +++ b/Source/Core/Common/Src/VideoBackendBase.h @@ -72,6 +72,7 @@ struct SCPFifoStruct // for GP watchdog hack volatile u32 Fake_GPWDToken; // cicular incrementer + volatile u32 isFifoProcesingData; }; class VideoBackend diff --git a/Source/Core/Core/Src/HW/ProcessorInterface.cpp b/Source/Core/Core/Src/HW/ProcessorInterface.cpp index 4653afb43e..4a18ce63b5 100644 --- a/Source/Core/Core/Src/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/Src/HW/ProcessorInterface.cpp @@ -191,7 +191,7 @@ void Write32(const u32 _uValue, const u32 _iAddress) case PI_FIFO_RESET: //Abort the actual frame - g_video_backend->Video_AbortFrame(); + //g_video_backend->Video_AbortFrame(); //Fifo_CPUWritePointer = Fifo_CPUBase; ?? //PanicAlert("Unknown write to PI_FIFO_RESET (%08x)", _uValue); WARN_LOG(PROCESSORINTERFACE, "Fifo reset (%08x)", _uValue); diff --git a/Source/Core/VideoCommon/Src/CommandProcessor.cpp b/Source/Core/VideoCommon/Src/CommandProcessor.cpp index d2c746c400..4ada117c4b 100644 --- a/Source/Core/VideoCommon/Src/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/Src/CommandProcessor.cpp @@ -474,7 +474,6 @@ void Write16(const u16 _Value, const u32 _Address) fifo.bFF_BPInt = tmpCtrl.BPInt; fifo.bFF_BPEnable = tmpCtrl.BPEnable; - fifo.bFF_GPReadEnable = tmpCtrl.GPReadEnable; fifo.bFF_HiWatermarkInt = tmpCtrl.FifoOverflowIntEnable; fifo.bFF_LoWatermarkInt = tmpCtrl.FifoUnderflowIntEnable; fifo.bFF_GPLinkEnable = tmpCtrl.GPLinkEnable; @@ -489,6 +488,15 @@ void Write16(const u16 _Value, const u32 _Address) if (bProcessFifoToLoWatermark) ProcessFifoToLoWatermark(); + if(fifo.bFF_GPReadEnable && !tmpCtrl.GPReadEnable) + { + fifo.bFF_GPReadEnable = tmpCtrl.GPReadEnable; + while(fifo.isFifoProcesingData) Common::YieldCPU(); + } + else + { + fifo.bFF_GPReadEnable = tmpCtrl.GPReadEnable; + } INFO_LOG(COMMANDPROCESSOR,"\t Write to CTRL_REGISTER : %04x", _Value); DEBUG_LOG(COMMANDPROCESSOR, "\t GPREAD %s | BP %s | Int %s | OvF %s | UndF %s | LINK %s" @@ -613,6 +621,12 @@ void Write16(const u16 _Value, const u32 _Address) break; case FIFO_RW_DISTANCE_LO: WriteLow((u32 &)fifo.CPReadWriteDistance, _Value & 0xFFE0); + if (fifo.CPReadWriteDistance == 0) + { + GPFifo::ResetGatherPipe(); + ResetVideoBuffer(); + IncrementCheckContextId(); + } DEBUG_LOG(COMMANDPROCESSOR,"try to write to FIFO_RW_DISTANCE_LO : %04x", _Value); break; @@ -699,11 +713,7 @@ void STACKALIGN GatherPipeBursted() OnOverflow = true; while (!CommandProcessor::interruptWaiting && fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance > fifo.CPEnd - fifo.CPBase - 64) - Common::YieldCPU(); - - - - + Common::YieldCPU(); } else { @@ -816,19 +826,19 @@ void SetFifoIdleFromVideoPlugin() // to 0 when PI_FIFO_RESET occurs. void AbortFrame() { - fifo.bFF_GPReadEnable = false; - while(IsFifoProcesingData()) Common::YieldCPU(); - GPFifo::ResetGatherPipe(); - ResetVideoBuffer(); - fifo.CPReadPointer = fifo.CPWritePointer; - fifo.CPReadWriteDistance = 0; - fifo.CPBreakpoint = 0; - fifo.bFF_Breakpoint = false; - fifo.CPCmdIdle = false; - PixelEngine::ResetSetToken(); - PixelEngine::ResetSetFinish(); - fifo.bFF_GPReadEnable = true; - IncrementCheckContextId(); + //fifo.bFF_GPReadEnable = false; + //while(IsFifoProcesingData()) Common::YieldCPU(); + //GPFifo::ResetGatherPipe(); + //ResetVideoBuffer(); + //fifo.CPReadPointer = fifo.CPWritePointer; + //fifo.CPReadWriteDistance = 0; + //fifo.CPBreakpoint = 0; + //fifo.bFF_Breakpoint = false; + //fifo.CPCmdIdle = false; + //PixelEngine::ResetSetToken(); + //PixelEngine::ResetSetFinish(); + //fifo.bFF_GPReadEnable = true; + //IncrementCheckContextId(); } void SetOverflowStatusFromGatherPipe() diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index e8391c5f2f..08112b2986 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -33,7 +33,6 @@ namespace { static volatile bool fifoStateRun = false; static volatile bool EmuRunning = false; -static volatile bool isFifoProcesingData = false; static u8 *videoBuffer; // STATE_TO_SAVE static int size = 0; @@ -96,10 +95,6 @@ void Fifo_RunLoop(bool run) EmuRunning = run; } -bool IsFifoProcesingData() -{ - return isFifoProcesingData; -} // Description: Fifo_EnterLoop() sends data through this function. void Fifo_SendFifoData(u8* _uData, u32 len) @@ -148,7 +143,7 @@ void Fifo_EnterLoop() while (!CommandProcessor::interruptWaiting && _fifo.bFF_GPReadEnable && _fifo.CPReadWriteDistance && (!AtBreakpoint() || CommandProcessor::OnOverflow)) { - isFifoProcesingData = true; + _fifo.isFifoProcesingData = true; CommandProcessor::isPossibleWaitingSetDrawDone = _fifo.bFF_GPLinkEnable; if (!fifoStateRun) break; @@ -188,7 +183,7 @@ void Fifo_EnterLoop() CommandProcessor::isPossibleWaitingSetDrawDone = false; } - isFifoProcesingData = false; + _fifo.isFifoProcesingData = false; CommandProcessor::SetFifoIdleFromVideoPlugin();