Tweak a few things in Sif.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2546 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-01-31 15:44:15 +00:00
parent c44db64537
commit 9c9760f963
3 changed files with 71 additions and 35 deletions

View File

@ -18,12 +18,17 @@
#define FIFO_SIF_W 128
// I'm not sure if removing the top 8 bits is correct or not, so this define lets me test it a bit.
// It doesn't seem like word has anything in the first 8 bits anyways, but data does (IRQ and tag id),
// so I'll have to play with it.
#define CHOP_OFF_DATA
struct sifData
{
s32 data;
s32 words;
s32 count;
s32 addr;
s32 count; // I think this is unused.
s32 addr; // This too.
};
struct sifFifo
@ -88,22 +93,25 @@ struct _sif
struct sifData data; // Only used in IOP.
};
/*struct _sif
/*
struct sif_ee
{
bool end; // Only used for EE.
bool busy;
};
struct sif_iop
{
bool end;
bool busy;
s32 counter; // Used to keep track of how much is left in IOP.
struct sifData data; // Only used in IOP.
};
struct _sif
{
sifFifo fifo; // Used in both.
struct ee
{
bool end; // Only used for EE.
bool busy;
}
struct iop
{
bool end;
bool busy;
s32 counter; // Used to keep track of how much is left in IOP.
struct sifData data; // Only used in IOP.
}
sif_ee ee;
sif_iop iop;
};*/
extern bool eesifbusy[2], iopsifbusy[2];
@ -123,7 +131,7 @@ extern void EEsif1Interrupt();
extern void sif0Interrupt();
extern void sif1Interrupt();
#define sif0_tag DMA_TAG(sif0.data.data)
#define sif1_tag DMA_TAG(sif1.data.data)
#define sif0tag DMA_TAG(sif0.data.data)
#define sif1tag DMA_TAG(sif1.data.data)
#endif /* __SIF_H__ */

View File

@ -88,6 +88,8 @@ static __forceinline bool WriteIOPtoFifo()
sif0.fifo.write((u32*)iopPhysMem(hw_dma(9).madr), writeSize);
hw_dma(9).madr += writeSize << 2;
// iop is 1/8th the clock rate of the EE and psxcycles is in words (not quadwords).
psxCycles += (writeSize >> 2) * BIAS; // fixme : should be >> 4
sif0.counter -= writeSize;
//}
@ -146,11 +148,15 @@ static __forceinline bool ProcessIOPTag()
hw_dma(9).tadr += 16; ///hw_dma(9).madr + 16 + sif0.sifData.words << 2;
// Looks like we are only copying the first 24 bits.
#ifdef CHOP_OFF_DATA
hw_dma(9).madr = sif0.data.data & 0xFFFFFF;
sif0.counter = sif0.data.words & 0xFFFFFF;
SIF_LOG("SIF0 IOP Tag: madr=%lx, tadr=%lx, counter=%lx (%08X_%08X)", HW_DMA9_MADR, HW_DMA9_TADR, sif0.counter, sif0.data.words, sif0.data.data);
#else
hw_dma(9).madr = sif0.data.data;
#endif
sif0.counter = sif0.data.words;
//if (sif0.data.words != ( sif0.data.words & 0xFFFFFF)) DevCon.WriteLn("sif0.data.words more then 24 bit.");
SIF_LOG("SIF0 IOP Tag: madr=%lx, tadr=%lx, counter=%lx (%08X_%08X)", hw_dma(9).madr, hw_dma(9).tadr, sif0.counter, sif0.data.words, sif0.data.data);
return true;
}
@ -160,8 +166,16 @@ static __forceinline void EndEE()
SIF_LOG("Sif0: End EE");
sif0.end = 0;
eesifbusy[0] = false;
if (cycles == 0) DevCon.Warning("SIF0 EE: cycles = 0"); // No transfer happened
else CPU_INT(DMAC_SIF0, cycles*BIAS); // Hence no Interrupt
if (cycles == 0)
{
// No transfer happened,
DevCon.Warning("SIF0 EE: cycles = 0");
}
else
{
// hence no Interrupt.
CPU_INT(DMAC_SIF0, cycles*BIAS);
}
}
// Stop transferring iop, and signal an interrupt.
@ -171,11 +185,19 @@ static __forceinline void EndIOP()
sif0.data.data = 0;
iopsifbusy[0] = false;
// iop is 1/8th the clock rate of the EE and psxcycles is in words (not quadwords)
// So when we're all done, the equation looks like thus:
//PSX_INT(IopEvt_SIF0, ( ( psxCycles*BIAS ) / 4 ) / 8);
if (psxCycles == 0) DevCon.Warning("SIF0 IOP: cycles = 0"); // No transfer happened
else PSX_INT(IopEvt_SIF0, psxCycles); // Hence no Interrupt
if (psxCycles == 0)
{
// No transfer happened,
DevCon.Warning("SIF0 IOP: cycles = 0");
}
else
{
// hence no Interrupt.
// iop is 1/8th the clock rate of the EE and psxcycles is in words (not quadwords)
// So when we're all done, the equation looks like thus:
//PSX_INT(IopEvt_SIF0, ( ( psxCycles*BIAS ) / 4 ) / 8);
PSX_INT(IopEvt_SIF0, psxCycles);
}
}
// Handle the EE transfer.
@ -204,7 +226,7 @@ static __forceinline void HandleEETransfer()
}
}
if (sif0dma->qwc > 0) // If we're reading something continue to do so
if (sif0dma->qwc > 0) // If we're writing something, continue to do so.
{
// Write from Fifo to EE.
WriteFifoToEE();
@ -244,7 +266,7 @@ static __forceinline void HandleIOPTransfer()
{
if (sif0.counter <= 0) // If there's no more to transfer
{
if (sif0_tag.IRQ || (sif0_tag.ID & 4))
if (sif0tag.IRQ || (sif0tag.ID & 4))
{
// Stop transferring iop, and signal an interrupt.
done = true;

View File

@ -167,11 +167,16 @@ static __forceinline bool SIFIOPReadTag()
// Read a tag.
sif1.fifo.read((u32*)&sif1.data, 4);
SIF_LOG("SIF 1 IOP: dest chain tag madr:%08X wc:%04X id:%X irq:%d",
sif1.data.data & 0xffffff, sif1.data.words, DMA_TAG(sif1.data.data).ID,
DMA_TAG(sif1.data.data).IRQ);
sif1.data.data & 0xffffff, sif1.data.words, sif1tag.ID, sif1tag.IRQ);
#ifdef CHOP_OFF_DATA
hw_dma(10).madr = sif1.data.data & 0xffffff;
#else
hw_dma(10).madr = sif1.data.data;
#endif
sif1.counter = sif1.data.words;
//if (sif1.data.words != ( sif1.data.words & 0xFFFFFF)) DevCon.WriteLn("sif1.data.words more then 24 bit.");
return true;
}
@ -216,6 +221,7 @@ static __forceinline void EndIOP()
else
{
// Hence no Interrupt
// iop is 1/8th the clock rate of the EE and psxcycles is in words (not quadwords)
PSX_INT(IopEvt_SIF1, min((psxCycles * 26), 1024));
}
}
@ -261,7 +267,7 @@ static __forceinline void HandleIOPTransfer()
if (sif1.counter <= 0)
{
if (sif1_tag.IRQ || (sif1_tag.ID & 4))
if (sif1tag.IRQ || (sif1tag.ID & 4))
{
done = true;
EndIOP();