From 0fd4e40286bfce77eb01f0f2323f2398bcedbce6 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Sat, 16 Jan 2010 03:01:10 +0000 Subject: [PATCH] newVif: fixed a bug... fixes Digital Devil Saga crashing. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2431 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/newVif.h | 2 +- pcsx2/x86/newVif_Unpack.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pcsx2/x86/newVif.h b/pcsx2/x86/newVif.h index 4a996321f2..bf3e840836 100644 --- a/pcsx2/x86/newVif.h +++ b/pcsx2/x86/newVif.h @@ -58,7 +58,7 @@ extern void VifUnpackSSE_Init(); #endif // nVifBlock - Ordered for Hashing; the 'num' field and the lower 6 bits of upkType are -// used as the hash bucke selector. +// used as the hash bucket selector. // struct __aligned16 nVifBlock { u8 num; // [00] Num Field diff --git a/pcsx2/x86/newVif_Unpack.cpp b/pcsx2/x86/newVif_Unpack.cpp index 9bd714d4a9..ed806168fe 100644 --- a/pcsx2/x86/newVif_Unpack.cpp +++ b/pcsx2/x86/newVif_Unpack.cpp @@ -132,9 +132,10 @@ int nVifUnpack(int idx, u8* data) { const bool doMode = vifRegs->mode && !(vif->tag.cmd & 0x10); const u8 upkNum = vif->cmd & 0x1f; const int diff = vifT - v.partTransfer; + if (size < diff) DevCon.WriteLn("newVif: Still not enough data for unpack!"); memcpy(&v.partBuffer[v.partTransfer], data, diff); - UnpackSingleTable[idx][doMode][isFill](v.partBuffer, size); - //DevCon.WriteLn("Diff = %d; vifT = %d; size = %d", diff, vifT, size); + UnpackSingleTable[idx][doMode][isFill](v.partBuffer, size + v.partTransfer); + //DevCon.WriteLn("[Diff=%d][size=%d][vifT=%d][pTrans=%d]", diff, size, vifT, v.partTransfer); data += diff; size -= diff; v.partTransfer = 0; @@ -145,7 +146,7 @@ int nVifUnpack(int idx, u8* data) { vif->tag.size = 0; vif->cmd = 0; } - else { // Partial Transfer + else { // Partial Transfer _nVifUnpack(idx, data, size, isFill); vif->tag.size -= ret; }