From 4509e085c6b68fccca50749112e7f59cb285e549 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Mon, 17 Aug 2009 20:41:32 +0000 Subject: [PATCH] Convert Sif.cpp & Vif.cpp to use the Tags.h code. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1646 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Sif.cpp | 43 ++++++++++++++++++++++--------------------- pcsx2/Vif.cpp | 38 ++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/pcsx2/Sif.cpp b/pcsx2/Sif.cpp index 703cadc327..21b91676e0 100644 --- a/pcsx2/Sif.cpp +++ b/pcsx2/Sif.cpp @@ -140,6 +140,7 @@ __forceinline void SIF0Dma() if (sif0.counter == 0) // If there's no more to transfer { // Note.. add normal mode here + // The if statement doesn't seem to match the description... if (sif0.sifData.data & 0xC0000000) // If NORMAL mode or end of CHAIN, or interrupt then stop DMA { SIF_LOG(" IOP SIF Stopped"); @@ -153,7 +154,7 @@ __forceinline void SIF0Dma() PSX_INT(IopEvt_SIF0, psxCycles); sif0.sifData.data = 0; - done = TRUE; + done = true; } else // Chain mode { @@ -173,7 +174,7 @@ __forceinline void SIF0Dma() SIF_LOG(" END"); else SIF_LOG(" CNT %08X, %08X", sif0.sifData.data, sif0.sifData.words); - done = FALSE; + done = false; } } else // There's some data ready to transfer into the fifo.. @@ -220,7 +221,8 @@ __forceinline void SIF0Dma() if (sif0dma->qwc == 0) { - if (((sif0dma->chcr & 0x80000080) == 0x80000080) || (sif0.end)) // Stop on tag IRQ or END + // Stop if TIE & the IRQ are set, or at the end. (I'll try to convert this to use the tags code later.) + if (((sif0dma->chcr & 0x80000080) == 0x80000080) || (sif0.end)) { if (sif0.end) SIF_LOG(" EE SIF end"); @@ -229,7 +231,7 @@ __forceinline void SIF0Dma() eesifbusy[0] = 0; CPU_INT(5, cycles*BIAS); - done = TRUE; + done = true; } else if (sif0.fifoSize >= 4) // Read a tag { @@ -243,11 +245,12 @@ __forceinline void SIF0Dma() SIF_LOG(" EE SIF dest chain tag madr:%08X qwc:%04X id:%X irq:%d(%08X_%08X)", sif0dma->madr, sif0dma->qwc, (tag[0] >> 28)&3, (tag[0] >> 31)&1, tag[1], tag[0]); - if ((psHu32(DMAC_CTRL) & 0x30) != 0 && ((tag[0] >> 28)&3) == 0) + // (tag[0] >> 28) & 3? Surely this is supposed to be (tag[0] >> 28) & 7? --arcum42 + if ((psHu32(DMAC_CTRL) & 0x30) != 0 && ((tag[0] >> 28) & 3) == 0) psHu32(DMAC_STADR) = sif0dma->madr + (sif0dma->qwc * 16); sif0.chain = 1; if (tag[0] & 0x40000000) sif0.end = 1; - done = FALSE; + done = false; } } @@ -258,7 +261,6 @@ __forceinline void SIF0Dma() __forceinline void SIF1Dma() { - int id; u32 *ptag; bool done = FALSE; int cycles = 0, psxCycles = 0; @@ -272,12 +274,12 @@ __forceinline void SIF1Dma() if (sif1dma->qwc == 0) // If there's no more to transfer { - if ((sif1dma->chcr & 0xc) == 0 || sif1.end) // If NORMAL mode or end of CHAIN then stop DMA + if ((CHCR::MOD(sif1dma) == NORMAL_MODE) || sif1.end) // If NORMAL mode or end of CHAIN then stop DMA { // Stop & signal interrupts on EE SIF_LOG("EE SIF1 End %x", sif1.end); eesifbusy[1] = 0; - done = TRUE; + done = true; CPU_INT(6, cycles*BIAS); sif1.chain = 0; sif1.end = 0; @@ -285,7 +287,7 @@ __forceinline void SIF1Dma() else // Chain mode { // Process DMA tag at sif1dma->tadr - done = FALSE; + done = false; ptag = _dmaGetAddr(sif1dma, sif1dma->tadr, 6); if (ptag == NULL) return; @@ -295,16 +297,15 @@ __forceinline void SIF1Dma() sif1dma->chcr = (sif1dma->chcr & 0xFFFF) | ((*ptag) & 0xFFFF0000); // Copy the tag sif1dma->qwc = (u16)ptag[0]; - if (sif1dma->chcr & 0x40) + if (CHCR::TTE(sif1dma)) { Console::WriteLn("SIF1 TTE"); SIF1write(ptag + 2, 2); } sif1.chain = 1; - id = (ptag[0] >> 28) & 0x7; - switch (id) + switch (Tag::Id(ptag)) { case TAG_REFE: // refe SIF_LOG(" REFE %08X", ptag[1]); @@ -342,7 +343,7 @@ __forceinline void SIF1Dma() default: Console::WriteLn("Bad addr1 source chain"); } - if ((sif1dma->chcr & 0x80) && (ptag[0] >> 31)) + if ((CHCR::TIE(sif1dma)) && (Tag::IRQ(ptag))) { Console::WriteLn("SIF1 TIE"); sif1.end = 1; @@ -355,7 +356,7 @@ __forceinline void SIF1Dma() u32 *data; data = _dmaGetAddr(sif1dma, sif1dma->madr, 6); - if (data == NULL) return; + if (data == NULL) return; //_dmaGetAddr(sif1dma, *data, sif1dma->madr, 6); @@ -374,7 +375,7 @@ __forceinline void SIF1Dma() { int size = sif1.counter; - if (size > 0) // If we're reading something continue to do so + if (size > 0) // If we're reading something, continue to do so. { int readSize = size; @@ -401,7 +402,7 @@ __forceinline void SIF1Dma() iopsifbusy[1] = 0; PSX_INT(IopEvt_SIF1, psxCycles); sif1.tagMode = 0; - done = TRUE; + done = true; } else if (sif1.fifoSize >= 4) // Read a tag { @@ -411,7 +412,7 @@ __forceinline void SIF1Dma() HW_DMA10_MADR = d.data & 0xffffff; sif1.counter = d.words; sif1.tagMode = (d.data >> 24) & 0xFF; - done = FALSE; + done = false; } } } @@ -433,14 +434,14 @@ __forceinline void sif1Interrupt() __forceinline void EEsif0Interrupt() { - sif0dma->chcr &= ~0x100; hwDmacIrq(DMAC_SIF0); + CHCR::clearSTR(sif0dma); } __forceinline void EEsif1Interrupt() { hwDmacIrq(DMAC_SIF1); - sif1dma->chcr &= ~0x100; + CHCR::clearSTR(sif1dma); } __forceinline void dmaSIF0() @@ -495,7 +496,7 @@ __forceinline void dmaSIF2() SIF_LOG("dmaSIF2 chcr = %lx, madr = %lx, qwc = %lx", sif2dma->chcr, sif2dma->madr, sif2dma->qwc); - sif2dma->chcr &= ~0x100; + CHCR::clearSTR(sif2dma); hwDmacIrq(DMAC_SIF2); Console::WriteLn("*PCSX2*: dmaSIF2"); } diff --git a/pcsx2/Vif.cpp b/pcsx2/Vif.cpp index 3f38cc471a..2cf78d4192 100644 --- a/pcsx2/Vif.cpp +++ b/pcsx2/Vif.cpp @@ -453,7 +453,7 @@ void mfifoVIF1transfer(int qwc) { ptag = (u32*)dmaGetAddr(vif1ch->tadr); - if (vif1ch->chcr & 0x40) + if (CHCR::TTE(vif1ch)) { if (vif1.stallontag) ret = VIF1transfer(ptag + (2 + vif1.irqoffset), 2 - vif1.irqoffset, 1); //Transfer Tag on Stall @@ -467,15 +467,14 @@ void mfifoVIF1transfer(int qwc) return; //IRQ set by VIFTransfer } } - - id = (ptag[0] >> 28) & 0x7; - vif1ch->qwc = (ptag[0] & 0xffff); - vif1ch->madr = ptag[1]; - - vif1ch->chcr = (vif1ch->chcr & 0xFFFF) | ((*ptag) & 0xFFFF0000); + + Tag::UnsafeTransfer(vif1ch, ptag); SPR_LOG("dmaChain %8.8x_%8.8x size=%d, id=%d, madr=%lx, tadr=%lx mfifo qwc = %x spr0 madr = %x", ptag[1], ptag[0], vif1ch->qwc, id, vif1ch->madr, vif1ch->tadr, vifqwc, spr0->madr); + + vif1ch->madr = ptag[1]; + id =Tag::Id(ptag); vifqwc--; switch (id) @@ -514,7 +513,7 @@ void mfifoVIF1transfer(int qwc) break; } - if ((vif1ch->chcr & 0x80) && (ptag[0] >> 31)) + if ((CHCR::TIE(vif1ch)) && (Tag::IRQ(ptag))) { VIF_LOG("dmaIrq Set"); vif1.done = true; @@ -530,29 +529,28 @@ void vifMFIFOInterrupt() { g_vifCycles = 0; - if(schedulepath3msk) Vif1MskPath3(); + if (schedulepath3msk) Vif1MskPath3(); - if((vif1Regs->stat & VIF1_STAT_VGW)) + if ((vif1Regs->stat & VIF1_STAT_VGW)) { - if(gif->chcr & 0x100) + if (CHCR::STR(gif)) { CPU_INT(10, 16); return; } - else vif1Regs->stat &= ~VIF1_STAT_VGW; + else + { + vif1Regs->stat &= ~VIF1_STAT_VGW; + } } - if((spr0->chcr & 0x100) && spr0->qwc == 0) + if ((CHCR::STR(spr0)) && (spr0->qwc == 0)) { - spr0->chcr &= ~0x100; + CHCR::clearSTR(spr0); hwDmacIrq(DMAC_FROM_SPR); } - - - - if (vif1.irq && vif1.tag.size == 0) { vif1Regs->stat |= VIF1_STAT_INT; @@ -561,7 +559,7 @@ void vifMFIFOInterrupt() if (vif1Regs->stat & (VIF1_STAT_VSS | VIF1_STAT_VIS | VIF1_STAT_VFS)) { vif1Regs->stat &= ~0x1F000000; // FQC=0 - vif1ch->chcr &= ~0x100; + CHCR::clearSTR(vif1ch); return; } } @@ -608,7 +606,7 @@ void vifMFIFOInterrupt() vif1.done = 1; g_vifCycles = 0; - vif1ch->chcr &= ~0x100; + CHCR::clearSTR(vif1ch); hwDmacIrq(DMAC_VIF1); VIF_LOG("vif mfifo dma end");