The last changes to clean up Vif wouldn't have worked in some situations, tried to rearrange it and space things out and skipping unnecessary checks

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@935 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
refraction 2009-04-09 21:02:37 +00:00
parent cf0c393514
commit feaed9f4fa
1 changed files with 46 additions and 99 deletions

View File

@ -356,77 +356,56 @@ static void _UNPACKpart(u32 offnum, u32 &x, T y)
template <class T> template <class T>
void __fastcall UNPACK_S(u32 *dest, T *data, int size) void __fastcall UNPACK_S(u32 *dest, T *data, int size)
{ {
while (size > 0) //S-# will always be a complete packet, no matter what. So we can skip the offset bits
{ writeX(*dest++, *data);
switch (_vifRegs->offset) writeY(*dest++, *data);
{ writeZ(*dest++, *data);
case OFFSET_X: writeW(*dest , *data);
case OFFSET_Y:
case OFFSET_Z:
_UNPACKpart(_vifRegs->offset, *dest++, *data);
size--;
break;
case OFFSET_W:
_UNPACKpart(_vifRegs->offset, *dest , *data);
size--;
break;
default:
if ((_vifRegs->offset > OFFSET_W) || (_vifRegs->offset < OFFSET_X)) _vifRegs->offset = 0;
break;
}
}
} }
template <class T> template <class T>
void __fastcall UNPACK_V2(u32 *dest, T *data, int size) void __fastcall UNPACK_V2(u32 *dest, T *data, int size)
{ {
while (size > 0) if(_vifRegs->offset == OFFSET_X && size > 0)
{ {
switch (_vifRegs->offset) _UNPACKpart(_vifRegs->offset, *dest++, *data++);
{ }
case OFFSET_X: if(_vifRegs->offset == OFFSET_Y && size > 0)
_UNPACKpart(_vifRegs->offset, *dest++, *data++); {
size--; _UNPACKpart(_vifRegs->offset, *dest++, *data);
break; }
case OFFSET_Y: if(_vifRegs->offset == OFFSET_Z)
_UNPACKpart(_vifRegs->offset, *dest++, *data); {
size--; _UNPACKpart(_vifRegs->offset, *dest++, *dest-2);
break; }
case OFFSET_Z: if(_vifRegs->offset == OFFSET_W)
_UNPACKpart(_vifRegs->offset, *dest++, *dest-2); {
break; _UNPACKpart(_vifRegs->offset, *dest, *data);
case OFFSET_W: _vifRegs->offset = 0;
_UNPACKpart(_vifRegs->offset, *dest , *data);
break;
default:
if ((_vifRegs->offset > OFFSET_W) || (_vifRegs->offset < OFFSET_X)) _vifRegs->offset = 0;
break;
}
} }
} }
template <class T> template <class T>
void __fastcall UNPACK_V3(u32 *dest, T *data, int size) void __fastcall UNPACK_V3(u32 *dest, T *data, int size)
{ {
while (size > 0) if(_vifRegs->offset == OFFSET_X && size > 0)
{ {
switch (_vifRegs->offset) _UNPACKpart(_vifRegs->offset, *dest++, *data++);
{ }
case OFFSET_X: if(_vifRegs->offset == OFFSET_Y && size > 0)
case OFFSET_Y: {
case OFFSET_Z: _UNPACKpart(_vifRegs->offset, *dest++, *data++);
_UNPACKpart(_vifRegs->offset, *dest++, *data++); }
size--; if(_vifRegs->offset == OFFSET_Z)
break; {
//V3-# does some bizzare thing with alignment, every 6qw of data the W becomes 0 (strange console!) _UNPACKpart(_vifRegs->offset, *dest++, *data++);
//Ape Escape doesnt seem to like it tho (what the hell?) gonna have to investigate }
case OFFSET_W: if(_vifRegs->offset == OFFSET_W)
_UNPACKpart(_vifRegs->offset, *dest, *data); {
break; //V3-# does some bizzare thing with alignment, every 6qw of data the W becomes 0 (strange console!)
default: //Ape Escape doesnt seem to like it tho (what the hell?) gonna have to investigate
if ((_vifRegs->offset > OFFSET_W) || (_vifRegs->offset < OFFSET_X)) _vifRegs->offset = 0; _UNPACKpart(_vifRegs->offset, *dest, *data);
break; _vifRegs->offset = 0;
}
} }
} }
@ -435,52 +414,20 @@ void __fastcall UNPACK_V4(u32 *dest, T *data , int size)
{ {
while (size > 0) while (size > 0)
{ {
switch (_vifRegs->offset) _UNPACKpart(_vifRegs->offset, *dest++, *data++);
{ size--;
case OFFSET_X:
case OFFSET_Y:
case OFFSET_Z:
_UNPACKpart(_vifRegs->offset, *dest++, *data++);
size--;
break;
case OFFSET_W:
_UNPACKpart(_vifRegs->offset, *dest , *data);
size--;
break;
default:
if ((_vifRegs->offset > OFFSET_W) || (_vifRegs->offset < OFFSET_X)) _vifRegs->offset = 0;
break;
}
} }
if (_vifRegs->offset > OFFSET_W) _vifRegs->offset = 0;
} }
void __fastcall UNPACK_V4_5(u32 *dest, u32 *data, int size) void __fastcall UNPACK_V4_5(u32 *dest, u32 *data, int size)
{ {
while (size > 0) //As with S-#, this will always be a complete packet
{ writeX(*dest++, ((*data & 0x001f) << 3));
switch (_vifRegs->offset) writeY(*dest++, ((*data & 0x03e0) >> 2));
{ writeZ(*dest++, ((*data & 0x7c00) >> 7));
case OFFSET_X: writeW(*dest, ((*data & 0x8000) >> 8));
_UNPACKpart(_vifRegs->offset, *dest++, ((*data & 0x001f) << 3));
size--;
break;
case OFFSET_Y:
_UNPACKpart(_vifRegs->offset, *dest++, ((*data & 0x03e0) >> 2));
size--;
break;
case OFFSET_Z:
_UNPACKpart(_vifRegs->offset, *dest++, ((*data & 0x7c00) >> 7));
size--;
break;
case OFFSET_W:
_UNPACKpart(_vifRegs->offset, *dest, ((*data & 0x8000) >> 8));
size--;
break;
default:
if ((_vifRegs->offset > OFFSET_W) || (_vifRegs->offset < OFFSET_X)) _vifRegs->offset = 0;
break;
}
}
} }
void __fastcall UNPACK_S_32(u32 *dest, u32 *data, int size) void __fastcall UNPACK_S_32(u32 *dest, u32 *data, int size)