diff --git a/Purei.vcproj b/Purei.vcproj
index 7fd3f154..f924c42a 100644
--- a/Purei.vcproj
+++ b/Purei.vcproj
@@ -956,158 +956,6 @@
RelativePath=".\Source\INTC.cpp"
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1526,50 +1374,6 @@
RelativePath=".\Source\Integer64.h"
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1698,6 +1502,10 @@
RelativePath=".\Source\Profiler.h"
>
+
+
@@ -1730,6 +1538,10 @@
RelativePath=".\Source\SIF.h"
>
+
+
@@ -1887,6 +1699,146 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
> 18) & 0x07]);
- Branch(true);
- }
- CCodeGen::End();
+ TestCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
+ BranchEx(true);
}
//02
void CCOP_FPU::BC1FL()
{
- CCodeGen::Begin(m_pB);
- {
- TestCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
- BranchLikely(false);
- }
- CCodeGen::End();
+ TestCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
+ BranchLikelyEx(false);
}
//03
void CCOP_FPU::BC1TL()
{
- CCodeGen::Begin(m_pB);
- {
- TestCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
- BranchLikely(true);
- }
- CCodeGen::End();
+ TestCCBit(m_nCCMask[(m_nOpcode >> 18) & 0x07]);
+ BranchLikelyEx(true);
}
//////////////////////////////////////////////////
@@ -383,15 +371,12 @@ void CCOP_FPU::C_LT_S()
//36
void CCOP_FPU::C_LE_S()
{
- CCodeGen::Begin(m_pB);
- {
- CFPU::PushSingle(&m_pCtx->m_State.nCOP10[m_nFT * 2]);
- CFPU::PushSingle(&m_pCtx->m_State.nCOP10[m_nFS * 2]);
- CFPU::Cmp(CCodeGen::CONDITION_BE);
+ m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFT * 2]));
+ m_codeGen->FP_PushSingle(offsetof(CMIPS, m_State.nCOP10[m_nFS * 2]));
- SetCCBit(true, m_nCCMask[((m_nOpcode >> 8) & 0x07)]);
- }
- CCodeGen::End();
+ m_codeGen->FP_Cmp(CCodeGen::CONDITION_BE);
+
+ SetCCBit(true, m_nCCMask[((m_nOpcode >> 8) & 0x07)]);
}
//////////////////////////////////////////////////
diff --git a/Source/CodeGen.cpp b/Source/CodeGen.cpp
index a2380316..c447ed2f 100644
--- a/Source/CodeGen.cpp
+++ b/Source/CodeGen.cpp
@@ -2052,6 +2052,36 @@ void CCodeGen::Shl64(uint8 nAmount)
}
}
+void CCodeGen::Sra()
+{
+ if(FitsPattern())
+ {
+ RelativeRelative::PatternValue ops = GetPattern();
+ unsigned int shiftAmount = AllocateRegister(REGISTER_SHIFTAMOUNT);
+ unsigned int resultRegister = AllocateRegister();
+ LoadRelativeInRegister(resultRegister, ops.first);
+ LoadRelativeInRegister(shiftAmount, ops.second);
+ m_Assembler.SarEd(CX86Assembler::MakeRegisterAddress(m_nRegisterLookupEx[resultRegister]));
+ FreeRegister(shiftAmount);
+ PushReg(resultRegister);
+ }
+ else if(FitsPattern())
+ {
+ ConstantRelative::PatternValue ops = GetPattern();
+ unsigned int shiftAmount = AllocateRegister(REGISTER_SHIFTAMOUNT);
+ unsigned int resultRegister = AllocateRegister();
+ LoadConstantInRegister(resultRegister, ops.first);
+ LoadRelativeInRegister(shiftAmount, ops.second);
+ m_Assembler.SarEd(CX86Assembler::MakeRegisterAddress(m_nRegisterLookupEx[resultRegister]));
+ FreeRegister(shiftAmount);
+ PushReg(resultRegister);
+ }
+ else
+ {
+ assert(0);
+ }
+}
+
void CCodeGen::Sra(uint8 nAmount)
{
if(FitsPattern())
@@ -2062,7 +2092,7 @@ void CCodeGen::Sra(uint8 nAmount)
}
else if(FitsPattern())
{
- UnaryRelativeSelfCallAsRegister(bind(&CCodeGen::Sra, nAmount));
+ UnaryRelativeSelfCallAsRegister(bind(&CCodeGen::Sra, this, nAmount));
}
else
{
diff --git a/Source/CodeGen.h b/Source/CodeGen.h
index 45e0e012..2acad57e 100644
--- a/Source/CodeGen.h
+++ b/Source/CodeGen.h
@@ -119,8 +119,9 @@ public:
void Shl(uint8);
static void Shl64();
void Shl64(uint8);
- static void Sra(uint8);
- static void Sra64(uint8);
+ void Sra();
+ void Sra(uint8);
+ void Sra64(uint8);
void Srl();
void Srl(uint8);
static void Srl64();
@@ -145,14 +146,16 @@ public:
void FP_Neg();
//SIMD (128-bits only)
- void MD_PushRel(size_t);
- void MD_PullRel(size_t);
+ virtual void MD_PushRel(size_t);
+ virtual void MD_PullRel(size_t);
void MD_PushReg(XMMREGISTER);
void MD_And();
void MD_Not();
void MD_Or();
void MD_SubB();
+ void MD_SubW();
+ void MD_Xor();
void SetStream(Framework::CStream*);
static CX86Assembler m_Assembler;
diff --git a/Source/CodeGen_FPU.cpp b/Source/CodeGen_FPU.cpp
index 8fe8a857..99bd3d05 100644
--- a/Source/CodeGen_FPU.cpp
+++ b/Source/CodeGen_FPU.cpp
@@ -368,15 +368,18 @@ void CCodeGen::FP_Cmp(CCodeGen::CONDITION condition)
case CONDITION_BL:
conditionCode = CX86Assembler::SSE_CMP_LT;
break;
+ case CONDITION_BE:
+ conditionCode = CX86Assembler::SSE_CMP_LE;
+ break;
default:
assert(0);
break;
}
XMMREGISTER tempResultRegister = AllocateXmmRegister();
unsigned int resultRegister = AllocateRegister();
- FP_LoadSingleRelativeInRegister(tempResultRegister, ops.first);
+ FP_LoadSingleRelativeInRegister(tempResultRegister, ops.second);
m_Assembler.CmpssEd(tempResultRegister,
- CX86Assembler::MakeIndRegOffAddress(g_nBaseRegister, ops.second),
+ CX86Assembler::MakeIndRegOffAddress(g_nBaseRegister, ops.first),
conditionCode);
//Can't move directly to register using MOVSS, so we use CVTTSS2SI
//0x00000000 -- CVT -> zero
diff --git a/Source/CodeGen_MD.cpp b/Source/CodeGen_MD.cpp
index 8338f041..e1253053 100644
--- a/Source/CodeGen_MD.cpp
+++ b/Source/CodeGen_MD.cpp
@@ -2,20 +2,20 @@
#include "CodeGen.h"
#include "CodeGen_StackPatterns.h"
-bool CCodeGen::Register128HasNextUse(XMMREGISTER registerId)
-{
- unsigned int nCount = m_Shadow.GetCount();
-
- for(unsigned int i = 0; i < nCount; i += 2)
- {
- if(m_Shadow.GetAt(i) == REGISTER128)
- {
- if(m_Shadow.GetAt(i + 1) == registerId) return true;
- }
- }
-
- return false;
-}
+bool CCodeGen::Register128HasNextUse(XMMREGISTER registerId)
+{
+ unsigned int nCount = m_Shadow.GetCount();
+
+ for(unsigned int i = 0; i < nCount; i += 2)
+ {
+ if(m_Shadow.GetAt(i) == REGISTER128)
+ {
+ if(m_Shadow.GetAt(i + 1) == registerId) return true;
+ }
+ }
+
+ return false;
+}
void CCodeGen::LoadRelative128InRegister(XMMREGISTER registerId, uint32 offset)
{
@@ -119,3 +119,37 @@ void CCodeGen::MD_SubB()
assert(0);
}
}
+
+void CCodeGen::MD_SubW()
+{
+ if(FitsPattern())
+ {
+ RelativeRelative128::PatternValue ops(GetPattern());
+ XMMREGISTER resultRegister = AllocateXmmRegister();
+ LoadRelative128InRegister(resultRegister, ops.first);
+ m_Assembler.PsubdVo(resultRegister,
+ CX86Assembler::MakeIndRegOffAddress(g_nBaseRegister, ops.second));
+ MD_PushReg(resultRegister);
+ }
+ else
+ {
+ assert(0);
+ }
+}
+
+void CCodeGen::MD_Xor()
+{
+ if(FitsPattern())
+ {
+ RelativeRelative128::PatternValue ops(GetPattern());
+ XMMREGISTER resultRegister = AllocateXmmRegister();
+ LoadRelative128InRegister(resultRegister, ops.first);
+ m_Assembler.PxorVo(resultRegister,
+ CX86Assembler::MakeIndRegOffAddress(g_nBaseRegister, ops.second));
+ MD_PushReg(resultRegister);
+ }
+ else
+ {
+ assert(0);
+ }
+}
diff --git a/Source/DMAC.cpp b/Source/DMAC.cpp
index f415375f..1b9056a3 100644
--- a/Source/DMAC.cpp
+++ b/Source/DMAC.cpp
@@ -1,9 +1,9 @@
#include
-#include "PS2VM.h"
#include "DMAC.h"
#include "INTC.h"
#include "GIF.h"
#include "SIF.h"
+#include "Ps2Const.h"
#include "Profiler.h"
#include "Log.h"
#include "RegisterStateFile.h"
@@ -143,11 +143,11 @@ uint32 CDMAC::ResumeDMA3(void* pBuffer, uint32 nSize)
if(m_D3_MADR & 0x80000000)
{
- pDst = m_spr + (m_D3_MADR & (CPS2VM::SPRSIZE - 1));
+ pDst = m_spr + (m_D3_MADR & (PS2::SPRSIZE - 1));
}
else
{
- pDst = m_ram + (m_D3_MADR & (CPS2VM::RAMSIZE - 1));
+ pDst = m_ram + (m_D3_MADR & (PS2::EERAMSIZE - 1));
}
memcpy(pDst, pBuffer, nSize * 0x10);
@@ -212,8 +212,8 @@ uint32 CDMAC::ReceiveSPRDMA(uint32 nSrcAddress, uint32 nCount, bool nTagIncluded
assert(nTagIncluded == false);
nDstAddress = m_D9_SADR;
- nDstAddress &= (CPS2VM::SPRSIZE - 1);
- nSrcAddress &= (CPS2VM::RAMSIZE - 1);
+ nDstAddress &= (PS2::SPRSIZE - 1);
+ nSrcAddress &= (PS2::EERAMSIZE - 1);
memcpy(m_spr + nDstAddress, m_ram + nSrcAddress, nCount * 0x10);
diff --git a/Source/GIF.cpp b/Source/GIF.cpp
index b9c2ece6..04ad73c9 100644
--- a/Source/GIF.cpp
+++ b/Source/GIF.cpp
@@ -2,7 +2,7 @@
#include
#include "GIF.h"
#include "uint128.h"
-#include "PS2VM.h"
+#include "Ps2Const.h"
#include "Profiler.h"
#include "Log.h"
@@ -283,7 +283,7 @@ uint32 CGIF::ReceiveDMA(uint32 nAddress, uint32 nQWC, uint32 unused, bool nTagIn
if(nAddress & 0x80000000)
{
pMemory = m_spr;
- nAddress &= CPS2VM::SPRSIZE - 1;
+ nAddress &= PS2::SPRSIZE - 1;
}
else
{
diff --git a/Source/GSH_OpenGL.cpp b/Source/GSH_OpenGL.cpp
index 083d6caa..48ae0829 100644
--- a/Source/GSH_OpenGL.cpp
+++ b/Source/GSH_OpenGL.cpp
@@ -1155,6 +1155,8 @@ void CGSH_OpenGL::DisplayTransferedImage(uint32 nAddress)
glBindTexture(GL_TEXTURE_2D, NULL);
glDeleteTextures(1, &nTexture);
+
+ FlipImpl();
}
void CGSH_OpenGL::SetVBlank()
diff --git a/Source/IOP_Cdvdfsv.cpp b/Source/IOP_Cdvdfsv.cpp
deleted file mode 100644
index 138b242e..00000000
--- a/Source/IOP_Cdvdfsv.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-#include
-#include
-#include "IOP_Cdvdfsv.h"
-#include "PS2VM.h"
-
-using namespace IOP;
-using namespace Framework;
-
-uint32 CCdvdfsv::m_nStreamPos = 0;
-
-CCdvdfsv::CCdvdfsv(uint32 nID)
-{
- m_nID = nID;
-}
-
-CCdvdfsv::~CCdvdfsv()
-{
-
-}
-
-void CCdvdfsv::Invoke(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(m_nID)
- {
- case MODULE_ID_1:
- Invoke592(nMethod, pArgs, nArgsSize, pRet, nRetSize);
- break;
- case MODULE_ID_2:
- Invoke593(nMethod, pArgs, nArgsSize, pRet, nRetSize);
- break;
- case MODULE_ID_4:
- Invoke595(nMethod, pArgs, nArgsSize, pRet, nRetSize);
- break;
- case MODULE_ID_6:
- Invoke597(nMethod, pArgs, nArgsSize, pRet, nRetSize);
- break;
- case MODULE_ID_7:
- Invoke59C(nMethod, pArgs, nArgsSize, pRet, nRetSize);
- break;
- }
-}
-
-void CCdvdfsv::SaveState(CStream* pStream)
-{
- if(m_nID != MODULE_ID_1) return;
-
- pStream->Write(&m_nStreamPos, 4);
-}
-
-void CCdvdfsv::LoadState(CStream* pStream)
-{
- if(m_nID != MODULE_ID_1) return;
-
- pStream->Read(&m_nStreamPos, 4);
-}
-
-void CCdvdfsv::Invoke592(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0:
- //Init
- uint32 nMode;
-
- assert(nArgsSize >= 4);
- assert(nRetSize >= 0x10);
-
- nMode = ((uint32*)pArgs)[0x00];
-
- Log("Init(mode = %i);\r\n", nMode);
-
- ((uint32*)pRet)[0x03] = 0xFF;
-
- break;
- default:
- Log("Unknown method invoked (0x%0.8X, 0x%0.8X).\r\n", m_nID, nMethod);
- break;
- }
-}
-
-void CCdvdfsv::Invoke593(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0x03:
-
- assert(nRetSize >= 4);
-
- Log("GetDiskType();\r\n");
-
- //Returns PS2DVD for now.
- ((uint32*)pRet)[0x00] = 0x14;
-
- break;
-
- case 0x04:
- assert(nRetSize >= 4);
-
- Log("GetError();\r\n");
-
- ((uint32*)pRet)[0x00] = 0x00;
- break;
-
- case 0x0C:
- //Status
- //Returns
- //0 - Stopped
- //1 - Open
- //2 - Spin
- //3 - Read
- //and more...
-
- assert(nRetSize >= 4);
-
- Log("Status();\r\n");
-
- ((uint32*)pRet)[0x00] = 0;
-
- break;
- case 0x22:
- //Set Media Mode (1 - CDROM, 2 - DVDROM)
- uint32 nMode;
-
- assert(nArgsSize >= 4);
- assert(nRetSize >= 4);
-
- nMode = ((uint32*)pArgs)[0x00];
-
- Log("SetMediaMode(mode = %i);\r\n", nMode);
-
- ((uint32*)pRet)[0x00] = 1;
-
- break;
- default:
- Log("Unknown method invoked (0x%0.8X, 0x%0.8X).\r\n", m_nID, nMethod);
- break;
- }
-}
-
-void CCdvdfsv::Invoke595(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 1:
- Read(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 4:
- //GetToc
- uint32 nBuffer;
-
- assert(nArgsSize >= 4);
- assert(nRetSize >= 4);
-
- nBuffer = ((uint32*)pArgs)[0x00];
-
- Log("GetToc(buffer = 0x%0.8X);\r\n", nBuffer);
-
- ((uint32*)pRet)[0x00] = 1;
- break;
- case 9:
- StreamCmd(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x0E:
- //DiskReady (returns 2 if ready, 6 if not ready)
-
- assert(nRetSize >= 4);
-
- Log("NDiskReady();\r\n");
-
- ((uint32*)pRet)[0x00] = 2;
- break;
- default:
- Log("Unknown method invoked (0x%0.8X, 0x%0.8X).\r\n", m_nID, nMethod);
- break;
- }
-}
-
-void CCdvdfsv::Invoke597(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0:
- SearchFile(pArgs, nArgsSize, pRet, nRetSize);
- break;
- default:
- Log("Unknown method invoked (0x%0.8X, 0x%0.8X).\r\n", m_nID, nMethod);
- break;
- }
-}
-
-void CCdvdfsv::Invoke59C(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0:
- //DiskReady (returns 2 if ready, 6 if not ready)
-
- uint32 nMode;
-
- assert(nRetSize >= 4);
- assert(nArgsSize >= 4);
-
- nMode = ((uint32*)pArgs)[0x00];
-
- Log("DiskReady(mode = %i);\r\n", nMode);
-
- ((uint32*)pRet)[0x00] = 2;
- break;
- default:
- Log("Unknown method invoked (0x%0.8X, 0x%0.8X).\r\n", m_nID, nMethod);
- break;
- }
-}
-
-void CCdvdfsv::Read(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- uint32 nSector, nCount, nDstAddr, nMode;
- unsigned int i;
-
- nSector = ((uint32*)pArgs)[0x00];
- nCount = ((uint32*)pArgs)[0x01];
- nDstAddr = ((uint32*)pArgs)[0x02];
- nMode = ((uint32*)pArgs)[0x04];
-
- Log("Read(sector = 0x%0.8X, count = 0x%0.8X, addr = 0x%0.8X, mode = 0x%0.8X);\r\n", \
- nSector,
- nCount,
- nDstAddr,
- nMode);
-
- for(i = 0; i < nCount; i++)
- {
- CPS2VM::m_pCDROM0->ReadBlock(nSector + i, CPS2VM::m_pRAM + (nDstAddr + (i * 0x800)));
- }
-
- if(nRetSize >= 4)
- {
- ((uint32*)pRet)[0] = 0;
- }
-}
-
-void CCdvdfsv::StreamCmd(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- uint32 nSector, nCount, nDstAddr, nCmd, nMode, i;
-
- nSector = ((uint32*)pArgs)[0x00];
- nCount = ((uint32*)pArgs)[0x01];
- nDstAddr = ((uint32*)pArgs)[0x02];
- nCmd = ((uint32*)pArgs)[0x03];
- nMode = ((uint32*)pArgs)[0x04];
-
- Log("StreamCmd(sector = 0x%0.8X, count = 0x%0.8X, addr = 0x%0.8X, cmd = 0x%0.8X);\r\n", \
- nSector,
- nCount,
- nDstAddr,
- nMode);
-
- switch(nCmd)
- {
- case 1:
- //Start
- m_nStreamPos = nSector;
- ((uint32*)pRet)[0] = 1;
-
- Log("StreamStart(pos = 0x%0.8X);\r\n", \
- nSector);
- break;
- case 2:
- //Read
- nDstAddr &= (CPS2VM::RAMSIZE - 1);
-
- for(i = 0; i < nCount; i++)
- {
- CPS2VM::m_pCDROM0->ReadBlock(m_nStreamPos, CPS2VM::m_pRAM + (nDstAddr + (i * 0x800)));
- m_nStreamPos++;
- }
-
- ((uint32*)pRet)[0] = nCount;
-
- Log("StreamRead(count = 0x%0.8X, dest = 0x%0.8X);\r\n", \
- nCount, \
- nDstAddr);
- break;
- case 5:
- //Init
- ((uint32*)pRet)[0] = 1;
-
- Log("StreamInit(bufsize = 0x%0.8X, numbuf = 0x%0.8X, buf = 0x%0.8X);\r\n", \
- nSector, \
- nCount, \
- nDstAddr);
- break;
- case 4:
- case 9:
- //Seek
- m_nStreamPos = nSector;
- ((uint32*)pRet)[0] = 1;
-
- Log("StreamSeek(pos = 0x%0.8X);\r\n", \
- nSector);
- break;
- }
-}
-
-void CCdvdfsv::SearchFile(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- char* sPath;
- char* sTemp;
- char sFixedPath[256];
- CISO9660* pISO;
- ISO9660::CDirectoryRecord Record;
-
- assert(nArgsSize >= 0x128);
- assert(nRetSize == 4);
-
- pISO = CPS2VM::m_pCDROM0;
- if(pISO == NULL)
- {
- *(uint32*)pRet = 0;
- return;
- }
-
- //0x12C structure
- //00 - Block Num
- //04 - Size
- //08
- //0C
- //10
- //14
- //18
- //1C
- //20 - Unknown
- //24 - Path
-
- sPath = (char*)pArgs + 0x24;
-
- strcpy(sFixedPath, sPath);
-
- //Fix all slashes
- sTemp = strchr(sFixedPath, '\\');
- while(sTemp != NULL)
- {
- *sTemp = '/';
- sTemp = strchr(sTemp + 1, '\\');
- }
-
- Log("SearchFile(path = %s);\r\n", sFixedPath);
-
- if(!pISO->GetFileRecord(&Record, sFixedPath))
- {
- *(uint32*)pRet = 0;
- return;
- }
-
- ((uint32*)pArgs)[0x00] = Record.GetPosition();
- ((uint32*)pArgs)[0x01] = Record.GetDataLength();
-
- *(uint32*)pRet = 1;
-}
-
-void CCdvdfsv::Log(const char* sFormat, ...)
-{
-#ifdef _DEBUG
-
- if(!CPS2VM::m_Logging.GetIOPLoggingStatus()) return;
-
- va_list Args;
- printf("IOP_Cdvdfsv: ");
- va_start(Args, sFormat);
- vprintf(sFormat, Args);
- va_end(Args);
-
-#endif
-}
diff --git a/Source/IOP_Cdvdfsv.h b/Source/IOP_Cdvdfsv.h
deleted file mode 100644
index 2a982973..00000000
--- a/Source/IOP_Cdvdfsv.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef _IOP_CDVDFSV_H_
-#define _IOP_CDVDFSV_H_
-
-#include "IOP_Module.h"
-
-namespace IOP
-{
-
- class CCdvdfsv : public CModule
- {
- public:
- CCdvdfsv(uint32);
- virtual ~CCdvdfsv();
- virtual void Invoke(uint32, void*, uint32, void*, uint32);
- virtual void SaveState(Framework::CStream*);
- virtual void LoadState(Framework::CStream*);
-
- enum MODULE_ID
- {
- MODULE_ID_1 = 0x80000592,
- MODULE_ID_2 = 0x80000593,
- MODULE_ID_3 = 0x80000594,
- MODULE_ID_4 = 0x80000595,
- MODULE_ID_5 = 0x80000596,
- MODULE_ID_6 = 0x80000597,
- MODULE_ID_7 = 0x8000059C,
- };
-
- private:
- void Invoke592(uint32, void*, uint32, void*, uint32);
- void Invoke593(uint32, void*, uint32, void*, uint32);
- void Invoke595(uint32, void*, uint32, void*, uint32);
- void Invoke597(uint32, void*, uint32, void*, uint32);
- void Invoke59C(uint32, void*, uint32, void*, uint32);
-
- //Methods
- void Read(void*, uint32, void*, uint32);
- void StreamCmd(void*, uint32, void*, uint32);
- void SearchFile(void*, uint32, void*, uint32);
-
- static void Log(const char*, ...);
-
- uint32 m_nID;
- static uint32 m_nStreamPos;
- };
-
-}
-
-#endif
diff --git a/Source/IOP_DbcMan.cpp b/Source/IOP_DbcMan.cpp
deleted file mode 100644
index b27c2c6a..00000000
--- a/Source/IOP_DbcMan.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-#include
-#include
-#include "IOP_DbcMan.h"
-#include "PS2VM.h"
-
-using namespace IOP;
-using namespace Framework;
-
-CDbcMan::CDbcMan()
-{
-
-}
-
-CDbcMan::~CDbcMan()
-{
- DeleteAllSockets();
-}
-
-void CDbcMan::Invoke(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0x80000901:
- CreateSocket(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x80000904:
- SetWorkAddr(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x8000091A:
- ReceiveData(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x80000963:
- GetVersionInformation(pArgs, nArgsSize, pRet, nRetSize);
- break;
- }
-}
-
-void CDbcMan::SaveState(CStream* pStream)
-{
- uint32 nCount, nID;
- SOCKET* pSocket;
- CList::ITERATOR itSocket;
-
- nCount = m_Socket.Count();
- pStream->Write(&nCount, 4);
-
- for(itSocket = m_Socket.Begin(); itSocket.HasNext(); itSocket++)
- {
- nID = itSocket.GetKey();
- pSocket = (*itSocket);
-
- pStream->Write(&nID, 4);
- pStream->Write(pSocket, sizeof(SOCKET));
- }
-}
-
-void CDbcMan::LoadState(CStream* pStream)
-{
- uint32 nCount, nID, i;
- SOCKET* pSocket;
-
- DeleteAllSockets();
-
- pStream->Read(&nCount, 4);
-
- for(i = 0; i < nCount; i++)
- {
- pSocket = new SOCKET;
-
- pStream->Read(&nID, 4);
- pStream->Read(pSocket, sizeof(SOCKET));
-
- m_Socket.Insert(pSocket, nID);
- }
-}
-
-void CDbcMan::SetButtonState(unsigned int nPadNumber, CPadListener::BUTTON nButton, bool nPressed)
-{
- SOCKET* pSocket;
- CList::ITERATOR itSocket;
- uint16 nStatus;
-
- for(itSocket = m_Socket.Begin(); itSocket.HasNext(); itSocket++)
- {
- pSocket = (*itSocket);
- if(pSocket->nPort != nPadNumber) continue;
-
- nStatus = (CPS2VM::m_pRAM[pSocket->nBuf1 + 0x1C] << 8) | (CPS2VM::m_pRAM[pSocket->nBuf1 + 0x1D]);
-
- nStatus &= (~nButton);
- if(!nPressed)
- {
- nStatus |= nButton;
- }
-
- CPS2VM::m_pRAM[pSocket->nBuf1 + 0x1C] = (uint8)(nStatus >> 8);
- CPS2VM::m_pRAM[pSocket->nBuf1 + 0x1D] = (uint8)(nStatus >> 0);
-
-// *(uint16*)&CPS2VM::m_pRAM[pSocket->nBuf1 + 0x1C] ^= 0x2010;
- }
-}
-
-void CDbcMan::CreateSocket(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- uint32 nType1, nType2, nPort, nSlot, nBuf1, nBuf2, nID;
- SOCKET* pSocket;
-
- assert(nArgsSize >= 0x30);
- assert(nRetSize >= 0x04);
-
- nType1 = ((uint32*)pArgs)[0x00];
- nType2 = ((uint32*)pArgs)[0x01];
- nPort = ((uint32*)pArgs)[0x02];
- nSlot = ((uint32*)pArgs)[0x03];
- nBuf1 = ((uint32*)pArgs)[0x0A];
- nBuf2 = ((uint32*)pArgs)[0x0B];
-
- pSocket = new SOCKET;
- pSocket->nPort = nPort;
- pSocket->nSlot = nSlot;
- pSocket->nBuf1 = nBuf1;
- pSocket->nBuf2 = nBuf2;
-
- nID = m_Socket.MakeKey();
- m_Socket.Insert(pSocket, nID);
-
- ((uint32*)pRet)[0x09] = nID;
-
- Log("CreateSocket(type1 = 0x%0.8X, type2 = 0x%0.8X, port = %i, slot = %i, buf1 = 0x%0.8X, buf2 = 0x%0.8X);\r\n", \
- nType1, \
- nType2, \
- nPort, \
- nSlot, \
- nBuf1, \
- nBuf2);
-}
-
-void CDbcMan::SetWorkAddr(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- uint32 nAddress;
-
- assert(nArgsSize == 0x400);
- assert(nRetSize == 0x400);
-
- //0 - Some number (0x0200) (size?)
- //1 - Address to bind with
-
- nAddress = ((uint32*)pArgs)[1];
-
- //Set Ready (?) status
- CPS2VM::m_pRAM[nAddress] = 1;
-
- ((uint32*)pRet)[0] = 0x00000000;
-
- Log("SetWorkAddr(addr = 0x%0.8X);\r\n", nAddress);
-}
-
-void CDbcMan::ReceiveData(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- uint32 nParam, nFlags, nSocket;
- SOCKET* pSocket;
-
- //Param Frame
- //0 - Socket ID
- //1 - Value passed in parameter to the library
- //2 - Some parameter (0x01, or some address)
-
- nSocket = ((uint32*)pArgs)[0];
- nFlags = ((uint32*)pArgs)[1];
- nParam = ((uint32*)pArgs)[2];
-
- pSocket = m_Socket.Find(nSocket);
- if(pSocket != NULL)
- {
- CPS2VM::m_pRAM[pSocket->nBuf1 + 0x02] = 0x20;
- *(uint32*)&CPS2VM::m_pRAM[pSocket->nBuf1 + 0x04] = 0x01;
- }
-
- //Return frame
- //0 - Success Status
- //1 - ???
- //2 - Size of returned data
- //3+ - Data
-
- ((uint32*)pRet)[0] = 0;
- ((uint32*)pRet)[2] = 0x1;
- ((uint32*)pRet)[3] = 0x1;
-
- Log("ReceiveData(socket = 0x%0.8X, flags = 0x%0.8X, param = 0x%0.8X);\r\n", nSocket, nFlags, nParam);
-}
-
-void CDbcMan::GetVersionInformation(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- assert(nArgsSize == 0x400);
- assert(nRetSize == 0x400);
-
- ((uint32*)pRet)[0] = 0x00000200;
-
- Log("GetVersionInformation();\r\n");
-}
-
-void CDbcMan::DeleteAllSockets()
-{
- while(m_Socket.Count() != 0)
- {
- delete m_Socket.Pull();
- }
-}
-
-void CDbcMan::Log(const char* sFormat, ...)
-{
-#ifdef _DEBUG
-
- if(!CPS2VM::m_Logging.GetIOPLoggingStatus()) return;
-
- va_list Args;
- printf("IOP_DbcMan: ");
- va_start(Args, sFormat);
- vprintf(sFormat, Args);
- va_end(Args);
-
-#endif
-}
diff --git a/Source/IOP_DbcMan.h b/Source/IOP_DbcMan.h
deleted file mode 100644
index e5fe0a5d..00000000
--- a/Source/IOP_DbcMan.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef _IOP_DBCMAN_H_
-#define _IOP_DBCMAN_H_
-
-#include "IOP_Module.h"
-#include "PadListener.h"
-#include "List.h"
-
-namespace IOP
-{
-
- class CDbcMan : public CModule, public CPadListener
- {
- public:
- CDbcMan();
- virtual ~CDbcMan();
- virtual void Invoke(uint32, void*, uint32, void*, uint32);
- virtual void SaveState(Framework::CStream*);
- virtual void LoadState(Framework::CStream*);
- virtual void SetButtonState(unsigned int, CPadListener::BUTTON, bool);
-
- enum MODULE_ID
- {
- MODULE_ID = 0x80000900
- };
-
- private:
- struct SOCKET
- {
- uint32 nPort;
- uint32 nSlot;
- uint32 nBuf1;
- uint32 nBuf2;
- };
-
- void CreateSocket(void*, uint32, void*, uint32);
- void SetWorkAddr(void*, uint32, void*, uint32);
- void ReceiveData(void*, uint32, void*, uint32);
- void GetVersionInformation(void*, uint32, void*, uint32);
-
- void DeleteAllSockets();
-
- void Log(const char*, ...);
-
- Framework::CList m_Socket;
- };
-
-}
-
-#endif
-
diff --git a/Source/IOP_Dummy.cpp b/Source/IOP_Dummy.cpp
deleted file mode 100644
index 69b48106..00000000
--- a/Source/IOP_Dummy.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#include
-#include "IOP_Dummy.h"
-
-using namespace IOP;
-using namespace Framework;
-
-void CDummy::Invoke(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 1:
- case 2:
- assert(nRetSize >= 4);
-
- ((uint32*)pRet)[0] = 1;
-
- break;
- }
-}
-
-void CDummy::LoadState(CStream* pStream)
-{
-
-}
-
-void CDummy::SaveState(CStream* pStream)
-{
-
-}
diff --git a/Source/IOP_Dummy.h b/Source/IOP_Dummy.h
deleted file mode 100644
index 65d15180..00000000
--- a/Source/IOP_Dummy.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _IOP_DUMMY_H_
-#define _IOP_DUMMY_H_
-
-#include "IOP_Module.h"
-
-namespace IOP
-{
- class CDummy : public CModule
- {
- public:
- virtual void Invoke(uint32, void*, uint32, void*, uint32);
- virtual void LoadState(Framework::CStream*);
- virtual void SaveState(Framework::CStream*);
-
- enum MODULE_ID
- {
- MODULE_ID = 0x00000030,
- };
-
- };
-};
-
-#endif
diff --git a/Source/IOP_FileIO.cpp b/Source/IOP_FileIO.cpp
deleted file mode 100644
index 0b3618e5..00000000
--- a/Source/IOP_FileIO.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-#include
-#include
-#include "IOP_FileIO.h"
-#include "PS2VM.h"
-#include "Config.h"
-#include "StdStream.h"
-
-using namespace IOP;
-using namespace Framework;
-
-CFileIO::CFileIO()
-{
- CConfig::GetInstance()->RegisterPreferenceBoolean("iop.fileio.stdlogging", false);
- CConfig::GetInstance()->RegisterPreferenceString("ps2.host.directory", "./vfs/host");
- CConfig::GetInstance()->RegisterPreferenceString("ps2.mc0.directory", "./vfs/mc0");
- CConfig::GetInstance()->RegisterPreferenceString("ps2.mc1.directory", "./vfs/mc1");
-
- m_Device.Insert(new CDirectoryDevice("mc0", "ps2.mc0.directory"));
- m_Device.Insert(new CDirectoryDevice("host", "ps2.host.directory"));
- m_Device.Insert(new CCDROM0Device());
-
- //Insert standard files if requested.
- if(CConfig::GetInstance()->GetPreferenceBoolean("iop.fileio.stdlogging"))
- {
- try
- {
- m_File.Insert(new CStdStream(fopen("ps2_stdout.txt", "ab")), 1);
- m_File.Insert(new CStdStream(fopen("ps2_stderr.txt", "ab")), 2);
- }
- catch(...)
- {
- //Humm, some error occured when opening these files...
- }
- }
-
- m_nFileID = 3;
-}
-
-CFileIO::~CFileIO()
-{
- while(m_File.Count() != 0)
- {
- delete m_File.Pull();
- }
- while(m_Device.Count() != 0)
- {
- delete m_Device.Pull();
- }
-}
-
-void CFileIO::Invoke(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0x00000000:
- assert(nRetSize == 4);
- *(uint32*)pRet = Open(*(uint32*)pArgs, ((char*)pArgs) + 4);
- break;
- case 0x00000001:
- assert(nRetSize == 4);
- *(uint32*)pRet = Close(*(uint32*)pArgs);
- break;
- case 0x00000002:
- assert(nRetSize == 4);
- *(uint32*)pRet = Read(((uint32*)pArgs)[0], ((uint32*)pArgs)[2], (void*)(CPS2VM::m_pRAM + ((uint32*)pArgs)[1]));
- break;
- case 0x00000003:
- assert(nRetSize == 4);
- *(uint32*)pRet = Write(((uint32*)pArgs)[0], ((uint32*)pArgs)[2], (void*)(CPS2VM::m_pRAM + ((uint32*)pArgs)[1]));
- break;
- case 0x00000004:
- assert(nRetSize == 4);
- *(uint32*)pRet = Seek(((uint32*)pArgs)[0], ((uint32*)pArgs)[1], ((uint32*)pArgs)[2]);
- break;
- default:
- assert(0);
- break;
- }
-}
-
-void CFileIO::SaveState(CStream* pStream)
-{
-
-}
-
-void CFileIO::LoadState(CStream* pStream)
-{
-
-}
-
-CStream* CFileIO::GetFile(uint32 nMode, const char* sPath)
-{
- char sDevice[256];
- char sDevicePath[256];
- CDevice* pDevice;
-
- if(!SplitPath(sPath, sDevice, sDevicePath))
- {
- return NULL;
- }
-
- pDevice = FindDevice(sDevice);
- if(pDevice == NULL)
- {
- return NULL;
- }
-
- return pDevice->OpenFile(nMode, sDevicePath);
-}
-
-bool CFileIO::SplitPath(const char* sPath, char* sDevice, char* sDevicePath)
-{
- const char* sSplit;
- unsigned int nLenght;
- unsigned int nDevLenght;
- unsigned int nDevPathLenght;
-
- nLenght = (unsigned int)strlen(sPath);
- sSplit = strchr(sPath, ':');
- if(sSplit == NULL)
- {
- //Invalid path
- return false;
- }
-
- nDevLenght = (unsigned int)(sSplit - sPath);
- nDevPathLenght = (unsigned int)(nLenght - (sSplit - sPath) - 1);
-
- strncpy(sDevice, sPath, nDevLenght);
- strncpy(sDevicePath, sSplit + 1, nDevPathLenght);
-
- sDevice[nDevLenght] = '\0';
- sDevicePath[nDevPathLenght] = '\0';
-
- return true;
-}
-
-CFileIO::CDevice* CFileIO::FindDevice(const char* sDeviceName)
-{
- CList::ITERATOR itDevice;
- CDevice* pDevice;
-
- for(itDevice = m_Device.Begin(); itDevice.HasNext(); itDevice++)
- {
- pDevice = (*itDevice);
- if(!strcmp(pDevice->GetName(), sDeviceName))
- {
- return pDevice;
- }
- }
-
- return NULL;
-}
-
-uint32 CFileIO::RegisterFile(CStream* pFile)
-{
- uint32 nFD;
- nFD = m_nFileID;
- m_File.Insert(pFile, nFD);
- m_nFileID++;
- return nFD;
-}
-
-uint32 CFileIO::Open(uint32 nMode, const char* sPath)
-{
-/*
- char sDevice[256];
- char sDevicePath[256];
- CDevice* pDevice;
-*/
- CStream* pFile;
-
- Log("Attempting to open file '%s'.\r\n", sPath);
-
- pFile = GetFile(nMode, sPath);
- if(pFile == NULL)
- {
- return 0xFFFFFFFF;
- }
-
- return RegisterFile(pFile);
-/*
- if(!SplitPath(sPath, sDevice, sDevicePath))
- {
- return 0xFFFFFFFF;
- }
-
- pDevice = FindDevice(sDevice);
- if(pDevice == NULL)
- {
- return 0xFFFFFFFF;
- }
-
- pFile = pDevice->OpenFile(nMode, sDevicePath);
- if(pFile == NULL)
- {
- return 0xFFFFFFFF;
- }
-*/
-}
-
-uint32 CFileIO::Close(uint32 nFile)
-{
- CStream* pFile;
-
- pFile = m_File.Remove(nFile);
- if(pFile == NULL)
- {
- return 0xFFFFFFFF;
- }
-
- delete pFile;
-
- return 0;
-}
-
-uint32 CFileIO::Read(uint32 nFile, uint32 nSize, void* pBuffer)
-{
- CStream* pFile;
-
- pFile = m_File.Find(nFile);
- if(pFile == NULL)
- {
- Log("Reading from an unopened file (fd = %i).\r\n", nFile);
- return 0xFFFFFFFF;
- }
-
- if(pFile->IsEOF())
- {
- return 0;
- }
-
- return (uint32)pFile->Read(pBuffer, nSize);
-}
-
-uint32 CFileIO::Write(uint32 nFile, uint32 nSize, void* pBuffer)
-{
- CStream* pFile;
- uint32 nAmount;
-
- pFile = m_File.Find(nFile);
- if(pFile == NULL)
- {
- if(nFile > 2)
- {
- Log("Writing to an unopened file (fd = %i).\r\n", nFile);
- }
- return 0xFFFFFFFF;
- }
-
- nAmount = (uint32)pFile->Write(pBuffer, nSize);
- pFile->Flush();
- return nAmount;
-}
-
-uint32 CFileIO::Seek(uint32 nFile, uint32 nOffset, uint32 nWhence)
-{
- CStream* pFile;
- STREAM_SEEK_DIRECTION nPosition;
-
- pFile = m_File.Find(nFile);
- if(pFile == NULL)
- {
- Log("Seeking in an unopened file (fd = %i).\r\n", nFile);
- return 0xFFFFFFFF;
- }
-
- switch(nWhence)
- {
- case 0:
- nPosition = Framework::STREAM_SEEK_SET;
- break;
- case 1:
- nPosition = Framework::STREAM_SEEK_CUR;
- break;
- case 2:
- nPosition = Framework::STREAM_SEEK_END;
- break;
- }
-
- pFile->Seek(nOffset, nPosition);
- return (uint32)pFile->Tell();
-}
-
-void CFileIO::Log(const char* sFormat, ...)
-{
-#ifdef _DEBUG
-
- if(!CPS2VM::m_Logging.GetIOPLoggingStatus()) return;
-
- va_list Args;
- printf("IOP_FileIO: ");
- va_start(Args, sFormat);
- vprintf(sFormat, Args);
- va_end(Args);
-
-#endif
-}
-
-/////////////////////////////////////////////
-//Devices Implementation
-/////////////////////////////////////////////
-
-CFileIO::CDevice::CDevice(const char* sName)
-{
- m_sName = sName;
-}
-
-const char* CFileIO::CDevice::GetName()
-{
- return m_sName;
-}
-
-CFileIO::CDirectoryDevice::CDirectoryDevice(const char* sName, const char* sBasePathPreference) :
-CDevice(sName)
-{
- m_sBasePathPreference = sBasePathPreference;
-}
-
-CStream* CFileIO::CDirectoryDevice::OpenFile(uint32 nMode, const char* sDevicePath)
-{
- FILE* pStream;
- char sPath[256];
- const char* sMode;
- const char* sBasePath;
-
- sBasePath = CConfig::GetInstance()->GetPreferenceString(m_sBasePathPreference);
-
- strcpy(sPath, sBasePath);
- if(sDevicePath[0] != '/')
- {
- strcat(sPath, "/");
- }
- strcat(sPath, sDevicePath);
-
- switch(nMode)
- {
- case 0:
- case O_RDONLY:
- sMode = "rb";
- break;
- case (O_RDWR | O_CREAT):
- sMode = "w+";
- break;
- default:
- assert(0);
- break;
- }
-
-
- pStream = fopen(sPath, sMode);
- if(pStream == NULL) return NULL;
-
- return new CStdStream(pStream);
-}
-
-CFileIO::CCDROM0Device::CCDROM0Device() :
-CFileIO::CDevice("cdrom0")
-{
-
-}
-
-CFileIO::CCDROM0Device::~CCDROM0Device()
-{
-
-}
-
-CStream* CFileIO::CCDROM0Device::OpenFile(uint32 nMode, const char* sDevicePath)
-{
- CISO9660* pISO;
-
- if(nMode != O_RDONLY) return NULL;
-
- pISO = CPS2VM::m_pCDROM0;
- if(pISO == NULL) return NULL;
-
- return pISO->Open(sDevicePath);
-}
diff --git a/Source/IOP_FileIO.h b/Source/IOP_FileIO.h
deleted file mode 100644
index ba3a16de..00000000
--- a/Source/IOP_FileIO.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef _IOP_FILEIO_H_
-#define _IOP_FILEIO_H_
-
-#include
-#include "IOP_Module.h"
-#include "List.h"
-#include "Stream.h"
-
-namespace IOP
-{
- class CFileIO : public CModule
- {
- public:
- CFileIO();
- ~CFileIO();
- virtual void Invoke(uint32, void*, uint32, void*, uint32);
- virtual void SaveState(Framework::CStream*);
- virtual void LoadState(Framework::CStream*);
- Framework::CStream* GetFile(uint32, const char*);
- uint32 Read(uint32, uint32, void*);
- uint32 Write(uint32, uint32, void*);
-
- enum MODULE_ID
- {
- MODULE_ID = 0x80000001
- };
-
- enum OPEN_FLAGS
- {
- O_RDONLY = 0x00000001,
- O_WRONLY = 0x00000002,
- O_RDWR = 0x00000003,
- O_CREAT = 0x00000200,
- };
-
- private:
- class CDevice
- {
- public:
- CDevice(const char*);
- virtual ~CDevice() {}
- virtual Framework::CStream* OpenFile(uint32, const char*) = 0;
- virtual const char* GetName();
-
- private:
- const char* m_sName;
- };
-
- class CDirectoryDevice : public CDevice
- {
- public:
- CDirectoryDevice(const char*, const char*);
- virtual Framework::CStream* OpenFile(uint32, const char*);
- private:
- const char* m_sBasePathPreference;
- };
-
- class CCDROM0Device : public CDevice
- {
- public:
- CCDROM0Device();
- virtual ~CCDROM0Device();
- virtual Framework::CStream* OpenFile(uint32, const char*);
- };
-
- bool SplitPath(const char*, char*, char*);
- CDevice* FindDevice(const char*);
- uint32 RegisterFile(Framework::CStream*);
-
- uint32 Open(uint32, const char*);
- uint32 Close(uint32);
- uint32 Seek(uint32, uint32, uint32);
-
- void Log(const char*, ...);
-
- uint32 m_nFileID;
-
- Framework::CList m_File;
- Framework::CList m_Device;
- };
-}
-
-#endif
diff --git a/Source/IOP_LibSD.cpp b/Source/IOP_LibSD.cpp
deleted file mode 100644
index ef38c52a..00000000
--- a/Source/IOP_LibSD.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "IOP_LibSD.h"
-
-using namespace IOP;
-using namespace Framework;
-
-void CLibSD::Invoke(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0x8100:
- //Not sure about this one
- GetBufferSize(pArgs, nArgsSize, pRet, nRetSize);
- break;
- }
-}
-
-void CLibSD::SaveState(CStream* pStream)
-{
-
-}
-
-void CLibSD::LoadState(CStream* pStream)
-{
-
-}
-
-void CLibSD::GetBufferSize(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- static uint32 nTemp = 0;
- nTemp += 0x400;
- ((uint32*)pRet)[0] = nTemp;
-}
diff --git a/Source/IOP_LibSD.h b/Source/IOP_LibSD.h
deleted file mode 100644
index 321f854f..00000000
--- a/Source/IOP_LibSD.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _IOP_LIBSD_H_
-#define _IOP_LIBSD_H_
-
-#include "IOP_Module.h"
-
-namespace IOP
-{
- class CLibSD : public CModule
- {
- public:
- virtual void Invoke(uint32, void*, uint32, void*, uint32);
- virtual void SaveState(Framework::CStream*);
- virtual void LoadState(Framework::CStream*);
-
- enum MODULE_ID
- {
- MODULE_ID = 0x80000701
- };
-
- private:
- void GetBufferSize(void*, uint32, void*, uint32);
- };
-
-};
-
-#endif
diff --git a/Source/IOP_LoadFile.cpp b/Source/IOP_LoadFile.cpp
deleted file mode 100644
index 2a7cd50c..00000000
--- a/Source/IOP_LoadFile.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#include
-#include
-#include
-#include "IOP_LoadFile.h"
-#include "PS2VM.h"
-
-using namespace IOP;
-using namespace Framework;
-
-void CLoadFile::Invoke(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0x00:
- LoadModule(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0xFF:
- //This is sometimes called after binding this server with a client
- Initialize(pArgs, nArgsSize, pRet, nRetSize);
- break;
- default:
- assert(0);
- break;
- }
-}
-
-void CLoadFile::SaveState(CStream* pStream)
-{
-
-}
-
-void CLoadFile::LoadState(CStream* pStream)
-{
-
-}
-
-void CLoadFile::LoadModule(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- char sModuleName[253];
-
- assert(nArgsSize == 512);
-
- //Sometimes called with 4, sometimes 8
- assert(nRetSize >= 4);
-
- memset(sModuleName, 0, 253);
- strncpy(sModuleName, &((const char*)pArgs)[8], 252);
-
- //Load the module???
- Log("Request to load module '%s' received.\r\n", sModuleName);
-
- //This function returns something negative upon failure
- *(uint32*)pRet = 0x00000000;
-}
-
-void CLoadFile::Initialize(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- assert(nArgsSize == 0);
- assert(nRetSize == 4);
-
- *(uint32*)pRet = 0x2E2E2E2E;
-}
-
-void CLoadFile::Log(const char* sFormat, ...)
-{
-#ifdef _DEBUG
-
- if(!CPS2VM::m_Logging.GetIOPLoggingStatus()) return;
-
- va_list Args;
- printf("IOP_LoadFile: ");
- va_start(Args, sFormat);
- vprintf(sFormat, Args);
- va_end(Args);
-
-#endif
-}
diff --git a/Source/IOP_LoadFile.h b/Source/IOP_LoadFile.h
deleted file mode 100644
index 3ac71930..00000000
--- a/Source/IOP_LoadFile.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _IOP_LOADFILE_H_
-#define _IOP_LOADFILE_H_
-
-#include "IOP_Module.h"
-
-namespace IOP
-{
- class CLoadFile : public CModule
- {
- public:
- virtual void Invoke(uint32, void*, uint32, void*, uint32);
- virtual void SaveState(Framework::CStream*);
- virtual void LoadState(Framework::CStream*);
-
- enum MODULE_ID
- {
- MODULE_ID = 0x80000006
- };
-
- private:
- void LoadModule(void*, uint32, void*, uint32);
- void Initialize(void*, uint32, void*, uint32);
- void Log(const char*, ...);
- };
-
-};
-
-#endif
diff --git a/Source/IOP_McServ.cpp b/Source/IOP_McServ.cpp
deleted file mode 100644
index 77c116e1..00000000
--- a/Source/IOP_McServ.cpp
+++ /dev/null
@@ -1,414 +0,0 @@
-#include
-#include
-#include
-#include "Config.h"
-#include "IOP_McServ.h"
-#include "PS2VM.h"
-
-using namespace IOP;
-using namespace Framework;
-using namespace boost;
-using namespace std;
-
-const char* CMcServ::m_sMcPathPreference[2] =
-{
- "ps2.mc0.directory",
- "ps2.mc1.directory",
-};
-
-CMcServ::CMcServ()
-{
- assert(sizeof(CMD) == 0x414);
- m_nNextHandle = 1;
-}
-
-CMcServ::~CMcServ()
-{
- //Close any handles that might still be in there...
-
- for(HandleMap::iterator itHandle = m_Handles.begin();
- itHandle != m_Handles.end();
- itHandle++)
- {
- fclose(itHandle->second);
- }
-}
-
-void CMcServ::Invoke(uint32 nMethod, void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- switch(nMethod)
- {
- case 0x01:
- GetInfo(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x02:
- Open(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x03:
- Close(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x05:
- Read(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0x0D:
- GetDir(pArgs, nArgsSize, pRet, nRetSize);
- break;
- case 0xFE:
- //Get version?
- GetVersionInformation(pArgs, nArgsSize, pRet, nRetSize);
- break;
- default:
- Log("Unknown method invoked (0x%0.8X).\r\n", nMethod);
- break;
- }
-}
-
-void CMcServ::SaveState(CStream* pStream)
-{
-
-}
-
-void CMcServ::LoadState(CStream* pStream)
-{
-
-}
-
-void CMcServ::GetInfo(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- assert(nArgsSize >= 0x1C);
-
- uint32 nPort, nSlot;
- uint32* pRetBuffer;
-
- bool nWantType;
- bool nWantFreeSpace;
- bool nWantFormatted;
-
- nPort = ((uint32*)pArgs)[1];
- nSlot = ((uint32*)pArgs)[2];
- nWantType = ((uint32*)pArgs)[3] != 0;
- nWantFreeSpace = ((uint32*)pArgs)[4] != 0;
- nWantFormatted = ((uint32*)pArgs)[5] != 0;
- pRetBuffer = (uint32*)&CPS2VM::m_pRAM[((uint32*)pArgs)[7]];
-
- Log("GetInfo(nPort = %i, nSlot = %i, nWantType = %i, nWantFreeSpace = %i, nWantFormatted = %i, nRetBuffer = 0x%0.8X);\r\n",
- nPort, nSlot, nWantType, nWantFreeSpace, nWantFormatted, ((uint32*)pArgs)[7]);
-
- if(nWantType)
- {
- pRetBuffer[0x00] = 2;
- }
- if(nWantFreeSpace)
- {
- pRetBuffer[0x01] = 0x800000;
- }
- if(nWantFormatted)
- {
- pRetBuffer[0x24] = 1;
- }
-
- ((uint32*)pRet)[0] = 0;
-}
-
-void CMcServ::Open(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- uint32 nHandle;
- CMD* pCmd;
- FILE* pFile;
- const char* sAccess;
-
- assert(nArgsSize >= 0x414);
-
- pCmd = reinterpret_cast(pArgs);
-
- Log("Open(nPort = %i, nSlot = %i, nFlags = %i, sName = %s);\r\n",
- pCmd->nPort, pCmd->nSlot, pCmd->nFlags, pCmd->sName);
-
- if(pCmd->nPort > 1)
- {
- assert(0);
- ((uint32*)pRet)[0] = -1;
- return;
- }
-
- filesystem::path Path;
-
- try
- {
- Path = filesystem::path(CConfig::GetInstance()->GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
- Path /= pCmd->sName;
- }
- catch(const exception& Exception)
- {
- Log("Error while executing Open: %s\r\n.", Exception.what());
- reinterpret_cast(pRet)[0] = -1;
- return;
- }
-
- sAccess = NULL;
- switch(pCmd->nFlags)
- {
- case 1:
- sAccess = "rb";
- break;
- }
-
- if(sAccess == NULL)
- {
- ((uint32*)pRet)[0] = -1;
- assert(0);
- return;
- }
-
- pFile = fopen(Path.string().c_str(), sAccess);
- if(pFile == NULL)
- {
- ((uint32*)pRet)[0] = -1;
- return;
- }
-
- nHandle = GenerateHandle();
- m_Handles[nHandle] = pFile;
-
- ((uint32*)pRet)[0] = nHandle;
-}
-
-void CMcServ::Close(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- FILECMD* pCmd;
-
- pCmd = reinterpret_cast(pArgs);
-
- Log("Close(nHandle = %i);\r\n",
- pCmd->nHandle);
-
- HandleMap::iterator itHandle;
-
- itHandle = m_Handles.find(pCmd->nHandle);
- if(itHandle == m_Handles.end())
- {
- ((uint32*)pRet)[0] = -1;
- assert(0);
- return;
- }
-
- fclose(itHandle->second);
- m_Handles.erase(itHandle);
-
- ((uint32*)pRet)[0] = 0;
-}
-
-void CMcServ::Read(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- FILECMD* pCmd;
- FILE* pFile;
- void* pDst;
-
- pCmd = reinterpret_cast(pArgs);
-
- Log("Read(nHandle = %i, nSize = 0x%0.8X, nBufferAddress = 0x%0.8X, nParamAddress = 0x%0.8X);\r\n",
- pCmd->nHandle, pCmd->nSize, pCmd->nBufferAddress, pCmd->nParamAddress);
-
- HandleMap::iterator itHandle;
-
- itHandle = m_Handles.find(pCmd->nHandle);
- if(itHandle == m_Handles.end())
- {
- ((uint32*)pRet)[0] = -1;
- assert(0);
- return;
- }
-
- pFile = itHandle->second;
- pDst = &CPS2VM::m_pRAM[pCmd->nBufferAddress];
-
- //This param buffer is used in the callback after calling this method... No clue what it's for
- ((uint32*)&CPS2VM::m_pRAM[pCmd->nParamAddress])[0] = 0;
- ((uint32*)&CPS2VM::m_pRAM[pCmd->nParamAddress])[1] = 0;
-
- ((uint32*)pRet)[0] = static_cast(fread(pDst, 1, pCmd->nSize, pFile));
-}
-
-void CMcServ::GetDir(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- uint32 nRet;
-
- nRet = 0;
-
- assert(nArgsSize >= 0x414);
-
- CMD* pCmd;
- pCmd = reinterpret_cast(pArgs);
-
- Log("GetDir(nPort = %i, nSlot = %i, nFlags = %i, nMaxEntries = %i, nTableAddress = 0x%0.8X, sName = %s);\r\n",
- pCmd->nPort, pCmd->nSlot, pCmd->nFlags, pCmd->nMaxEntries, pCmd->nTableAddress, pCmd->sName);
-
- if(pCmd->nPort > 1)
- {
- assert(0);
- ((uint32*)pRet)[0] = -1;
- return;
- }
-
- try
- {
- filesystem::path McPath(CConfig::GetInstance()->GetPreferenceString(m_sMcPathPreference[pCmd->nPort]), filesystem::native);
- McPath = filesystem::complete(McPath);
-
- if(filesystem::exists(McPath))
- {
- CPathFinder PathFinder(McPath, reinterpret_cast(&CPS2VM::m_pRAM[pCmd->nTableAddress]), pCmd->nMaxEntries, pCmd->sName);
- nRet = PathFinder.Search();
- }
- }
- catch(const exception& Exception)
- {
- Log("Error while executing GetDir: %s\r\n.", Exception.what());
- }
-
- ((uint32*)pRet)[0] = nRet;
-}
-
-void CMcServ::GetVersionInformation(void* pArgs, uint32 nArgsSize, void* pRet, uint32 nRetSize)
-{
- assert(nArgsSize == 0x30);
- assert(nRetSize == 0x0C);
-
- ((uint32*)pRet)[0] = 0x00000000;
- ((uint32*)pRet)[1] = 0x0000020A; //mcserv version
- ((uint32*)pRet)[2] = 0x0000020E; //mcman version
-
- Log("Init();\r\n");
-}
-
-uint32 CMcServ::GenerateHandle()
-{
- return m_nNextHandle++;
-}
-
-void CMcServ::Log(const char* sFormat, ...)
-{
-#ifdef _DEBUG
-
- if(!CPS2VM::m_Logging.GetIOPLoggingStatus()) return;
-
- va_list Args;
- printf("IOP_McServ: ");
- va_start(Args, sFormat);
- vprintf(sFormat, Args);
- va_end(Args);
-
-#endif
-}
-
-/////////////////////////////////////////////
-//CPathFinder Implementation
-/////////////////////////////////////////////
-
-CMcServ::CPathFinder::CPathFinder(const filesystem::path& BasePath, ENTRY* pEntry, unsigned int nMax, const char* sFilter)
-{
- m_BasePath = BasePath;
- m_pEntry = pEntry;
- m_nIndex = 0;
- m_nMax = nMax;
- m_sFilter = sFilter;
-}
-
-CMcServ::CPathFinder::~CPathFinder()
-{
-
-}
-
-unsigned int CMcServ::CPathFinder::Search()
-{
- SearchRecurse(m_BasePath);
- return m_nIndex;
-}
-
-void CMcServ::CPathFinder::SearchRecurse(const filesystem::path& Path)
-{
- filesystem::directory_iterator itEnd;
-
- for(filesystem::directory_iterator itElement(Path);
- itElement != itEnd;
- itElement++)
- {
- string sRelativePath((*itElement).string());
-
- //"Extract" a more appropriate relative path from the memory card point of view
- sRelativePath.erase(0, m_BasePath.string().size());
-
- //Attempt to match this against the filter
- if(MatchesFilter(sRelativePath.c_str()))
- {
- //This fits... fill in the information
-
- ENTRY* pEntry;
- pEntry = &m_pEntry[m_nIndex];
-
- //strncpy(reinterpret_cast(pEntry->sName), sRelativePath.c_str(), 0x1F);
- strncpy(reinterpret_cast(pEntry->sName), (*itElement).leaf().c_str(), 0x1F);
- pEntry->sName[0x1F] = 0;
-
- if(filesystem::is_directory(*itElement))
- {
- pEntry->nSize = 0;
- pEntry->nAttributes = 0x8427;
- }
- else
- {
- pEntry->nSize = static_cast(filesystem::file_size(*itElement));
- pEntry->nAttributes = 0x8497;
- }
-
- m_nIndex++;
- }
-
- if(filesystem::is_directory(*itElement))
- {
- SearchRecurse(*itElement);
- }
- }
-}
-
-//Based on an algorithm found on http://xoomer.alice.it/acantato/dev/wildcard/wildmatch.html
-bool CMcServ::CPathFinder::MatchesFilter(const char* sPath)
-{
- const char* sPattern;
- const char* s;
- const char* p;
- bool nStar;
-
- sPattern = m_sFilter.c_str();
- nStar = false;
-
-_loopStart:
-
- for(s = sPath, p = sPattern; *s; s++, p++)
- {
- switch(*p)
- {
- case '*':
- nStar = true;
- sPath = s;
- sPattern = p;
- if((*++p) == 0) return true;
- goto _loopStart;
- break;
- default:
- if(toupper(*s) != toupper(*p))
- {
- goto _starCheck;
- }
- break;
- }
- }
-
- if(*p == '*') p++;
- return (*p) == 0;
-
-_starCheck:
- if(!nStar) return false;
- sPath++;
- goto _loopStart;
-}
diff --git a/Source/IOP_McServ.h b/Source/IOP_McServ.h
deleted file mode 100644
index f160f87e..00000000
--- a/Source/IOP_McServ.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef _IOP_MCSERV_H_
-#define _IOP_MCSERV_H_
-
-#include "IOP_Module.h"
-#include
-#include