From 752034c519684efda6ad260355e79cbcfabd318d Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 14 Sep 2010 00:39:40 +0000 Subject: [PATCH] Bugfix for Tri-ace games and possibly others (bug introduced in r3762, caused by missing 'vifRegs.num is actually 256' checks) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3765 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/newVif.h | 20 +++++--------------- pcsx2/x86/newVif_Dynarec.cpp | 12 +++++------- pcsx2/x86/newVif_Unpack.cpp | 4 ++-- pcsx2/x86/newVif_UnpackSSE.h | 2 +- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/pcsx2/x86/newVif.h b/pcsx2/x86/newVif.h index 1e507c593e..7f63bb6b91 100644 --- a/pcsx2/x86/newVif.h +++ b/pcsx2/x86/newVif.h @@ -51,11 +51,6 @@ _vifT extern void dVifUnpack (const u8* data, bool isFill); #define xmmRow xmm6 #define xmmTemp xmm7 -#ifdef _MSC_VER -# pragma pack(1) -# pragma warning(disable:4996) // 'function': was declared deprecated -#endif - // nVifBlock - Ordered for Hashing; the 'num' field and the lower 6 bits of upkType are // used as the hash bucket selector. // @@ -63,17 +58,12 @@ struct __aligned16 nVifBlock { u8 num; // [00] Num Field u8 upkType; // [01] Unpack Type [usn*1:mask*1:upk*4] u8 mode; // [02] Mode Field - u8 cl; // [04] CL Field - u8 wl; // [05] WL Field - u8 scl; // [03] Start Cycle - u32 mask; // [06] Mask Field - u8 padding[2];// [10] through [11] + u8 cl; // [03] CL Field + u32 mask; // [04] Mask Field + u8 wl; // [08] WL Field + u8 padding[3];// [09] through [11] uptr startPtr; // [12] Start Ptr of RecGen Code -} __packed; // 16 bytes - -#ifdef _MSC_VER -# pragma pack() -#endif +}; // 16 bytes #define _hSize 0x4000 // [usn*1:mask*1:upk*4:num*8] hash... #define _cmpS (sizeof(nVifBlock) - (4)) diff --git a/pcsx2/x86/newVif_Dynarec.cpp b/pcsx2/x86/newVif_Dynarec.cpp index d4de6ba4eb..8325341da5 100644 --- a/pcsx2/x86/newVif_Dynarec.cpp +++ b/pcsx2/x86/newVif_Dynarec.cpp @@ -138,14 +138,14 @@ static void ShiftDisplacementWindow( xAddressVoid& addr, const xRegister32& modR if(addImm) xADD(modReg, addImm); } -void VifUnpackSSE_Dynarec::CompileRoutine(vifStruct& vif) { +void VifUnpackSSE_Dynarec::CompileRoutine() { const int upkNum = vB.upkType & 0xf; const u8& vift = nVifT[upkNum]; const int cycleSize = isFill ? vB.cl : vB.wl; const int blockSize = isFill ? vB.wl : vB.cl; const int skipSize = blockSize - cycleSize; - uint vNum = vB.num; + uint vNum = vB.num ? vB.num : 256; doMode = (upkNum == 0xf) ? 0 : doMode; // V4_5 has no mode feature. pxAssume(vCL == 0); @@ -256,13 +256,12 @@ _vifT __fi void dVifUnpack(const u8* data, bool isFill) { vifStruct& vif = GetVifX; VIFregisters& vifRegs = vifXRegs; - const u8 upkType = vif.cmd & 0x1f | ((!!vif.usn) << 5); - const int doMask = vif.cmd & 0x10; + const u8 upkType = (vif.cmd & 0x1f) | (vif.usn << 5); + const int doMask = (vif.cmd & 0x10); _vBlock.upkType = upkType; _vBlock.num = (u8&)vifRegs.num; _vBlock.mode = (u8&)vifRegs.mode; - //_vBlock.scl = vif.cl; // scl is always zero now (effectively padding) _vBlock.cl = vifRegs.cycle.cl; _vBlock.wl = vifRegs.cycle.wl; @@ -281,7 +280,7 @@ _vifT __fi void dVifUnpack(const u8* data, bool isFill) { xSetPtr(v.recPtr); _vBlock.startPtr = (uptr)xGetAlignedCallTarget(); v.vifBlocks->add(_vBlock); - VifUnpackSSE_Dynarec( v, _vBlock ).CompileRoutine(vif); + VifUnpackSSE_Dynarec( v, _vBlock ).CompileRoutine(); nVif[idx].recPtr = xGetPtr(); // [TODO] : Ideally we should test recompile buffer limits prior to each instruction, @@ -290,7 +289,6 @@ _vifT __fi void dVifUnpack(const u8* data, bool isFill) { // Run the block we just compiled. Various conditions may force us to still use // the interpreter unpacker though, so a recursive call is the safest way here... - //dVifUnpack(data); dVifExecuteUnpack(data, isFill); } diff --git a/pcsx2/x86/newVif_Unpack.cpp b/pcsx2/x86/newVif_Unpack.cpp index 9d661135ad..0c692292c9 100644 --- a/pcsx2/x86/newVif_Unpack.cpp +++ b/pcsx2/x86/newVif_Unpack.cpp @@ -106,11 +106,11 @@ _vifT int nVifUnpack(const u8* data) { v.bSize += size; data = v.buffer; + vif.cl = 0; vifRegs.num = (vifXRegs.code >> 16) & 0xff; // grab NUM form the original VIFcode input. + if (!vifRegs.num) vifRegs.num = 256; } - vif.cl = 0; - if (newVifDynaRec) dVifUnpack(data, isFill); else _nVifUnpack(idx, data, vifRegs.mode, isFill); diff --git a/pcsx2/x86/newVif_UnpackSSE.h b/pcsx2/x86/newVif_UnpackSSE.h index 8509a7beac..231a080b35 100644 --- a/pcsx2/x86/newVif_UnpackSSE.h +++ b/pcsx2/x86/newVif_UnpackSSE.h @@ -126,7 +126,7 @@ public: virtual bool IsUnmaskedOp() const{ return !doMode && !doMask; } - void CompileRoutine(vifStruct& vif); + void CompileRoutine(); protected: virtual void doMaskWrite(const xRegisterSSE& regX) const;