Skip to content

Commit

Permalink
Stall DMA on DIRECT/DIRECTHL.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpd002 committed Mar 1, 2024
1 parent 4ae1d25 commit a83d935
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Source/ee/Vif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ uint32 CVif::ReceiveDMA(uint32 address, uint32 qwc, uint32 unused, bool tagInclu
//Is waiting for program end, don't bother
return 0;
}
if(m_stallDma)
{
m_stallDma = false;
return m_stallDmaCount;
}

#ifdef PROFILE
CProfilerZone profilerZone(m_vifProfilerZone);
Expand All @@ -376,7 +381,21 @@ uint32 CVif::ReceiveDMA(uint32 address, uint32 qwc, uint32 unused, bool tagInclu
assert((remainingSize & 0x0F) == 0);
remainingSize /= 0x10;

return qwc - remainingSize;
uint32 result = qwc - remainingSize;
if(result == 0)
{
m_stallDma = false;
}

if(m_stallDma)
{
m_stallDmaCount = result;
return 0;
}
else
{
return result;
}
}

bool CVif::IsWaitingForProgramEnd() const
Expand Down
3 changes: 3 additions & 0 deletions Source/ee/Vif.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ class CVif
uint8 m_fifoBuffer[FIFO_SIZE];
uint32 m_fifoIndex = 0;

bool m_stallDma = false;
uint32 m_stallDmaCount = 0;

STAT m_STAT;
ERR m_ERR;
CYCLE m_CYCLE;
Expand Down
3 changes: 3 additions & 0 deletions Source/ee/Vif1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ void CVif1::ExecuteCommand(StreamType& stream, CODE nCommand)

void CVif1::Cmd_DIRECT(StreamType& stream, CODE nCommand)
{
m_stallDma = true;
m_stallDmaCount = 0;

uint32 nSize = stream.GetAvailableReadBytes();
assert((nSize & 0x03) == 0);

Expand Down

0 comments on commit a83d935

Please sign in to comment.