From 5bdc1947f44791b262ede56d3c5dbe18239bc601 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 9 Aug 2009 03:42:02 +0000 Subject: [PATCH] A few minor modifications to CDVD and IPU. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1612 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD/CDVD.cpp | 12 ++++---- pcsx2/IPU/IPU.cpp | 71 ++++++++++++++++++++++----------------------- pcsx2/IPU/IPU.h | 1 + 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 3273973c4b..a6d38995c2 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -1094,8 +1094,8 @@ static void cdvdWrite04(u8 rt) { // NCOMMAND break; case N_CD_READ: // CdRead - cdvd.SeekToSector = *(uint*)(cdvd.Param+0); - cdvd.nSectors = *(int*)(cdvd.Param+4); + cdvd.SeekToSector = (cdvd.Param[0] << 0) | (cdvd.Param[1] << 8) | (cdvd.Param[2]<< 16) | (cdvd.Param[3] << 24); + cdvd.nSectors = (cdvd.Param[4] << 0) | (cdvd.Param[5] << 8) | (cdvd.Param[6]<< 16) | (cdvd.Param[7] << 24); cdvd.RetryCnt = (cdvd.Param[8] == 0) ? 0x100 : cdvd.Param[8]; cdvd.SpindlCtrl = cdvd.Param[9]; cdvd.Speed = 24; @@ -1129,8 +1129,8 @@ static void cdvdWrite04(u8 rt) { // NCOMMAND case N_CD_READ_CDDA: // CdReadCDDA case N_CD_READ_XCDDA: // CdReadXCDDA - cdvd.SeekToSector = *(int*)(cdvd.Param+0); - cdvd.nSectors = *(int*)(cdvd.Param+4); + cdvd.SeekToSector = (cdvd.Param[0] << 0) | (cdvd.Param[1] << 8) | (cdvd.Param[2]<< 16) | (cdvd.Param[3] << 24); + cdvd.nSectors = (cdvd.Param[4] << 0) | (cdvd.Param[5] << 8) | (cdvd.Param[6]<< 16) | (cdvd.Param[7] << 24); if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; @@ -1175,8 +1175,8 @@ static void cdvdWrite04(u8 rt) { // NCOMMAND break; case N_DVD_READ: // DvdRead - cdvd.SeekToSector = *(int*)(cdvd.Param+0); - cdvd.nSectors = *(int*)(cdvd.Param+4); + cdvd.SeekToSector = (cdvd.Param[0] << 0) | (cdvd.Param[1] << 8) | (cdvd.Param[2]<< 16) | (cdvd.Param[3] << 24); + cdvd.nSectors = (cdvd.Param[4] << 0) | (cdvd.Param[5] << 8) | (cdvd.Param[6]<< 16) | (cdvd.Param[7] << 24); if (cdvd.Param[8] == 0) cdvd.RetryCnt = 0x100; diff --git a/pcsx2/IPU/IPU.cpp b/pcsx2/IPU/IPU.cpp index 4b4cd3845c..4adf2495f2 100644 --- a/pcsx2/IPU/IPU.cpp +++ b/pcsx2/IPU/IPU.cpp @@ -117,7 +117,7 @@ extern "C" PCSX2_ALIGNED16(u8 _readbits[80]); //local buffer (ring buffer) u8* readbits = _readbits; // always can decrement by one 1qw -#define SATURATE_4BITS(val) ((val)>15 ? 15 : (val)) +//#define SATURATE_4BITS(val) ((val)>15 ? 15 : (val)) __forceinline void IPUProcessInterrupt() { @@ -317,21 +317,20 @@ __forceinline u64 ipuRead64(u32 mem) void ipuSoftReset() { mpeg2_init(); - FIFOto_clear(); - memzero_obj(fifo_output); - FOwritepos = 0; - FOreadpos = 0; + FIFOfrom_clear(); + coded_block_pattern = 0; - + ipuRegs->ctrl._u32 = 0; + ipuRegs->top = 0; + ipuCurCmd = 0xffffffff; + g_BP.BP = 0; - g_BP.IFC = 0; g_BP.FP = 0; g_BP.bufferhasnew = 0; - ipuRegs->top = 0; + g_nCmdIndex = 0; - ipuCurCmd = 0xffffffff; g_nCmdPos[0] = 0; g_nCmdPos[1] = 0; } @@ -404,10 +403,10 @@ __forceinline void ipuWrite64(u32 mem, u64 value) static void ipuBCLR(u32 val) { FIFOto_clear(); + g_BP.BP = val & 0x7F; g_BP.FP = 0; g_BP.bufferhasnew = 0; - g_BP.IFC = 0; ipuRegs->ctrl.BUSY = 0; ipuRegs->cmd.BUSY = 0; memzero_ptr<80>(readbits); @@ -1333,14 +1332,12 @@ int FIFOto_read(void *value) } // transfer 1 qword, split into two transfers - ((u32*)value)[0] = fifo_input[FIreadpos]; - fifo_input[FIreadpos] = 0; - ((u32*)value)[1] = fifo_input[FIreadpos+1]; - fifo_input[FIreadpos+1] = 0; - ((u32*)value)[2] = fifo_input[FIreadpos+2]; - fifo_input[FIreadpos+2] = 0; - ((u32*)value)[3] = fifo_input[FIreadpos+3]; - fifo_input[FIreadpos+3] = 0; + for (int i = 0; i <= 3; i++) + { + ((u32*)value)[i] = fifo_input[FIreadpos + i]; + fifo_input[FIreadpos + i] = 0; + } + FIreadpos = (FIreadpos + 4) & 31; g_BP.IFC--; return 1; @@ -1356,10 +1353,10 @@ int FIFOto_write(u32* pMem, int size) while (transsize-- > 0) { - fifo_input[FIwritepos] = pMem[0]; - fifo_input[FIwritepos+1] = pMem[1]; - fifo_input[FIwritepos+2] = pMem[2]; - fifo_input[FIwritepos+3] = pMem[3]; + for (int i = 0; i <= 3; i++) + { + fifo_input[FIwritepos + i] = pMem[i]; + } FIwritepos = (FIwritepos + 4) & 31; pMem += 4; } @@ -1597,6 +1594,13 @@ int IPU1dma() return totalqwc; } +void FIFOfrom_clear() +{ + memzero_obj(fifo_output); + ipuRegs->ctrl.OFC = 0; + FOreadpos = 0; + FOwritepos = 0; +} int FIFOfrom_write(const u32 *value, int size) { @@ -1609,10 +1613,10 @@ int FIFOfrom_write(const u32 *value, int size) while (transsize-- > 0) { - fifo_output[FOwritepos] = ((u32*)value)[0]; - fifo_output[FOwritepos+1] = ((u32*)value)[1]; - fifo_output[FOwritepos+2] = ((u32*)value)[2]; - fifo_output[FOwritepos+3] = ((u32*)value)[3]; + for (int i = 0; i <= 3; i++) + { + fifo_output[FOwritepos + i] = ((u32*)value)[i]; + } FOwritepos = (FOwritepos + 4) & 31; value += 4; } @@ -1627,14 +1631,11 @@ int FIFOfrom_write(const u32 *value, int size) static __forceinline void _FIFOfrom_readsingle(void *value) { // transfer 1 qword, split into two transfers - ((u32*)value)[0] = fifo_output[FOreadpos]; - fifo_output[FOreadpos] = 0; - ((u32*)value)[1] = fifo_output[FOreadpos+1]; - fifo_output[FOreadpos+1] = 0; - ((u32*)value)[2] = fifo_output[FOreadpos+2]; - fifo_output[FOreadpos+2] = 0; - ((u32*)value)[3] = fifo_output[FOreadpos+3]; - fifo_output[FOreadpos+3] = 0; + for (int i = 0; i <= 3; i++) + { + ((u32*)value)[i] = fifo_output[FOreadpos + i]; + fifo_output[FOreadpos + i] = 0; + } FOreadpos = (FOreadpos + 4) & 31; } @@ -1658,8 +1659,6 @@ void FIFOfrom_read(void *value, int size) } } - - int IPU0dma() { int readsize; diff --git a/pcsx2/IPU/IPU.h b/pcsx2/IPU/IPU.h index c148bac652..ca6e6498a1 100644 --- a/pcsx2/IPU/IPU.h +++ b/pcsx2/IPU/IPU.h @@ -273,5 +273,6 @@ void FIFOfrom_read(void *value,int size); int FIFOto_read(void *value); int FIFOto_write(u32* pMem, int size); void FIFOto_clear(); +void FIFOfrom_clear(); #endif