diff --git a/pcsx2/FiFo.cpp b/pcsx2/FiFo.cpp index eb8a821942..d8aaf8bb02 100644 --- a/pcsx2/FiFo.cpp +++ b/pcsx2/FiFo.cpp @@ -56,9 +56,7 @@ void __fastcall ReadFIFO_VIF1(mem128_t* out) GetMTGS().WaitGS(); GSreadFIFO((u64*)out); vif1.GSLastDownloadSize--; -#if USE_OLD_GIF == 0 // d GUNIT_LOG("ReadFIFO_VIF1"); -#endif if (vif1.GSLastDownloadSize <= 16) gifRegs.stat.OPH = false; vif1Regs.stat.FQC = min((u32)16, vif1.GSLastDownloadSize); @@ -95,61 +93,30 @@ void __fastcall WriteFIFO_VIF1(const mem128_t *value) { VIF_LOG("WriteFIFO/VIF1 <- %ls", value->ToString().c_str()); - if (vif1Regs.stat.FDR) + if (vif1Regs.stat.FDR) { DevCon.Warning("writing to fifo when fdr is set!"); - if (vif1Regs.stat.test(VIF1_STAT_INT | VIF1_STAT_VSS | VIF1_STAT_VIS | VIF1_STAT_VFS) ) + } + if (vif1Regs.stat.test(VIF1_STAT_INT | VIF1_STAT_VSS | VIF1_STAT_VIS | VIF1_STAT_VFS) ) { DevCon.Warning("writing to vif1 fifo when stalled"); + } + if (vif1.irqoffset != 0 && vif1.vifstalled == true) { + DevCon.Warning("Offset on VIF1 FIFO start!"); + } vif1ch.qwc += 1; - if(vif1.irqoffset != 0 && vif1.vifstalled == true) DevCon.Warning("Offset on VIF1 FIFO start!"); + bool ret = VIF1transfer((u32*)value, 4); -#if USE_OLD_GIF == 1 // d - if(GSTransferStatus.PTH2 == STOPPED_MODE && gifRegs.stat.APATH == GIF_APATH2) - { - if(gifRegs.stat.DIR == 0)gifRegs.stat.OPH = false; - gifRegs.stat.APATH = GIF_APATH_IDLE; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - } -#endif - - if (vif1.cmd) - { - if(vif1.done == true && vif1ch.qwc == 0) vif1Regs.stat.VPS = VPS_WAITING; - } - else - { - vif1Regs.stat.VPS = VPS_IDLE; + if (vif1.cmd) { + if (vif1.done && !vif1ch.qwc) vif1Regs.stat.VPS = VPS_WAITING; } + else vif1Regs.stat.VPS = VPS_IDLE; pxAssertDev( ret, "vif stall code not implemented" ); } void __fastcall WriteFIFO_GIF(const mem128_t *value) { -#if USE_OLD_GIF == 1 // d - GIF_LOG("WriteFIFO/GIF <- %ls", value->ToString().c_str()); - - //CopyQWC(&psHu128(GIF_FIFO), value); - //CopyQWC(&nloop0_packet, value); - - GetMTGS().PrepDataPacket(GIF_PATH_3, 1); - GIFPath_CopyTag( GIF_PATH_3, value, 1 ); - GetMTGS().SendDataPacket(); - - if(GSTransferStatus.PTH3 >= PENDINGSTOP_MODE ) - { - GSTransferStatus.PTH3 = STOPPED_MODE; - if(gifRegs.stat.APATH == GIF_APATH3) - { - if(gifRegs.stat.DIR == 0)gifRegs.stat.OPH = false; - gifRegs.stat.APATH = GIF_APATH_IDLE; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - } - } -#else GUNIT_LOG("WriteFIFO_GIF()"); gifUnit.TransferGSPacketData(GIF_TRANS_FIFO, (u8*)value, 16); -#endif } - diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index 85152eb794..6bc9adcfc4 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -52,11 +52,6 @@ void gsInit() memzero(g_RealGSMem); } -#if USE_OLD_GIF == 1 // d -extern bool SIGNAL_IMR_Pending; -extern u32 SIGNAL_Data_Pending[2]; -#endif - void gsReset() { GetMTGS().ResetGS(); @@ -64,15 +59,6 @@ void gsReset() UpdateVSyncRate(); memzero(g_RealGSMem); -#if USE_OLD_GIF == 1 // d - GSTransferStatus = (STOPPED_MODE<<8) | (STOPPED_MODE<<4) | STOPPED_MODE; - SIGNAL_IMR_Pending = false; - - // FIXME: This really doesn't belong here, and I seriously doubt it's needed. - // If it is needed it should be in the GIF portion of hwReset(). --air - gifUnit.ResetRegs(); -#endif - CSRreg.Reset(); GSIMR = 0x7f00; } @@ -84,16 +70,12 @@ static __fi void gsCSRwrite( const tGS_CSR& csr ) // perform a soft reset -- which is a clearing of all GIFpaths -- and fall back to doing // a full reset if the plugin doesn't support soft resets. - if( GSgifSoftReset != NULL ) - { + if (GSgifSoftReset != NULL) { GIFPath_Clear( GIF_PATH_1 ); GIFPath_Clear( GIF_PATH_2 ); GIFPath_Clear( GIF_PATH_3 ); } - else - { - GetMTGS().SendSimplePacket( GS_RINGTYPE_RESET, 0, 0, 0 ); - } + else GetMTGS().SendSimplePacket( GS_RINGTYPE_RESET, 0, 0, 0 ); SIGNAL_IMR_Pending = false; #else @@ -115,26 +97,8 @@ static __fi void gsCSRwrite( const tGS_CSR& csr ) if(csr.SIGNAL) { -#if USE_OLD_GIF == 1 // d // SIGNAL : What's not known here is whether or not the SIGID register should be updated // here or when the IMR is cleared (below). - - if(SIGNAL_IMR_Pending == true) - { - //DevCon.Warning("Firing pending signal"); - GIF_LOG("GS SIGNAL (pending) data=%x_%x IMR=%x CSRr=%x",SIGNAL_Data_Pending[0], SIGNAL_Data_Pending[1], GSIMR, GSCSRr); - GSSIGLBLID.SIGID = (GSSIGLBLID.SIGID&~SIGNAL_Data_Pending[1])|(SIGNAL_Data_Pending[0]&SIGNAL_Data_Pending[1]); - - if (!(GSIMR&0x100)) gsIrq(); - - CSRreg.SIGNAL = true; //Just to be sure :P - } - else CSRreg.SIGNAL = false; - - SIGNAL_IMR_Pending = false; - - if(gifRegs.stat.P1Q && gifRegs.stat.APATH <= GIF_APATH1) gsPath1Interrupt(); -#else GUNIT_LOG("csr.SIGNAL"); if (gifUnit.gsSIGNAL.queued) { //DevCon.Warning("Firing pending signal"); @@ -142,12 +106,11 @@ static __fi void gsCSRwrite( const tGS_CSR& csr ) | (gifUnit.gsSIGNAL.data[0]&gifUnit.gsSIGNAL.data[1]); if (!(GSIMR&0x100)) gsIrq(); - CSRreg.SIGNAL = true; // Just to be sure :P + CSRreg.SIGNAL = true; // Just to be sure :p } else CSRreg.SIGNAL = false; gifUnit.gsSIGNAL.queued = false; - gifUnit.Execute(); -#endif + gifUnit.Execute(); // Resume paused transfers } if(csr.FINISH) CSRreg.FINISH = false; @@ -163,9 +126,8 @@ static __fi void IMRwrite(u32 value) if(CSRreg.GetInterruptMask() & (~(GSIMR >> 8) & 0x1f)) gsIrq(); -#if USE_OLD_GIF == 1 // d - if( SIGNAL_IMR_Pending && !(GSIMR & 0x100)) - { + GUNIT_LOG("IMRwrite()"); + if (gifUnit.gsSIGNAL.queued && !(GSIMR & 0x100)) { // Note: PS2 apps are expected to write a successive 1 and 0 to the IMR in order to // trigger the gsInt and clear the second pending SIGNAL interrupt -- if they fail // to do so, the GS will freeze again upon the very next SIGNAL). @@ -173,19 +135,9 @@ static __fi void IMRwrite(u32 value) // What's not known here is whether or not the SIGID register should be updated // here or when the GS is resumed during CSR write (above). - //GIF_LOG("GS SIGNAL (pending) data=%x_%x IMR=%x CSRr=%x\n",CSR_SIGNAL_Data[0], CSR_SIGNAL_Data[1], GSIMR, GSCSRr); - //GSSIGLBLID.SIGID = (GSSIGLBLID.SIGID&~CSR_SIGNAL_Data[1])|(CSR_SIGNAL_Data[0]&CSR_SIGNAL_Data[1]); - CSRreg.SIGNAL = true; gsIrq(); } -#else - GUNIT_LOG("IMRwrite()"); - if (gifUnit.gsSIGNAL.queued && !(GSIMR & 0x100)) { - CSRreg.SIGNAL = true; - gsIrq(); - } -#endif } __fi void gsWrite8(u32 mem, u8 value) @@ -308,14 +260,19 @@ void __fastcall gsWrite64_page_01( u32 mem, const mem64_t* value ) switch( mem ) { case GS_BUSDIR: -#if USE_OLD_GIF == 1 // d //This is probably a complete hack, however writing to BUSDIR "should" start a transfer //Only problem is it kills killzone :(. // (yes it *is* a complete hack; both lines here in fact --air) //========================================================================= //gifRegs.stat.OPH = true; // Bleach wants it, Killzone hates it. - - gifRegs.stat.DIR = (u32)value[0]; + + GUNIT_LOG("GIF - busdir"); + gifRegs.stat.DIR = value[0] & 1; + if (gifRegs.stat.DIR) { // Assume will do local->host transfer? + gifRegs.stat.OPH = true; // Is OPH set on local->host transfers? + DevCon.WriteLn("Busdir - Local->Host Transfer"); + } + //========================================================================= // BUSDIR INSANITY !! MTGS FLUSH NEEDED // @@ -327,16 +284,6 @@ void __fastcall gsWrite64_page_01( u32 mem, const mem64_t* value ) // the GS and MTGS register states, and upload our screwy busdir register in the process. :) gsWrite64_generic( mem, value ); GetMTGS().WaitGS(); -#else - GUNIT_LOG("GIF - busdir"); - gifRegs.stat.DIR = value[0] & 1; - if (gifRegs.stat.DIR) { // Assume will do local->host transfer? - gifRegs.stat.OPH = true; // Is OPH set on local->host transfers? - DevCon.WriteLn("Busdir - Local->Host Transfer"); - } - gsWrite64_generic( mem, value ); - GetMTGS().WaitGS(); -#endif return; case GS_CSR: @@ -498,10 +445,6 @@ void gsResetFrameSkip() void SaveStateBase::gsFreeze() { FreezeMem(PS2MEM_GS, 0x2000); -#if USE_OLD_GIF == 1 // d - Freeze(SIGNAL_IMR_Pending); -#endif Freeze(gsRegionMode); - gifPathFreeze(); } diff --git a/pcsx2/Gif.cpp b/pcsx2/Gif.cpp index 2b9fba5cb4..642b682a54 100644 --- a/pcsx2/Gif.cpp +++ b/pcsx2/Gif.cpp @@ -34,57 +34,6 @@ static u32 gscycles = 0, prevcycles = 0, mfifocycles = 0; static u32 gifqwc = 0; static bool gifmfifoirq = false; -#if USE_OLD_GIF == 1 // d - -//Just some temporary bits to store Path1 transfers if another is in progress. -__aligned16 u8 Path1Buffer[0x1000000]; -u32 Path1WritePos = 0; -u32 Path1ReadPos = 0; - -extern bool SIGNAL_IMR_Pending; -void gsPath1Interrupt() -{ - if ((gifRegs.stat.APATH <= GIF_APATH1 || (gifRegs.stat.IP3 == true)) - && Path1WritePos > 0 && !gifRegs.stat.PSE && SIGNAL_IMR_Pending == false) { - gifRegs.stat.P1Q = false; - - if (uint size = (Path1WritePos - Path1ReadPos)) { - GetMTGS().PrepDataPacket(GIF_PATH_1, size); - //DevCon.Warning("Flush Size = %x", size); - while(size > 0 && SIGNAL_IMR_Pending == false) { - uint count = GIFPath_CopyTag(GIF_PATH_1, ((u128*)Path1Buffer) + Path1ReadPos, size); - Path1ReadPos += count; - size -= count; - - if(GSTransferStatus.PTH1 == STOPPED_MODE) { - gifRegs.stat.OPH = false; - gifRegs.stat.APATH = GIF_APATH_IDLE; - } - } - GetMTGS().SendDataPacket(); - - if (Path1ReadPos == Path1WritePos) { - Path1WritePos = Path1ReadPos = 0; - } - else { - //DevCon.Warning("Queue quitting early due to signal or EOP %x", size); - gifRegs.stat.P1Q = true; - } - } - } - else { - if(gifRegs.stat.PSE) DevCon.Warning("Path1 paused by GIF_CTRL"); - if(gifRegs.stat.P1Q == false && Path1ReadPos != Path1WritePos) { - DevCon.Warning("Wa's Goin on ere then?"); - gifRegs.stat.P1Q = true; - } - //DevCon.Warning("Looping??? IP3 %x APATH %x OPH %x", gifRegs.stat.IP3, gifRegs.stat.APATH, gifRegs.stat.OPH); - //if(!(cpuRegs.interrupt & (1<<28)) && Path1WritePos > 0)CPU_INT(28, 128); - } - -} -#endif - static __fi void clearFIFOstuff(bool full) { if (full) CSRreg.FIFO = CSR_FIFO_FULL; else CSRreg.FIFO = CSR_FIFO_EMPTY; @@ -109,28 +58,11 @@ __fi void gifInterrupt() return; } -#if USE_OLD_GIF == 1 // d - if(SIGNAL_IMR_Pending == true) { - //DevCon.Warning("Path 3 Paused"); - CPU_INT(DMAC_GIF, 128); - return; - } - - if(GSTransferStatus.PTH3 == PENDINGSTOP_MODE) { - GSTransferStatus.PTH3 = STOPPED_MODE; - if(gifRegs.stat.APATH == GIF_APATH3) { - gifRegs.stat.APATH = GIF_APATH_IDLE; - gifRegs.stat.OPH = false; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - } - } -#else if (gifUnit.gsSIGNAL.queued) { //DevCon.WriteLn("Path 3 Paused"); CPU_INT(DMAC_GIF, 128); return; } -#endif if (!(gifch.chcr.STR)) return; @@ -141,33 +73,23 @@ __fi void gifInterrupt() CPU_INT( DMAC_GIF, 64 ); return; } - GIFdma(); return; } - gifRegs.stat.clear_flags(GIF_STAT_FQC); - - gscycles = 0; - gspath3done = false; - gifch.chcr.STR = false; + gifRegs.stat.FQC = 0; + gscycles = 0; + gspath3done = false; + gifch.chcr.STR = false; clearFIFOstuff(false); hwDmacIrq(DMAC_GIF); DMA_LOG("GIF DMA End"); } -static u32 WRITERING_DMA(u32 *pMem, u32 qwc) -{ -#if USE_OLD_GIF == 1 // d - GetMTGS().PrepDataPacket(GIF_PATH_3, qwc); - uint size = GIFPath_CopyTag(GIF_PATH_3, (u128*)pMem, qwc); - GetMTGS().SendDataPacket(); - return size; -#else +static u32 WRITERING_DMA(u32 *pMem, u32 qwc) { uint size = gifUnit.TransferGSPacketData(GIF_TRANS_DMA, (u8*)pMem, qwc*16) / 16; incGifChAddr(size); return size; -#endif } int _GIFchain() @@ -232,40 +154,12 @@ static __fi tDMA_TAG* ReadTag2() return ptag; } -bool CheckPaths(EE_EventType Channel) -{ -#if USE_OLD_GIF == 1 // d - if((GSTransferStatus.PTH3 == IMAGE_MODE && gifRegs.mode.IMT) /*|| GSTransferStatus.PTH3 == WAITING_MODE*/) { - if((gifRegs.stat.P1Q == true || gifRegs.stat.P2Q == true) || (gifRegs.stat.APATH > GIF_APATH_IDLE && gifRegs.stat.APATH < GIF_APATH3)) { - if((vif1.cmd & 0x7f) != 0x51 || gifRegs.stat.P1Q == true) { - //DevCon.Warning("GIF Stall 1 P1Q %x P2Q %x APATH %x PTH3 %x vif1cmd %x", gifRegs.stat.P1Q, gifRegs.stat.P2Q, gifRegs.stat.APATH, GSTransferStatus.PTH3, vif1.cmd); - gifRegs.stat.IP3 = true; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - CPU_INT(DMAC_GIF, 16); - return false; - } - } - } - else if(GSTransferStatus.PTH3 == STOPPED_MODE) { - //This should cover both scenarios, as DIRECTHL doesn't gain priority when image mode is running (PENDINGIMAGE_MODE == finished). - if((gifRegs.stat.P1Q == true || gifRegs.stat.P2Q == true) - || (gifRegs.stat.APATH > GIF_APATH_IDLE && gifRegs.stat.APATH < GIF_APATH3) || vif1Regs.stat.VGW == true) { - //DevCon.Warning("GIF Stall 2 P1Q %x P2Q %x APATH %x PTH3 %x vif1cmd %x", gifRegs.stat.P1Q, gifRegs.stat.P2Q, gifRegs.stat.APATH, GSTransferStatus.PTH3, vif1.cmd); - gifRegs.stat.IP3 = true; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - CPU_INT(DMAC_GIF, 16); - return false; - } - } - - gifRegs.stat.IP3 = false; -#else +bool CheckPaths(EE_EventType Channel) { // Can't do Path 3, so try dma again later... if(!gifUnit.CanDoPath3()) { CPU_INT(Channel, 128); return false; } -#endif return true; } @@ -339,13 +233,7 @@ void GIFdma() { gifRegs.stat.FQC = min((u16)0x10, gifch.qwc);// FQC=31, hack ;) (for values of 31 that equal 16) [ used to be 0xE00; // APATH=3] -#if USE_OLD_GIF == 1 // ... - gifRegs.stat.set_flags(GIF_STAT_P3Q); - if(CheckPaths(DMAC_GIF) == false) return; - gifRegs.stat.clear_flags(GIF_STAT_P3Q); -#else - if(CheckPaths(DMAC_GIF) == false) return; -#endif + if (CheckPaths(DMAC_GIF) == false) return; GIFchain(); //Transfers the data set by the switch CPU_INT(DMAC_GIF, gscycles); @@ -408,55 +296,6 @@ static __fi bool mfifoGIFrbTransfer() u16 mfifoqwc = min(QWCinGIFMFIFO(gifch.madr), gifch.qwc); if (mfifoqwc == 0) return true; //Lets skip all this, we don't have the data -#if USE_OLD_GIF == 1 // d - u32 *src; - GetMTGS().PrepDataPacket(GIF_PATH_3, mfifoqwc); - - // TODO (minor optimization): The new GIFpath parser can do rather efficient wrapping of - // its own internally now. We just need to groom a version of it that can wrap around MFIFO - // memory similarly to how it wraps VU1 memory on PATH1. - GIF_LOG("MFIFO QWC to Transfer %x", mfifoqwc); - /* Check if the transfer should wrap around the ring buffer */ - if ( (gifch.madr + (mfifoqwc * 16)) > (dmacRegs.rbor.ADDR + dmacRegs.rbsr.RMSK + 16)) { - DevCon.Warning("0mfifoGIFrbTransfer() - Wrap [%d]", mfifoqwc); - uint s1 = ((dmacRegs.rbor.ADDR + dmacRegs.rbsr.RMSK + 16) - gifch.madr) >> 4; - uint s2 = (mfifoqwc - s1); - GIF_LOG("Split transfer doing %x QWC of %x Total QWC", s1, mfifoqwc); - /* it does (wrap around), so first copy 's1' bytes from 'addr' to 'data' */ - /* and second copy 's2' bytes from 'maddr' to '&data[s1]' */ - - gifch.madr = dmacRegs.rbor.ADDR + (gifch.madr & dmacRegs.rbsr.RMSK); - src = (u32*)PSM(gifch.madr); - if (src == NULL) return false; - uint copied = GIFPath_CopyTag(GIF_PATH_3, (u128*)src, s1); - - if (copied == s1) { // but only copy second if first didn't abort prematurely for some reason. - GIF_LOG("Transferring last %x QWC", s2); - src = (u32*)PSM(dmacRegs.rbor.ADDR); - gifch.madr = dmacRegs.rbor.ADDR; - if (src == NULL) return false; - copied += GIFPath_CopyTag(GIF_PATH_3, (u128*)src, s2); - } - - mfifoqwc = copied; - GIF_LOG("Copied %x QWC, %x QWC Left", mfifoqwc, gifch.qwc); - DevCon.Warning("1mfifoGIFrbTransfer() - Wrap [%d]", mfifoqwc); - } - else { - //DevCon.WriteLn("mfifoGIFrbTransfer() - Norm[%d]", mfifoqwc*16); - GIF_LOG("Direct MFIFO transfer doing %x Total QWC", mfifoqwc); - /* it doesn't, so just transfer 'qwc*16' words from 'gifch.madr' to GS */ - - gifch.madr = dmacRegs.rbor.ADDR + (gifch.madr & dmacRegs.rbsr.RMSK); - src = (u32*)PSM(gifch.madr); - if (src == NULL) return false; - mfifoqwc = GIFPath_CopyTag(GIF_PATH_3, (u128*)src, mfifoqwc); - GIF_LOG("%X QWC Copied direct %x QWC Left", mfifoqwc, gifch.qwc); - } - - GetMTGS().SendDataPacket(); - mfifocycles += (mfifoqwc) * 2; // guessing -#else if(!gifUnit.CanDoPath3()) { DevCon.Warning("mfifoGIFrbTransfer() - Can't do path3"); return true; // Skip if can't do path3 @@ -483,7 +322,6 @@ static __fi bool mfifoGIFrbTransfer() incGifChAddr(t2); mfifocycles += t2 * 2; // guessing } -#endif return true; } @@ -571,14 +409,11 @@ void mfifoGIFtransfer(int qwc) } #if USE_OLD_GIF == 1 // ... - if (vif1Regs.mskpath3 || gifRegs.mode.M3R) - { + if (vif1Regs.mskpath3 || gifRegs.mode.M3R) { if ((gifch.qwc == 0) && (gifstate & GIF_STATE_DONE)) gifstate |= GIF_STATE_STALL; - if (GSTransferStatus.PTH3 == STOPPED_MODE) - { + if (GSTransferStatus.PTH3 == STOPPED_MODE) { DevCon.Warning("GIFMFIFO PTH3 MASK Paused by VIF QWC %x"); - MSKPATH3_LOG("Path3 Paused by VIF Idling"); gifRegs.stat.set_flags(GIF_STAT_P3Q); return; @@ -607,76 +442,49 @@ void gifMFIFOInterrupt() return; } -#if USE_OLD_GIF == 1 // d - if(SIGNAL_IMR_Pending == true) { - //DevCon.Warning("Path 3 Paused"); - CPU_INT(DMAC_MFIFO_GIF, 128); - return; - } - - if(GSTransferStatus.PTH3 == PENDINGSTOP_MODE) { - GSTransferStatus.PTH3 = STOPPED_MODE; - if(gifRegs.stat.APATH == GIF_APATH3) { - gifRegs.stat.APATH = GIF_APATH_IDLE; - gifRegs.stat.OPH = false; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - } - } -#else if (gifUnit.gsSIGNAL.queued) { //DevCon.WriteLn("Path 3 Paused"); CPU_INT(DMAC_MFIFO_GIF, 128); return; } -#endif if((gifstate & GIF_STATE_EMPTY)) { FireMFIFOEmpty(); if(!(gifstate & GIF_STATE_STALL)) return; } -#if USE_OLD_GIF == 1 // d -#endif - if(CheckPaths(DMAC_MFIFO_GIF) == false) return; + if (CheckPaths(DMAC_MFIFO_GIF) == false) return; - if (!(gifch.chcr.STR)) - { + if(!gifch.chcr.STR) { Console.WriteLn("WTF GIFMFIFO"); cpuRegs.interrupt &= ~(1 << 11); return; } - if (!(gifstate & GIF_STATE_STALL)) - { - if (QWCinGIFMFIFO(gifch.tadr) == 0) - { + if (!(gifstate & GIF_STATE_STALL)) { + + if (QWCinGIFMFIFO(gifch.tadr) == 0) { gifstate |= GIF_STATE_EMPTY; CPU_INT(DMAC_MFIFO_GIF, 4); return; } - mfifoGIFtransfer(0); return; } -#ifdef PCSX2_DEVBUILD if ((gifstate & GIF_STATE_READY) || (gifch.qwc > 0)) { - Console.Error("gifMFIFO Panic > Shouldn't go here!"); + DevCon.Error("gifMFIFO Panic > Shouldn't go here!"); return; } -#endif + //if(gifqwc > 0) Console.WriteLn("GIF MFIFO ending with stuff in it %x", gifqwc); if (!gifmfifoirq) gifqwc = 0; gspath3done = false; - gscycles = 0; + gscycles = 0; -#if USE_OLD_GIF == 1 // d - gifRegs.stat.clear_flags(GIF_STAT_APATH3 | GIF_STAT_P3Q | GIF_STAT_FQC); // APATH, P3Q, FQC = 0 - vif1Regs.stat.VGW = false; -#else - gifRegs.stat.clear_flags(GIF_STAT_FQC); // FQC = 0 -#endif + gifRegs.stat.FQC = 0; + //vif1Regs.stat.VGW = false; // old code had this gifch.chcr.STR = false; gifstate = GIF_STATE_READY; @@ -685,31 +493,11 @@ void gifMFIFOInterrupt() clearFIFOstuff(false); } -void SaveStateBase::gifDmaFreeze() -{ - FreezeTag( "GIFdma" ); - - Freeze( gifstate ); - Freeze( gifqwc ); - Freeze( gspath3done ); - Freeze( gscycles ); +void SaveStateBase::gifDmaFreeze() { // Note: mfifocycles is not a persistent var, so no need to save it here. - -#if USE_OLD_GIF == 1 // d - int bufsize = Path1WritePos - Path1ReadPos; - Freeze(bufsize); - - if(!IsSaving()) { - // We can just load the queued Path1 data into the front of the buffer, and - // reset the ReadPos and WritePos accordingly. - FreezeMem(Path1Buffer, bufsize); - Path1ReadPos = 0; - Path1WritePos = bufsize; - } - else { - // Only want to save the actual Path1 data between readpos and writepos. The - // rest of the buffer is just unused-ness! - FreezeMem(&Path1Buffer[Path1ReadPos], bufsize); - } -#endif + FreezeTag("GIFdma"); + Freeze(gifstate); + Freeze(gifqwc); + Freeze(gspath3done); + Freeze(gscycles); } diff --git a/pcsx2/Gif.h b/pcsx2/Gif.h index cb546483ab..c31f219d31 100644 --- a/pcsx2/Gif.h +++ b/pcsx2/Gif.h @@ -56,62 +56,6 @@ enum GIF_PATH_STATE { GIF_PATH_IMAGE = 3 // Path is on a IMAGE gif tag }; -enum gifstate_t { - GIF_STATE_READY = 0, - GIF_STATE_STALL = 1, - GIF_STATE_DONE = 2, - GIF_STATE_EMPTY = 0x10 -}; - -enum GSTransferModes { // 0 = Image Mode (DirectHL), 1 = transferring, 2 = Stopped at End of Packet - WAITING_MODE = 0, - IMAGE_MODE = 1, - TRANSFER_MODE = 2, - PENDINGSTOP_MODE = 3, - IDLE_MODE = 4, - STOPPED_MODE = 5 -}; - -union tGSTransferStatus { - struct { - u32 PTH1 : 4; // Resets Vif(0/1) when written. - u32 PTH2 : 4; // Causes a Forcebreak to Vif((0/1) when true. (Stall) - u32 PTH3 : 4; // Stops after the end of the Vifcode in progress when true. (Stall) - u32 reserved : 20; - }; - u32 _u32; - - tGSTransferStatus(u32 val) { _u32 = val; } - bool test (u32 flags) const { return !!(_u32 & flags); } - void set_flags (u32 flags) { _u32 |= flags; } - void clear_flags(u32 flags) { _u32 &= ~flags; } - void reset() { _u32 = 0; } - wxString desc() const { return wxsFormat(L"GSTransferStatus.PTH3: 0x%x", _u32); } -}; - -//GIF_STAT -enum gif_stat_flags { - GIF_STAT_M3R = (1), // GIF_MODE Mask - GIF_STAT_M3P = (1<<1), // VIF PATH3 Mask - GIF_STAT_IMT = (1<<2), // Intermittent Transfer Mode - GIF_STAT_PSE = (1<<3), // Temporary Transfer Stop - GIF_STAT_IP3 = (1<<5), // Interrupted PATH3 - GIF_STAT_P3Q = (1<<6), // PATH3 request Queued - GIF_STAT_P2Q = (1<<7), // PATH2 request Queued - GIF_STAT_P1Q = (1<<8), // PATH1 request Queued - GIF_STAT_OPH = (1<<9), // Output Path (Outputting Data) - GIF_STAT_APATH1 = (1<<10), // Data Transfer Path 1 (In progress) - GIF_STAT_APATH2 = (2<<10), // Data Transfer Path 2 (In progress) - GIF_STAT_APATH3 = (3<<10), // Data Transfer Path 3 (In progress) (Mask too) - GIF_STAT_DIR = (1<<12), // Transfer Direction - GIF_STAT_FQC = (31<<24) // QWC in GIF-FIFO -}; - -enum gif_mode_flags { - GIF_MODE_M3R = (1), - GIF_MODE_IMT = (1<<2) -}; - enum GIF_FLG { GIF_FLG_PACKED = 0, GIF_FLG_REGLIST = 1, @@ -138,6 +82,13 @@ enum GIF_REG { GIF_REG_NOP = 0x0f, }; +enum gifstate_t { + GIF_STATE_READY = 0, + GIF_STATE_STALL = 1, + GIF_STATE_DONE = 2, + GIF_STATE_EMPTY = 0x10 +}; + union tGIF_CTRL { struct { @@ -178,13 +129,6 @@ union tGIF_MODE wxString desc() { return wxsFormat(L"Mode: 0x%x", _u32); } }; -enum gif_paths { - GIF_APATH_IDLE = 0, - GIF_APATH1, - GIF_APATH2, - GIF_APATH3 -}; - union tGIF_STAT { struct { @@ -341,22 +285,3 @@ extern void GIFdma(); extern void dmaGIF(); extern void mfifoGIFtransfer(int qwc); extern void gifMFIFOInterrupt(); - -#if USE_OLD_GIF == 1 // d -extern u8 schedulepath3msk; -extern tGSTransferStatus GSTransferStatus; -extern bool CheckPath2GIF(EE_EventType channel); - -//Just some temporary bits to store Path1 transfers if another is in progress. -extern void gsPath1Interrupt(); -extern __aligned16 u8 Path1Buffer[0x1000000]; -extern u32 Path1WritePos; -extern u32 Path1ReadPos; - -extern void GIFPath_Initialize(); -extern int GIFPath_CopyTag(GIF_PATH pathidx, const u128* pMem, u32 size); -extern int GIFPath_ParseTagQuick(GIF_PATH pathidx, const u8* pMem, u32 size); -extern void GIFPath_Reset(); -extern void GIFPath_Clear( GIF_PATH pathidx ); -#endif - diff --git a/pcsx2/Hw.cpp b/pcsx2/Hw.cpp index a009de4a1c..3f45f280f8 100644 --- a/pcsx2/Hw.cpp +++ b/pcsx2/Hw.cpp @@ -150,6 +150,7 @@ void FireMFIFOEmpty() if (dmacRegs.ctrl.MFD == MFD_VIF1) vif1Regs.stat.FQC = 0; if (dmacRegs.ctrl.MFD == MFD_GIF) gifRegs.stat.FQC = 0; } + // Write 'size' bytes to memory address 'addr' from 'data'. __ri bool hwMFIFOWrite(u32 addr, const u128* data, uint qwc) { diff --git a/pcsx2/HwWrite.cpp b/pcsx2/HwWrite.cpp index bcae960515..d7e9a215bf 100644 --- a/pcsx2/HwWrite.cpp +++ b/pcsx2/HwWrite.cpp @@ -93,12 +93,9 @@ void __fastcall _hwWrite32( u32 mem, u32 value ) // Not exactly sure what RST needs to do gifRegs.ctrl.write(value & 9); if (gifRegs.ctrl.RST) { -#if USE_OLD_GIF == 1 // d - gifUnit.ResetRegs(); // hmm? -#else GUNIT_LOG("GIF CTRL - Reset"); - gifUnit.Reset(true); // hmm? -#endif + gifUnit.Reset(true); // Should it reset gsSIGNAL? + //gifUnit.ResetRegs(); } gifRegs.stat.PSE = gifRegs.ctrl.PSE; return; @@ -108,11 +105,8 @@ void __fastcall _hwWrite32( u32 mem, u32 value ) { // need to set GIF_MODE (hamster ball) gifRegs.mode.write(value); - - // set/clear bits 0 and 2 as per the GIF_MODE value. - const u32 bitmask = GIF_MODE_M3R | GIF_MODE_IMT; - psHu32(GIF_STAT) &= ~bitmask; - psHu32(GIF_STAT) |= (u32)value & bitmask; + gifRegs.stat.M3R = gifRegs.mode.M3R; + gifRegs.stat.IMT = gifRegs.mode.IMT; return; } } diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index c28eb0ee78..1b3b33beee 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -114,13 +114,6 @@ void SysMtgsThread::ResetGS() SendSimplePacket( GS_RINGTYPE_RESET, 0, 0, 0 ); SendSimplePacket( GS_RINGTYPE_FRAMESKIP, 0, 0, 0 ); SetEvent(); - -#if USE_OLD_GIF == 1 // d - GIFPath_Reset(); -#else - //DevCon.WriteLn("ResetGS()"); - //gifUnit.Reset(); -#endif } struct RingCmdPacket_Vsync @@ -334,7 +327,7 @@ void SysMtgsThread::ExecuteTaskInThread() switch( tag.command ) { -#if USE_OLD_GIF == 1 || COPY_GS_PACKET_TO_MTGS == 1 // d +#if COPY_GS_PACKET_TO_MTGS == 1 // d case GS_RINGTYPE_P1: { uint datapos = (m_ReadPos+1) & RingBufferMask; diff --git a/pcsx2/VUops.cpp b/pcsx2/VUops.cpp index 0fe2e5e587..241ea00c28 100644 --- a/pcsx2/VUops.cpp +++ b/pcsx2/VUops.cpp @@ -2025,13 +2025,6 @@ static __ri void _vuXGKICK(VURegs * VU) { // flush all pipelines first (in the right order) _vuFlushAll(VU); -#if USE_OLD_GIF == 1 // todo - u8* data = ((u8*)VU->Mem + ((VU->VI[_Is_].US[0]*16) & 0x3fff)); - u32 size; - GetMTGS().PrepDataPacket( GIF_PATH_1, 0x400 ); - size = GIFPath_CopyTag( GIF_PATH_1, (u128*)data, (0x400-(VU->VI[_Is_].US[0] & 0x3ff)) ); - GetMTGS().SendDataPacket(); -#else u32 addr = (VU->VI[_Is_].US[0] & 0x3ff) * 16; u32 diff = 0x4000 - addr; u32 size = gifUnit.GetGSPacketSize(GIF_PATH_1, VU->Mem, addr); @@ -2044,7 +2037,6 @@ static __ri void _vuXGKICK(VURegs * VU) else { gifUnit.TransferGSPacketData(GIF_TRANS_XGKICK, &VU->Mem[addr], size, true); } -#endif } static __ri void _vuXTOP(VURegs * VU) { diff --git a/pcsx2/Vif.cpp b/pcsx2/Vif.cpp index 55717af25b..66e12918b5 100644 --- a/pcsx2/Vif.cpp +++ b/pcsx2/Vif.cpp @@ -23,10 +23,6 @@ __aligned16 vifStruct vif0, vif1; -#if USE_OLD_GIF == 1 // d -tGSTransferStatus GSTransferStatus((STOPPED_MODE<<8) | (STOPPED_MODE<<4) | STOPPED_MODE); -#endif - void vif0Reset() { /* Reset the whole VIF, meaning the internal pcsx2 vars and all the registers */ @@ -175,20 +171,17 @@ __fi void vif1FBRST(u32 value) { vif1ch.chcr.STR = false; #if USE_OLD_GIF == 1 // ... - //DevCon.Warning("VIF FBRST Reset MSK = %x", vif1Regs.mskpath3); if(vif1Regs.mskpath3 == 1 && GSTransferStatus.PTH3 == STOPPED_MODE && gifch.chcr.STR == true) { DevCon.Warning("VIF Path3 Resume on FBRST MSK = %x", vif1Regs.mskpath3); gifInterrupt(); vif1Regs.mskpath3 = false; - gifRegs.stat.M3P = 0; + gifRegs.stat.M3P = false; } - vif1Regs.mskpath3 = false; - gifRegs.stat.M3P = 0; -#else +#endif GUNIT_WARN(Color_Red, "VIF FBRST Reset MSK = %x", vif1Regs.mskpath3); vif1Regs.mskpath3 = false; gifRegs.stat.M3P = 0; -#endif + vif1Regs.err.reset(); vif1.inprogress = 0; vif1.cmd = 0; diff --git a/pcsx2/Vif1_Dma.cpp b/pcsx2/Vif1_Dma.cpp index 17ecfa90f4..bb10f85abd 100644 --- a/pcsx2/Vif1_Dma.cpp +++ b/pcsx2/Vif1_Dma.cpp @@ -47,15 +47,6 @@ __fi void vif1FLUSH() //DevCon.Warning("VIF1 adding %x cycles", (VU1.cycle - _cycles) * BIAS); g_vifCycles += (VU1.cycle - _cycles) * BIAS; } -#if USE_OLD_GIF == 1 // d - if ((gifRegs.stat.P1Q == true) - && ((vif1.cmd & 0x7f) != 0x14) // cmd != MSCAL - && ((vif1.cmd & 0x7f) != 0x17)) { // cmd != MSCNT - vif1.vifstalled = true; - vif1Regs.stat.VGW = true; - vif1.GifWaitState = 2; - } -#endif } void vif1TransferToMemory() @@ -253,110 +244,11 @@ __fi void vif1SetupTransfer() } } -#if USE_OLD_GIF == 1 // d -extern bool SIGNAL_IMR_Pending; - -bool CheckPath2GIF(EE_EventType channel) -{ - if ((vif1Regs.stat.VGW)) - { - if( vif1.GifWaitState == 0 ) //DIRECT/HL Check - { - if(GSTransferStatus.PTH3 < STOPPED_MODE || gifRegs.stat.P1Q) - { - if(gifRegs.stat.IMT && GSTransferStatus.PTH3 <= IMAGE_MODE && (vif1.cmd & 0x7f) == 0x50 && gifRegs.stat.P1Q == false) - { - vif1Regs.stat.VGW = false; - } - else - { - //DevCon.Warning("VIF1-0 stall P1Q %x P2Q %x APATH %x PTH3 %x vif1cmd %x", gifRegs.stat.P1Q, gifRegs.stat.P2Q, gifRegs.stat.APATH, GSTransferStatus.PTH3, vif1.cmd); - CPU_INT(channel, 128); - return false; - } - } - else - { - vif1Regs.stat.VGW = false; - } - } - else if( vif1.GifWaitState == 1 ) // Else we're flushing path3 :), but of course waiting for the microprogram to finish - { - if (gifRegs.stat.P1Q) - { - //DevCon.Warning("VIF1-1 stall P1Q %x P2Q %x APATH %x PTH3 %x vif1cmd %x", gifRegs.stat.P1Q, gifRegs.stat.P2Q, gifRegs.stat.APATH, GSTransferStatus.PTH3, vif1.cmd); - CPU_INT(channel, 128); - return false; - } - - if (GSTransferStatus.PTH3 < STOPPED_MODE) - { - //DevCon.Warning("VIF1-11 stall P1Q %x P2Q %x APATH %x PTH3 %x vif1cmd %x", gifRegs.stat.P1Q, gifRegs.stat.P2Q, gifRegs.stat.APATH, GSTransferStatus.PTH3, vif1.cmd); - //DevCon.Warning("PTH3 %x P1Q %x P3Q %x IP3 %x", GSTransferStatus.PTH3, gifRegs.stat.P1Q, gifRegs.stat.P3Q, gifRegs.stat.IP3 ); - CPU_INT(channel, 128); - return false; - } - - vif1Regs.stat.VGW = false; - - } - else if( vif1.GifWaitState == 3 ) // Any futher GIF transfers are paused. - { - if (gifRegs.ctrl.PSE) - { - //DevCon.Warning("VIF1-1 stall P1Q %x P2Q %x APATH %x PTH3 %x vif1cmd %x", gifRegs.stat.P1Q, gifRegs.stat.P2Q, gifRegs.stat.APATH, GSTransferStatus.PTH3, vif1.cmd); - CPU_INT(channel, 128); - return false; - } - - vif1Regs.stat.VGW = false; - - } - else //Normal Flush - { - if (gifRegs.stat.P1Q) - { - //DevCon.Warning("VIF1-2 stall P1Q %x P2Q %x APATH %x PTH3 %x vif1cmd %x", gifRegs.stat.P1Q, gifRegs.stat.P2Q, gifRegs.stat.APATH, GSTransferStatus.PTH3, vif1.cmd); - CPU_INT(channel, 128); - return false; - } - - vif1Regs.stat.VGW = false; - } - } - - if(SIGNAL_IMR_Pending == true && (vif1.cmd & 0x7e) == 0x50) - { - //DevCon.Warning("Path 2 Paused"); - CPU_INT(channel, 128); - return false; - } - - return true; -} -#endif - __fi void vif1Interrupt() { VIF_LOG("vif1Interrupt: %8.8x", cpuRegs.cycle); g_vifCycles = 0; -#if USE_OLD_GIF == 1 // d - if (schedulepath3msk & 0x10) { - MSKPATH3_LOG("Scheduled Path3 Mask Firing"); - Vif1MskPath3(); - } - - if (GSTransferStatus.PTH2 == PENDINGSTOP_MODE) { - GSTransferStatus.PTH2 = STOPPED_MODE; - - if(gifRegs.stat.APATH == GIF_APATH2) { - if(gifRegs.stat.DIR == 0) gifRegs.stat.OPH = false; - gifRegs.stat.APATH = GIF_APATH_IDLE; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - } - } -#endif //Some games (Fahrenheit being one) start vif first, let it loop through blankness while it sets MFIFO mode, so we need to check it here. if (dmacRegs.ctrl.MFD == MFD_VIF1) { diff --git a/pcsx2/Vif1_MFIFO.cpp b/pcsx2/Vif1_MFIFO.cpp index f6d5b108a7..484a6ea73e 100644 --- a/pcsx2/Vif1_MFIFO.cpp +++ b/pcsx2/Vif1_MFIFO.cpp @@ -255,30 +255,11 @@ void vifMFIFOInterrupt() g_vifCycles = 0; VIF_LOG("vif mfifo interrupt"); - - if (dmacRegs.ctrl.MFD != MFD_VIF1) - { + if (dmacRegs.ctrl.MFD != MFD_VIF1) { DevCon.Warning("Not in VIF MFIFO mode! Stopping VIF MFIFO"); return; } -#if USE_OLD_GIF == 1 // d - if (GSTransferStatus.PTH2 == PENDINGSTOP_MODE) { - GSTransferStatus.PTH2 = STOPPED_MODE; - - if(gifRegs.stat.APATH == GIF_APATH2) { - if(gifRegs.stat.DIR == 0)gifRegs.stat.OPH = false; - gifRegs.stat.APATH = GIF_APATH_IDLE; - if(gifRegs.stat.P1Q) gsPath1Interrupt(); - } - } - - if (schedulepath3msk & 0x10) { - MSKPATH3_LOG("Scheduled Path3 Mask Firing on MFIFO VIF"); - Vif1MskPath3(); - } -#endif - #if USE_OLD_GIF == 1 // ... if(vif1ch.chcr.DIR && CheckPath2GIF(DMAC_MFIFO_VIF) == false) { SPR_LOG("Waiting for PATH to be ready"); diff --git a/pcsx2/Vif_Codes.cpp b/pcsx2/Vif_Codes.cpp index eb69c92764..0465dc4987 100644 --- a/pcsx2/Vif_Codes.cpp +++ b/pcsx2/Vif_Codes.cpp @@ -82,28 +82,6 @@ static __fi void vuExecMicro(int idx, u32 addr) { GetVifX.vifstalled = true; } -#if USE_OLD_GIF == 1 // d -u8 schedulepath3msk = 0; -#endif - -void Vif1MskPath3() { -#if USE_OLD_GIF == 1 // d - vif1Regs.mskpath3 = schedulepath3msk & 0x1; - GIF_LOG("VIF MSKPATH3 %x gif str %x path3 status %x", vif1Regs.mskpath3, gifch.chcr.STR, GSTransferStatus.PTH3); - gifRegs.stat.M3P = vif1Regs.mskpath3; - - if(!vif1Regs.mskpath3) { - MSKPATH3_LOG("Disabling Path3 Mask"); - if(gifRegs.stat.P3Q) { - MSKPATH3_LOG("Path3 Waiting to Transfer, triggering"); - gifInterrupt(); - } - } - else { MSKPATH3_LOG("Path3 Mask Enabled"); } - schedulepath3msk = 0; -#endif -} - //------------------------------------------------------------------ // Vif0/Vif1 Code Implementations //------------------------------------------------------------------ @@ -115,135 +93,6 @@ vifOp(vifCode_Base) { return 0; } -#if USE_OLD_GIF == 1 // d -extern bool SIGNAL_IMR_Pending; -static __aligned16 u32 partial_write[4]; -static uint partial_count = 0; - -template __fi int _vifCode_Direct(int pass, const u8* data, bool isDirectHL) { - pass1 { - vif1Only(); - int vifImm = (u16)vif1Regs.code; - vif1.tag.size = vifImm ? (vifImm*4) : (65536*4); - vif1.vifstalled = true; - gifRegs.stat.P2Q = true; - if (gifRegs.stat.PSE) // temporarily stop - { - Console.WriteLn("Gif dma temp paused? VIF DIRECT"); - vif1.GifWaitState = 3; - vif1Regs.stat.VGW = true; - } - //Should cause this to split here to try and time PATH3 right. - return 0; - } - pass2 { - vif1Only(); - - //Only check if Path 1 or 3 are busy, else we dont care :D - if (GSTransferStatus.PTH3 < STOPPED_MODE || gifRegs.stat.P1Q == true) - { - //If currently transferring PATH2, or GIF is in image mode (or waiting) and we are using DIRECT command and path1 isnt waiting - if(gifRegs.stat.APATH == GIF_APATH2 || ((GSTransferStatus.PTH3 <= IMAGE_MODE && (vif1.cmd & 0x7f) == 0x50) && gifRegs.stat.P1Q == false)) - { - //Do nothing, allow it - vif1Regs.stat.VGW = false; - //if(gifRegs.stat.APATH != GIF_APATH2)DevCon.Warning("Continue DIRECT/HL %x P3 %x APATH %x P1Q %x", vif1.cmd, GSTransferStatus.PTH3, gifRegs.stat.APATH, gifRegs.stat.P1Q); - } - else - { - //Using Direct/HL while Path3 is busy or Path 1 is busy - //DevCon.Warning("Stall DIRECT/HL %x P3 %x APATH %x P1Q %x", vif1.cmd, GSTransferStatus.PTH3, gifRegs.stat.APATH, gifRegs.stat.P1Q); - vif1Regs.stat.VGW = true; // PATH3 is in image mode (DIRECTHL), or busy (BOTH no IMT) - vif1.GifWaitState = 0; - vif1.vifstalled = true; - return 0; - } - } - if(SIGNAL_IMR_Pending == true) - { - //DevCon.Warning("Path 2 Paused (At start)"); - vif1.vifstalled = true; - return 0; - } - if (gifRegs.stat.PSE) // temporarily stop - { - Console.WriteLn("Gif dma temp paused? VIF DIRECT"); - vif1.GifWaitState = 3; - vif1.vifstalled = true; - vif1Regs.stat.VGW = true; - return 0; - } - - // HACK ATTACK! - // we shouldn't be clearing the queue flag here at all. Ideally, the queue statuses - // should be checked, handled, and cleared from the EOP check in GIFPath only. --air - gifRegs.stat.clear_flags(GIF_STAT_P2Q); - - uint minSize = aMin(vif1.vifpacketsize, vif1.tag.size); - uint ret; - - if(minSize < 4 || partial_count > 0) - { - // When TTE==1, the VIF might end up sending us 8-byte packets instead of the usual 16-byte - // variety, if DIRECT tags cross chain dma boundaries. The actual behavior of real hardware - // is unknown at this time, but it seems that games *only* ever try to upload zero'd data - // in this situation. - // - // Games that use TTE==1 and DIRECT in this fashion: ICO - // - // Because DIRECT normally has a strict QWC alignment requirement, and this funky behavior - // only seems to happen on TTE mode transfers with their split-64-bit packets, there shouldn't - // be any need to worry about queuing more than 16 bytes of data, - // - minSize = aMin(minSize, 4-partial_count); - - for( uint i=0; i<(minSize & 3); ++i) - { - partial_write[partial_count++] = ((u32*)data)[i]; - - } - - pxAssume( partial_count <= 4 ); - - if (partial_count == 4) - { - GetMTGS().PrepDataPacket(GIF_PATH_2, 1); - GIFPath_CopyTag(GIF_PATH_2, (u128*)partial_write, 1); - GetMTGS().SendDataPacket(); - partial_count = 0; - } - - ret = minSize; - } - else - { - if (!minSize) - DevCon.Warning("VIF DIRECT (PATH2): No Data Transfer?"); - - // TTE=1 mode is the only time we should be getting DIRECT packet sizes that are - // not a multiple of QWC, and those are assured to be under 128 bits in size. - // So if this assert is triggered then it probably means something else is amiss. - pxAssertMsg((minSize & 3) == 0, "DIRECT packet size is not a multiple of QWC." ); - - GetMTGS().PrepDataPacket(GIF_PATH_2, minSize/4); - ret = GIFPath_CopyTag(GIF_PATH_2, (u128*)data, minSize/4)*4; - GetMTGS().SendDataPacket(); - } - - vif1.tag.size -= ret; - - if(vif1.tag.size == 0) - { - vif1.cmd = 0; - } - - vif1.vifstalled = true; - - return ret; - } - return 0; -} -#else template __fi int _vifCode_Direct(int pass, const u8* data, bool isDirectHL) { vif1Only(); pass1 { @@ -275,7 +124,6 @@ template __fi int _vifCode_Direct(int pass, const u8* data, bool isDire } return 0; } -#endif vifOp(vifCode_Direct) { pass3 { VifCodeLog("Direct"); } @@ -287,13 +135,9 @@ vifOp(vifCode_DirectHL) { return _vifCode_Direct(pass, (u8*)data, 1); } -// ToDo: FixMe vifOp(vifCode_Flush) { vif1Only(); vifStruct& vifX = GetVifX; -#if USE_OLD_GIF == 1 // d - pass1 { vifFlush(idx); vifX.cmd = 0; } -#else pass1or2 { vif1Regs.stat.VGW = false; vifFlush(idx); @@ -305,31 +149,13 @@ vifOp(vifCode_Flush) { } else vifX.cmd = 0; } -#endif pass3 { VifCodeLog("Flush"); } return 0; } -// ToDo: FixMe vifOp(vifCode_FlushA) { vif1Only(); vifStruct& vifX = GetVifX; -#if USE_OLD_GIF == 1 // d - pass1 { - vifFlush(idx); - // Gif is already transferring so wait for it. - if (gifRegs.stat.P1Q || GSTransferStatus.PTH3 < STOPPED_MODE) { - //DevCon.Warning("VIF FlushA Wait MSK = %x", vif1Regs.mskpath3); - MSKPATH3_LOG("Waiting for Path3 to Flush"); - //DevCon.WriteLn("FlushA path3 Wait! PTH3 MD %x STR %x", GSTransferStatus.PTH3, gif->chcr.STR); - vif1Regs.stat.VGW = true; - vifX.GifWaitState = 1; - vifX.vifstalled = true; - } - //else DevCon.WriteLn("FlushA path3 no Wait! PTH3 MD %x STR %x", GSTransferStatus.PTH3, gif->chcr.STR); - vifX.cmd = 0; - } -#else pass1or2 { Gif_Path& p3 = gifUnit.gifPath[GIF_PATH_3]; u32 p1or2 = gifUnit.checkPaths(1,1,0); @@ -366,7 +192,6 @@ vifOp(vifCode_FlushA) { } else vifX.cmd = 0; } -#endif pass3 { VifCodeLog("FlushA"); } return 0; } @@ -452,10 +277,6 @@ vifOp(vifCode_MSCAL) { vifOp(vifCode_MSCALF) { vifStruct& vifX = GetVifX; - -#if USE_OLD_GIF == 1 // d - pass1 { vifFlush(idx); vuExecMicro(idx, (u16)(vifXRegs.code) << 3); vifX.cmd = 0; } -#else pass1or2 { vifXRegs.stat.VGW = false; vifFlush(idx); @@ -469,7 +290,6 @@ vifOp(vifCode_MSCALF) { vifX.cmd = 0; } } -#endif pass3 { VifCodeLog("MSCALF"); } return 0; } @@ -485,14 +305,6 @@ vifOp(vifCode_MSCNT) { vifOp(vifCode_MskPath3) { vif1Only(); pass1 { -#if USE_OLD_GIF == 1 // d - MSKPATH3_LOG("Direct MSKPATH3"); - schedulepath3msk = 0x10 | (vif1Regs.code >> 15) & 0x1; - - if(vif1ch.chcr.STR && vif1.lastcmd != 0x13) vif1.vifstalled = true; - else Vif1MskPath3(); - vif1.cmd = 0; -#else vif1Regs.mskpath3 = (vif1Regs.code >> 15) & 0x1; gifRegs.stat.M3P = (vif1Regs.code >> 15) & 0x1; GUNIT_LOG("Vif1 - MskPath3 [p3 = %s]", vif1Regs.mskpath3 ? "disabled" : "enabled"); @@ -503,7 +315,6 @@ vifOp(vifCode_MskPath3) { //} } vif1.cmd = 0; -#endif } pass3 { VifCodeLog("MskPath3"); } return 0; diff --git a/pcsx2/Vif_Dma.h b/pcsx2/Vif_Dma.h index 1f42b2164d..4746d661d0 100644 --- a/pcsx2/Vif_Dma.h +++ b/pcsx2/Vif_Dma.h @@ -81,7 +81,8 @@ struct vifStruct { u8 inprogress; u32 lastcmd; u8 dmamode; - u8 GifWaitState; // 0 = General PATH checking, 1 = Flush path 3, 2 == Wait for VU1 + u8 Unused_GifWaitState; // Only here for saved state compatibility + //u8 GifWaitState; // 0 = General PATH checking, 1 = Flush path 3, 2 == Wait for VU1 }; extern __aligned16 vifStruct vif0, vif1; @@ -93,7 +94,6 @@ extern void vif0Interrupt(); extern void vif0Reset(); extern void vif1Interrupt(); -extern void Vif1MskPath3(); extern void vif1Reset(); typedef int __fastcall FnType_VifCmdHandler(int pass, const u32 *data); diff --git a/pcsx2/x86/microVU_Lower.inl b/pcsx2/x86/microVU_Lower.inl index 438b15de7a..1008812c72 100644 --- a/pcsx2/x86/microVU_Lower.inl +++ b/pcsx2/x86/microVU_Lower.inl @@ -1120,36 +1120,6 @@ mVUop(mVU_XITOP) { //------------------------------------------------------------------ void __fastcall mVU_XGKICK_(u32 addr) { -#if USE_OLD_GIF == 1 // d - extern void gsPath1Interrupt(); - extern bool SIGNAL_IMR_Pending; - - addr &= 0x3ff; - u8* data = vuRegs[1].Mem + (addr*16); - u32 diff = 0x400 - addr; - u32 size; - - size = GIFPath_ParseTagQuick(GIF_PATH_1, data, diff); - u8* pDest = &Path1Buffer[Path1WritePos*16]; - - Path1WritePos += size; - - pxAssertMsg((Path1WritePos < sizeof(Path1Buffer)), "XGKick Buffer Overflow detected on Path1Buffer!"); - //DevCon.Warning("Storing size %x PATH 1", size); - - if (size > diff) { - //DevCon.Status("XGkick Wrap!"); - memcpy_qwc(pDest, vuRegs[1].Mem + (addr*16), diff); - memcpy_qwc(pDest+(diff*16), vuRegs[1].Mem, size-diff); - } - else { - memcpy_qwc(pDest, vuRegs[1].Mem + (addr*16), size); - } - //if(!gifRegs.stat.P1Q) CPU_INT(28, 128); - gifRegs.stat.P1Q = true; - - gsPath1Interrupt(); -#else addr = (addr & 0x3ff) * 16; u32 diff = 0x4000 - addr; u32 size = gifUnit.GetGSPacketSize(GIF_PATH_1, vuRegs[1].Mem, addr); @@ -1162,7 +1132,6 @@ void __fastcall mVU_XGKICK_(u32 addr) { else { gifUnit.TransferGSPacketData(GIF_TRANS_XGKICK, &vuRegs[1].Mem[addr], size, true); } -#endif } static __fi void mVU_XGKICK_DELAY(mV, bool memVI) { diff --git a/pcsx2/x86/sVU_Lower.cpp b/pcsx2/x86/sVU_Lower.cpp index 87bf430592..749c028149 100644 --- a/pcsx2/x86/sVU_Lower.cpp +++ b/pcsx2/x86/sVU_Lower.cpp @@ -1976,35 +1976,6 @@ void recVUMI_XTOP( VURegs *VU, int info ) void __fastcall VU1XGKICK_MTGSTransfer(u32 addr) { -#if USE_OLD_GIF == 1 // todo - extern bool SIGNAL_IMR_Pending; - addr &= 0x3fff; - u8* data = VU1.Mem + (addr); - u32 diff = 0x400 - (addr / 16); - u32 size; - u8* pDest; - - //DevCon.Warning("GIF APATH busy %x Holding for later W %x, R %x", gifRegs.stat.APATH, Path1WritePos, Path1ReadPos); - size = GIFPath_ParseTagQuick(GIF_PATH_1, data, diff); - pDest = &Path1Buffer[Path1WritePos*16]; - - Path1WritePos += size; - - pxAssertMsg((Path1WritePos+size < sizeof(Path1Buffer)), "XGKick Buffer Overflow detected on Path1Buffer!"); - - if (size > diff) { - //DevCon.Status("XGkick Wrap!"); - memcpy_qwc(pDest, VU1.Mem + addr, diff); - memcpy_qwc(pDest+(diff*16), VU1.Mem, size-diff); - } - else { - memcpy_qwc(pDest, VU1.Mem + addr, size); - } - //if(!gifRegs.stat.P1Q) CPU_INT(28, 128); - gifRegs.stat.P1Q = true; -//} - gsPath1Interrupt(); -#else addr &= 0x3fff; u32 diff = 0x4000 - addr; u32 size = gifUnit.GetGSPacketSize(GIF_PATH_1, vuRegs[1].Mem, addr); @@ -2017,6 +1988,5 @@ void __fastcall VU1XGKICK_MTGSTransfer(u32 addr) else { gifUnit.TransferGSPacketData(GIF_TRANS_XGKICK, &vuRegs[1].Mem[addr], size, true); } -#endif } //------------------------------------------------------------------