From 4233c33cfefe73213a5189c723ef631617d45fb6 Mon Sep 17 00:00:00 2001 From: jpd002 Date: Mon, 24 Sep 2012 02:37:03 +0000 Subject: [PATCH] Plugged SIO2 emulation module in the IOP subsystem. We now allow PADMAD and DBCMAN modules coming from games to be emulated and receive SIF packets. Added a special case for the SetModeAndLock command in SIO2. Removed DBCMAN module emulation. git-svn-id: http://svn.purei.org/purei/trunk@1005 b36208d7-6611-0410-8bec-b1987f11c4a2 --- Source/PS2VM.cpp | 10 +- Source/iop/IopBios.cpp | 16 +- Source/iop/IopBios.h | 3 - Source/iop/Iop_DbcMan.cpp | 271 ------------------------------- Source/iop/Iop_DbcMan.h | 62 ------- Source/iop/Iop_DbcMan320.cpp | 140 ---------------- Source/iop/Iop_DbcMan320.h | 38 ----- Source/iop/Iop_SifCmd.cpp | 16 +- Source/iop/Iop_Sio2.cpp | 13 +- Source/iop/Iop_SubSystem.cpp | 18 ++ Source/iop/Iop_SubSystem.h | 4 + build_win32/Play.vcxproj | 4 - build_win32/Play.vcxproj.filters | 12 -- 13 files changed, 50 insertions(+), 557 deletions(-) delete mode 100644 Source/iop/Iop_DbcMan.cpp delete mode 100644 Source/iop/Iop_DbcMan.h delete mode 100644 Source/iop/Iop_DbcMan320.cpp delete mode 100644 Source/iop/Iop_DbcMan320.h diff --git a/Source/PS2VM.cpp b/Source/PS2VM.cpp index a6768ec6..dd1618ec 100644 --- a/Source/PS2VM.cpp +++ b/Source/PS2VM.cpp @@ -576,7 +576,6 @@ void CPS2VM::SaveVMState(const char* sPath, unsigned int& result) m_intc.SaveState(archive); m_sif.SaveState(archive); m_vif.SaveState(archive); - m_iopOs->GetDbcman()->SaveState(archive); m_iopOs->GetPadman()->SaveState(archive); //TODO: Save CDVDFSV state @@ -625,7 +624,6 @@ void CPS2VM::LoadVMState(const char* sPath, unsigned int& result) m_intc.LoadState(archive); m_sif.LoadState(archive); m_vif.LoadState(archive); - m_iopOs->GetDbcman()->LoadState(archive); m_iopOs->GetPadman()->LoadState(archive); } catch(...) @@ -809,11 +807,11 @@ void CPS2VM::LoadBIOS() void CPS2VM::RegisterModulesInPadHandler() { - if(m_pad == NULL) return; + if(m_pad == NULL) return; - m_pad->RemoveAllListeners(); - m_pad->InsertListener(m_iopOs->GetDbcman()); - m_pad->InsertListener(m_iopOs->GetPadman()); + m_pad->RemoveAllListeners(); + m_pad->InsertListener(m_iopOs->GetPadman()); + m_pad->InsertListener(&m_iop.m_sio2); } void CPS2VM::FillFakeIopRam() diff --git a/Source/iop/IopBios.cpp b/Source/iop/IopBios.cpp index 5b267471..bbbc0aac 100644 --- a/Source/iop/IopBios.cpp +++ b/Source/iop/IopBios.cpp @@ -13,7 +13,6 @@ #include "../StructCollectionStateFile.h" #ifdef _IOP_EMULATE_MODULES -#include "Iop_DbcMan320.h" #include "Iop_Cdvdfsv.h" #include "Iop_McServ.h" #include "Iop_FileIo.h" @@ -76,8 +75,8 @@ CIopBios::CIopBios(CMIPS& cpu, uint8* ram, uint32 ramSize) , m_ioman(NULL) , m_modload(NULL) #ifdef _IOP_EMULATE_MODULES -, m_dbcman(NULL) , m_padman(NULL) +, m_cdvdfsv(NULL) #endif , m_rescheduleNeeded(false) , m_threadFinishAddress(0) @@ -200,13 +199,6 @@ void CIopBios::Reset(Iop::CSifMan* sifMan) { RegisterModule(new Iop::CMcServ(*m_sifMan)); } - { - m_dbcman = new Iop::CDbcMan(*m_sifMan); - RegisterModule(m_dbcman); - } - { - RegisterModule(new Iop::CDbcMan320(*m_sifMan, *m_dbcman)); - } { m_padman = new Iop::CPadMan(*m_sifMan); RegisterModule(m_padman); @@ -1399,11 +1391,6 @@ Iop::CCdvdman* CIopBios::GetCdvdman() #ifdef _IOP_EMULATE_MODULES -Iop::CDbcMan* CIopBios::GetDbcman() -{ - return m_dbcman; -} - Iop::CPadMan* CIopBios::GetPadman() { return m_padman; @@ -1787,7 +1774,6 @@ void CIopBios::DeleteModules() m_modload = NULL; m_sysmem = NULL; #ifdef _IOP_EMULATE_MODULES - m_dbcman = NULL; m_padman = NULL; m_cdvdfsv = NULL; #endif diff --git a/Source/iop/IopBios.h b/Source/iop/IopBios.h index 74401f58..02dd83cc 100644 --- a/Source/iop/IopBios.h +++ b/Source/iop/IopBios.h @@ -16,7 +16,6 @@ #include "Iop_Modload.h" #include "Iop_Dynamic.h" #ifdef _IOP_EMULATE_MODULES -#include "Iop_DbcMan.h" #include "Iop_PadMan.h" #include "Iop_Cdvdfsv.h" #endif @@ -122,7 +121,6 @@ public: Iop::CIoman* GetIoman(); Iop::CCdvdman* GetCdvdman(); #ifdef _IOP_EMULATE_MODULES - Iop::CDbcMan* GetDbcman(); Iop::CPadMan* GetPadman(); Iop::CCdvdfsv* GetCdvdfsv(); #endif @@ -347,7 +345,6 @@ private: Iop::CSysmem* m_sysmem; Iop::CModload* m_modload; #ifdef _IOP_EMULATE_MODULES - Iop::CDbcMan* m_dbcman; Iop::CPadMan* m_padman; Iop::CCdvdfsv* m_cdvdfsv; #endif diff --git a/Source/iop/Iop_DbcMan.cpp b/Source/iop/Iop_DbcMan.cpp deleted file mode 100644 index 27f75dd8..00000000 --- a/Source/iop/Iop_DbcMan.cpp +++ /dev/null @@ -1,271 +0,0 @@ -#include -#include -#include "IOP_DbcMan.h" -#include "../Log.h" -#include "../RegisterStateFile.h" - -#define LOG_NAME ("iop_dbcman") - -#define SOCKET_STATE_BASE_PATH ("iop_dbcman/socket_") -#define SOCKET_STATE_EXTENSION (".xml") - -using namespace Iop; -using namespace std; -using namespace Framework; -using namespace boost; -using namespace PS2; - -CDbcMan::CDbcMan(CSifMan& sif) : -m_nextSocketId(0), -m_workAddress(0), -m_buttonStatIndex(0x1C) -{ - sif.RegisterModule(MODULE_ID, this); -} - -CDbcMan::~CDbcMan() -{ - -} - -string CDbcMan::GetId() const -{ - return "dbcman"; -} - -string CDbcMan::GetFunctionName(unsigned int) const -{ - return "unknown"; -} - -void CDbcMan::Invoke(CMIPS& context, unsigned int functionId) -{ - throw runtime_error("Not implemented."); -} - -bool CDbcMan::Invoke(uint32 method, uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - switch(method) - { - case 0x80000901: - CreateSocket(args, argsSize, ret, retSize, ram); - break; - case 0x80000904: - SetWorkAddr(args, argsSize, ret, retSize, ram); - break; - case 0x8000091A: - ReceiveData(args, argsSize, ret, retSize, ram); - break; - case 0x80000963: - GetVersionInformation(args, argsSize, ret, retSize, ram); - break; - default: - CLog::GetInstance().Print(LOG_NAME, "Unknown method invoked (0x%0.8X).\r\n", method); - break; - } - return true; -} - -void CDbcMan::SaveState(CZipArchiveWriter& archive) -{ - for(SocketMap::const_iterator socketIterator(m_sockets.begin()); - socketIterator != m_sockets.end(); socketIterator++) - { - uint32 id = socketIterator->first; - const SOCKET& socket = socketIterator->second; - string path = SOCKET_STATE_BASE_PATH + lexical_cast(id) + SOCKET_STATE_EXTENSION; - CRegisterStateFile* registerFile = new CRegisterStateFile(path.c_str()); - registerFile->SetRegister32("id", id); - registerFile->SetRegister32("port", socket.nPort); - registerFile->SetRegister32("slot", socket.nSlot); - registerFile->SetRegister32("buffer1", socket.buf1); - registerFile->SetRegister32("buffer2", socket.buf2); - archive.InsertFile(registerFile); - } -} - -void CDbcMan::LoadState(CZipArchiveReader& archive) -{ - string regexString = SOCKET_STATE_BASE_PATH + string(".*") + SOCKET_STATE_EXTENSION; - CZipArchiveReader::FileNameList fileList = archive.GetFileNameList(regexString.c_str()); - for(CZipArchiveReader::FileNameList::const_iterator fileIterator(fileList.begin()); - fileIterator != fileList.end(); fileIterator++) - { - CRegisterStateFile registerFile(*archive.BeginReadFile(fileIterator->c_str())); - SOCKET socket; - uint32 id = registerFile.GetRegister32("id"); - socket.nPort = registerFile.GetRegister32("port"); - socket.nSlot = registerFile.GetRegister32("slot"); - socket.buf1 = registerFile.GetRegister32("buffer1"); - socket.buf2 = registerFile.GetRegister32("buffer2"); - m_sockets[id] = socket; - m_nextSocketId = max(id + 1, m_nextSocketId); - } -} - -void CDbcMan::SetButtonState(unsigned int nPadNumber, CControllerInfo::BUTTON nButton, bool nPressed, uint8* ram) -{ - uint32 buttonMask = GetButtonMask(nButton); - uint32 buttonStatIndex = m_buttonStatIndex; - - for(SocketMap::const_iterator socketIterator(m_sockets.begin()); - socketIterator != m_sockets.end(); socketIterator++) - { - const SOCKET& socket = socketIterator->second; - if(socket.nPort != nPadNumber) continue; - - uint8* buffer = &ram[socket.buf1]; - uint16 nStatus = (buffer[buttonStatIndex + 0] << 8) | (buffer[buttonStatIndex + 1]); - nStatus &= (~buttonMask); - if(!nPressed) - { - nStatus |= buttonMask; - } - - buffer[buttonStatIndex + 0] = static_cast(nStatus >> 8); - buffer[buttonStatIndex + 1] = static_cast(nStatus >> 0); - -// *(uint16*)&CPS2VM::m_pRAM[pSocket->nBuf1 + 0x1C] ^= 0x2010; -// *(uint16*)&ram[socket.buf1 + 0x3C] ^= 0xFFFF; - } -} - -void CDbcMan::SetAxisState(unsigned int padNumber, CControllerInfo::BUTTON axis, uint8 axisValue, uint8* ram) -{ - static const unsigned int s_axisIndex[4] = - { - 4, - 5, - 6, - 7 - }; - - uint32 buttonStatIndex = m_buttonStatIndex; - for(SocketMap::const_iterator socketIterator(m_sockets.begin()); - socketIterator != m_sockets.end(); socketIterator++) - { - const SOCKET& socket = socketIterator->second; - if(socket.nPort != padNumber) continue; - - uint8* buffer = &ram[socket.buf1]; - buffer[buttonStatIndex + s_axisIndex[axis]] = axisValue; - } -} - -void CDbcMan::CreateSocket(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - assert(argsSize >= 0x30); - assert(retSize >= 0x04); - - uint32 nType1 = args[0x00]; - uint32 nType2 = args[0x01]; - uint32 nPort = args[0x02]; - uint32 nSlot = args[0x03]; - uint32 nBuf1 = args[0x0A]; - uint32 nBuf2 = args[0x0B]; - - SOCKET socket; - socket.nPort = nPort; - socket.nSlot = nSlot; - socket.buf1 = nBuf1; - socket.buf2 = nBuf2; - - uint32 id = m_nextSocketId++; - m_sockets[id] = socket; - - ret[0x09] = id; - - assert(m_workAddress != 0); - *(reinterpret_cast(&ram[m_workAddress]) + id) = 1; - - CLog::GetInstance().Print(LOG_NAME, "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(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - assert(argsSize >= 0x90); - assert(retSize >= 0x90); - - //0 - Some number (0x0200) (size?) - //1 - Address to bind with - - m_workAddress = args[1]; - - //Set Ready (?) status - *reinterpret_cast(&ram[m_workAddress]) = 1; - - ret[0] = 0x00000000; - - CLog::GetInstance().Print(LOG_NAME, "SetWorkAddr(addr = 0x%0.8X);\r\n", m_workAddress); -} - -void CDbcMan::ReceiveData(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - //Param Frame - //0 - Socket ID - //1 - Value passed in parameter to the library - //2 - Some parameter (0x01, or some address) - - uint32 nSocket = args[0]; - uint32 nFlags = args[1]; - uint32 nParam = args[2]; - - SocketMap::iterator socketIterator = m_sockets.find(nSocket); - if(socketIterator != m_sockets.end()) - { - SOCKET& socket(socketIterator->second); - uint8* buffer = &ram[socket.buf1]; - - buffer[0x02] = 0x20; - - *reinterpret_cast(&buffer[0x04]) = 0x01; - - //For Guilty Gear - *reinterpret_cast(&buffer[0x7C]) = 0x01; - } - - //Return frame - //0 - Success Status - //1 - ??? - //2 - Size of returned data - //3+ - Data - - ret[0] = 0; - ret[2] = 0x1; - ret[3] = 0x1; - - CLog::GetInstance().Print(LOG_NAME, "ReceiveData(socket = 0x%0.8X, flags = 0x%0.8X, param = 0x%0.8X);\r\n", nSocket, nFlags, nParam); -} - -void CDbcMan::GetVersionInformation(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - assert(argsSize == 0x400); - assert(retSize == 0x400); - - ret[0] = 0x00000200; - - CLog::GetInstance().Print(LOG_NAME, "GetVersionInformation();\r\n"); -} - -CDbcMan::SOCKET* CDbcMan::GetSocket(uint32 socketId) -{ - SocketMap::iterator socketIterator = m_sockets.find(socketId); - if(socketIterator == m_sockets.end()) return NULL; - return &socketIterator->second; -} - -uint32 CDbcMan::GetButtonStatIndex() const -{ - return m_buttonStatIndex; -} - -void CDbcMan::SetButtonStatIndex(uint32 buttonStatIndex) -{ - m_buttonStatIndex = buttonStatIndex; -} diff --git a/Source/iop/Iop_DbcMan.h b/Source/iop/Iop_DbcMan.h deleted file mode 100644 index 8e17937c..00000000 --- a/Source/iop/Iop_DbcMan.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _IOP_DBCMAN_H_ -#define _IOP_DBCMAN_H_ - -#include -#include "Iop_Module.h" -#include "Iop_SifMan.h" -#include "../PadListener.h" -#include "zip/ZipArchiveWriter.h" -#include "zip/ZipArchiveReader.h" - -namespace Iop -{ - - class CDbcMan : public CModule, public CPadListener, public CSifModule - { - public: - struct SOCKET - { - uint32 nPort; - uint32 nSlot; - uint32 buf1; - uint32 buf2; - }; - - CDbcMan(CSifMan&); - virtual ~CDbcMan(); - std::string GetId() const; - std::string GetFunctionName(unsigned int) const; - void Invoke(CMIPS&, unsigned int); - virtual bool Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*); - virtual void SaveState(Framework::CZipArchiveWriter&); - virtual void LoadState(Framework::CZipArchiveReader&); - virtual void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*); - virtual void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*); - - void CreateSocket(uint32*, uint32, uint32*, uint32, uint8*); - void SetWorkAddr(uint32*, uint32, uint32*, uint32, uint8*); - void ReceiveData(uint32*, uint32, uint32*, uint32, uint8*); - void GetVersionInformation(uint32*, uint32, uint32*, uint32, uint8*); - - uint32 GetButtonStatIndex() const; - void SetButtonStatIndex(uint32); - SOCKET* GetSocket(uint32); - - private: - enum MODULE_ID - { - MODULE_ID = 0x80000900 - }; - - typedef std::map SocketMap; - - SocketMap m_sockets; - uint32 m_nextSocketId; - uint32 m_workAddress; - uint32 m_buttonStatIndex; - }; - -} - -#endif - diff --git a/Source/iop/Iop_DbcMan320.cpp b/Source/iop/Iop_DbcMan320.cpp deleted file mode 100644 index 337086ba..00000000 --- a/Source/iop/Iop_DbcMan320.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include "Iop_DbcMan320.h" -#include "../Log.h" - -#define LOG_NAME ("iop_dbcman320") - -using namespace Iop; - -CDbcMan320::CDbcMan320(CSifMan& sif, CDbcMan& dbcMan) : -m_dbcMan(dbcMan) -{ - sif.RegisterModule(MODULE_ID, this); -} - -CDbcMan320::~CDbcMan320() -{ - -} - -std::string CDbcMan320::GetId() const -{ - return "dbcman320"; -} - -std::string CDbcMan320::GetFunctionName(unsigned int) const -{ - return "unknown"; -} - -void CDbcMan320::Invoke(CMIPS& context, unsigned int functionId) -{ - throw std::runtime_error("Not implemented."); -} - -bool CDbcMan320::Invoke(uint32 method, uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - switch(method) - { - case 0x80001301: - m_dbcMan.CreateSocket(args, argsSize, ret, retSize, ram); - break; - case 0x80001303: - { - InitializeSocket(args, argsSize, ret, retSize, ram); - CLog::GetInstance().Print(LOG_NAME, "Function0x80001303.\r\n"); -// m_dbcMan.SetButtonStatIndex(0x2C); - ret[0] = 0x1; - } - break; - case 0x80001304: - m_dbcMan.SetWorkAddr(args, argsSize, ret, retSize, ram); - break; - case 0x8000131A: - ReceiveData(args, argsSize, ret, retSize, ram); - break; - case 0x80001363: - GetVersionInformation(args, argsSize, ret, retSize, ram); - break; - default: - CLog::GetInstance().Print(LOG_NAME, "Unknown method invoked (0x%0.8X).\r\n", method); - break; - } - return true; -} - -void CDbcMan320::SaveState(Framework::CZipArchiveWriter& archive) -{ - -} - -void CDbcMan320::LoadState(Framework::CZipArchiveReader& archive) -{ - -} - -void CDbcMan320::ReceiveData(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - //Param Frame - //0 - Socket ID - //1 - Value passed in parameter to the library - //2 - Some parameter (0x01, or some address) - - uint32 nSocket = args[0]; - uint32 nFlags = args[1]; - uint32 nParam = args[2]; - - CDbcMan::SOCKET* socket = m_dbcMan.GetSocket(nSocket); - if(socket != NULL) - { - uint8* buffer = &ram[socket->buf1]; - - //For Guilty Gear - buffer[0x03] = 0x10; - - //For Valkyrie Profile 2 - Size of the data to copy - buffer[0x02] = 0x10; - - *reinterpret_cast(&buffer[0x04]) = 0x01; - - //For Guilty Gear - *reinterpret_cast(&buffer[0x7C]) = 0x01; - } - - //Return frame - //0 - Success Status - //1 - ??? - //2 - Size of returned data - //3+ - Data - - ret[0] = 0; - ret[2] = 0x1; - ret[3] = 0x1; - - CLog::GetInstance().Print(LOG_NAME, "ReceiveData(socket = 0x%0.8X, flags = 0x%0.8X, param = 0x%0.8X);\r\n", nSocket, nFlags, nParam); -} - -void CDbcMan320::GetVersionInformation(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - assert(argsSize == 0x90); - assert(retSize == 0x90); - - ret[0] = 0x00000320; - - CLog::GetInstance().Print(LOG_NAME, "GetVersionInformation();\r\n"); -} - -void CDbcMan320::InitializeSocket(uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram) -{ - uint32 nSocket = args[0]; - - CDbcMan::SOCKET* sock = m_dbcMan.GetSocket(nSocket); - if(sock == NULL) return; - - uint32 buttonStatIndex = m_dbcMan.GetButtonStatIndex(); - - uint8* buffer = &ram[sock->buf1]; - buffer[buttonStatIndex + 4] = 0x7F; - buffer[buttonStatIndex + 5] = 0x7F; - buffer[buttonStatIndex + 6] = 0x7F; - buffer[buttonStatIndex + 7] = 0x7F; -} diff --git a/Source/iop/Iop_DbcMan320.h b/Source/iop/Iop_DbcMan320.h deleted file mode 100644 index 6ca3e681..00000000 --- a/Source/iop/Iop_DbcMan320.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _IOP_DBCMAN320_H_ -#define _IOP_DBCMAN320_H_ - -#include "Iop_Module.h" -#include "Iop_DbcMan.h" -#include "Iop_SifMan.h" -#include "zip/ZipArchiveWriter.h" -#include "zip/ZipArchiveReader.h" - -namespace Iop -{ - class CDbcMan320 : public CModule, public CSifModule - { - public: - CDbcMan320(CSifMan&, CDbcMan&); - virtual ~CDbcMan320(); - std::string GetId() const; - std::string GetFunctionName(unsigned int) const; - void Invoke(CMIPS&, unsigned int); - virtual bool Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*); - virtual void SaveState(Framework::CZipArchiveWriter&); - virtual void LoadState(Framework::CZipArchiveReader&); - - private: - enum MODULE_ID - { - MODULE_ID = 0x80001300 - }; - - void ReceiveData(uint32*, uint32, uint32*, uint32, uint8*); - void GetVersionInformation(uint32*, uint32, uint32*, uint32, uint8*); - void InitializeSocket(uint32*, uint32, uint32*, uint32, uint8*); - - CDbcMan& m_dbcMan; - }; -}; - -#endif diff --git a/Source/iop/Iop_SifCmd.cpp b/Source/iop/Iop_SifCmd.cpp index a12b0414..cacd0996 100644 --- a/Source/iop/Iop_SifCmd.cpp +++ b/Source/iop/Iop_SifCmd.cpp @@ -286,7 +286,21 @@ void CSifCmd::SifRegisterRpc(CMIPS& context) serverDataAddr, serverId, function, buffer, cfunction, cbuffer, queueAddr); static const uint32 libSdServerId = 0x80000701; - if(serverId == libSdServerId || ((serverId & 0x80000000) == 0)) + static const uint32 padManServerId0 = 0x80000100; + static const uint32 padManServerId1 = 0x80000101; + static const uint32 padManServerId2 = 0x8000010F; + static const uint32 padManServerId3 = 0x0000011F; + static const uint32 dbcManServerId0 = 0x80000900; + static const uint32 dbcManServerId1 = 0x80001300; + if( + (serverId == libSdServerId) || + (serverId == padManServerId0) || + (serverId == padManServerId1) || + (serverId == padManServerId2) || + (serverId == padManServerId3) || + (serverId == dbcManServerId0) || + (serverId == dbcManServerId1) || + ((serverId & 0x80000000) == 0)) { CSifDynamic* module = new CSifDynamic(*this, serverDataAddr); m_servers.push_back(module); diff --git a/Source/iop/Iop_Sio2.cpp b/Source/iop/Iop_Sio2.cpp index 1f075302..600e9911 100644 --- a/Source/iop/Iop_Sio2.cpp +++ b/Source/iop/Iop_Sio2.cpp @@ -237,17 +237,20 @@ void CSio2::ProcessCommand() break; case 0x44: //Set Mode & Lock { - assert(dstSize == 9); + assert(dstSize == 5 || dstSize == 9); uint8 mode = m_inputBuffer[3]; uint8 lock = m_inputBuffer[4]; //cmdBuffer[3] == 0x01 ? (u8)ID_ANALOG : (u8)ID_DIGITAL; //cmdBuffer[4] == 0x03 -> Mode Lock m_outputBuffer[outputOffset + 0x03] = 0x00; m_outputBuffer[outputOffset + 0x04] = 0x00; - m_outputBuffer[outputOffset + 0x05] = 0x00; - m_outputBuffer[outputOffset + 0x06] = 0x00; - m_outputBuffer[outputOffset + 0x07] = 0x00; - m_outputBuffer[outputOffset + 0x08] = 0x00; + if(dstSize == 9) + { + m_outputBuffer[outputOffset + 0x05] = 0x00; + m_outputBuffer[outputOffset + 0x06] = 0x00; + m_outputBuffer[outputOffset + 0x07] = 0x00; + m_outputBuffer[outputOffset + 0x08] = 0x00; + } CLog::GetInstance().Print(LOG_NAME, "Pad %d: SetModeAndLock(mode = %d, lock = %d);\r\n", padId, mode, lock); } break; diff --git a/Source/iop/Iop_SubSystem.cpp b/Source/iop/Iop_SubSystem.cpp index db517040..b0df1d2e 100644 --- a/Source/iop/Iop_SubSystem.cpp +++ b/Source/iop/Iop_SubSystem.cpp @@ -25,6 +25,9 @@ CSubSystem::CSubSystem(bool ps2Mode) , m_spuCore1(m_spuRam, SPU_RAM_SIZE) , m_spu(m_spuCore0) , m_spu2(m_spuCore0, m_spuCore1) +#ifdef _IOP_EMULATE_MODULES +, m_sio2(m_intc) +#endif , m_cpuArch(MIPS_REGSIZE_32) , m_copScu(MIPS_REGSIZE_32) { @@ -110,6 +113,9 @@ void CSubSystem::Reset() m_spuCore1.Reset(); m_spu.Reset(); m_spu2.Reset(); +#ifdef _IOP_EMULATE_MODULES + m_sio2.Reset(); +#endif m_counters.Reset(); m_dmac.Reset(); m_intc.Reset(); @@ -148,6 +154,12 @@ uint32 CSubSystem::ReadIoRegister(uint32 address) { return m_counters.ReadRegister(address); } +#ifdef _IOP_EMULATE_MODULES + else if(address >= CSio2::ADDR_BEGIN && address <= CSio2::ADDR_END) + { + return m_sio2.ReadRegister(address); + } +#endif else if(address >= CSpu2::REGS_BEGIN && address <= CSpu2::REGS_END) { return m_spu2.ReadRegister(address); @@ -189,6 +201,12 @@ uint32 CSubSystem::WriteIoRegister(uint32 address, uint32 value) { m_counters.WriteRegister(address, value); } +#ifdef _IOP_EMULATE_MODULES + else if(address >= CSio2::ADDR_BEGIN && address <= CSio2::ADDR_END) + { + m_sio2.WriteRegister(address, value); + } +#endif else if(address >= CSpu2::REGS_BEGIN && address <= CSpu2::REGS_END) { return m_spu2.WriteRegister(address, value); diff --git a/Source/iop/Iop_SubSystem.h b/Source/iop/Iop_SubSystem.h index fa496b29..155f38a8 100644 --- a/Source/iop/Iop_SubSystem.h +++ b/Source/iop/Iop_SubSystem.h @@ -9,6 +9,7 @@ #include "Iop_SpuBase.h" #include "Iop_Spu.h" #include "Iop_Spu2.h" +#include "Iop_Sio2.h" #include "Iop_Dmac.h" #include "Iop_Intc.h" #include "Iop_RootCounters.h" @@ -47,6 +48,9 @@ namespace Iop CSpuBase m_spuCore1; CSpu m_spu; CSpu2 m_spu2; +#ifdef _IOP_EMULATE_MODULES + CSio2 m_sio2; +#endif CMIPS m_cpu; CMA_MIPSIV m_cpuArch; CCOP_SCU m_copScu; diff --git a/build_win32/Play.vcxproj b/build_win32/Play.vcxproj index b3b2a812..7fdcbfe6 100644 --- a/build_win32/Play.vcxproj +++ b/build_win32/Play.vcxproj @@ -193,8 +193,6 @@ - - @@ -376,8 +374,6 @@ - - diff --git a/build_win32/Play.vcxproj.filters b/build_win32/Play.vcxproj.filters index e8bfdc44..3bc42689 100644 --- a/build_win32/Play.vcxproj.filters +++ b/build_win32/Play.vcxproj.filters @@ -163,12 +163,6 @@ Source Files\Core\Iop\Modules - - Source Files\Core\Iop\Modules - - - Source Files\Core\Iop\Modules - Source Files\Core\Iop\Modules @@ -705,18 +699,12 @@ Source Files\Core\Iop - - Source Files\Core\Iop\Modules - Source Files\Core\Iop\Modules Source Files\Core\Iop\Modules - - Source Files\Core\Iop\Modules - Source Files\Core\Iop\Modules