Skip to content

Commit

Permalink
Use ReadValue to fetch VIFcode and other simple values.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpd002 committed May 1, 2024
1 parent 727ab79 commit 9f8d623
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Source/ee/Vif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ void CVif::ProcessPacket(StreamType& stream)
break;
}

stream.Read(&m_CODE, sizeof(CODE));
stream.ReadValue<4>(&m_CODE);

if(m_CODE.nI != 0)
{
Expand Down Expand Up @@ -643,7 +643,7 @@ void CVif::Cmd_STROW(StreamType& stream, CODE nCommand)
while(m_NUM != 0 && stream.GetAvailableReadBytes())
{
assert(m_NUM <= 4);
stream.Read(&m_R[4 - m_NUM], 4);
stream.ReadValue<4>(&m_R[4 - m_NUM]);
m_NUM--;
}

Expand All @@ -662,7 +662,7 @@ void CVif::Cmd_STCOL(StreamType& stream, CODE nCommand)
while(m_NUM != 0 && stream.GetAvailableReadBytes())
{
assert(m_NUM <= 4);
stream.Read(&m_C[4 - m_NUM], 4);
stream.ReadValue<4>(&m_C[4 - m_NUM]);
m_NUM--;
}

Expand All @@ -680,7 +680,7 @@ void CVif::Cmd_STMASK(StreamType& stream, CODE command)
{
while(m_NUM != 0 && stream.GetAvailableReadBytes())
{
stream.Read(&m_MASK, 4);
stream.ReadValue<4>(&m_MASK);
m_NUM--;
}

Expand Down
11 changes: 10 additions & 1 deletion Source/ee/Vif.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,26 @@ class CVif
memcpy(readBuffer, reinterpret_cast<uint8*>(&m_buffer) + m_bufferPosition, ValueSize);
m_bufferPosition += ValueSize;
}
else
else if(!m_tagIncluded || (ValueSize <= 8))
{
uint128 qw[2];
qw[0] = m_buffer;
uint32 startPosition = m_bufferPosition;
bool hasTag = m_tagIncluded;
m_bufferPosition = BUFFERSIZE;
SyncBuffer();
qw[1] = m_buffer;
if(hasTag)
{
qw[1].nD0 = qw[1].nD1;
}
m_bufferPosition += (ValueSize - availableBufferSize);
memcpy(readBuffer, reinterpret_cast<uint8*>(&qw) + startPosition, ValueSize);
}
else
{
Read(buffer, ValueSize);
}
}

void Flush();
Expand Down

0 comments on commit 9f8d623

Please sign in to comment.