1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/* GSnull
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
// 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;
extern GSVars gs;
PCSX2_ALIGNED16(u8 g_RealGSMem[0x2000]);
template <int index>
void _GSgifTransfer(const u32 *pMem, u32 size)
{
// FUNCLOG
pathInfo *path = &gs.path[index];
while (size > 0) {
//GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size);
if (path->nloop == 0) {
path->setTag(pMem);
pMem += 4;
size--;
// 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) {
gs.q = 1.0f;
if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED)) {
u32 tagprim = path->tag.PRIM;
GIFRegHandlerPRIM((u32 *)&tagprim);
}
}
} else {
switch (path->mode) {
case GIF_FLG_PACKED: {
// first try a shortcut for a very common case
if (path->adonly && size >= path->nloop) {
size -= path->nloop;
do {
GIFPackedRegHandlerA_D(pMem);
pMem += 4; //sizeof(GIFPackedReg)/4;
} while (--path->nloop > 0);
break;
}
do {
u32 reg = path->GetReg();
GIFPackedRegHandlers[reg](pMem);
pMem += 4; //sizeof(GIFPackedReg)/4;
size--;
} while (path->StepReg() && (size > 0));
break;
}
case GIF_FLG_REGLIST: {
//GSLog::Writeln("%8.8x%8.8x %d L", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
size *= 2;
do {
GIFRegHandlers[path->GetReg()](pMem);
pMem += 2;
size--;
} while (path->StepReg() && (size > 0));
if (size & 1)
pMem += 2;
size /= 2;
break;
}
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);
//GSLog::Writeln("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len);
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;
}
pMem += len * 4;
path->nloop -= len;
size -= len;
break;
}
default: // GIF_IMAGE
GSLog::WriteLn("*** WARNING **** Unexpected GIFTag flag.");
assert(0);
path->nloop = 0;
break;
}
}
}
}
#define DO_GIF_TRANSFERS
// 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
}
EXPORT_C_(void)
GSgifTransfer(const u32 *pMem, u32 size)
{
#ifdef DO_GIF_TRANSFERS
_GSgifTransfer<3>(const_cast<u32 *>(pMem), size);
#endif
}
EXPORT_C_(void)
GSgifTransfer2(u32 *pMem, u32 size)
{
#ifdef DO_GIF_TRANSFERS
_GSgifTransfer<1>(const_cast<u32 *>(pMem), size);
#endif
}
EXPORT_C_(void)
GSgifTransfer3(u32 *pMem, u32 size)
{
#ifdef DO_GIF_TRANSFERS
_GSgifTransfer<2>(const_cast<u32 *>(pMem), size);
#endif
}
void InitPath()
{
gs.path[0].mode = gs.path[1].mode = gs.path[2].mode = gs.path[3].mode = 0;
}
|