zzogl-pg: Borrowed enough of the old transfer function in the new one to get it to work properly. Needs more testing.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2810 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-04-03 09:47:20 +00:00
parent 7c817d97e7
commit 1254cd22a5
2 changed files with 174 additions and 152 deletions

View File

@ -86,7 +86,6 @@ __forceinline void gifTransferLog(int index, u32 *pMem, u32 size)
} }
#ifdef NEW_GIF_TRANSFER #ifdef NEW_GIF_TRANSFER
extern int g_GSMultiThreaded; extern int g_GSMultiThreaded;
template<int index> void _GSgifTransfer(u32 *pMem, u32 size) template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
@ -120,8 +119,6 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
{ {
gs.q = 1.0f; gs.q = 1.0f;
// ASSERT(!(path.tag.PRE && path.tag.FLG == GIF_FLG_REGLIST)); // kingdom hearts
if(path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED)) if(path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED))
{ {
u32 tagprim = path->tag.PRIM; u32 tagprim = path->tag.PRIM;
@ -131,51 +128,91 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
} }
else else
{ {
switch(path->tag.FLG) switch(path->mode)
{ {
case GIF_FLG_PACKED: case GIF_FLG_PACKED:
{ {
// Needs to be looked at.
// first try a shortcut for a very common case
/*if(path.adonly && size >= path.nloop)
{
size -= path.nloop;
do do
{ {
u32 reg = path->GetReg(); GIFPackedRegHandlerA_D(pMem);
g_GIFPackedRegHandlers[reg](pMem); mem += sizeof(GIFPackedReg);
}
while(--path.nloop > 0);*/
do
{
g_GIFPackedRegHandlers[path->GetReg()](pMem);
path->reg += 4;
if (path->nreg == path->reg)
{
path->reg = 0;
if( path->nloop-- <= 1 )
{
size--;
pMem += 4;
break;
}
}
pMem += 4; pMem += 4;
size--; size--;
} }
while(path->StepReg() && size > 0); while (size > 0);
break; break;
} }
case GIF_FLG_REGLIST: case GIF_FLG_REGLIST:
{ {
// Needs to be looked at.
//GS_LOG("%8.8x%8.8x %d L\n", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
size *= 2; size *= 2;
do do
{ {
int reg = path->GetReg(); g_GIFRegHandlers[path->GetReg()](pMem);
g_GIFRegHandlers[reg](pMem);
path->reg += 4;
if (path->nreg == path->reg)
{
path->reg = 0;
if( path->nloop-- <= 1 )
{
size--;
pMem += 2;
break;
}
}
pMem += 2; pMem += 2;
size--; size--;
} }
while(path->StepReg() && size > 0); while(size > 0);
if (size & 1) pMem += 2; if(size & 1) pMem += 2;
size /= 2; size /= 2;
break; break;
} }
case GIF_FLG_IMAGE2: // hmmm
{
assert(0);
path->nloop = 0;
break;
}
case GIF_FLG_IMAGE: // FROM_VFRAM case GIF_FLG_IMAGE: // FROM_VFRAM
case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too.
{ {
int len = (int)min(size, path->nloop); int len = (int)min(size, path->nloop);
//ERROR_LOG("GIF_FLG_IMAGE(%d)=%d\n", gs.imageTransfer, len);
switch(gs.imageTransfer) switch(gs.imageTransfer)
{ {
@ -187,16 +224,17 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
break; break;
case 2: case 2:
//Move(); //Move();
//ERROR_LOG("GIF_FLG_IMAGE MOVE");
break; break;
case 3: case 3:
assert(0); //assert(0);
break; break;
default: default:
assert(0); //assert(0);
break; break;
} }
pMem += len * 16; pMem += len * 4;
path->nloop -= len; path->nloop -= len;
size -= len; size -= len;
@ -205,11 +243,11 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
default: // GIF_IMAGE default: // GIF_IMAGE
GS_LOG("*** WARNING **** Unexpected GIFTag flag\n"); GS_LOG("*** WARNING **** Unexpected GIFTag flag\n");
assert(0); assert(0);
path->nloop = 0;
break; break;
} }
} }
if (index == 0) if (index == 0)
{ {
if(path->tag.EOP && path->nloop == 0) if(path->tag.EOP && path->nloop == 0)
@ -219,14 +257,14 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
} }
} }
if(index == 0) // This is the case when not all data was readed from one try: VU1 has too much data.
// So we should redo reading from the start.
if (index == 0)
{ {
if(size == 0 && path->nloop > 0) if(size == 0 && path->nloop > 0)
{ {
if (g_GSMultiThreaded) if (g_GSMultiThreaded)
{ {
// TODO
path->nloop = 0; path->nloop = 0;
} }
else else
@ -241,28 +279,14 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
{ {
FUNCLOG FUNCLOG
pathInfo *path = &gs.path[0];
//GS_LOG("GSgifTransfer1 0x%x (mode %d)\n", addr, path->mode); //GS_LOG("GSgifTransfer1 0x%x (mode %d)\n", addr, path->mode);
// addr &= 0x3fff;
#ifdef _DEBUG #ifdef _DEBUG
PRIM_LOG("count: %d\n", count); PRIM_LOG("count: %d\n", count);
count++; count++;
#endif #endif
path->nloop = 0;
path->eop = 0;
_GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr)/16); _GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr)/16);
if (!path->eop && (path->nloop > 0))
{
assert( (addr&0xf) == 0 ); //BUG
path->nloop = 0;
ERROR_LOG("Transfer1 - 2\n");
return;
}
} }
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size) void CALLBACK GSgifTransfer2(u32 *pMem, u32 size)
@ -280,7 +304,6 @@ void CALLBACK GSgifTransfer3(u32 *pMem, u32 size)
//GS_LOG("GSgifTransfer3 size = %lx (mode %d, gs.path3.tag.nloop = %d)\n", size, gs.path[2].mode, gs.path[2].tag.nloop); //GS_LOG("GSgifTransfer3 size = %lx (mode %d, gs.path3.tag.nloop = %d)\n", size, gs.path[2].mode, gs.path[2].tag.nloop);
nPath3Hack = 0;
_GSgifTransfer<2>(pMem, size); _GSgifTransfer<2>(pMem, size);
} }
#else #else

