mirror of https://github.com/PCSX2/pcsx2.git
This commit doesn't change anything of the emulator.
I coded a new way for the IOP to handle DMAs, but it needs too many modifications in other parts of the emulator, and I'm not in the mood to code all that right now. If anyone wants to try & get this code actually working, go on, else leave it #if'd away. git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@634 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
a165a01495
commit
0340f701a9
111
pcsx2/IopDma.cpp
111
pcsx2/IopDma.cpp
|
@ -232,3 +232,114 @@ void iopIntcIrq( uint irqType )
|
|||
psxHu32(0x1070)|= 1<<irqType;
|
||||
iopTestIntc();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Gigaherz's "Improved DMA Handling" Engine WIP...
|
||||
//
|
||||
// YES THIS FUCKING SIMPLE CODE IS ALL THE IOP DMAS NEED! (well, when all the fuckups I might have done get fixed)
|
||||
#if FALSE
|
||||
|
||||
typedef s32 (* DmaHandler) (s32 channel, u32* data, u32 wordsLeft, u32* wordsProcessed);
|
||||
typedef void (* DmaIHandler)(s32 channel);
|
||||
|
||||
struct DmaHandlerInfo {
|
||||
DmaHandler Read;
|
||||
DmaHandler Write;
|
||||
DmaIHandler Interrupt;
|
||||
};
|
||||
|
||||
struct DmaStatusInfo {
|
||||
u32 Control;
|
||||
u32 Width; // bytes/word, for timing purposes
|
||||
u32 MemAddr;
|
||||
u32 ByteCount;
|
||||
u32 Target;
|
||||
};
|
||||
|
||||
// FIXME: Dummy constants, to be "filled in" with proper values later
|
||||
#define DMA_CTRL_ACTIVE 1
|
||||
#define DMA_CTRL_DIRECTION 2
|
||||
|
||||
#define DMA_CHANNEL_MAX 16 /* ? */
|
||||
|
||||
DmaStatusInfo IopChannels[DMA_CHANNEL_MAX]; // I dont' knwo how many there are, 10?
|
||||
|
||||
DmaHandlerInfo IopDmaHandlers[DMA_CHANNEL_MAX] = {
|
||||
{0}, //0
|
||||
{0}, //1
|
||||
{0}, //2
|
||||
{cdvdDmaRead, errorDmaWrite,cdvdDmaInterrupt}, //3: CDVD
|
||||
{spu2DmaRead, spu2DmaWrite, spu2DmaInterrupt}, //4: Spu Core0
|
||||
{0}, //5
|
||||
{0}, //6: OT?
|
||||
{spu2DmaRead, spu2DmaWrite, spu2DmaInterrupt}, //7: Spu Core1
|
||||
{dev9DmaRead, dev9DmaWrite, dev9DmaInterrupt}, //8: Dev9
|
||||
{sif0DmaRead, sif0DmaWrite, sif0DmaInterrupt}, //9: SIF0
|
||||
{sif1DmaRead, sif1DmaWrite, sif1DmaInterrupt}, //10: SIF1
|
||||
//...
|
||||
};
|
||||
|
||||
// Prototypes. To be implemented later (or in other parts of the emulator)
|
||||
void SetDmaUpdateTarget(u32 delay);
|
||||
void RaiseDmaIrq(u32 channel);
|
||||
|
||||
// WARNING: CALLER ****[MUST]**** CALL IopDmaUpdate RIGHT AFTER THIS!
|
||||
void IopDmaStart(int channel, u32 chcr, u32 madr, u32 bcr)
|
||||
{
|
||||
// I dont' really understand this, but it's used above. Is this BYTES OR WHAT?
|
||||
int size = (bcr >> 16) * (bcr & 0xFFFF);
|
||||
|
||||
IopChannels[channel].Control = chcr;
|
||||
IopChannels[channel].MemAddr = madr;
|
||||
IopChannels[channel].ByteCount = size;
|
||||
}
|
||||
|
||||
void IopDmaUpdate(u32 elapsed)
|
||||
{
|
||||
u32 MinDelay = 0xFFFFFFFF;
|
||||
|
||||
for(int i=0;i<DMA_CHANNEL_MAX;i++)
|
||||
{
|
||||
DmaStatusInfo *ch = IopChannels+i;
|
||||
|
||||
if(ch->Control&DMA_CTRL_ACTIVE)
|
||||
{
|
||||
ch->Target-=elapsed;
|
||||
if(ch->Target<=0)
|
||||
{
|
||||
if(ch->ByteCount<=0)
|
||||
{
|
||||
ch->Control &= ~DMA_CTRL_ACTIVE;
|
||||
RaiseDmaIrq(i);
|
||||
IopDmaHandlers[i].Interrupt(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Make sure it's the right order
|
||||
DmaHandler handler = (ch->Control&DMA_CTRL_DIRECTION)?IopDmaHandlers[i].Read:IopDmaHandlers[i].Write;
|
||||
|
||||
u32 BCount = 0;
|
||||
s32 Target = (handler)?handler(i,(u32*)PSXM(ch->MemAddr),ch->ByteCount,&BCount):0;
|
||||
|
||||
ch->Target = 100;
|
||||
if(Target<0)
|
||||
{
|
||||
// TODO: ... What to do if the plugin errors? :P
|
||||
}
|
||||
else if(BCount!=0)
|
||||
{
|
||||
ch->MemAddr += BCount;
|
||||
ch->ByteCount -= BCount;
|
||||
|
||||
ch->Target = BCount / ch->Width;
|
||||
}
|
||||
|
||||
if (Target!=0) ch->Target=Target;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -108,10 +108,10 @@ _SPU2close SPU2close;
|
|||
_SPU2shutdown SPU2shutdown;
|
||||
_SPU2write SPU2write;
|
||||
_SPU2read SPU2read;
|
||||
_SPU2readDMA4Mem SPU2readDMA4Mem;
|
||||
//_SPU2readDMA4Mem SPU2readDMA4Mem;
|
||||
_SPU2writeDMA4Mem SPU2writeDMA4Mem;
|
||||
_SPU2interruptDMA4 SPU2interruptDMA4;
|
||||
_SPU2readDMA7Mem SPU2readDMA7Mem;
|
||||
//_SPU2readDMA7Mem SPU2readDMA7Mem;
|
||||
_SPU2writeDMA7Mem SPU2writeDMA7Mem;
|
||||
_SPU2setDMABaseAddr SPU2setDMABaseAddr;
|
||||
_SPU2interruptDMA7 SPU2interruptDMA7;
|
||||
|
@ -407,10 +407,10 @@ int LoadSPU2plugin(const string& filename) {
|
|||
MapSymbol_Error(SPU2close);
|
||||
MapSymbol_Error(SPU2write);
|
||||
MapSymbol_Error(SPU2read);
|
||||
MapSymbol_Error(SPU2readDMA4Mem);
|
||||
//MapSymbol_Error(SPU2readDMA4Mem);
|
||||
MapSymbol_Error(SPU2writeDMA4Mem);
|
||||
MapSymbol_Error(SPU2interruptDMA4);
|
||||
MapSymbol_Error(SPU2readDMA7Mem);
|
||||
//MapSymbol_Error(SPU2readDMA7Mem);
|
||||
MapSymbol_Error(SPU2writeDMA7Mem);
|
||||
MapSymbol_Error(SPU2interruptDMA7);
|
||||
MapSymbol(SPU2setDMABaseAddr);
|
||||
|
|
Loading…
Reference in New Issue