diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp index e4c2df02b9..aa5b1460d3 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp @@ -25,24 +25,28 @@ int cellNetCtlGetState(mem32_t state) cellNetCtl->Log("cellNetCtlGetState(state_addr=0x%x)", state.GetAddr()); state = CELL_NET_CTL_STATE_Disconnected; // TODO: Allow other states + return CELL_OK; } -int cellNetCtlAddHandler() +int cellNetCtlAddHandler(mem_ptr_t handler, mem32_t arg, s32 hid) { - UNIMPLEMENTED_FUNC(cellNetCtl); + cellNetCtl->Todo("cellNetCtlAddHandler(handler_addr=0x%x, arg_addr=0x%x, hid=%x)", handler.GetAddr(), arg.GetAddr(), hid); + return CELL_OK; } -int cellNetCtlDelHandler() +int cellNetCtlDelHandler(s32 hid) { - UNIMPLEMENTED_FUNC(cellNetCtl); + cellNetCtl->Todo("cellNetCtlDelHandler(hid=%x)", hid); + return CELL_OK; } -int cellNetCtlGetInfo() +int cellNetCtlGetInfo(s32 code, mem_ptr_t info) { - UNIMPLEMENTED_FUNC(cellNetCtl); + cellNetCtl->Todo("cellNetCtlGetInfo(code=%x, info_addr=0x%x)", code, info.GetAddr()); + return CELL_OK; } @@ -55,7 +59,8 @@ int cellNetCtlNetStartDialogLoadAsync(mem_ptr_t p int cellNetCtlNetStartDialogAbortAsync() { - UNIMPLEMENTED_FUNC(cellNetCtl); + cellNetCtl->Todo("cellNetCtlNetStartDialogAbortAsync()"); + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h index 6a2786eb73..fc25822aaa 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h @@ -207,7 +207,7 @@ struct CellNetCtlSSID u8 padding[3]; }; -struct CellNetCtlInfo +union CellNetCtlInfo { be_t device; CellNetCtlEtherAddr ether_addr; @@ -255,4 +255,6 @@ struct CellNetCtlNatInfo be_t stun_status; be_t nat_type; be_t mapped_addr; -}; \ No newline at end of file +}; + +typedef void(cellNetCtlHandler)(s32 prev_state, s32 new_state, s32 event, s32 error_code, mem32_t arg); \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp index 6859c20edf..a624ce8267 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSail.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSail.cpp @@ -1,7 +1,9 @@ #include "stdafx.h" #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" - +#include "Emu/SysCalls/lv2/sys_cond.h" +#include "Emu/SysCalls/lv2/sys_mutex.h" +#include "cellSpurs.h" #include "cellSail.h" Module *cellSail = nullptr; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSail.h b/rpcs3/Emu/SysCalls/Modules/cellSail.h index 924567b65b..89a3155e7b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSail.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSail.h @@ -3,16 +3,579 @@ // Error Codes enum { - CELL_SAIL_ERROR_INVALID_ARG = 0x80610701, - CELL_SAIL_ERROR_INVALID_STATE = 0x80610702, + CELL_SAIL_ERROR_INVALID_ARG = 0x80610701, + CELL_SAIL_ERROR_INVALID_STATE = 0x80610702, CELL_SAIL_ERROR_UNSUPPORTED_STREAM = 0x80610703, CELL_SAIL_ERROR_INDEX_OUT_OF_RANGE = 0x80610704, - CELL_SAIL_ERROR_EMPTY = 0x80610705, - CELL_SAIL_ERROR_FULLED = 0x80610706, - CELL_SAIL_ERROR_USING = 0x80610707, - CELL_SAIL_ERROR_NOT_AVAILABLE = 0x80610708, - CELL_SAIL_ERROR_CANCEL = 0x80610709, - CELL_SAIL_ERROR_MEMORY = 0x806107F0, - CELL_SAIL_ERROR_INVALID_FD = 0x806107F1, - CELL_SAIL_ERROR_FATAL = 0x806107FF, + CELL_SAIL_ERROR_EMPTY = 0x80610705, + CELL_SAIL_ERROR_FULLED = 0x80610706, + CELL_SAIL_ERROR_USING = 0x80610707, + CELL_SAIL_ERROR_NOT_AVAILABLE = 0x80610708, + CELL_SAIL_ERROR_CANCEL = 0x80610709, + CELL_SAIL_ERROR_MEMORY = 0x806107F0, + CELL_SAIL_ERROR_INVALID_FD = 0x806107F1, + CELL_SAIL_ERROR_FATAL = 0x806107FF, }; + +struct CellSailAudioFormat +{ + s8 coding; + s8 chNum; + be_t sampleNum; + be_t fs; + be_t chLayout; + be_t reserved0; // Specify both -1 + be_t reserved1; +}; + +struct CellSailAudioFrameInfo +{ + be_t pPcm; + be_t status; + be_t pts; + be_t reserved; // Specify 0 +}; + +struct CellSailVideoFormat +{ + s8 coding; + s8 scan; + s8 bitsPerColor; + s8 frameRate; + be_t width; + be_t height; + be_t pitch; + be_t alpha; + s8 colorMatrix; + s8 aspectRatio; + s8 colorRange; + s8 reserved1; // Specify all three -1 + be_t reserved2; + be_t reserved3; +}; + +struct CellSailVideoFrameInfo +{ + be_t pPic; + be_t status; + be_t pts; + be_t reserved; // Specify both 0 + be_t interval; + u8 structure; + s8 repeatNum; + u8 reserved2[4]; +}; + +struct CellSailSourceBufferItem +{ + u8 pBuf; + be_t size; + be_t sessionId; + be_t reserved; // Specify 0 +}; + +struct CellSailSourceStartCommand +{ + be_t startFlags; + be_t startArg; + be_t lengthArg; + be_t optionalArg0; + be_t optionalArg1; +}; + +struct CellSailSourceStreamingProfile +{ + be_t reserved0; // Specify 0 + be_t numItems; + be_t maxBitrate; + be_t reserved1; // Specify 0 + be_t duration; + be_t streamSize; +}; + +union CellSailEvent +{ + struct u32x2 { + be_t major; + be_t minor; + }; + + struct ui64 { + be_t value; + }; +}; + +typedef void(*CellSailMemAllocatorFuncAlloc)(u32 pArg, u32 boundary, u32 size); +typedef void(*CellSailMemAllocatorFuncFree)(u32 pArg, u32 boundary, u32 pMemory); + +typedef int(*CellSailSoundAdapterFuncMakeup)(u32 pArg); +typedef int(*CellSailSoundAdapterFuncCleanup)(u32 pArg); +typedef void(*CellSailSoundAdapterFuncFormatChanged)(u32 pArg, mem_ptr_t pFormat, u32 sessionId); + +typedef int(*CellSailGraphicsAdapterFuncMakeup)(u32 pArg); +typedef int(*CellSailGraphicsAdapterFuncCleanup)(u32 pArg); +typedef void(*CellSailGraphicsAdapterFuncFormatChanged)(u32 pArg, mem_ptr_t pFormat, u32 sessionId); +typedef int(*CellSailGraphicsAdapterFuncAllocFrame)(u32 pArg, u32 size, s32 num, u8 ppFrame); +typedef int(*CellSailGraphicsAdapterFuncFreeFrame)(u32 pArg, s32 num, u8 ppFrame); + +typedef int(*CellSailSourceFuncMakeup)(u32 pArg, s8 pProtocolNames); +typedef int(*CellSailSourceFuncCleanup)(u32 pArg); +typedef void(*CellSailSourceFuncOpen)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, mem_ptr_t pProfile); +typedef void(*CellSailSourceFuncClose)(u32 pArg); +typedef void(*CellSailSourceFuncStart)(u32 pArg, mem_ptr_t pCommand, u32 sessionId); +typedef void(*CellSailSourceFuncStop)(u32 pArg); +typedef void(*CellSailSourceFuncCancel)(u32 pArg); +typedef int(*CellSailSourceFuncCheckout)(u32 pArg, mem_ptr_t ppItem); +typedef int(*CellSailSourceFuncCheckin)(u32 pArg, mem_ptr_t pItem); +typedef int(*CellSailSourceFuncClear)(u32 pArg); +typedef int(*CellSailSourceFuncRead)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, u64 offset, u8 pBuf, u32 size, u64 pTotalSize); +typedef int(*CellSailSourceFuncReadSync)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, u64 offset, u8 pBuf, u32 size, u64 pTotalSize); +typedef int(*CellSailSourceFuncGetCapabilities)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, u64 pCapabilities); +typedef int(*CellSailSourceFuncInquireCapability)(u32 pArg, s32 streamType, u32 pMediaInfo, s8 pUri, mem_ptr_t pCommand); +typedef void(*CellSailSourceCheckFuncError)(u32 pArg, s8 pMsg, s32 line); + +typedef int(*CellSailFsFuncOpen)(s8 pPath, s32 flag, s32 pFd, u32 pArg, u64 size); +typedef int(*CellSailFsFuncOpenSecond)(s8 pPath, s32 flag, s32 fd, u32 pArg, u64 size); +typedef int(*CellSailFsFuncClose)(s32 fd); +typedef int(*CellSailFsFuncFstat)(s32 fd, mem_ptr_t pStat); +typedef int(*CellSailFsFuncRead)(s32 fd, u32 pBuf, u64 numBytes, u64 pNumRead); +typedef int(*CellSailFsFuncLseek)(s32 fd, s64 offset, s32 whence, u64 pPosition); +typedef int(*CellSailFsFuncCancel)(s32 fd); + +typedef int(*CellSailRendererAudioFuncMakeup)(u32 pArg); +typedef int(*CellSailRendererAudioFuncCleanup)(u32 pArg); +typedef void(*CellSailRendererAudioFuncOpen)(u32 pArg, mem_ptr_t pInfo, u32 frameNum); +typedef void(*CellSailRendererAudioFuncClose)(u32 pArg); +typedef void(*CellSailRendererAudioFuncStart)(u32 pArg, bool buffering); +typedef void(*CellSailRendererAudioFuncStop)(u32 pArg, bool flush); +typedef void(*CellSailRendererAudioFuncCancel)(u32 pArg); +typedef int(*CellSailRendererAudioFuncCheckout)(u32 pArg, mem_ptr_t ppInfo); +typedef int(*CellSailRendererAudioFuncCheckin)(u32 pArg, mem_ptr_t pInfo); + +typedef int(*CellSailRendererVideoFuncMakeup)(u32 pArg); +typedef int(*CellSailRendererVideoFuncCleanup)(u32 pArg); +typedef void(*CellSailRendererVideoFuncOpen)(u32 pArg, mem_ptr_t pInfo, u32 frameNum, u32 minFrameNum); +typedef void(*CellSailRendererVideoFuncClose)(u32 pArg); +typedef void(*CellSailRendererVideoFuncStart)(u32 pArg, bool buffering); +typedef void(*CellSailRendererVideoFuncStop)(u32 pArg, bool flush, bool keepRendering); +typedef void(*CellSailRendererVideoFuncCancel)(u32 pArg); +typedef int(*CellSailRendererVideoFuncCheckout)(u32 pArg, mem_ptr_t ppInfo); +typedef int(*CellSailRendererVideoFuncCheckin)(u32 pArg, mem_ptr_t pInfo); + +typedef void(*CellSailPlayerFuncNotified)(u32 pArg, mem_ptr_t event, u64 arg0, u64 arg1); + +struct CellSailMemAllocatorFuncs +{ + CellSailMemAllocatorFuncAlloc pAlloc; + CellSailMemAllocatorFuncFree pFree; +}; + +struct CellSailMemAllocator +{ + CellSailMemAllocatorFuncs callbacks; + be_t pArg; +}; + +struct CellSailFuture +{ + u32 mutex_id; + u32 cond_id; + volatile be_t flags; + be_t result; + be_t userParam; +}; + +struct CellSailSoundAdapterFuncs +{ + CellSailSoundAdapterFuncMakeup pMakeup; + CellSailSoundAdapterFuncCleanup pCleanup; + CellSailSoundAdapterFuncFormatChanged pFormatChanged; +}; + +struct CellSailSoundFrameInfo +{ + be_t pBuffer; + be_t sessionId; + be_t tag; + be_t status; + be_t pts; +}; + +struct CellSailSoundAdapter +{ + be_t internalData[32]; +}; + +struct CellSailGraphicsAdapterFuncs +{ + CellSailGraphicsAdapterFuncMakeup pMakeup; + CellSailGraphicsAdapterFuncCleanup pCleanup; + CellSailGraphicsAdapterFuncFormatChanged pFormatChanged; + CellSailGraphicsAdapterFuncAllocFrame pAlloc; + CellSailGraphicsAdapterFuncFreeFrame pFree; +}; + +struct CellSailGraphicsFrameInfo +{ + be_t pBuffer; + be_t sessionId; + be_t tag; + be_t status; + be_t pts; +}; + +struct CellSailGraphicsAdapter +{ + be_t internalData[32]; +}; + +struct CellSailAuInfo +{ + be_t pAu; + be_t size; + be_t status; + be_t sessionId; + be_t pts; + be_t dts; + be_t reserved; // Specify 0 +}; + +struct CellSailAuReceiver +{ + be_t internalData[64]; +}; + +struct CellSailRendererAudioFuncs +{ + CellSailRendererAudioFuncMakeup pMakeup; + CellSailRendererAudioFuncCleanup pCleanup; + CellSailRendererAudioFuncOpen pOpen; + CellSailRendererAudioFuncClose pClose; + CellSailRendererAudioFuncStart pStart; + CellSailRendererAudioFuncStop pStop; + CellSailRendererAudioFuncCancel pCancel; + CellSailRendererAudioFuncCheckout pCheckout; + CellSailRendererAudioFuncCheckin pCheckin; +}; + +struct CellSailRendererAudioAttribute +{ + be_t thisSize; + CellSailAudioFormat pPreferredFormat; +}; + +struct CellSailRendererAudio +{ + be_t internalData[32]; +}; + +struct CellSailRendererVideoFuncs +{ + CellSailRendererVideoFuncMakeup pMakeup; + CellSailRendererVideoFuncCleanup pCleanup; + CellSailRendererVideoFuncOpen pOpen; + CellSailRendererVideoFuncClose pClose; + CellSailRendererVideoFuncStart pStart; + CellSailRendererVideoFuncStop pStop; + CellSailRendererVideoFuncCancel pCancel; + CellSailRendererVideoFuncCheckout pCheckout; + CellSailRendererVideoFuncCheckin pCheckin; +}; + +struct CellSailRendererVideoAttribute +{ + be_t thisSize; + CellSailVideoFormat *pPreferredFormat; +}; + +struct CellSailRendererVideo +{ + be_t internalData[32]; +}; + +struct CellSailSourceFuncs +{ + CellSailSourceFuncMakeup pMakeup; + CellSailSourceFuncCleanup pCleanup; + CellSailSourceFuncOpen pOpen; + CellSailSourceFuncClose pClose; + CellSailSourceFuncStart pStart; + CellSailSourceFuncStop pStop; + CellSailSourceFuncCancel pCancel; + CellSailSourceFuncCheckout pCheckout; + CellSailSourceFuncCheckin pCheckin; + CellSailSourceFuncClear pClear; + CellSailSourceFuncRead pRead; + CellSailSourceFuncReadSync pReadSync; + CellSailSourceFuncGetCapabilities pGetCapabilities; + CellSailSourceFuncInquireCapability pInquireCapability; +}; + +struct CellSailSource +{ + be_t internalData[20]; +}; + +struct CellSailSourceCheckStream +{ + be_t streamType; + be_t pMediaInfo; + s8 pUri; +}; + +struct CellSailSourceCheckResource +{ + CellSailSourceCheckStream ok; + CellSailSourceCheckStream readError; + CellSailSourceCheckStream openError; + CellSailSourceCheckStream startError; + CellSailSourceCheckStream runningError; +}; + +struct CellSailMp4DateTime +{ + be_t second; + be_t minute; + be_t hour; + be_t day; + be_t month; + be_t year; + //be_t reserved0; + //be_t reserved1; +}; + +struct CellSailMp4Movie +{ + be_t internalData[16]; +}; + +struct CellSailMp4MovieInfo +{ + CellSailMp4DateTime creationDateTime; + CellSailMp4DateTime modificationDateTime; + be_t trackCount; + be_t movieTimeScale; + be_t movieDuration; + //be_t reserved[16]; +}; + +struct CellSailMp4Track +{ + be_t internalData[6]; +}; + +struct CellSailMp4TrackInfo +{ + bool isTrackEnabled; + u8 reserved0[3]; + be_t trackId; + be_t trackDuration; + be_t layer; + be_t alternateGroup; + be_t reserved1[2]; + be_t trackWidth; + be_t trackHeight; + be_t language; + be_t reserved2; + be_t mediaType; + //be_t reserved3[3]; +}; + +struct CellSailAviMovie +{ + be_t internalData[16]; +}; + +struct CellSailAviMovieInfo +{ + be_t maxBytesPerSec; + be_t flags; + be_t reserved0; + be_t streams; + be_t suggestedBufferSize; + be_t width; + be_t height; + be_t scale; + be_t rate; + be_t length; + //be_t reserved1; + //be_t reserved2; +}; + +struct CellSailAviMainHeader +{ + be_t microSecPerFrame; + be_t maxBytesPerSec; + be_t paddingGranularity; + be_t flags; + be_t totalFrames; + be_t initialFrames; + be_t streams; + be_t suggestedBufferSize; + be_t width; + be_t height; + //be_t reserved[4]; +}; + +struct CellSailAviExtendedHeader +{ + be_t totalFrames; +}; + +struct CellSailAviStream +{ + be_t internalData[2]; +}; + +struct CellSailAviMediaType +{ + be_t fccType; + be_t fccHandler; + union u { + struct audio { + be_t formatTag; + be_t reserved; // Specify 0 + union u { + struct mpeg { + be_t headLayer; // Specify 0 + be_t reserved; // Specify 0 + }; + }; + }; + struct video { + be_t compression; + be_t reserved; // Specify 0 + }; + }; +}; + +struct CellSailAviStreamHeader +{ + be_t fccType; + be_t fccHandler; + be_t flags; + be_t priority; + be_t initialFrames; + be_t scale; + be_t rate; + be_t start; + be_t length; + be_t suggestedBufferSize; + be_t quality; + be_t sampleSize; + struct frame { + be_t left; + be_t top; + be_t right; + be_t bottom; + }; +}; + +struct CellSailBitmapInfoHeader +{ + be_t size; + be_t width; + be_t height; + be_t planes; + be_t bitCount; + be_t compression; + be_t sizeImage; + be_t xPelsPerMeter; + be_t yPelsPerMeter; + be_t clrUsed; + be_t clrImportant; +}; + +struct CellSailWaveFormatEx +{ + be_t formatTag; + be_t channels; + be_t samplesPerSec; + be_t avgBytesPerSec; + be_t blockAlign; + be_t bitsPerSample; + be_t cbSize; +}; + +struct CellSailMpeg1WaveFormat +{ + CellSailWaveFormatEx wfx; + be_t headLayer; + be_t headBitrate; + be_t headMode; + be_t headModeExt; + be_t headEmphasis; + be_t headFlags; + be_t PTSLow; + be_t PTSHigh; +}; + +struct CellSailMpegLayer3WaveFormat +{ + CellSailWaveFormatEx wfx; + be_t ID; + be_t flags; + be_t blockSize; + be_t framesPerBlock; + be_t codecDelay; +}; + +struct CellSailDescriptor +{ + be_t internalData[32]; +}; + +struct CellSailStartCommand +{ + be_t startType; + be_t seekType; + be_t terminusType; + be_t flags; + be_t startArg; + be_t reserved; + be_t seekArg; + be_t terminusArg; +}; + +struct CellSailFsReadFuncs +{ + CellSailFsFuncOpen pOpen; + CellSailFsFuncOpenSecond pOpenSecond; + CellSailFsFuncClose pClose; + CellSailFsFuncFstat pFstat; + CellSailFsFuncRead pRead; + CellSailFsFuncLseek pLseek; + CellSailFsFuncCancel pCancel; + be_t reserved[2]; // Specify 0 +}; + +struct CellSailFsRead +{ + be_t capability; + CellSailFsReadFuncs funcs; +}; + +struct CellSailPlayerAttribute +{ + be_t preset; + be_t maxAudioStreamNum; + be_t maxVideoStreamNum; + be_t maxUserStreamNum; + be_t queueDepth; + be_t reserved0; // All three specify 0 + be_t reserved1; + be_t reserved2; +}; + +struct CellSailPlayerResource +{ + CellSpurs pSpurs; + be_t reserved0; // All three specify 0 + be_t reserved1; + be_t reserved2; +}; + +struct CellSailPlayer +{ + be_t internalData[128]; +}; \ No newline at end of file diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index 343637046f..1c4b688c24 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -889,8 +889,8 @@ void cellSysutil_init() cellSysutil->AddFunc(0x2a8eada2, cellSaveDataFixedLoad2); cellSysutil->AddFunc(0x8b7ed64b, cellSaveDataAutoSave2); cellSysutil->AddFunc(0xfbd5c856, cellSaveDataAutoLoad2); - //cellSysutil->AddFunc(0x4dd03a4e, cellSaveDataListAutoSave); - //cellSysutil->AddFunc(0x21425307, cellSaveDataListAutoLoad); + cellSysutil->AddFunc(0x4dd03a4e, cellSaveDataListAutoSave); + cellSysutil->AddFunc(0x21425307, cellSaveDataListAutoLoad); //cellSysutil->AddFunc(0xedadd797, cellSaveDataDelete2); //cellSysutil->AddFunc(0x0f03cfb0, cellSaveDataUserListSave); //cellSysutil->AddFunc(0x39dd8425, cellSaveDataUserListLoad); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp index d3b465417c..29805f3b39 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp @@ -291,7 +291,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m mem_func_ptr_t funcList, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataListSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=%d, userdata_addr=0x%x)", + cellSysutil->Warning("cellSaveDataListSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); MemoryAllocator result; @@ -307,6 +307,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); std::vector saveEntries; + for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) { if (entry->flags & DirEntry_TypeDir && entry->name.substr(0,dirNamePrefix.size()) == dirNamePrefix) @@ -326,12 +327,14 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); listGet->dirList.SetAddr(setBuf->buf_addr); CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + for (u32 i=0; iresult < 0) { cellSysutil->Error("cellSaveDataListSave2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -357,6 +360,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t setList, m cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; } + /*if (statSet->setParam.GetAddr()) addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); // TODO: This *is* wrong */ @@ -371,7 +375,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m mem_func_ptr_t funcList, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=%d, userdata_addr=0x%x)", + cellSysutil->Warning("cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcList_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); MemoryAllocator result; @@ -382,11 +386,13 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); + if(!dir.IsOpened()) return CELL_SAVEDATA_ERROR_INTERNAL; std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); std::vector saveEntries; + for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) { if (entry->flags & DirEntry_TypeDir && entry->name.substr(0,dirNamePrefix.size()) == dirNamePrefix) @@ -406,12 +412,14 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); listGet->dirList.SetAddr(setBuf->buf_addr); CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + for (u32 i=0; iresult < 0) { cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; @@ -437,6 +445,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, m cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; } + /*if (statSet->setParam.GetAddr()) // TODO: Write PARAM.SFO file */ @@ -451,7 +460,7 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t setList, mem_func_ptr_t funcFixed, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataFixedSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcFixed_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=%d, userdata_addr=0x%x)", + cellSysutil->Warning("cellSaveDataFixedSave2(version=%d, setList_addr=0x%x, setBuf_addr=0x%x, funcFixed_addr=0x%x, funcStat_addr=0x%x, funcFile_addr=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); MemoryAllocator result; @@ -520,7 +529,7 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t setList, mem_func_ptr_t funcFixed, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataFixedLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)", + cellSysutil->Warning("cellSaveDataFixedLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); MemoryAllocator result; @@ -589,7 +598,7 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataAutoSave2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)", + cellSysutil->Warning("cellSaveDataAutoSave2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, dirName_addr, errDialog, setBuf.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); MemoryAllocator result; @@ -642,7 +651,7 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataAutoLoad2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)", + cellSysutil->Warning("cellSaveDataAutoLoad2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, dirName_addr, errDialog, setBuf.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); MemoryAllocator result; @@ -688,15 +697,172 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ return CELL_SAVEDATA_RET_OK; } -int cellSaveDataListAutoSave() //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile,sys_memory_container_t container, void *userdata +int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_t setList, mem_ptr_t setBuf, mem_func_ptr_t funcFixed, + mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Warning("cellSaveDataListAutoSave(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", + version, errDialog, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); + + MemoryAllocator result; + MemoryAllocator listGet; + MemoryAllocator listSet; + MemoryAllocator statGet; + MemoryAllocator statSet; + + std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user + vfsDir dir(saveBaseDir); + + if (!dir.IsOpened()) + return CELL_SAVEDATA_ERROR_INTERNAL; + + std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); + std::vector saveEntries; + + for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) + { + if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix) + { + // Count the amount of matches and the amount of listed directories + listGet->dirListNum++; + if (listGet->dirListNum > setBuf->dirListMax) + continue; + listGet->dirNum++; + + std::string saveDir = saveBaseDir + entry->name; + addSaveDataEntry(saveEntries, saveDir); + } + } + + // Sort the entries and fill the listGet->dirList array + std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); + listGet->dirList.SetAddr(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + + for (u32 i = 0; iresult < 0) { + LOG_ERROR(HLE, "cellSaveDataListAutoSave: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. + return CELL_SAVEDATA_ERROR_CBRESULT; + } + + setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum); + if (listSet->newData.GetAddr()) + addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); + if (saveEntries.size() == 0) { + LOG_WARNING(HLE, "cellSaveDataListAutoSave: No save entries found!"); // TODO: Find a better way to handle this error + return CELL_SAVEDATA_RET_OK; + } + + u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition); + // TODO: Display the dialog here + u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry + getSaveDataStat(saveEntries[selectedIndex], statGet.GetAddr()); + result->userdata_addr = userdata_addr; + + funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + Memory.Free(statGet->fileList.GetAddr()); + if (result->result < 0) { + LOG_ERROR(HLE, "cellSaveDataListAutoSave: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. + return CELL_SAVEDATA_ERROR_CBRESULT; + } + + /*if (statSet->setParam.GetAddr()) + addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); // TODO: This *is* wrong + */ + + // Enter the loop where the save files are read/created/deleted. + s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + return CELL_SAVEDATA_RET_OK; } -int cellSaveDataListAutoLoad() //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_t setList, mem_ptr_t setBuf, mem_func_ptr_t funcFixed, + mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Warning("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", + version, errDialog, setList.GetAddr(), setBuf.GetAddr(), funcFixed.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); + + MemoryAllocator result; + MemoryAllocator listGet; + MemoryAllocator listSet; + MemoryAllocator statGet; + MemoryAllocator statSet; + + std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user + vfsDir dir(saveBaseDir); + + if (!dir.IsOpened()) + return CELL_SAVEDATA_ERROR_INTERNAL; + + std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); + std::vector saveEntries; + + for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) + { + if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix) + { + // Count the amount of matches and the amount of listed directories + listGet->dirListNum++; + if (listGet->dirListNum > setBuf->dirListMax) + continue; + listGet->dirNum++; + + std::string saveDir = saveBaseDir + entry->name; + addSaveDataEntry(saveEntries, saveDir); + } + } + + // Sort the entries and fill the listGet->dirList array + std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); + listGet->dirList.SetAddr(setBuf->buf_addr); + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.GetAddr()); + + for (u32 i = 0; iresult < 0) { + LOG_ERROR(HLE, "cellSaveDataListAutoLoad: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. + return CELL_SAVEDATA_ERROR_CBRESULT; + } + + setSaveDataList(saveEntries, (u32)listSet->fixedList.GetAddr(), listSet->fixedListNum); + if (listSet->newData.GetAddr()) + addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr()); + if (saveEntries.size() == 0) { + LOG_WARNING(HLE, "cellSaveDataListAutoLoad: No save entries found!"); // TODO: Find a better way to handle this error + return CELL_SAVEDATA_RET_OK; + } + + u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition); + // TODO: Display the dialog here + u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry + getSaveDataStat(saveEntries[selectedIndex], statGet.GetAddr()); + result->userdata_addr = userdata_addr; + + funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + Memory.Free(statGet->fileList.GetAddr()); + + if (result->result < 0) { + LOG_ERROR(HLE, "cellSaveDataListAutoLoad: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. + return CELL_SAVEDATA_ERROR_CBRESULT; + } + + /*if (statSet->setParam.GetAddr()) + // TODO: Write PARAM.SFO file + */ + + // Enter the loop where the save files are read/created/deleted. + s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); + return CELL_SAVEDATA_RET_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.h b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.h index b3a12116be..6dc680cf92 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.h @@ -296,3 +296,9 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t setBuf, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr); + +int cellSaveDataListAutoSave(u32 version, u32 errDialog, mem_ptr_t setList, mem_ptr_t setBuf, mem_func_ptr_t funcFixed, + mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr); + +int cellSaveDataListAutoLoad(u32 version, u32 errDialog, mem_ptr_t setList, mem_ptr_t setBuf, mem_func_ptr_t funcFixed, + mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, u32 container, u32 userdata_addr); \ No newline at end of file diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index fc79993072..af9e5d180a 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -233,18 +233,18 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) Emu.Stop(); // Open and install PKG file - wxString filePath = ctrl.GetPath(); - rFile pkg_f(filePath.ToStdString(), rFile::read); // TODO: Use VFS to install PKG files + std::string filePath = ctrl.GetPath().ToStdString(); + rFile pkg_f(filePath, rFile::read); // TODO: Use VFS to install PKG files if (pkg_f.IsOpened()) { PKGLoader pkg(pkg_f); pkg.Install("/dev_hdd0/game/"); pkg.Close(); - } - // Refresh game list - m_game_viewer->Refresh(); + // Refresh game list + m_game_viewer->Refresh(); + } } void MainFrame::BootElf(wxCommandEvent& WXUNUSED(event)) diff --git a/rpcs3/Loader/PKG.cpp b/rpcs3/Loader/PKG.cpp index 11fa014e20..33b31725b3 100644 --- a/rpcs3/Loader/PKG.cpp +++ b/rpcs3/Loader/PKG.cpp @@ -26,17 +26,16 @@ bool PKGLoader::Install(std::string dest) std::string titleID = std::string(title_id).substr(7, 9); - if (rExists(dest+titleID)) { + if (rExists(dest + titleID)) { rMessageDialog d_overwrite(NULL, "Another installation was found. Do you want to overwrite it?", "PKG Decrypter / Installer", rYES_NO|rCENTRE); if (d_overwrite.ShowModal() != rID_YES) { LOG_ERROR(LOADER, "PKG Loader: Another installation found in: %s", titleID.c_str()); return false; } - // TODO: Remove the following two lines and remove the folder dest+titleID - LOG_ERROR(LOADER, "PKG Loader: Another installation found in: %s", titleID.c_str()); - return false; + + rRmdir(dest + titleID); } - if (!rMkdir(dest+titleID)) { + if (!rMkdir(dest + titleID)) { LOG_ERROR(LOADER, "PKG Loader: Could not make the installation directory: %s", titleID.c_str()); return false; }