Gracefully handle cases where GIF transfer doesn't complete.

This commit is contained in:
Jean-Philip Desjardins 2016-10-09 16:18:37 -04:00
parent 72569d2cb3
commit 930e7357cf
2 changed files with 10 additions and 6 deletions

View File

@ -368,17 +368,19 @@ uint32 CGIF::ReceiveDMA(uint32 address, uint32 qwc, uint32 unused, bool tagInclu
memory = m_ram; memory = m_ram;
} }
uint32 start = address;
uint32 end = address + size;
if(tagIncluded) if(tagIncluded)
{ {
assert(qwc >= 0); assert(qwc >= 0);
size -= 0x10;
address += 0x10; address += 0x10;
} }
uint32 end = address + size; address += ProcessMultiplePackets(memory, address, end, CGsPacketMetadata(3));
uint32 processed = ProcessMultiplePackets(memory, address, end, CGsPacketMetadata(3)); assert(address <= end);
assert(processed == size);
return qwc; return (address - start) / 0x10;
} }
uint32 CGIF::GetRegister(uint32 address) uint32 CGIF::GetRegister(uint32 address)

View File

@ -164,8 +164,10 @@ void CVif1::Cmd_DIRECT(StreamType& stream, CODE nCommand)
{ {
auto packet = stream.GetDirectPointer(); auto packet = stream.GetDirectPointer();
uint32 processed = m_gif.ProcessMultiplePackets(packet, 0, nSize, CGsPacketMetadata(2)); uint32 processed = m_gif.ProcessMultiplePackets(packet, 0, nSize, CGsPacketMetadata(2));
assert(processed == nSize); assert(processed <= nSize);
stream.Advance(processed); stream.Advance(processed);
//Adjust size in case not everything was processed by GIF
nSize = processed;
} }
m_CODE.nIMM -= (nSize / 0x10); m_CODE.nIMM -= (nSize / 0x10);