Fixed Gradius V, had to destroy the templates arcum did a bit to get it to work without ape escape crashing (sorry mate lol. Took out my V3_# discovery, ape escape is getting spikey now, so ill just remove it. Also altered V2_# to work slightly different incase the packet starts on the Y vector, it now wont suffer underrunning (possible bad data)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@928 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
refraction 2009-04-08 21:19:50 +00:00
parent 57f9c2bc64
commit 1250953ff0
3 changed files with 47 additions and 77 deletions

View File

@ -190,6 +190,8 @@ extern bool SrcLog_GPU( const char* fmt, ... );
#define MEMCARDS_LOG 0&&
#endif
//#define VIFUNPACKDEBUG //enable unpack debugging output
#ifdef VIFUNPACKDEBUG
#define VIFUNPACK_LOG VIF_LOG
#else

View File

@ -333,89 +333,57 @@ static __releaseinline void writeW(u32 &dest, u32 data)
template <class T>
static void _UNPACKpart(u32 offnum, u32 &x, T y)
{
if (_vifRegs->offset == offnum)
{
switch (offnum)
{
case OFFSET_X:
writeX(x,y);
break;
case OFFSET_Y:
writeY(x,y);
break;
case OFFSET_Z:
writeZ(x,y);
break;
case OFFSET_W:
writeW(x,y);
break;
default:
break;
}
_vifRegs->offset++;
}
}
template <class T>
static void _UNPACKpart(u32 offnum, u32 &x, T y, int size)
{
if(size == 0) return;
if (_vifRegs->offset == offnum)
switch (offnum)
{
switch (offnum)
{
case OFFSET_X:
writeX(x,y);
break;
case OFFSET_Y:
writeY(x,y);
break;
case OFFSET_Z:
writeZ(x,y);
break;
case OFFSET_W:
writeW(x,y);
break;
default:
break;
}
size--;
_vifRegs->offset++;
case OFFSET_X:
writeX(x,y);
break;
case OFFSET_Y:
writeY(x,y);
break;
case OFFSET_Z:
writeZ(x,y);
break;
case OFFSET_W:
writeW(x,y);
break;
default:
break;
}
_vifRegs->offset++;
}
template <class T>
void __fastcall UNPACK_S(u32 *dest, T *data, int size)
{
_UNPACKpart(OFFSET_X, *dest++, *data, size);
_UNPACKpart(OFFSET_Y, *dest++, *data, size);
_UNPACKpart(OFFSET_Z, *dest++, *data, size);
_UNPACKpart(OFFSET_W, *dest , *data, size);
if(size > 0 && _vifRegs->offset == OFFSET_X ) { _UNPACKpart(OFFSET_X, *dest++, *data); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Y ) { _UNPACKpart(OFFSET_Y, *dest++, *data); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Z ) { _UNPACKpart(OFFSET_Z, *dest++, *data); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_W ) { _UNPACKpart(OFFSET_W, *dest , *data); size--; }
if (_vifRegs->offset == 4) _vifRegs->offset = 0;
}
template <class T>
void __fastcall UNPACK_V2(u32 *dest, T *data, int size)
{
_UNPACKpart(OFFSET_X, *dest++, *data++, size);
_UNPACKpart(OFFSET_Y, *dest++, *data--, size);
_UNPACKpart(OFFSET_Z, *dest++, *data++);
_UNPACKpart(OFFSET_W, *dest , *data);
if(size > 0 && _vifRegs->offset == OFFSET_X ) { _UNPACKpart(OFFSET_X, *dest++, *data++); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Y ) { _UNPACKpart(OFFSET_Y, *dest++, *data); size--; }
if( _vifRegs->offset == OFFSET_Z )_UNPACKpart(OFFSET_Z, *dest++, *dest-2);
if( _vifRegs->offset == OFFSET_W )_UNPACKpart(OFFSET_W, *dest , *data);
if (_vifRegs->offset == 4) _vifRegs->offset = 0;
}
template <class T>
void __fastcall UNPACK_V3(u32 *dest, T *data, int size)
{
_UNPACKpart(OFFSET_X, *dest++, *data++, size);
_UNPACKpart(OFFSET_Y, *dest++, *data++, size);
_UNPACKpart(OFFSET_Z, *dest++, *data++, size);
if(size > 0 && _vifRegs->offset == OFFSET_X ) { _UNPACKpart(OFFSET_X, *dest++, *data++); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Y ) { _UNPACKpart(OFFSET_Y, *dest++, *data++); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Z ) { _UNPACKpart(OFFSET_Z, *dest++, *data++); size--; }
//V3-# does some bizzare thing with alignment, every 6qw of data the W becomes 0 (strange console!)
if((_vif->qwcalign % 24) == 0)
_UNPACKpart(OFFSET_W, *dest, 0);
else
_UNPACKpart(OFFSET_W, *dest, *data);
//Ape Escape doesnt seem to like it tho (what the hell?) gonna have to investigate
if( _vifRegs->offset == OFFSET_W )_UNPACKpart(OFFSET_W, *dest, *data);
if (_vifRegs->offset == 4) _vifRegs->offset = 0;
}
@ -423,19 +391,19 @@ void __fastcall UNPACK_V3(u32 *dest, T *data, int size)
template <class T>
void __fastcall UNPACK_V4(u32 *dest, T *data , int size)
{
_UNPACKpart(OFFSET_X, *dest++, *data++, size);
_UNPACKpart(OFFSET_Y, *dest++, *data++, size);
_UNPACKpart(OFFSET_Z, *dest++, *data++, size);
_UNPACKpart(OFFSET_W, *dest , *data, size);
if(size > 0 && _vifRegs->offset == OFFSET_X ) { _UNPACKpart(OFFSET_X, *dest++, *data++); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Y ) { _UNPACKpart(OFFSET_Y, *dest++, *data++); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Z ) { _UNPACKpart(OFFSET_Z, *dest++, *data++); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_W ) { _UNPACKpart(OFFSET_W, *dest , *data); size--; }
if (_vifRegs->offset == 4) _vifRegs->offset = 0;
}
void __fastcall UNPACK_V4_5(u32 *dest, u32 *data, int size)
{
_UNPACKpart(OFFSET_X, *dest++, ((*data & 0x001f) << 3), size);
_UNPACKpart(OFFSET_Y, *dest++, ((*data & 0x03e0) >> 2), size);
_UNPACKpart(OFFSET_Z, *dest++, ((*data & 0x7c00) >> 7), size);
_UNPACKpart(OFFSET_W, *dest, ((*data & 0x8000) >> 8), size);
if(size > 0 && _vifRegs->offset == OFFSET_X ) { _UNPACKpart(OFFSET_X, *dest++, ((*data & 0x001f) << 3)); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Y ) { _UNPACKpart(OFFSET_Y, *dest++, ((*data & 0x03e0) >> 2)); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_Z ) { _UNPACKpart(OFFSET_Z, *dest++, ((*data & 0x7c00) >> 7)); size--; }
if(size > 0 && _vifRegs->offset == OFFSET_W ) { _UNPACKpart(OFFSET_W, *dest, ((*data & 0x8000) >> 8)); size--; }
if (_vifRegs->offset == 4) _vifRegs->offset = 0;
}

View File

@ -29,7 +29,7 @@
using namespace std; // for min / max
//#define VIFUNPACKDEBUG //enable unpack debugging output
#define gif ((DMACh*)&PS2MEM_HW[0xA000])
@ -379,6 +379,7 @@ static void VIFunpack(u32 *data, vifCode *v, int size, const unsigned int VIFdma
VIF_LOG("VIF%d UNPACK: Mode=%x, v->size=%d, size=%d, v->addr=%x",
VIFdmanum, v->cmd & 0xf, v->size, size, v->addr);
VIFUNPACK_LOG("USN %x Masking %x Mask %x Mode %x CL %x WL %x Offset %x", vif->usn, (vifRegs->code & 0x10000000) >> 28, vifRegs->mask, vifRegs->mode, vifRegs->cycle.cl, vifRegs->cycle.wl, vifRegs->offset);
#ifdef _DEBUG
if (v->size != size)
{
@ -422,6 +423,8 @@ static void VIFunpack(u32 *data, vifCode *v, int size, const unsigned int VIFdma
VIFUNPACK_LOG("Aligning packet size = %d offset %d addr %x", size, vifRegs->offset, vif->tag.addr);
if(((size / ft->dsize) + vifRegs->offset) < (u32)ft->qsize)
VIFUNPACK_LOG("Warning! Size needed to align %x size chunks available %x offset %x", ft->qsize - ((size / ft->dsize) + vifRegs->offset), vifRegs->offset);
// SSE doesn't handle such small data
if (v->size != (size >> 2))
ProcessMemSkip(size, unpackType, VIFdmanum);
@ -439,8 +442,9 @@ static void VIFunpack(u32 *data, vifCode *v, int size, const unsigned int VIFdma
unpacksize = 0;
Console::WriteLn("Unpack align offset = 0");
}
VIFUNPACK_LOG("Increasing dest by %x from offset %x", (4 - ft->qsize) + unpacksize, vifRegs->offset);
destinc = (4 - ft->qsize) + unpacksize;
vif->qwcalign += unpacksize * ft->dsize;
func(dest, (u32*)cdata, unpacksize);
size -= unpacksize * ft->dsize;
cdata += unpacksize * ft->dsize;
@ -482,7 +486,6 @@ static void VIFunpack(u32 *data, vifCode *v, int size, const unsigned int VIFdma
while ((size >= ft->gsize) && (vifRegs->num > 0))
{
vif->qwcalign += ft->gsize;
func(dest, (u32*)cdata, ft->qsize);
cdata += ft->gsize;
size -= ft->gsize;
@ -596,7 +599,6 @@ static void VIFunpack(u32 *data, vifCode *v, int size, const unsigned int VIFdma
while ((size >= ft->gsize) && (vifRegs->num > 0))
{
vif->qwcalign += ft->gsize; //Must do this before the transfer, else the confusing packets dont go right :P
func(dest, (u32*)cdata, ft->qsize);
cdata += ft->gsize;
size -= ft->gsize;
@ -651,7 +653,6 @@ static void VIFunpack(u32 *data, vifCode *v, int size, const unsigned int VIFdma
//VIF_LOG("warning, end with size = %d", size);
/* unpack one qword */
vif->qwcalign += (size / ft->dsize) * ft->dsize;
func(dest, (u32*)cdata, size / ft->dsize);
size = 0;
@ -789,7 +790,6 @@ static __forceinline void vif0UNPACK(u32 *data)
len = ((((32 >> vl) * (vn + 1)) * n) + 31) >> 5;
}
vif0.qwcalign = 0;
vif0.cl = 0;
vif0.tag.cmd = vif0.cmd;
vif0.tag.addr &= 0xfff;
@ -1519,7 +1519,7 @@ static __forceinline void vif1UNPACK(u32 *data)
else
vif1.tag.addr = vif1Regs->code & 0x3ff;
vif1.qwcalign = 0;
vif1Regs->offset = 0;
vif1.cl = 0;
vif1.tag.addr <<= 4;
vif1.tag.cmd = vif1.cmd;