wip of IPC

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1070 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2008-11-04 21:34:12 +00:00
parent ffe1a671ea
commit ff084ad22a
4 changed files with 48 additions and 33 deletions

View File

@ -21,7 +21,6 @@
#include "WII_IPC_HLE_Device_FileIO.h" #include "WII_IPC_HLE_Device_FileIO.h"
std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size) std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size)
{ {
char Buffer[128]; char Buffer[128];
@ -60,6 +59,8 @@ CWII_IPC_HLE_Device_FileIO::~CWII_IPC_HLE_Device_FileIO()
bool bool
CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress) CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress)
{ {
LOG(WII_IPC_FILEIO, "FileIO: Close %s", GetDeviceName().c_str());
Memory::Write_U32(0, _CommandAddress+4); Memory::Write_U32(0, _CommandAddress+4);
return true; return true;
} }
@ -81,6 +82,8 @@ CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
m_Filename = std::string(HLE_IPC_BuildFilename(GetDeviceName().c_str(), 64)); m_Filename = std::string(HLE_IPC_BuildFilename(GetDeviceName().c_str(), 64));
if (File::Exists(m_Filename.c_str()))
{
switch(_Mode) switch(_Mode)
{ {
case 0x01: m_pFileHandle = fopen(m_Filename.c_str(), "rb"); break; case 0x01: m_pFileHandle = fopen(m_Filename.c_str(), "rb"); break;
@ -88,6 +91,7 @@ CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
case 0x03: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break; case 0x03: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break;
default: PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode"); break; default: PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode"); break;
} }
}
if (m_pFileHandle != NULL) if (m_pFileHandle != NULL)
{ {

View File

@ -14,6 +14,7 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifndef _WII_IPC_HLE_DEVICE_FILEIO_H_ #ifndef _WII_IPC_HLE_DEVICE_FILEIO_H_
#define _WII_IPC_HLE_DEVICE_FILEIO_H_ #define _WII_IPC_HLE_DEVICE_FILEIO_H_

View File

@ -64,13 +64,9 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
char* pTitleID = (char*)&TitleID; char* pTitleID = (char*)&TitleID;
char Path[260+1]; char Path[260+1];
sprintf(Path, "Wii/title/00010000/%02x%02x%02x%02x", (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]); sprintf(Path, "Wii/title/00010000/%02x%02x%02x%02x/data/nocopy/", (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]);
if (!File::IsDirectory(Path))
{ CreateDirectoryStruct(Path);
File::CreateDir(Path);
sprintf(Path, "Wii/title/00010000/%02x%02x%02x%02x/data", (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]);
File::CreateDir(Path);
}
} }
Memory::Write_U32(GetDeviceID(), _CommandAddress+4); Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
@ -186,8 +182,15 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
Extensions.push_back("*.*"); Extensions.push_back("*.*");
CFileSearch FileSearch(Extensions, Directories); CFileSearch FileSearch(Extensions, Directories);
fsBlock = (u32)FileSearch.GetFileNames().size();
iNodes = fsBlock * 10; u64 overAllSize = 0;
for (size_t i=0; i<FileSearch.GetFileNames().size(); i++)
{
overAllSize += File::GetSize(FileSearch.GetFileNames()[i].c_str());
}
fsBlock = (u32)(overAllSize / (16 * 1024)); // one bock is 16kb
iNodes = (u32)(FileSearch.GetFileNames().size());
ReturnValue = 0; ReturnValue = 0;
@ -327,7 +330,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
std::string FilenameRename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn+Offset), 64); std::string FilenameRename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn+Offset), 64);
Offset += 64; Offset += 64;
CreateDirectoryStruct(FilenameRename); // F|RES: i think that we dont need this - CreateDirectoryStruct(Filename);
if (rename(Filename.c_str(), FilenameRename.c_str()) == 0) if (rename(Filename.c_str(), FilenameRename.c_str()) == 0)
{ {
@ -352,10 +355,19 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
u16 GroupID = Memory::Read_U16(Addr); Addr += 2; u16 GroupID = Memory::Read_U16(Addr); Addr += 2;
std::string Filename(HLE_IPC_BuildFilename((const char*)Memory::GetPointer(Addr), 64)); std::string Filename(HLE_IPC_BuildFilename((const char*)Memory::GetPointer(Addr), 64));
Addr += 64; Addr += 64;
Addr += 9; // unk memory;
u8 Attribs = Memory::Read_U8(Addr);
LOG(WII_IPC_FILEIO, "FS: CreateFile %s (attrib: 0x%02x)", Filename.c_str(), Attribs); u8 OwnerPerm = Memory::Read_U8(Addr); Addr++;
u8 GroupPerm = Memory::Read_U8(Addr); Addr++;
u8 OtherPerm = Memory::Read_U8(Addr); Addr++;
u8 Attributes = Memory::Read_U8(Addr); Addr++;
LOG(WII_IPC_FILEIO, "FS: CreateFile %s", Filename.c_str());
LOG(WII_IPC_FILEIO, " OwnerID: 0x08%x", OwnerID);
LOG(WII_IPC_FILEIO, " GroupID: 0x04%x", GroupID);
LOG(WII_IPC_FILEIO, " OwnerPerm: 0x02%x", OwnerPerm);
LOG(WII_IPC_FILEIO, " GroupPerm: 0x02%x", GroupPerm);
LOG(WII_IPC_FILEIO, " OtherPerm: 0x02%x", OtherPerm);
LOG(WII_IPC_FILEIO, " Attributes: 0x02%x", Attributes);
// check if the file allready exist // check if the file allready exist
if (File::Exists(Filename.c_str())) if (File::Exists(Filename.c_str()))
@ -365,7 +377,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
} }
// create the file // create the file
CreateDirectoryStruct(Filename); // F|RES: i think that we dont need this - CreateDirectoryStruct(Filename);
bool Result = File::CreateEmptyFile(Filename.c_str()); bool Result = File::CreateEmptyFile(Filename.c_str());
if (!Result) if (!Result)
{ {
@ -373,7 +385,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
return FS_RESULT_FATAL; return FS_RESULT_FATAL;
} }
LOG(WII_IPC_FILEIO, " result = FS_RESULT_OK", Filename.c_str(), Attribs); LOG(WII_IPC_FILEIO, " result = FS_RESULT_OK", Filename.c_str());
return FS_RESULT_OK; return FS_RESULT_OK;
} }
break; break;

View File

@ -72,8 +72,8 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtl(u32 _CommandAddress)
bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress)
{ {
/* /*
Memory::Write_U8(255, 0x80149950); // BTM LOG Memory::Write_U8(255, 0x80149950); // BTM LOG
// 3 logs L2Cap // 3 logs L2Cap
// 4 logs l2_csm$ // 4 logs l2_csm$
@ -328,10 +328,9 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
#ifdef _WIN32 #ifdef _WIN32
static bool test = true; static bool test = true;
if (GetAsyncKeyState(VK_LBUTTON) && GetAsyncKeyState(VK_RBUTTON)) if (test && GetAsyncKeyState(VK_LBUTTON) && GetAsyncKeyState(VK_RBUTTON))
{
if (test)
{ {
test = false;
for (size_t i=0; i<m_WiiMotes.size(); i++) for (size_t i=0; i<m_WiiMotes.size(); i++)
{ {
if (m_WiiMotes[i].EventPagingChanged(2)) if (m_WiiMotes[i].EventPagingChanged(2))
@ -340,9 +339,8 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
SendEventRequestConnection(m_WiiMotes[i]); SendEventRequestConnection(m_WiiMotes[i]);
} }
} }
test = false;
}
} }
#endif #endif
return 0; return 0;