2009-10-30 22:34:27 +00:00
|
|
|
/* GSnull
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-11-01 06:47:32 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-10-30 22:34:27 +00:00
|
|
|
*
|
2009-11-01 06:47:32 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-10-30 22:34:27 +00:00
|
|
|
*
|
2009-11-01 06:47:32 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-10-30 22:34:27 +00:00
|
|
|
*/
|
|
|
|
|
2009-11-01 06:47:32 +00:00
|
|
|
|
2009-10-30 22:34:27 +00:00
|
|
|
// Processes a GIFtag & packet, and throws out some gsIRQs as needed.
|
|
|
|
// Used to keep interrupts in sync with the EE, while the GS itself
|
|
|
|
// runs potentially several frames behind.
|
|
|
|
// size - size of the packet in simd128's
|
|
|
|
|
|
|
|
#include "GS.h"
|
|
|
|
#include "GifTransfer.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
extern GSVars gs;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
|
|
|
PCSX2_ALIGNED16( u8 g_RealGSMem[0x2000] );
|
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
// FUNCLOG
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
pathInfo *path = &gs.path[index];
|
2010-08-07 05:46:25 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
while (size > 0)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-07 05:46:25 +00:00
|
|
|
//GS_LOG(_T("Transfer(%08x, %d) START\n"), pMem, size);
|
2010-08-06 09:30:36 +00:00
|
|
|
if (path->nloop == 0)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
path->setTag(pMem);
|
|
|
|
pMem += 4;
|
|
|
|
size--;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
// eeuser 7.2.2. GIFtag: "... when NLOOP is 0, the GIF does not output anything, and
|
|
|
|
// values other than the EOP field are disregarded."
|
|
|
|
if (path->nloop > 0)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
gs.q = 1.0f;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED))
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
u32 tagprim = path->tag.PRIM;
|
2010-08-07 05:46:25 +00:00
|
|
|
GIFRegHandlerPRIM((u32*)&tagprim);
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
switch (path->mode)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
case GIF_FLG_PACKED:
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
// first try a shortcut for a very common case
|
|
|
|
|
|
|
|
if (path->adonly && size >= path->nloop)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-06 09:30:36 +00:00
|
|
|
size -= path->nloop;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
do
|
|
|
|
{
|
2010-08-07 05:46:25 +00:00
|
|
|
GIFPackedRegHandlerA_D(pMem);
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
pMem += 4; //sizeof(GIFPackedReg)/4;
|
|
|
|
}
|
|
|
|
while(--path->nloop > 0);
|
|
|
|
break;
|
|
|
|
}
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
u32 reg = path->GetReg();
|
2010-08-07 05:46:25 +00:00
|
|
|
GIFPackedRegHandlers[reg](pMem);
|
2010-08-06 09:30:36 +00:00
|
|
|
|
|
|
|
pMem += 4; //sizeof(GIFPackedReg)/4;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
while (path->StepReg() && (size > 0));
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
case GIF_FLG_REGLIST:
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
2010-08-07 05:46:25 +00:00
|
|
|
//GS_Log("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
size *= 2;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
do
|
|
|
|
{
|
2010-08-07 05:46:25 +00:00
|
|
|
GIFRegHandlers[path->GetReg()](pMem);
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
pMem += 2;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
while (path->StepReg() && (size > 0));
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
if (size & 1) pMem += 2;
|
|
|
|
size /= 2;
|
|
|
|
break;
|
|
|
|
}
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
case GIF_FLG_IMAGE: // FROM_VFRAM
|
|
|
|
case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too.
|
|
|
|
{
|
|
|
|
int len = min(size, path->nloop);
|
|
|
|
//GS_LOG("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len);
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
switch (gs.imageTransfer)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
//TransferHostLocal(pMem, len * 4);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// This can't happen; downloads can not be started or performed as part of
|
|
|
|
// a GIFtag operation. They're an entirely separate process that can only be
|
|
|
|
// done through the ReverseFIFO transfer (aka ReadFIFO). --air
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
// //TransferLocalLocal();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
//assert(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
//assert(0);
|
|
|
|
break;
|
|
|
|
}
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
pMem += len * 4;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
path->nloop -= len;
|
|
|
|
size -= len;
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
default: // GIF_IMAGE
|
|
|
|
GS_LOG("*** WARNING **** Unexpected GIFTag flag.");
|
|
|
|
assert(0);
|
|
|
|
path->nloop = 0;
|
|
|
|
break;
|
2009-10-30 22:34:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
#define DO_GIF_TRANSFERS
|
2009-10-30 22:34:27 +00:00
|
|
|
|
2010-08-07 08:25:10 +00:00
|
|
|
// Obsolete. Included because it's still in GSdef.
|
|
|
|
EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr)
|
|
|
|
{
|
|
|
|
#ifdef DO_GIF_TRANSFERS
|
|
|
|
_GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr) / 16);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-07 05:46:25 +00:00
|
|
|
EXPORT_C_(void) GSgifTransfer(const u32 *pMem, u32 size)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
#ifdef DO_GIF_TRANSFERS
|
2010-08-07 05:46:25 +00:00
|
|
|
_GSgifTransfer<3>(const_cast<u32*>(pMem), size);
|
2009-10-30 22:34:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
EXPORT_C_(void) GSgifTransfer2(u32 *pMem, u32 size)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
#ifdef DO_GIF_TRANSFERS
|
2010-08-06 09:30:36 +00:00
|
|
|
_GSgifTransfer<1>(const_cast<u32*>(pMem), size);
|
2009-10-30 22:34:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-06 09:30:36 +00:00
|
|
|
EXPORT_C_(void) GSgifTransfer3(u32 *pMem, u32 size)
|
2009-10-30 22:34:27 +00:00
|
|
|
{
|
|
|
|
#ifdef DO_GIF_TRANSFERS
|
2010-08-06 09:30:36 +00:00
|
|
|
_GSgifTransfer<2>(const_cast<u32*>(pMem), size);
|
2009-10-30 22:34:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-06 22:58:30 +00:00
|
|
|
void InitPath()
|
|
|
|
{
|
|
|
|
gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = gs.path[3].mode = 0;
|
|
|
|
}
|
|
|
|
|