View File

@ -22,8 +22,9 @@
#include "Regs.h" #include "Regs.h"
#include "Util.h" #include "Util.h"
// This is fairly broken right now, and shouldn't be enabled unless you feel like fixing it. // If you notice bugs in the newest revisions, you might try disabling this,
//#define NEW_GIF_TRANSFER // to see if they are related.
#define NEW_GIF_TRANSFER
enum GIF_FLG enum GIF_FLG
{ {
GIF_FLG_PACKED = 0, GIF_FLG_PACKED = 0,
@ -68,6 +69,16 @@ union GIFTag
typedef struct typedef struct
{ {
#ifdef NEW_GIF_TRANSFER
int mode;
int reg;
u64 regs;
int nloop;
int eop;
int nreg;
u32 adonly;
GIFTag tag;
#else
int mode; int mode;
int regn; int regn;
u64 regs; u64 regs;
@ -76,6 +87,7 @@ typedef struct
int nreg; int nreg;
u32 adonly; u32 adonly;
GIFTag tag; GIFTag tag;
#endif
#ifdef NEW_GIF_TRANSFER #ifdef NEW_GIF_TRANSFER
void setTag(u32 *data) void setTag(u32 *data)
@ -85,45 +97,33 @@ typedef struct
nloop = tag.NLOOP; nloop = tag.NLOOP;
eop = tag.EOP; eop = tag.EOP;
mode = tag.FLG; mode = tag.FLG;
nreg = tag.NREG;
//regs = tag.REGS;
//regn = 0;
ERROR_LOG("GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d\n", // Hmm....
data[3], data[2], data[1], data[0], nreg = tag.NREG << 2;
eop, nloop, mode, nreg, tag.PRE); if (nreg == 0) nreg = 64;
regs = tag.REGS;
reg = 0;
switch (mode) // GS_LOG("GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d\n",
{ // data[3], data[2], data[1], data[0],
case GIF_FLG_PACKED: // path->eop, path->nloop, mode, path->nreg, tag.PRE);
regs = *(u64 *)(data+2);
regn = 0;
break;
case GIF_FLG_REGLIST:
regs = *(u64 *)(data+2);
regn = 0;
break;
}
adonly = (nreg == 1) && ((u8)regs == 0xe);
} }
u32 GetReg() u32 GetReg()
{ {
return (regs >> regn) & 0xf; return (regs >> reg) & 0xf;
} }
bool StepReg() bool StepReg()
{ {
regn += 1; reg += 4;
if ((regn & 0xf) == nreg) if (reg == nreg)
{ {
regn = 0; reg = 0;
if (--nloop <= 0) if (--nloop == 0)
{ {
return false; return false;
} }
@ -131,7 +131,6 @@ typedef struct
return true; return true;
} }
#else #else
void setTag(u32 *data) void setTag(u32 *data)
{ {
tag.set(data); tag.set(data);