2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +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-02-09 21:15:56 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +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-03-30 13:21:15 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +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-02-09 21:15:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PrecompiledHeader.h"
|
|
|
|
#include "Common.h"
|
2009-11-14 12:02:56 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
#include "SPR.h"
|
|
|
|
#include "VUmicro.h"
|
2011-08-12 02:31:49 +00:00
|
|
|
#include "MTVU.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
extern void mfifoGIFtransfer(int);
|
|
|
|
|
2009-09-20 21:24:00 +00:00
|
|
|
static bool spr0finished = false;
|
|
|
|
static bool spr1finished = false;
|
2011-03-15 16:54:13 +00:00
|
|
|
static bool spr0lastqwc = false;
|
|
|
|
static bool spr1lastqwc = false;
|
2009-03-04 13:00:32 +00:00
|
|
|
static u32 mfifotransferred = 0;
|
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
void sprInit()
|
|
|
|
{
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 20:20:14 +00:00
|
|
|
static void TestClearVUs(u32 madr, u32 qwc, bool isWrite)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2012-12-19 20:20:14 +00:00
|
|
|
if (madr >= 0x11000000 && (madr < 0x11010000))
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
|
|
|
if (madr < 0x11004000)
|
|
|
|
{
|
2012-12-19 20:20:14 +00:00
|
|
|
if(isWrite == true)
|
|
|
|
{
|
|
|
|
DbgCon.Warning("scratch pad clearing vu0");
|
|
|
|
|
|
|
|
CpuVU0->Clear(madr&0xfff, qwc * 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(((madr & 0xff0) + (qwc * 16)) > 0x1000 )
|
|
|
|
{
|
|
|
|
DevCon.Warning("Warning! SPR%d Crossing in to VU0 Micro Mirror address! Start MADR = %x, End MADR = %x", isWrite ? 0 : 1, madr, madr + (qwc * 16));
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
else if (madr >= 0x11008000 && madr < 0x1100c000)
|
2012-12-19 20:20:14 +00:00
|
|
|
{
|
|
|
|
if(isWrite == true)
|
|
|
|
{
|
|
|
|
DbgCon.Warning("scratch pad clearing vu1");
|
|
|
|
|
|
|
|
CpuVU1->Clear(madr&0x3fff, qwc * 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (madr >= 0x11004000 && madr < 0x11008000)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2012-12-19 20:20:14 +00:00
|
|
|
//SPR trying to write to to VU0 Mem mirror address.
|
|
|
|
if(((madr & 0xff0) + (qwc * 16)) > 0x1000)
|
|
|
|
{
|
|
|
|
DevCon.Warning("Warning! SPR%d Crossing in to VU0 Mem Mirror address! Start MADR = %x, End MADR = %x", isWrite ? 0 : 1, madr, madr + (qwc * 16));
|
2011-08-12 02:31:49 +00:00
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
int _SPR0chain()
|
|
|
|
{
|
2009-12-05 08:01:00 +00:00
|
|
|
tDMA_TAG *pMem;
|
2011-02-22 22:19:21 +00:00
|
|
|
int partialqwc = 0;
|
2010-08-31 05:22:26 +00:00
|
|
|
if (spr0ch.qwc == 0) return 0;
|
|
|
|
pMem = SPRdmaGetAddr(spr0ch.madr, true);
|
2009-02-09 21:15:56 +00:00
|
|
|
if (pMem == NULL) return -1;
|
|
|
|
|
2011-08-25 13:48:44 +00:00
|
|
|
if(spr0ch.madr >= dmacRegs.rbor.ADDR && spr0ch.madr < (dmacRegs.rbor.ADDR + dmacRegs.rbsr.RMSK + 16))
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2011-04-09 20:21:09 +00:00
|
|
|
partialqwc = spr0ch.qwc;
|
2011-02-22 22:19:21 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if ((spr0ch.madr & ~dmacRegs.rbsr.RMSK) != dmacRegs.rbor.ADDR)
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.WriteLn("SPR MFIFO Write outside MFIFO area");
|
2010-04-25 00:31:27 +00:00
|
|
|
else
|
2011-02-22 22:19:21 +00:00
|
|
|
mfifotransferred += partialqwc;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2011-02-22 22:19:21 +00:00
|
|
|
hwMFIFOWrite(spr0ch.madr, &psSu128(spr0ch.sadr), partialqwc);
|
|
|
|
spr0ch.madr += partialqwc << 4;
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.madr = dmacRegs.rbor.ADDR + (spr0ch.madr & dmacRegs.rbsr.RMSK);
|
2011-02-22 22:19:21 +00:00
|
|
|
spr0ch.sadr += partialqwc << 4;
|
|
|
|
spr0ch.qwc -= partialqwc;
|
2011-08-25 13:36:23 +00:00
|
|
|
|
|
|
|
spr0finished = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-22 22:19:21 +00:00
|
|
|
|
2011-02-02 10:10:04 +00:00
|
|
|
//Taking an arbitary small value for games which like to check the QWC/MADR instead of STR, so get most of
|
|
|
|
//the cycle delay out of the way before the end.
|
2011-04-09 20:21:09 +00:00
|
|
|
partialqwc = spr0ch.qwc;
|
2011-02-02 10:10:04 +00:00
|
|
|
memcpy_qwc(pMem, &psSu128(spr0ch.sadr), partialqwc);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-09-04 02:31:57 +00:00
|
|
|
// clear VU mem also!
|
2012-12-19 20:20:14 +00:00
|
|
|
TestClearVUs(spr0ch.madr, partialqwc, true);
|
2011-02-02 10:10:04 +00:00
|
|
|
|
|
|
|
spr0ch.madr += partialqwc << 4;
|
|
|
|
spr0ch.sadr += partialqwc << 4;
|
|
|
|
spr0ch.qwc -= partialqwc;
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2011-02-02 10:10:04 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2011-02-22 22:19:21 +00:00
|
|
|
return (partialqwc); // bus is 1/2 the ee speed
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi void SPR0chain()
|
2009-04-15 01:25:11 +00:00
|
|
|
{
|
2011-03-15 16:54:13 +00:00
|
|
|
int cycles = 0;
|
2011-03-15 20:04:28 +00:00
|
|
|
cycles = _SPR0chain() * BIAS;
|
2011-04-09 20:21:09 +00:00
|
|
|
CPU_INT(DMAC_FROM_SPR, cycles);
|
2009-04-15 01:25:11 +00:00
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
void _SPR0interleave()
|
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
int qwc = spr0ch.qwc;
|
|
|
|
int sqwc = dmacRegs.sqwc.SQWC;
|
|
|
|
int tqwc = dmacRegs.sqwc.TQWC;
|
2009-12-05 08:01:00 +00:00
|
|
|
tDMA_TAG *pMem;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
if (tqwc == 0) tqwc = qwc;
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
//Console.WriteLn("dmaSPR0 interleave");
|
2009-03-30 13:21:15 +00:00
|
|
|
SPR_LOG("SPR0 interleave size=%d, tqwc=%d, sqwc=%d, addr=%lx sadr=%lx",
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.qwc, tqwc, sqwc, spr0ch.madr, spr0ch.sadr);
|
2009-03-30 13:21:15 +00:00
|
|
|
|
2010-11-19 16:29:28 +00:00
|
|
|
CPU_INT(DMAC_FROM_SPR, qwc * BIAS);
|
2010-06-22 23:10:40 +00:00
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
while (qwc > 0)
|
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.qwc = std::min(tqwc, qwc);
|
|
|
|
qwc -= spr0ch.qwc;
|
|
|
|
pMem = SPRdmaGetAddr(spr0ch.madr, true);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
switch (dmacRegs.ctrl.MFD)
|
2009-09-04 02:31:57 +00:00
|
|
|
{
|
|
|
|
case MFD_VIF1:
|
|
|
|
case MFD_GIF:
|
2010-08-31 05:22:26 +00:00
|
|
|
hwMFIFOWrite(spr0ch.madr, &psSu128(spr0ch.sadr), spr0ch.qwc);
|
|
|
|
mfifotransferred += spr0ch.qwc;
|
2009-09-04 02:31:57 +00:00
|
|
|
break;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-09-04 02:31:57 +00:00
|
|
|
case NO_MFD:
|
|
|
|
case MFD_RESERVED:
|
|
|
|
// clear VU mem also!
|
2012-12-19 20:20:14 +00:00
|
|
|
TestClearVUs(spr0ch.madr, spr0ch.qwc, true);
|
2010-08-31 05:22:26 +00:00
|
|
|
memcpy_qwc(pMem, &psSu128(spr0ch.sadr), spr0ch.qwc);
|
2009-09-04 02:31:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.sadr += spr0ch.qwc * 16;
|
|
|
|
spr0ch.madr += (sqwc + spr0ch.qwc) * 16;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.qwc = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
static __fi void _dmaSPR0()
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
if (dmacRegs.ctrl.STS == STS_fromSPR)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2011-05-04 11:53:24 +00:00
|
|
|
DevCon.Warning("SPR0 stall %d", dmacRegs.ctrl.STS);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
// Transfer Dn_QWC from SPR to Dn_MADR
|
2010-08-31 05:22:26 +00:00
|
|
|
switch(spr0ch.chcr.MOD)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2009-08-19 12:08:50 +00:00
|
|
|
case NORMAL_MODE:
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
|
|
|
SPR0chain();
|
2009-09-20 21:24:00 +00:00
|
|
|
spr0finished = true;
|
2009-03-30 13:21:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-19 12:08:50 +00:00
|
|
|
case CHAIN_MODE:
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2009-12-05 08:01:00 +00:00
|
|
|
tDMA_TAG *ptag;
|
2010-06-22 23:10:40 +00:00
|
|
|
bool done = false;
|
2009-08-19 12:08:50 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (spr0ch.qwc > 0)
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
|
|
|
SPR0chain();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Destination Chain Mode
|
2010-08-31 05:22:26 +00:00
|
|
|
ptag = (tDMA_TAG*)&psSu32(spr0ch.sadr);
|
|
|
|
spr0ch.sadr += 16;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.unsafeTransfer(ptag);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.madr = ptag[1]._u32; //MADR = ADDR field + SPR
|
2009-08-19 12:08:50 +00:00
|
|
|
|
|
|
|
SPR_LOG("spr0 dmaChain %8.8x_%8.8x size=%d, id=%d, addr=%lx spr=%lx",
|
2010-08-31 05:22:26 +00:00
|
|
|
ptag[1]._u32, ptag[0]._u32, spr0ch.qwc, ptag->ID, spr0ch.madr, spr0ch.sadr);
|
2009-08-19 12:08:50 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (dmacRegs.ctrl.STS == STS_fromSPR) // STS == fromSPR
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
Console.WriteLn("SPR stall control");
|
2009-08-19 12:08:50 +00:00
|
|
|
}
|
|
|
|
|
2009-12-05 08:01:00 +00:00
|
|
|
switch (ptag->ID)
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
|
|
|
case TAG_CNTS: // CNTS - Transfer QWC following the tag (Stall Control)
|
2010-08-31 05:22:26 +00:00
|
|
|
if (dmacRegs.ctrl.STS == STS_fromSPR) dmacRegs.stadr.ADDR = spr0ch.madr + (spr0ch.qwc * 16); //Copy MADR to DMAC_STADR stall addr register
|
2009-08-19 12:08:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_CNT: // CNT - Transfer QWC following the tag.
|
2009-10-19 11:45:37 +00:00
|
|
|
done = false;
|
2009-08-19 12:08:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG_END: // End - Transfer QWC following the tag
|
2009-10-19 11:45:37 +00:00
|
|
|
done = true;
|
2009-08-19 12:08:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-08-19 12:08:50 +00:00
|
|
|
SPR0chain();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (spr0ch.chcr.TIE && ptag->IRQ) //Check TIE bit of CHCR and IRQ bit of tag
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
//Console.WriteLn("SPR0 TIE");
|
2009-10-19 11:45:37 +00:00
|
|
|
done = true;
|
2009-08-19 12:08:50 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-09-20 21:24:00 +00:00
|
|
|
spr0finished = done;
|
2009-08-19 12:08:50 +00:00
|
|
|
SPR_LOG("spr0 dmaChain complete %8.8x_%8.8x size=%d, id=%d, addr=%lx spr=%lx",
|
2010-08-31 05:22:26 +00:00
|
|
|
ptag[1]._u32, ptag[0]._u32, spr0ch.qwc, ptag->ID, spr0ch.madr);
|
2009-08-19 12:08:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
//case INTERLEAVE_MODE:
|
|
|
|
default:
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2009-08-19 12:08:50 +00:00
|
|
|
_SPR0interleave();
|
2010-06-25 23:13:41 +00:00
|
|
|
spr0finished = true;
|
2009-08-19 12:08:50 +00:00
|
|
|
break;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-02-12 23:19:54 +00:00
|
|
|
void SPRFROMinterrupt()
|
|
|
|
{
|
2010-06-22 23:10:40 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (!spr0finished || spr0ch.qwc > 0)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2010-06-22 23:10:40 +00:00
|
|
|
_dmaSPR0();
|
|
|
|
|
2011-03-15 20:03:03 +00:00
|
|
|
//the qwc check is simply because having data still to transfer from the packet can freak games out if they do a d.tadr == s.madr check
|
|
|
|
//and there is still data to come over (FF12 ingame menu)
|
|
|
|
if(mfifotransferred != 0 && spr0ch.qwc == 0)
|
2009-04-12 04:56:06 +00:00
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
switch (dmacRegs.ctrl.MFD)
|
2009-09-04 02:31:57 +00:00
|
|
|
{
|
2010-06-22 23:10:40 +00:00
|
|
|
case MFD_VIF1: // Most common case.
|
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
if ((spr0ch.madr & ~dmacRegs.rbsr.RMSK) != dmacRegs.rbor.ADDR) Console.WriteLn("VIF MFIFO Write outside MFIFO area");
|
|
|
|
spr0ch.madr = dmacRegs.rbor.ADDR + (spr0ch.madr & dmacRegs.rbsr.RMSK);
|
|
|
|
//Console.WriteLn("mfifoVIF1transfer %x madr %x, tadr %x", vif1ch.chcr._u32, vif1ch.madr, vif1ch.tadr);
|
2010-06-22 23:10:40 +00:00
|
|
|
mfifoVIF1transfer(mfifotransferred);
|
|
|
|
mfifotransferred = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MFD_GIF:
|
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
if ((spr0ch.madr & ~dmacRegs.rbsr.RMSK) != dmacRegs.rbor.ADDR) Console.WriteLn("GIF MFIFO Write outside MFIFO area");
|
|
|
|
spr0ch.madr = dmacRegs.rbor.ADDR + (spr0ch.madr & dmacRegs.rbsr.RMSK);
|
2010-06-22 23:10:40 +00:00
|
|
|
//Console.WriteLn("mfifoGIFtransfer %x madr %x, tadr %x", gif->chcr._u32, gif->madr, gif->tadr);
|
|
|
|
mfifoGIFtransfer(mfifotransferred);
|
|
|
|
mfifotransferred = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2009-09-04 02:31:57 +00:00
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
}
|
2011-04-09 20:21:09 +00:00
|
|
|
|
|
|
|
return;
|
2009-04-12 04:56:06 +00:00
|
|
|
}
|
2010-04-15 00:32:58 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2011-03-15 16:54:13 +00:00
|
|
|
spr0lastqwc = false;
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.chcr.STR = false;
|
2009-06-06 09:24:10 +00:00
|
|
|
hwDmacIrq(DMAC_FROM_SPR);
|
2011-02-24 11:07:13 +00:00
|
|
|
DMA_LOG("SPR0 DMA End");
|
2009-02-12 23:19:54 +00:00
|
|
|
}
|
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
void dmaSPR0() // fromSPR
|
|
|
|
{
|
2009-03-27 06:34:51 +00:00
|
|
|
SPR_LOG("dmaSPR0 chcr = %lx, madr = %lx, qwc = %lx, sadr = %lx",
|
2010-08-31 05:22:26 +00:00
|
|
|
spr0ch.chcr._u32, spr0ch.madr, spr0ch.qwc, spr0ch.sadr);
|
2009-02-13 21:22:50 +00:00
|
|
|
|
2010-06-22 23:10:40 +00:00
|
|
|
|
|
|
|
spr0finished = false; //Init
|
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if(spr0ch.chcr.MOD == CHAIN_MODE && spr0ch.qwc > 0)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
//DevCon.Warning(L"SPR0 QWC on Chain " + spr0ch.chcr.desc());
|
|
|
|
if (spr0ch.chcr.tag().ID == TAG_END) // but not TAG_REFE?
|
2011-03-15 16:54:13 +00:00
|
|
|
{ // Correct not REFE, Destination Chain doesnt have REFE!
|
2010-06-22 23:10:40 +00:00
|
|
|
spr0finished = true;
|
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
}
|
2010-06-22 23:10:40 +00:00
|
|
|
|
|
|
|
SPRFROMinterrupt();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi static void SPR1transfer(const void* data, int qwc)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2012-12-19 20:20:14 +00:00
|
|
|
if ((spr1ch.madr >= 0x11000000) && (spr1ch.madr < 0x11010000))
|
|
|
|
{
|
|
|
|
TestClearVUs(spr1ch.madr, spr1ch.qwc, false);
|
|
|
|
}
|
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
memcpy_qwc(&psSu128(spr1ch.sadr), data, qwc);
|
|
|
|
spr1ch.sadr += qwc * 16;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 16:54:13 +00:00
|
|
|
|
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
int _SPR1chain()
|
|
|
|
{
|
2009-12-05 08:01:00 +00:00
|
|
|
tDMA_TAG *pMem;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (spr1ch.qwc == 0) return 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
pMem = SPRdmaGetAddr(spr1ch.madr, false);
|
2009-02-09 21:15:56 +00:00
|
|
|
if (pMem == NULL) return -1;
|
2011-02-02 10:10:04 +00:00
|
|
|
int partialqwc = 0;
|
|
|
|
//Taking an arbitary small value for games which like to check the QWC/MADR instead of STR, so get most of
|
|
|
|
//the cycle delay out of the way before the end.
|
2011-04-09 20:21:09 +00:00
|
|
|
partialqwc = spr1ch.qwc;
|
2011-02-02 10:10:04 +00:00
|
|
|
|
|
|
|
SPR1transfer(pMem, partialqwc);
|
|
|
|
spr1ch.madr += partialqwc * 16;
|
|
|
|
spr1ch.qwc -= partialqwc;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-11-19 16:29:28 +00:00
|
|
|
hwDmacSrcTadrInc(spr1ch);
|
2011-03-15 16:54:13 +00:00
|
|
|
|
2011-02-02 10:10:04 +00:00
|
|
|
return (partialqwc);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-09 04:10:38 +00:00
|
|
|
__fi void SPR1chain()
|
2009-04-15 01:25:11 +00:00
|
|
|
{
|
2011-03-15 16:54:13 +00:00
|
|
|
int cycles = 0;
|
2011-02-24 11:07:13 +00:00
|
|
|
if(!CHECK_IPUWAITHACK)
|
|
|
|
{
|
2011-03-15 20:04:28 +00:00
|
|
|
cycles = _SPR1chain() * BIAS;
|
2011-04-09 20:21:09 +00:00
|
|
|
CPU_INT(DMAC_TO_SPR, cycles);
|
2011-02-24 11:07:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_SPR1chain();
|
|
|
|
CPU_INT(DMAC_TO_SPR, 8);
|
|
|
|
}
|
2009-04-15 01:25:11 +00:00
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
void _SPR1interleave()
|
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
int qwc = spr1ch.qwc;
|
|
|
|
int sqwc = dmacRegs.sqwc.SQWC;
|
|
|
|
int tqwc = dmacRegs.sqwc.TQWC;
|
2009-12-05 08:01:00 +00:00
|
|
|
tDMA_TAG *pMem;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
if (tqwc == 0) tqwc = qwc;
|
|
|
|
SPR_LOG("SPR1 interleave size=%d, tqwc=%d, sqwc=%d, addr=%lx sadr=%lx",
|
2010-08-31 05:22:26 +00:00
|
|
|
spr1ch.qwc, tqwc, sqwc, spr1ch.madr, spr1ch.sadr);
|
2010-11-19 16:29:28 +00:00
|
|
|
CPU_INT(DMAC_TO_SPR, qwc * BIAS);
|
2009-03-30 13:21:15 +00:00
|
|
|
while (qwc > 0)
|
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
spr1ch.qwc = std::min(tqwc, qwc);
|
|
|
|
qwc -= spr1ch.qwc;
|
|
|
|
pMem = SPRdmaGetAddr(spr1ch.madr, false);
|
|
|
|
memcpy_qwc(&psSu128(spr1ch.sadr), pMem, spr1ch.qwc);
|
|
|
|
spr1ch.sadr += spr1ch.qwc * 16;
|
|
|
|
spr1ch.madr += (sqwc + spr1ch.qwc) * 16;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
spr1ch.qwc = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
void _dmaSPR1() // toSPR work function
|
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
switch(spr1ch.chcr.MOD)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2009-08-19 12:08:50 +00:00
|
|
|
case NORMAL_MODE:
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2009-08-19 12:08:50 +00:00
|
|
|
//int cycles = 0;
|
2009-02-25 19:31:26 +00:00
|
|
|
// Transfer Dn_QWC from Dn_MADR to SPR1
|
|
|
|
SPR1chain();
|
2009-09-20 21:24:00 +00:00
|
|
|
spr1finished = true;
|
2009-02-25 19:31:26 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-19 12:08:50 +00:00
|
|
|
case CHAIN_MODE:
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2009-12-05 08:01:00 +00:00
|
|
|
tDMA_TAG *ptag;
|
2009-08-29 00:35:20 +00:00
|
|
|
bool done = false;
|
2009-08-19 12:08:50 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (spr1ch.qwc > 0)
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
SPR_LOG("spr1 Normal or in Progress size=%d, addr=%lx taddr=%lx saddr=%lx", spr1ch.qwc, spr1ch.madr, spr1ch.tadr, spr1ch.sadr);
|
2009-08-19 12:08:50 +00:00
|
|
|
// Transfer Dn_QWC from Dn_MADR to SPR1
|
|
|
|
SPR1chain();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Chain Mode
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
ptag = SPRdmaGetAddr(spr1ch.tadr, false); //Set memory pointer to TADR
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (!spr1ch.transfer("SPR1 Tag", ptag))
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
2009-08-29 00:35:20 +00:00
|
|
|
done = true;
|
2009-09-20 21:24:00 +00:00
|
|
|
spr1finished = done;
|
2009-08-19 12:08:50 +00:00
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
spr1ch.madr = ptag[1]._u32; //MADR = ADDR field + SPR
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-08-19 12:08:50 +00:00
|
|
|
// Transfer dma tag if tte is set
|
2010-08-31 05:22:26 +00:00
|
|
|
if (spr1ch.chcr.TTE)
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
2009-12-05 08:01:00 +00:00
|
|
|
SPR_LOG("SPR TTE: %x_%x\n", ptag[3]._u32, ptag[2]._u32);
|
2010-07-19 05:40:35 +00:00
|
|
|
SPR1transfer(ptag, 1); //Transfer Tag
|
2009-08-19 12:08:50 +00:00
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
|
2010-06-22 23:10:40 +00:00
|
|
|
SPR_LOG("spr1 dmaChain %8.8x_%8.8x size=%d, id=%d, addr=%lx taddr=%lx saddr=%lx",
|
2010-08-31 05:22:26 +00:00
|
|
|
ptag[1]._u32, ptag[0]._u32, spr1ch.qwc, ptag->ID, spr1ch.madr, spr1ch.tadr, spr1ch.sadr);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
done = (hwDmacSrcChain(spr1ch, ptag->ID));
|
2009-08-19 12:08:50 +00:00
|
|
|
SPR1chain(); //Transfers the data set by the switch
|
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if (spr1ch.chcr.TIE && ptag->IRQ) //Check TIE bit of CHCR and IRQ bit of tag
|
2009-08-19 12:08:50 +00:00
|
|
|
{
|
|
|
|
SPR_LOG("dmaIrq Set");
|
2009-03-30 13:21:15 +00:00
|
|
|
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
//Console.WriteLn("SPR1 TIE");
|
2009-08-29 00:35:20 +00:00
|
|
|
done = true;
|
2009-08-19 12:08:50 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-08-19 12:08:50 +00:00
|
|
|
spr1finished = done;
|
|
|
|
break;
|
2009-02-25 19:31:26 +00:00
|
|
|
}
|
2009-08-19 12:08:50 +00:00
|
|
|
//case INTERLEAVE_MODE:
|
|
|
|
default:
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2009-08-19 12:08:50 +00:00
|
|
|
_SPR1interleave();
|
2010-06-25 23:13:41 +00:00
|
|
|
spr1finished = true;
|
2009-08-19 12:08:50 +00:00
|
|
|
break;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
}
|
2009-02-12 23:19:54 +00:00
|
|
|
}
|
2009-10-19 11:45:37 +00:00
|
|
|
|
2009-03-30 13:21:15 +00:00
|
|
|
void dmaSPR1() // toSPR
|
|
|
|
{
|
2009-02-12 23:19:54 +00:00
|
|
|
SPR_LOG("dmaSPR1 chcr = 0x%x, madr = 0x%x, qwc = 0x%x\n"
|
2009-03-30 13:21:15 +00:00
|
|
|
" tadr = 0x%x, sadr = 0x%x",
|
2010-08-31 05:22:26 +00:00
|
|
|
spr1ch.chcr._u32, spr1ch.madr, spr1ch.qwc,
|
|
|
|
spr1ch.tadr, spr1ch.sadr);
|
2010-06-22 23:10:40 +00:00
|
|
|
|
|
|
|
spr1finished = false; //Init
|
|
|
|
|
2010-08-31 05:22:26 +00:00
|
|
|
if(spr1ch.chcr.MOD == CHAIN_MODE && spr1ch.qwc > 0)
|
2009-03-30 13:21:15 +00:00
|
|
|
{
|
2010-08-31 05:22:26 +00:00
|
|
|
//DevCon.Warning(L"SPR1 QWC on Chain " + spr1ch.chcr.desc());
|
|
|
|
if ((spr1ch.chcr.tag().ID == TAG_END) || (spr1ch.chcr.tag().ID == TAG_REFE))
|
2010-06-22 23:10:40 +00:00
|
|
|
{
|
|
|
|
spr1finished = true;
|
|
|
|
}
|
2009-03-30 13:21:15 +00:00
|
|
|
}
|
2010-06-22 23:10:40 +00:00
|
|
|
|
|
|
|
SPRTOinterrupt();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SPRTOinterrupt()
|
|
|
|
{
|
2010-06-22 23:10:40 +00:00
|
|
|
SPR_LOG("SPR1 Interrupt");
|
2010-08-31 05:22:26 +00:00
|
|
|
if (!spr1finished || spr1ch.qwc > 0)
|
2010-06-22 23:10:40 +00:00
|
|
|
{
|
|
|
|
_dmaSPR1();
|
2011-04-09 20:21:09 +00:00
|
|
|
return;
|
2010-06-22 23:10:40 +00:00
|
|
|
}
|
2010-04-15 00:32:58 +00:00
|
|
|
|
2011-02-24 11:07:13 +00:00
|
|
|
DMA_LOG("SPR1 DMA End");
|
2010-08-31 05:22:26 +00:00
|
|
|
spr1ch.chcr.STR = false;
|
2011-03-15 16:54:13 +00:00
|
|
|
spr1lastqwc = false;
|
2009-06-06 09:24:10 +00:00
|
|
|
hwDmacIrq(DMAC_TO_SPR);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 17:23:02 +00:00
|
|
|
void SaveStateBase::sprFreeze()
|
2009-03-04 13:00:32 +00:00
|
|
|
{
|
2009-03-30 13:21:15 +00:00
|
|
|
FreezeTag("SPRdma");
|
2009-03-19 04:16:24 +00:00
|
|
|
|
|
|
|
Freeze(spr0finished);
|
|
|
|
Freeze(spr1finished);
|
|
|
|
Freeze(mfifotransferred);
|
2009-09-19 05:03:54 +00:00
|
|
|
}
|