From 5b6b73237820b13e640077ee09c6597d96d765c1 Mon Sep 17 00:00:00 2001 From: Nolan Check Date: Mon, 20 Jul 2009 01:10:00 +0000 Subject: [PATCH] Simplify fifo code git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3855 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/CommandProcessor.cpp | 5 ++ Source/Core/VideoCommon/Src/Fifo.cpp | 62 ++++++-------------- 2 files changed, 24 insertions(+), 43 deletions(-) diff --git a/Source/Core/Core/Src/HW/CommandProcessor.cpp b/Source/Core/Core/Src/HW/CommandProcessor.cpp index ab019c8f4a..4e3242f55d 100644 --- a/Source/Core/Core/Src/HW/CommandProcessor.cpp +++ b/Source/Core/Core/Src/HW/CommandProcessor.cpp @@ -422,6 +422,11 @@ void Write16(const u16 _Value, const u32 _Address) Common::AtomicStore(fifo.bFF_GPLinkEnable, tmpCtrl.GPLinkEnable); Common::AtomicStore(fifo.bFF_BPEnable, tmpCtrl.BPEnable); + if (m_CPCtrlReg.BPEnable && !tmpCtrl.BPEnable) + { + fifo.bFF_Breakpoint = 0; + } + // TOCHECK (mb2): could BP irq be cleared with w16 to STATUS_REGISTER? // funny hack: eg in MP1 if we disable the clear breakpoint ability by commenting this block // the game is of course faster but looks stable too. diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 53974fcd41..0365238a05 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -122,15 +122,9 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) { fifoStateRun = true; SCPFifoStruct &_fifo = *video_initialize.pCPFifo; - s32 distToSend; while (fifoStateRun) { - video_initialize.pPeekMessages(); - - VideoFifo_CheckEFBAccess(); - - VideoFifo_CheckSwapRequest(); s_criticalFifo.Enter(); @@ -139,56 +133,35 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) { Common::AtomicStore(_fifo.CPReadIdle, 0); - while (_fifo.bFF_GPReadEnable && _fifo.CPReadWriteDistance) + do { if(!fifoStateRun) break; - // Create pointer to video data and send it to the VideoPlugin u32 readPtr = _fifo.CPReadPointer; + u8 *uData = video_initialize.pGetMemoryPointer(readPtr); - - // if we are on BP mode we must send 32B chunks to Video plugin for BP checking - // TODO (mb2): test & check if MP1/MP2 realy need this now. - if (_fifo.bFF_BPEnable) - { - if (readPtr == _fifo.CPBreakpoint) - { - Common::AtomicStore(_fifo.bFF_Breakpoint, 1); - video_initialize.pUpdateInterrupts(); - break; - } - distToSend = 32; - readPtr += 32; - if ( readPtr >= _fifo.CPEnd) - readPtr = _fifo.CPBase; - } - else - { - distToSend = _fifo.CPReadWriteDistance; - // send 1024B chunk max length to have better control over PeekMessages' period - distToSend = distToSend > 1024 ? 1024 : distToSend; - if ((distToSend + readPtr) >= _fifo.CPEnd) // TODO: better? - { - distToSend =_fifo.CPEnd - readPtr; - readPtr = _fifo.CPBase; - } - else - readPtr += distToSend; - } - // Execute new instructions found in uData - Fifo_SendFifoData(uData, distToSend); + Fifo_SendFifoData(uData, 32); + + readPtr += 32; + if (readPtr >= _fifo.CPEnd) + readPtr = _fifo.CPBase; Common::AtomicStore(_fifo.CPReadPointer, readPtr); - Common::AtomicAdd(_fifo.CPReadWriteDistance, -distToSend); + Common::AtomicAdd(_fifo.CPReadWriteDistance, -32); + + if (_fifo.bFF_BPEnable && (readPtr == _fifo.CPBreakpoint)) + { + _fifo.bFF_Breakpoint = 1; + video_initialize.pUpdateInterrupts(); + } video_initialize.pPeekMessages(); - VideoFifo_CheckEFBAccess(); - VideoFifo_CheckSwapRequest(); - } + + } while (_fifo.bFF_GPReadEnable && _fifo.CPReadWriteDistance && !(_fifo.bFF_BPEnable && _fifo.bFF_Breakpoint)); Common::AtomicStore(_fifo.CPReadIdle, 1); video_initialize.pSetFifoIdle(); @@ -196,6 +169,9 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) else { Common::YieldCPU(); + video_initialize.pPeekMessages(); + VideoFifo_CheckEFBAccess(); + VideoFifo_CheckSwapRequest(); } s_criticalFifo.Leave();