Vif - Cleanups/refactoring

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2585 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2010-02-11 04:36:47 +00:00
parent 706c68c1cd
commit 76194c82dc
6 changed files with 64 additions and 97 deletions

View File

@ -21,6 +21,10 @@
#include "GS.h"
#include "Gif.h"
vifStruct vif0;
vifStruct vif1;
Path3Modes Path3progress = STOPPED_MODE;
void vif0Init() { initNewVif(0); }
void vif1Init() { initNewVif(1); }

View File

@ -19,10 +19,6 @@
#include "VUmicro.h"
#include "newVif.h"
extern int (__fastcall *Vif0TransTLB[128])(u32 *data);
extern void (*Vif0CMDTLB[75])();
vifStruct vif0;
__forceinline void vif0FLUSH()
{
int _cycles = VU0.cycle;
@ -32,42 +28,6 @@ __forceinline void vif0FLUSH()
g_vifCycles += (VU0.cycle - _cycles) * BIAS;
}
static __forceinline void vif0UNPACK(u32 *data)
{
int vifNum;
if ((vif0Regs->cycle.wl == 0) && (vif0Regs->cycle.wl < vif0Regs->cycle.cl))
{
Console.WriteLn("Vif0 CL %d, WL %d", vif0Regs->cycle.cl, vif0Regs->cycle.wl);
vif0.cmd &= ~0x7f;
return;
}
vif0FLUSH();
vif0.tag.addr = (vif0Regs->code & 0xff) << 4;
vif0.usn = (vif0Regs->code >> 14) & 0x1;
vifNum = (vif0Regs->code >> 16) & 0xff;
if (vifNum == 0) vifNum = 256;
vif0Regs->num = vifNum;
if (vif0Regs->cycle.wl <= vif0Regs->cycle.cl)
{
vif0.tag.size = ((vifNum * VIFfuncTable[ vif0.cmd & 0xf ].gsize) + 3) >> 2;
}
else
{
int n = vif0Regs->cycle.cl * (vifNum / vif0Regs->cycle.wl) +
_limit(vifNum % vif0Regs->cycle.wl, vif0Regs->cycle.cl);
vif0.tag.size = ((n * VIFfuncTable[ vif0.cmd & 0xf ].gsize) + 3) >> 2;
}
vif0.cl = 0;
vif0.tag.cmd = vif0.cmd;
vif0Regs->offset = 0;
}
bool VIF0transfer(u32 *data, int size, bool istag)
{
int ret;
@ -103,7 +63,7 @@ bool VIF0transfer(u32 *data, int size, bool istag)
if ((vif0.cmd & 0x60) == 0x60)
{
vif0UNPACK(data);
vif0UnpackSetup(data);
}
else
{
@ -173,9 +133,9 @@ bool VIF0transfer(u32 *data, int size, bool istag)
if (!istag)
{
transferred = transferred >> 2;
vif0ch->madr += (transferred << 4);
vif0ch->qwc -= transferred;
transferred = transferred >> 2;
vif0ch->madr +=(transferred << 4);
vif0ch->qwc -= transferred;
}
return true;

View File

@ -21,12 +21,6 @@
#include "VUmicro.h"
#include "newVif.h"
extern void (*Vif1CMDTLB[82])();
extern int (__fastcall *Vif1TransTLB[128])(u32 *data);
Path3Modes Path3progress = STOPPED_MODE;
vifStruct vif1;
__forceinline void vif1FLUSH()
{
if (VU0.VI[REG_VPU_STAT].UL & 0x100)
@ -40,49 +34,6 @@ __forceinline void vif1FLUSH()
}
}
static __forceinline void vif1UNPACK(u32 *data)
{
int vifNum;
if ((vif1Regs->cycle.wl == 0) && (vif1Regs->cycle.wl < vif1Regs->cycle.cl))
{
Console.WriteLn("Vif1 CL %d, WL %d", vif1Regs->cycle.cl, vif1Regs->cycle.wl);
vif1.cmd &= ~0x7f;
return;
}
//vif1FLUSH();
vif1.usn = (vif1Regs->code >> 14) & 0x1;
vifNum = (vif1Regs->code >> 16) & 0xff;
if (vifNum == 0) vifNum = 256;
vif1Regs->num = vifNum;
if (vif1Regs->cycle.wl <= vif1Regs->cycle.cl)
{
vif1.tag.size = ((vifNum * VIFfuncTable[ vif1.cmd & 0xf ].gsize) + 3) >> 2;
}
else
{
int n = vif1Regs->cycle.cl * (vifNum / vif1Regs->cycle.wl) +
_limit(vifNum % vif1Regs->cycle.wl, vif1Regs->cycle.cl);
vif1.tag.size = ((n * VIFfuncTable[ vif1.cmd & 0xf ].gsize) + 3) >> 2;
}
if ((vif1Regs->code >> 15) & 0x1)
vif1.tag.addr = (vif1Regs->code + vif1Regs->tops) & 0x3ff;
else
vif1.tag.addr = vif1Regs->code & 0x3ff;
vif1Regs->offset = 0;
vif1.cl = 0;
vif1.tag.addr <<= 4;
vif1.tag.cmd = vif1.cmd;
}
bool VIF1transfer(u32 *data, int size, bool istag)
{
int ret;
@ -127,7 +78,7 @@ bool VIF1transfer(u32 *data, int size, bool istag)
if ((vif1.cmd & 0x60) == 0x60)
{
vif1UNPACK(data);
vif1UnpackSetup(data);
}
else
{
@ -200,9 +151,9 @@ bool VIF1transfer(u32 *data, int size, bool istag)
if (!istag)
{
transferred = transferred >> 2;
vif1ch->madr += (transferred << 4);
vif1ch->qwc -= transferred;
transferred = transferred >> 2;
vif1ch->madr +=(transferred << 4);
vif1ch->qwc -= transferred;
}
if (vif1Regs->stat.VGW) vif1.vifstalled = true;

View File

@ -60,6 +60,11 @@ extern void Vif1MskPath3();
extern void vif1Write32(u32 mem, u32 value);
extern void vif1Reset();
extern void (*Vif0CMDTLB[82])();
extern void (*Vif1CMDTLB[82])();
extern int (__fastcall *Vif0TransTLB[128])(u32 *data);
extern int (__fastcall *Vif1TransTLB[128])(u32 *data);
__forceinline static int _limit(int a, int max)
{
return ((a > max) ? max : a);

View File

@ -293,3 +293,47 @@ const __aligned16 VIFUnpackFuncTable VIFfuncTable[32] =
UnpackFuncSet( false )
UnpackFuncSet( true )
};
//----------------------------------------------------------------------------
// Unpack Setup Code
//----------------------------------------------------------------------------
_vifT void vifUnpackSetup(u32 *data) {
if ((vifXRegs->cycle.wl == 0) && (vifXRegs->cycle.wl < vifXRegs->cycle.cl)) {
Console.WriteLn("Vif%d CL %d, WL %d", idx, vifXRegs->cycle.cl, vifXRegs->cycle.wl);
vifX.cmd &= ~0x7f;
return; // Skipping write and 0 write-cycles, so do nothing!
}
if (!idx) vif0FLUSH(); // Only VU0?
vifX.usn = (vifXRegs->code >> 14) & 0x01;
int vifNum = (vifXRegs->code >> 16) & 0xff;
if (vifNum == 0) vifNum = 256;
vifXRegs->num = vifNum;
if (vifXRegs->cycle.wl <= vifXRegs->cycle.cl) {
if (!idx) vif0.tag.size = ((vifNum * VIFfuncTable[ vif0.cmd & 0xf ].gsize) + 3) >> 2;
else vif1.tag.size = ((vifNum * VIFfuncTable[ vif1.cmd & 0xf ].gsize) + 3) >> 2;
}
else {
int n = vifXRegs->cycle.cl * (vifNum / vifXRegs->cycle.wl) +
_limit(vifNum % vifXRegs->cycle.wl, vifXRegs->cycle.cl);
if (!idx) vif0.tag.size = ((n * VIFfuncTable[ vif0.cmd & 0xf ].gsize) + 3) >> 2;
else vif1.tag.size = ((n * VIFfuncTable[ vif1.cmd & 0xf ].gsize) + 3) >> 2;
}
u32 addr = vifXRegs->code;
if (idx && ((addr>>15)&1)) addr += vif1Regs->tops;
vifX.tag.addr = (addr<<4) & (idx ? 0x3ff0 : 0xff0);
vifX.cl = 0;
vifX.tag.cmd = vifX.cmd;
vifXRegs->offset = 0;
}
void vif0UnpackSetup(u32 *data) { vifUnpackSetup<0>(data); }
void vif1UnpackSetup(u32 *data) { vifUnpackSetup<1>(data); }

View File

@ -54,3 +54,6 @@ extern const __aligned16 VIFUnpackFuncTable VIFfuncTable[32];
extern int nVifUnpack (int idx, u8 *data);
extern void initNewVif (int idx);
extern void resetNewVif(int idx);
extern __forceinline void vif0UnpackSetup(u32 *data);
extern __forceinline void vif1UnpackSetup(u32 *data);