diff --git a/bin/dev_hdd0/home/00000001/savedata/.gitignore b/bin/dev_hdd0/home/00000001/savedata/.gitignore new file mode 100644 index 0000000000..8f6c3111a2 --- /dev/null +++ b/bin/dev_hdd0/home/00000001/savedata/.gitignore @@ -0,0 +1,6 @@ +# Note: This folder has to exist. Once the User Account manager is implemented, make sure it creates this folder in case it's missing and delete this .gitignore file. + +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/bin/dev_hdd0/home/00000001/trophy/.gitignore b/bin/dev_hdd0/home/00000001/trophy/.gitignore new file mode 100644 index 0000000000..8f6c3111a2 --- /dev/null +++ b/bin/dev_hdd0/home/00000001/trophy/.gitignore @@ -0,0 +1,6 @@ +# Note: This folder has to exist. Once the User Account manager is implemented, make sure it creates this folder in case it's missing and delete this .gitignore file. + +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index df298b434c..3a10863859 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -2,7 +2,7 @@ #include "unself.h" SELFDecrypter::SELFDecrypter(vfsStream& s) - : self_f(s), key_v() + : self_f(s), key_v(), data_buf_length(0) { } @@ -92,9 +92,10 @@ bool SELFDecrypter::LoadHeaders(bool isElf32) { ControlInfo* cinfo = new ControlInfo(); cinfo->Load(self_f); - ctrlinfo_arr.Move(cinfo); i += cinfo->size; + + ctrlinfo_arr.Move(cinfo); } // Read ELF section headers. @@ -369,6 +370,9 @@ bool SELFDecrypter::DecryptData() self_f.Seek(meta_shdr[i].data_offset); self_f.Read(buf, meta_shdr[i].data_size); + // Zero out our ctr nonce + memset(ctr_stream_block, 0, sizeof(ctr_stream_block)); + // Perform AES-CTR encryption on the data blocks. aes_setkey_enc(&aes, data_key, 128); aes_crypt_ctr(&aes, meta_shdr[i].data_size, &ctr_nc_off, data_iv, ctr_stream_block, buf, buf); diff --git a/rpcs3/Emu/Audio/AudioManager.cpp b/rpcs3/Emu/Audio/AudioManager.cpp index eb0e094cc2..f0cbfc0d78 100644 --- a/rpcs3/Emu/Audio/AudioManager.cpp +++ b/rpcs3/Emu/Audio/AudioManager.cpp @@ -23,11 +23,8 @@ void AudioManager::Init() void AudioManager::Close() { - if(m_audio_out) - { - delete m_audio_out; - m_audio_out = nullptr; - } + delete m_audio_out; + m_audio_out = nullptr; } u8 AudioManager::GetState() diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index b4c6a5e025..fda8b8807a 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -30,7 +30,7 @@ CPUThread::~CPUThread() void CPUThread::Close() { - ThreadBase::Stop(); + ThreadBase::Stop(m_sync_wait); DoStop(); delete m_dec; diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 10348c5c20..ba9801f685 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -226,7 +226,7 @@ public: new_item.branch_pc = pc; new_item.pc = PC; - m_call_stack.AddCpy(new_item); + m_call_stack.Push(new_item); } virtual u64 CallStackGetNextPC(u64 pc) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index bd6c6570e5..05405efc13 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -165,11 +165,8 @@ void PPUThread::DoPause() void PPUThread::DoStop() { - if(m_dec) - { - delete m_dec; - m_dec = nullptr; - } + delete m_dec; + m_dec = nullptr; } bool dump_enable = false; diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index fc2c69f7e5..38ee1197b8 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -260,35 +260,35 @@ void VFS::Init(const wxString& path) { UnMountAll(); - Array entries; + std::vector entries; SaveLoadDevices(entries, true); - for(uint i=0; i& res, bool is_load) +void VFS::SaveLoadDevices(std::vector& res, bool is_load) { IniEntry entries_count; entries_count.Init("count", "VFSManager"); @@ -300,61 +300,25 @@ void VFS::SaveLoadDevices(Array& res, bool is_load) if(!count) { - int idx; - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_hdd0/"; - res[idx].mount = "/dev_hdd0/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_hdd1/"; - res[idx].mount = "/dev_hdd1/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_flash/"; - res[idx].mount = "/dev_flash/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_usb000/"; - res[idx].mount = "/dev_usb000/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(EmulatorDir)/dev_usb000/"; - res[idx].mount = "/dev_usb/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(GameDir)"; - res[idx].mount = "/app_home/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(GameDir)/../"; - res[idx].mount = "/dev_bdvd/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = ""; - res[idx].mount = "/host_root/"; - res[idx].device = vfsDevice_LocalFile; - - idx = res.Move(new VFSManagerEntry()); - res[idx].path = "$(GameDir)"; - res[idx].mount = "/"; - res[idx].device = vfsDevice_LocalFile; + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_hdd0/", "/dev_hdd0/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_hdd1/", "/dev_hdd1/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_flash/", "/dev_flash/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb000/"); + res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb/"); + res.emplace_back(vfsDevice_LocalFile, "$(GameDir)", "/app_home/"); + res.emplace_back(vfsDevice_LocalFile, "$(GameDir)/../", "/dev_bdvd/"); + res.emplace_back(vfsDevice_LocalFile, "", "/host_root/"); + res.emplace_back(vfsDevice_LocalFile, "$(GameDir)", "/"); return; } - res.SetCount(count); + res.resize(count); } else { - count = res.GetCount(); - entries_count.SaveValue(res.GetCount()); + count = res.size(); + entries_count.SaveValue(res.size()); } for(int i=0; i& res, bool is_load) if(is_load) { - new (res + i) VFSManagerEntry(); + res[i] = VFSManagerEntry(); res[i].path = strdup(entry_path.LoadValue(wxEmptyString).c_str()); res[i].device_path = strdup(entry_device_path.LoadValue(wxEmptyString).c_str()); res[i].mount = strdup(entry_mount.LoadValue(wxEmptyString).c_str()); diff --git a/rpcs3/Emu/FS/VFS.h b/rpcs3/Emu/FS/VFS.h index 8876726bb8..f624ba6892 100644 --- a/rpcs3/Emu/FS/VFS.h +++ b/rpcs3/Emu/FS/VFS.h @@ -1,4 +1,5 @@ #pragma once + #include "vfsDevice.h" enum vfsDeviceType @@ -15,10 +16,10 @@ static const char* vfsDeviceTypeNames[] = struct VFSManagerEntry { - char* device_path; - char* path; - char* mount; vfsDeviceType device; + const char* device_path; + const char* path; + const char* mount; VFSManagerEntry() : device(vfsDevice_LocalFile) @@ -27,6 +28,15 @@ struct VFSManagerEntry , mount("") { } + + VFSManagerEntry(const vfsDeviceType& device, const char* path, const char* mount) + : device(device) + , device_path("") + , path(path) + , mount(mount) + + { + } }; struct VFS @@ -51,5 +61,5 @@ struct VFS vfsDevice* GetDeviceLocal(const wxString& local_path, wxString& path) const; void Init(const wxString& path); - void SaveLoadDevices(Array& res, bool is_load); + void SaveLoadDevices(std::vector& res, bool is_load); }; \ No newline at end of file diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index 3f8dc8ac39..e3ed1c35f8 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -294,7 +294,7 @@ public: out.Create(tex.GetWidth(), tex.GetHeight(), data, alpha); out.SaveFile(name, wxBITMAP_TYPE_PNG); - free(alldata); + delete[] alldata; //free(data); //free(alpha); } diff --git a/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp b/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp index e7afc40429..4ca63b9d6d 100644 --- a/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp +++ b/rpcs3/Emu/GS/GL/GLProgramBuffer.cpp @@ -8,7 +8,7 @@ int GLProgramBuffer::SearchFp(const RSXShaderProgram& rsx_fp, GLShaderProgram& g if(memcmp(&m_buf[i].fp_data[0], &Memory[rsx_fp.addr], m_buf[i].fp_data.GetCount()) != 0) continue; gl_fp.id = m_buf[i].fp_id; - gl_fp.shader = m_buf[i].fp_shader.c_str(); + gl_fp.shader = m_buf[i].fp_shader; return i; } diff --git a/rpcs3/Emu/HDD/HDD.h b/rpcs3/Emu/HDD/HDD.h index c403df21f5..ba7c86e0ed 100644 --- a/rpcs3/Emu/HDD/HDD.h +++ b/rpcs3/Emu/HDD/HDD.h @@ -583,13 +583,12 @@ public: } u64 new_block = FindFreeBlock(); - - ConLog.Write("CREATION ENTRY AT 0x%llx", new_block); if(!new_block) { return false; } + ConLog.Write("CREATING ENTRY AT 0x%llx", new_block); WriteBlock(new_block, g_used_block); { @@ -739,7 +738,7 @@ public: return false; } - ConLog.Write("ENTRY FINDED AT 0x%llx", file_block); + ConLog.Write("ENTRY FOUND AT 0x%llx", file_block); m_file.Open(file_block); return vfsFileBase::Open(path, mode); @@ -769,7 +768,7 @@ public: if(entry.type == vfsHDD_Entry_Dir && name != "." && name != "..") { - ConLog.Warning("removing sub folder '%s'", name.wx_str()); + ConLog.Warning("Removing sub folder '%s'", name.wx_str()); RemoveBlocksDir(entry.data_block); } else if(entry.type == vfsHDD_Entry_File) diff --git a/rpcs3/Emu/Memory/Memory.cpp b/rpcs3/Emu/Memory/Memory.cpp index 8bf12506dc..234432aaab 100644 --- a/rpcs3/Emu/Memory/Memory.cpp +++ b/rpcs3/Emu/Memory/Memory.cpp @@ -535,7 +535,7 @@ template<> __forceinline u64 MemoryBase::ReverseData<2>(u64 val) { return Revers template<> __forceinline u64 MemoryBase::ReverseData<4>(u64 val) { return Reverse32(val); } template<> __forceinline u64 MemoryBase::ReverseData<8>(u64 val) { return Reverse64(val); } -VirtualMemoryBlock::VirtualMemoryBlock() : MemoryBlock() +VirtualMemoryBlock::VirtualMemoryBlock() : MemoryBlock(), m_reserve_size(0) { } diff --git a/rpcs3/Emu/Memory/MemoryBlock.h b/rpcs3/Emu/Memory/MemoryBlock.h index 2b0d11c04e..1e4bc16415 100644 --- a/rpcs3/Emu/Memory/MemoryBlock.h +++ b/rpcs3/Emu/Memory/MemoryBlock.h @@ -13,7 +13,7 @@ struct MemInfo { } - MemInfo() + MemInfo() : addr(0), size(0) { } }; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index 61f4f27d56..4181430a47 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -30,7 +30,7 @@ next: { if (Emu.IsStopped()) { - ConLog.Warning("adecRead() aborted"); + ConLog.Warning("adecRawRead() aborted"); return 0; } Sleep(1); @@ -47,7 +47,7 @@ next: { if (!Memory.CopyToReal(buf, adec.reader.addr, adec.reader.size)) { - ConLog.Error("adecRead: data reading failed (reader.size=0x%x)", adec.reader.size); + ConLog.Error("adecRawRead: data reading failed (reader.size=0x%x)", adec.reader.size); Emu.Pause(); return 0; } @@ -66,7 +66,7 @@ next: } break; default: - ConLog.Error("adecRead(): sequence error (task %d)", adec.job.Peek().type); + ConLog.Error("adecRawRead(): sequence error (task %d)", adec.job.Peek().type); return -1; } @@ -83,7 +83,7 @@ next: } else if (!Memory.CopyToReal(buf, adec.reader.addr, buf_size)) { - ConLog.Error("adecRead: data reading failed (buf_size=0x%x)", buf_size); + ConLog.Error("adecRawRead: data reading failed (buf_size=0x%x)", buf_size); Emu.Pause(); return 0; } @@ -702,7 +702,12 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr) if (!Memory.IsGoodAddr(outBuffer_addr, af.size)) { result = CELL_ADEC_ERROR_FATAL; - goto end; + if (af.data) + { + av_frame_unref(af.data); + av_frame_free(&af.data); + } + return result; } if (!af.data) // fake: empty data @@ -711,13 +716,10 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr) memset(buf, 0, 4096); Memory.CopyFromReal(outBuffer_addr, buf, 4096); free(buf);*/ - goto end; + return result; } // copy data SwrContext* swr = nullptr; - u8* out = nullptr; - - out = (u8*)malloc(af.size); /*swr = swr_alloc_set_opts(NULL, AV_CH_LAYOUT_STEREO, AV_SAMPLE_FMT_FLT, 48000, frame->channel_layout, (AVSampleFormat)frame->format, frame->sample_rate, 0, NULL); @@ -726,10 +728,17 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr) { ConLog.Error("cellAdecGetPcm(%d): swr_alloc_set_opts() failed", handle); Emu.Pause(); - goto end; - } + free(out); + if (af.data) + { + av_frame_unref(af.data); + av_frame_free(&af.data); + } + return result; + }*/ + u8* out = (u8*)malloc(af.size); // something is wrong - swr_convert(swr, &out, frame->nb_samples, (const u8**)frame->extended_data, frame->nb_samples); */ + //swr_convert(swr, &out, frame->nb_samples, (const u8**)frame->extended_data, frame->nb_samples); // reverse byte order, extract data: float* in_f[2]; @@ -748,8 +757,7 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr) Emu.Pause(); } -end: - if (out) free(out); + free(out); if (swr) swr_free(&swr); if (af.data) @@ -827,4 +835,4 @@ void cellAdec_init() av_register_all(); avcodec_register_all(); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 2f0539052f..fed9c0dc34 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -133,9 +133,9 @@ int cellGameBootCheck(mem32_t type, mem32_t attributes, mem_ptr_t contentInfoPath, mem_list_ptr_t buf, u32 bufsize) +int cellGameGetParamString(u32 id, u32 buf_addr, u32 bufsize) { - cellGame.Warning("cellGameGetParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf.GetAddr(), bufsize); + cellGame.Warning("cellGameGetParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf_addr, bufsize); - if(!buf.IsGood()) + if(!Memory.IsGoodAddr(buf_addr)) return CELL_GAME_ERROR_PARAM; // TODO: Locate the PARAM.SFO. The following path may be wrong. @@ -223,46 +223,41 @@ int cellGameGetParamString(u32 id, mem_list_ptr_t buf, u32 bufsize) if(!psf.Load(false)) return CELL_GAME_ERROR_FAILURE; + std::string data; switch(id) { - // WARNING: Is there any difference between all these "CELL_GAME_PARAMID_TITLE*" IDs? - case CELL_GAME_PARAMID_TITLE: - case CELL_GAME_PARAMID_TITLE_DEFAULT: - case CELL_GAME_PARAMID_TITLE_JAPANESE: - case CELL_GAME_PARAMID_TITLE_ENGLISH: - case CELL_GAME_PARAMID_TITLE_FRENCH: - case CELL_GAME_PARAMID_TITLE_SPANISH: - case CELL_GAME_PARAMID_TITLE_GERMAN: - case CELL_GAME_PARAMID_TITLE_ITALIAN: - case CELL_GAME_PARAMID_TITLE_DUTCH: - case CELL_GAME_PARAMID_TITLE_PORTUGUESE: - case CELL_GAME_PARAMID_TITLE_RUSSIAN: - case CELL_GAME_PARAMID_TITLE_KOREAN: - case CELL_GAME_PARAMID_TITLE_CHINESE_T: - case CELL_GAME_PARAMID_TITLE_CHINESE_S: - case CELL_GAME_PARAMID_TITLE_FINNISH: - case CELL_GAME_PARAMID_TITLE_SWEDISH: - case CELL_GAME_PARAMID_TITLE_DANISH: - case CELL_GAME_PARAMID_TITLE_NORWEGIAN: - case CELL_GAME_PARAMID_TITLE_POLISH: - case CELL_GAME_PARAMID_TITLE_PORTUGUESE_BRAZIL: - case CELL_GAME_PARAMID_TITLE_ENGLISH_UK: - Memory.WriteString(buf.GetAddr(), psf.m_info.name.Left(bufsize)); - break; - case CELL_GAME_PARAMID_TITLE_ID: - Memory.WriteString(buf.GetAddr(), psf.m_info.serial.Left(bufsize)); - break; - case CELL_GAME_PARAMID_VERSION: - Memory.WriteString(buf.GetAddr(), psf.m_info.fw.Left(bufsize)); - break; - case CELL_GAME_PARAMID_APP_VER: - Memory.WriteString(buf.GetAddr(), psf.m_info.app_ver.Left(bufsize)); - break; + case CELL_GAME_PARAMID_TITLE: data = psf.GetString("TITLE"); break; // TODO: Is this value correct? + case CELL_GAME_PARAMID_TITLE_DEFAULT: data = psf.GetString("TITLE"); break; + case CELL_GAME_PARAMID_TITLE_JAPANESE: data = psf.GetString("TITLE_00"); break; + case CELL_GAME_PARAMID_TITLE_ENGLISH: data = psf.GetString("TITLE_01"); break; + case CELL_GAME_PARAMID_TITLE_FRENCH: data = psf.GetString("TITLE_02"); break; + case CELL_GAME_PARAMID_TITLE_SPANISH: data = psf.GetString("TITLE_03"); break; + case CELL_GAME_PARAMID_TITLE_GERMAN: data = psf.GetString("TITLE_04"); break; + case CELL_GAME_PARAMID_TITLE_ITALIAN: data = psf.GetString("TITLE_05"); break; + case CELL_GAME_PARAMID_TITLE_DUTCH: data = psf.GetString("TITLE_06"); break; + case CELL_GAME_PARAMID_TITLE_PORTUGUESE: data = psf.GetString("TITLE_07"); break; + case CELL_GAME_PARAMID_TITLE_RUSSIAN: data = psf.GetString("TITLE_08"); break; + case CELL_GAME_PARAMID_TITLE_KOREAN: data = psf.GetString("TITLE_09"); break; + case CELL_GAME_PARAMID_TITLE_CHINESE_T: data = psf.GetString("TITLE_10"); break; + case CELL_GAME_PARAMID_TITLE_CHINESE_S: data = psf.GetString("TITLE_11"); break; + case CELL_GAME_PARAMID_TITLE_FINNISH: data = psf.GetString("TITLE_12"); break; + case CELL_GAME_PARAMID_TITLE_SWEDISH: data = psf.GetString("TITLE_13"); break; + case CELL_GAME_PARAMID_TITLE_DANISH: data = psf.GetString("TITLE_14"); break; + case CELL_GAME_PARAMID_TITLE_NORWEGIAN: data = psf.GetString("TITLE_15"); break; + case CELL_GAME_PARAMID_TITLE_POLISH: data = psf.GetString("TITLE_16"); break; + case CELL_GAME_PARAMID_TITLE_PORTUGUESE_BRAZIL: data = psf.GetString("TITLE_17"); break; + case CELL_GAME_PARAMID_TITLE_ENGLISH_UK: data = psf.GetString("TITLE_18"); break; + + case CELL_GAME_PARAMID_TITLE_ID: data = psf.GetString("TITLE_ID"); break; + case CELL_GAME_PARAMID_VERSION: data = psf.GetString("PS3_SYSTEM_VER"); break; + case CELL_GAME_PARAMID_APP_VER: data = psf.GetString("APP_VER"); break; default: return CELL_GAME_ERROR_INVALID_ID; } + data.resize(bufsize-1); + Memory.WriteString(buf_addr, data.c_str()); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index a00b49d4ff..fa1f85e283 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -711,7 +711,7 @@ int32_t cellGcmMapLocalMemory(u64 address, u64 size) } else { - printf("RSX local memory already mapped"); + cellGcmSys.Error("RSX local memory already mapped"); return CELL_GCM_ERROR_FAILURE; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp deleted file mode 100644 index d0cf1a4dda..0000000000 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ /dev/null @@ -1,435 +0,0 @@ -#include "stdafx.h" -#include "Emu/SysCalls/SysCalls.h" -#include "Emu/SysCalls/SC_FUNC.h" - -// TODO: Is this really a module? Or is everything part of cellSysutil? -void cellSaveData_init(); -Module cellSaveData("cellSaveData", cellSaveData_init); - -// Error codes -enum -{ - CELL_SAVEDATA_RET_OK = 0, - CELL_SAVEDATA_RET_CANCEL = 1, - CELL_SAVEDATA_ERROR_CBRESULT, - CELL_SAVEDATA_ERROR_ACCESS_ERROR, - CELL_SAVEDATA_ERROR_INTERNAL, - CELL_SAVEDATA_ERROR_PARAM, - CELL_SAVEDATA_ERROR_NOSPACE, - CELL_SAVEDATA_ERROR_BROKEN, - CELL_SAVEDATA_ERROR_FAILURE, - CELL_SAVEDATA_ERROR_BUSY, - CELL_SAVEDATA_ERROR_NOUSER, -}; - -// Constants -enum -{ - // CellSaveDataParamSize - CELL_SAVEDATA_DIRNAME_SIZE = 32, - CELL_SAVEDATA_FILENAME_SIZE = 13, - CELL_SAVEDATA_SECUREFILEID_SIZE = 16, - CELL_SAVEDATA_PREFIX_SIZE = 256, - CELL_SAVEDATA_LISTITEM_MAX = 2048, - CELL_SAVEDATA_SECUREFILE_MAX = 113, - CELL_SAVEDATA_DIRLIST_MAX = 2048, - CELL_SAVEDATA_INVALIDMSG_MAX = 256, - CELL_SAVEDATA_INDICATORMSG_MAX = 64, - - // CellSaveDataSystemParamSize - CELL_SAVEDATA_SYSP_TITLE_SIZE = 128, - CELL_SAVEDATA_SYSP_SUBTITLE_SIZE = 128, - CELL_SAVEDATA_SYSP_DETAIL_SIZE = 1024, - CELL_SAVEDATA_SYSP_LPARAM_SIZE = 8, -}; - -// Datatypes -struct CellSaveDataSetList -{ - be_t sortType; - be_t sortOrder; - be_t dirNamePrefix_addr; // char* -}; - -struct CellSaveDataSetBuf -{ - be_t dirListMax; - be_t fileListMax; - be_t reserved[6]; - be_t bufSize; - be_t buf_addr; // void* -}; - -struct CellSaveDataNewDataIcon -{ - be_t title_addr; // char* - be_t iconBufSize; - be_t iconBuf_addr; // void* -}; - -struct CellSaveDataListNewData -{ - be_t iconPosition; - be_t dirName_addr; // char* - be_t icon_addr; // CellSaveDataNewDataIcon* -}; - -struct CellSaveDataDirList -{ - s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE]; - s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE]; -}; - -struct CellSaveDataListGet -{ - be_t dirNum; - be_t dirListNum; - be_t dirList_addr; // CellSaveDataDirList* -}; - -struct CellSaveDataListSet -{ - be_t focusPosition; - be_t focusDirName_addr; // char* - be_t fixedListNum; - be_t fixedList_addr; // CellSaveDataDirList* - be_t newData_addr; // CellSaveDataListNewData* -}; - -struct CellSaveDataFixedSet -{ - be_t dirName_addr; // char* - be_t newIcon_addr; // CellSaveDataNewDataIcon* - be_t option; -}; - -struct CellSaveDataSystemFileParam -{ - s8 title[CELL_SAVEDATA_SYSP_TITLE_SIZE]; - s8 subTitle[CELL_SAVEDATA_SYSP_SUBTITLE_SIZE]; - s8 detail[CELL_SAVEDATA_SYSP_DETAIL_SIZE]; - be_t attribute; - s8 reserved2[4]; - s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE]; - s8 reserved[256]; -}; - -struct CellSaveDataDirStat -{ - be_t st_atime_; - be_t st_mtime_; - be_t st_ctime_; - s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE]; -}; - -struct CellSaveDataFileStat -{ - be_t fileType; - u8 reserved1[4]; - be_t st_size; - be_t st_atime_; - be_t st_mtime_; - be_t st_ctime_; - u8 fileName[CELL_SAVEDATA_FILENAME_SIZE]; - u8 reserved2[3]; -}; - -struct CellSaveDataStatGet -{ - be_t hddFreeSizeKB; - be_t isNewData; - CellSaveDataDirStat dir; - CellSaveDataSystemFileParam getParam; - be_t bind; - be_t sizeKB; - be_t sysSizeKB; - be_t fileNum; - be_t fileListNum; - be_t fileList_addr; // CellSaveDataFileStat* -}; - -struct CellSaveDataAutoIndicator -{ - be_t dispPosition; - be_t dispMode; - be_t dispMsg_addr; // char* - be_t picBufSize; - be_t picBuf_addr; // void* -}; - -struct CellSaveDataStatSet -{ - be_t setParam_addr; // CellSaveDataSystemFileParam* - be_t reCreateMode; - be_t indicator_addr; // CellSaveDataAutoIndicator* -}; - -struct CellSaveDataFileGet -{ - be_t excSize; -}; - -struct CellSaveDataFileSet -{ - be_t fileOperation; - be_t reserved_addr; // void* - be_t fileType; - u8 secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE]; - be_t fileName_addr; // char* - be_t fileOffset; - be_t fileSize; - be_t fileBufSize; - be_t fileBuf_addr; // void* -}; - -struct CellSaveDataCBResult -{ - be_t result; - be_t progressBarInc; - be_t errNeedSizeKB; - be_t invalidMsg_addr; // char* - be_t userdata_addr; // void* -}; - -struct CellSaveDataDoneGet -{ - be_t excResult; - s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE]; - be_t sizeKB; - be_t hddFreeSizeKB; -}; - -// Functions -int cellSaveDataListSave2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataListLoad2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataFixedSave2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile,sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataFixedLoad2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataAutoSave2() //u32 version, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataAutoLoad2() //u32 version, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - 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 -{ - UNIMPLEMENTED_FUNC(cellSaveData); - 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 -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataDelete2() //sys_memory_container_t container -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_CANCEL; -} - -int cellSaveDataFixedDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserListSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserListLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserFixedSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserFixedLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserAutoSave() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserAutoLoad() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserListAutoSave() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserListAutoLoad() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserFixedDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -//void cellSaveDataEnableOverlay(); //int enable - - -// Functions (Extensions) -int cellSaveDataListDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataListImport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataListExport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataFixedImport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataFixedExport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserListDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone,sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserListImport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserListExport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserFixedImport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserFixedExport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB -{ - UNIMPLEMENTED_FUNC(cellSaveData); - return CELL_SAVEDATA_RET_OK; -} - -// Callback Functions -void (*CellSaveDataFixedCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataListGet *get, CellSaveDataFixedSet *set - -void (*CellSaveDataListCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataListGet *get, CellSaveDataListSet *set - -void (*CellSaveDataStatCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataStatGet *get, CellSaveDataStatSet *set - -void (*CellSaveDataFileCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataFileGet *get, CellSaveDataFileSet *set - -void (*CellSaveDataDoneCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataDoneGet *get - -void cellSaveData_init() -{ - cellSaveData.AddFunc(0x04c06fc2, cellSaveDataGetListItem); - cellSaveData.AddFunc(0x273d116a, cellSaveDataUserListExport); - cellSaveData.AddFunc(0x27cb8bc2, cellSaveDataListDelete); - cellSaveData.AddFunc(0x39d6ee43, cellSaveDataUserListImport); - cellSaveData.AddFunc(0x46a2d878, cellSaveDataFixedExport); - cellSaveData.AddFunc(0x491cc554, cellSaveDataListExport); - cellSaveData.AddFunc(0x52541151, cellSaveDataFixedImport); - cellSaveData.AddFunc(0x529231b0, cellSaveDataUserFixedImport); - cellSaveData.AddFunc(0x6b4e0de6, cellSaveDataListImport); - cellSaveData.AddFunc(0x7048a9ba, cellSaveDataUserListDelete); - cellSaveData.AddFunc(0x95ae2cde, cellSaveDataUserFixedExport); - cellSaveData.AddFunc(0xf6482036, cellSaveDataUserGetListItem); - cellSaveData.AddFunc(0x2de0d663, cellSaveDataListSave2); - cellSaveData.AddFunc(0x1dfbfdd6, cellSaveDataListLoad2); - cellSaveData.AddFunc(0x2aae9ef5, cellSaveDataFixedSave2); - cellSaveData.AddFunc(0x2a8eada2, cellSaveDataFixedLoad2); - cellSaveData.AddFunc(0x8b7ed64b, cellSaveDataAutoSave2); - cellSaveData.AddFunc(0xfbd5c856, cellSaveDataAutoLoad2); - cellSaveData.AddFunc(0x4dd03a4e, cellSaveDataListAutoSave); - cellSaveData.AddFunc(0x21425307, cellSaveDataListAutoLoad); - cellSaveData.AddFunc(0xedadd797, cellSaveDataDelete2); - cellSaveData.AddFunc(0x0f03cfb0, cellSaveDataUserListSave); - cellSaveData.AddFunc(0x39dd8425, cellSaveDataUserListLoad); - cellSaveData.AddFunc(0x40b34847, cellSaveDataUserFixedSave); - cellSaveData.AddFunc(0x6e7264ed, cellSaveDataUserFixedLoad); - cellSaveData.AddFunc(0x52aac4fa, cellSaveDataUserAutoSave); - cellSaveData.AddFunc(0xcdc6aefd, cellSaveDataUserAutoLoad); - cellSaveData.AddFunc(0x0e091c36, cellSaveDataUserListAutoSave); - //cellSaveData.AddFunc(0xe7fa820b, cellSaveDataEnableOverlay); -} diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index f578345de2..40141a8d91 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -4,6 +4,7 @@ #include "Emu/Audio/sysutil_audio.h" #include "cellSysutil.h" +#include "cellSysutil_SaveData.h" #include "Loader/PSF.h" @@ -885,16 +886,18 @@ int cellHddGameCheck(u32 version, u32 dirName_addr, u32 errDialog, mem_func_ptr_ return CELL_HDDGAME_ERROR_BROKEN; } - get->getParam.parentalLevel = psf.m_info.parental_lvl; - get->getParam.attribute = psf.m_info.attr; - get->getParam.resolution = psf.m_info.resolution; - get->getParam.soundFormat = psf.m_info.sound_format; - memcpy(get->getParam.title, psf.m_info.name.mb_str(), CELL_HDDGAME_SYSP_TITLE_SIZE); - memcpy(get->getParam.dataVersion, psf.m_info.app_ver.mb_str(), CELL_HDDGAME_SYSP_VERSION_SIZE); + get->getParam.parentalLevel = psf.GetInteger("PARENTAL_LEVEL"); + get->getParam.attribute = psf.GetInteger("ATTRIBUTE"); + get->getParam.resolution = psf.GetInteger("RESOLUTION"); + get->getParam.soundFormat = psf.GetInteger("SOUND_FORMAT"); + memcpy(get->getParam.title, psf.GetString("TITLE"), CELL_HDDGAME_SYSP_TITLE_SIZE); + memcpy(get->getParam.dataVersion, psf.GetString("APP_VER"), CELL_HDDGAME_SYSP_VERSION_SIZE); memcpy(get->getParam.titleId, dirName.c_str(), CELL_HDDGAME_SYSP_TITLEID_SIZE); for (u32 i=0; igetParam.titleLang[i], psf.m_info.name.mb_str(), CELL_HDDGAME_SYSP_TITLE_SIZE); // TODO: Get real titleLang name + char key [16]; + sprintf(key, "TITLE_%02d", i); + memcpy(get->getParam.titleLang[i], psf.GetString(key), CELL_HDDGAME_SYSP_TITLE_SIZE); } } @@ -947,4 +950,35 @@ void cellSysutil_init() //cellSysutil.AddFunc(0xf82e2ef7, cellHddGameGetSizeKB); //cellSysutil.AddFunc(0x9ca9ffa7, cellHddGameSetSystemVer); //cellSysutil.AddFunc(0xafd605b3, cellHddGameExitBroken); + + //cellSysutil_SaveData + //cellSysutil.AddFunc(0x04c06fc2, cellSaveDataGetListItem); + //cellSysutil.AddFunc(0x273d116a, cellSaveDataUserListExport); + //cellSysutil.AddFunc(0x27cb8bc2, cellSaveDataListDelete); + //cellSysutil.AddFunc(0x39d6ee43, cellSaveDataUserListImport); + //cellSysutil.AddFunc(0x46a2d878, cellSaveDataFixedExport); + //cellSysutil.AddFunc(0x491cc554, cellSaveDataListExport); + //cellSysutil.AddFunc(0x52541151, cellSaveDataFixedImport); + //cellSysutil.AddFunc(0x529231b0, cellSaveDataUserFixedImport); + //cellSysutil.AddFunc(0x6b4e0de6, cellSaveDataListImport); + //cellSysutil.AddFunc(0x7048a9ba, cellSaveDataUserListDelete); + //cellSysutil.AddFunc(0x95ae2cde, cellSaveDataUserFixedExport); + //cellSysutil.AddFunc(0xf6482036, cellSaveDataUserGetListItem); + cellSysutil.AddFunc(0x2de0d663, cellSaveDataListSave2); + cellSysutil.AddFunc(0x1dfbfdd6, cellSaveDataListLoad2); + //cellSysutil.AddFunc(0x2aae9ef5, cellSaveDataFixedSave2); + //cellSysutil.AddFunc(0x2a8eada2, cellSaveDataFixedLoad2); + //cellSysutil.AddFunc(0x8b7ed64b, cellSaveDataAutoSave2); + //cellSysutil.AddFunc(0xfbd5c856, cellSaveDataAutoLoad2); + //cellSysutil.AddFunc(0x4dd03a4e, cellSaveDataListAutoSave); + //cellSysutil.AddFunc(0x21425307, cellSaveDataListAutoLoad); + //cellSysutil.AddFunc(0xedadd797, cellSaveDataDelete2); + //cellSysutil.AddFunc(0x0f03cfb0, cellSaveDataUserListSave); + //cellSysutil.AddFunc(0x39dd8425, cellSaveDataUserListLoad); + //cellSysutil.AddFunc(0x40b34847, cellSaveDataUserFixedSave); + //cellSysutil.AddFunc(0x6e7264ed, cellSaveDataUserFixedLoad); + //cellSysutil.AddFunc(0x52aac4fa, cellSaveDataUserAutoSave); + //cellSysutil.AddFunc(0xcdc6aefd, cellSaveDataUserAutoLoad); + //cellSysutil.AddFunc(0x0e091c36, cellSaveDataUserListAutoSave); + //cellSysutil.AddFunc(0xe7fa820b, cellSaveDataEnableOverlay); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp new file mode 100644 index 0000000000..e885856e4c --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp @@ -0,0 +1,396 @@ +#include "stdafx.h" +#include "Emu/SysCalls/SysCalls.h" +#include "Emu/SysCalls/SC_FUNC.h" +#include + +#include "cellSysutil_SaveData.h" +#include "Loader/PSF.h" +#include "stblib/stb_image.h" + +//#include "Emu/SysCalls/Dialogs/SaveDataList.h" + +extern Module cellSysutil; + +// Auxiliary Classes +class sortSaveDataEntry +{ + u32 sortType; + u32 sortOrder; +public: + sortSaveDataEntry(u32 type, u32 order) : sortType(type), sortOrder(order) {} + bool operator()(const SaveDataListEntry& entry1, const SaveDataListEntry& entry2) const + { + if (sortOrder == CELL_SAVEDATA_SORTORDER_DESCENT) + { + if (sortType == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME) + return entry1.timestamp >= entry2.timestamp; + else //if (sortType == CELL_SAVEDATA_SORTTYPE_SUBTITLE) + return entry1.subtitle >= entry2.subtitle; + } + else //if (sortOrder == CELL_SAVEDATA_SORTORDER_ASCENT) + { + if (sortType == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME) + return entry1.timestamp < entry2.timestamp; + else //if (sortType == CELL_SAVEDATA_SORTTYPE_SUBTITLE) + return entry1.subtitle < entry2.subtitle; + } + } +}; + + +// Auxiliary Functions +u64 getSaveDataSize(const std::string& dirName) +{ + vfsDir dir(dirName); + if (!dir.IsOpened()) + return 0; + + u64 totalSize = 0; + for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) { + if (entry->flags & DirEntry_TypeFile) { + vfsFile file(dirName+"/"+entry->name); + totalSize += file.GetSize(); + } + } + return totalSize; +} + +void getSaveDataEntry(std::vector& saveEntries, const std::string& saveDir) +{ + // PSF parameters + vfsFile f(saveDir + "/PARAM.SFO"); + PSFLoader psf(f); + if(!psf.Load(false)) + return; + + // PNG icon + wxString localPath; + int width, height, actual_components; + Emu.GetVFS().GetDevice(saveDir + "/ICON0.PNG", localPath); + + SaveDataListEntry saveEntry; + saveEntry.dirName = psf.GetString("SAVEDATA_DIRECTORY"); + saveEntry.listParam = psf.GetString("SAVEDATA_LIST_PARAM"); + saveEntry.title = psf.GetString("TITLE"); + saveEntry.subtitle = psf.GetString("SUB_TITLE"); + saveEntry.details = psf.GetString("DETAIL"); + saveEntry.sizeKb = getSaveDataSize(saveDir)/1024; + saveEntry.timestamp = 0; // TODO + saveEntry.iconBuffer = stbi_load(localPath.mb_str(), &width, &height, &actual_components, 3); + + saveEntries.push_back(saveEntry); +} + + +// Functions +int cellSaveDataListSave2(u32 version, mem_ptr_t setList, mem_ptr_t setBuf, + mem_func_ptr_t funcList, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, + u32 container, u32 userdata) +{ + cellSysutil.Warning("cellSaveDataListSave2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)", + version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata); + + if (!setList.IsGood() || !setBuf.IsGood() || !funcList.IsGood() || !funcStat.IsGood() || !funcFile.IsGood()) + return CELL_SAVEDATA_ERROR_PARAM; + + MemoryAllocator result; + MemoryAllocator listGet; + MemoryAllocator listSet; + + 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 = std::string(Memory.ReadString(setList->dirNamePrefix_addr).mb_str()); + std::vector saveEntries; + for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) + { + if (entry->flags & DirEntry_TypeDir || entry->name.Left(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 + (const char*)(entry->name.mb_str()); + getSaveDataEntry(saveEntries, saveDir); + } + } + + // Sort the entries and fill the listGet->dirList array + std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); + listGet->dirList_addr = setBuf->buf_addr; + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList_addr); + for (u32 i=0; i statGet; + MemoryAllocator statSet; + funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + + MemoryAllocator fileGet; + MemoryAllocator fileSet; + funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr()); + + for (auto& entry : saveEntries) { + delete[] entry.iconBuffer; + entry.iconBuffer = nullptr; + } + + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, mem_ptr_t setBuf, + mem_func_ptr_t funcList, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, + u32 container, u32 userdata) +{ + cellSysutil.Warning("cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)", + version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata); + + if (!setList.IsGood() || !setBuf.IsGood() || !funcList.IsGood() || !funcStat.IsGood() || !funcFile.IsGood()) + return CELL_SAVEDATA_ERROR_PARAM; + + MemoryAllocator result; + MemoryAllocator listGet; + MemoryAllocator listSet; + + 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 = std::string(Memory.ReadString(setList->dirNamePrefix_addr).mb_str()); + std::vector saveEntries; + for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) + { + if (entry->flags & DirEntry_TypeDir || entry->name.Left(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 + (const char*)(entry->name.mb_str()); + getSaveDataEntry(saveEntries, saveDir); + } + } + + // Sort the entries and fill the listGet->dirList array + std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); + listGet->dirList_addr = setBuf->buf_addr; + CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList_addr); + for (u32 i=0; i statGet; + MemoryAllocator statSet; + funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); + + MemoryAllocator fileGet; + MemoryAllocator fileSet; + funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr()); + + for (auto& entry : saveEntries) { + delete[] entry.iconBuffer; + entry.iconBuffer = nullptr; + } + + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataFixedSave2(u32 version, 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); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataFixedLoad2(u32 version, 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); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataAutoSave2(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) +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +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) +{ + UNIMPLEMENTED_FUNC(cellSysutil); + 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 +{ + UNIMPLEMENTED_FUNC(cellSysutil); + 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 +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataDelete2() //sys_memory_container_t container +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_CANCEL; +} + +int cellSaveDataFixedDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserListSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserListLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserFixedSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserFixedLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserAutoSave() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserAutoLoad() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserListAutoSave() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserListAutoLoad() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserFixedDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +//void cellSaveDataEnableOverlay(); //int enable + + +// Functions (Extensions) +int cellSaveDataListDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataListImport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataListExport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataFixedImport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataFixedExport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserListDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone,sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserListImport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserListExport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserFixedImport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserFixedExport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} + +int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB +{ + UNIMPLEMENTED_FUNC(cellSysutil); + return CELL_SAVEDATA_RET_OK; +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.h b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.h new file mode 100644 index 0000000000..16cf91ca72 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.h @@ -0,0 +1,238 @@ +#pragma once + +// Return codes +enum +{ + CELL_SAVEDATA_RET_OK = 0, + CELL_SAVEDATA_RET_CANCEL = 1, + CELL_SAVEDATA_ERROR_CBRESULT = 0x8002b401, + CELL_SAVEDATA_ERROR_ACCESS_ERROR = 0x8002b402, + CELL_SAVEDATA_ERROR_INTERNAL = 0x8002b403, + CELL_SAVEDATA_ERROR_PARAM = 0x8002b404, + CELL_SAVEDATA_ERROR_NOSPACE = 0x8002b405, + CELL_SAVEDATA_ERROR_BROKEN = 0x8002b406, + CELL_SAVEDATA_ERROR_FAILURE = 0x8002b407, + CELL_SAVEDATA_ERROR_BUSY = 0x8002b408, + CELL_SAVEDATA_ERROR_NOUSER = 0x8002b409, + CELL_SAVEDATA_ERROR_SIZEOVER = 0x8002b40a, + CELL_SAVEDATA_ERROR_NODATA = 0x8002b40b, + CELL_SAVEDATA_ERROR_NOTSUPPORTED = 0x8002b40c, +}; + +// Constants +enum +{ + // CellSaveDataParamSize + CELL_SAVEDATA_DIRNAME_SIZE = 32, + CELL_SAVEDATA_FILENAME_SIZE = 13, + CELL_SAVEDATA_SECUREFILEID_SIZE = 16, + CELL_SAVEDATA_PREFIX_SIZE = 256, + CELL_SAVEDATA_LISTITEM_MAX = 2048, + CELL_SAVEDATA_SECUREFILE_MAX = 113, + CELL_SAVEDATA_DIRLIST_MAX = 2048, + CELL_SAVEDATA_INVALIDMSG_MAX = 256, + CELL_SAVEDATA_INDICATORMSG_MAX = 64, + + // CellSaveDataSystemParamSize + CELL_SAVEDATA_SYSP_TITLE_SIZE = 128, + CELL_SAVEDATA_SYSP_SUBTITLE_SIZE = 128, + CELL_SAVEDATA_SYSP_DETAIL_SIZE = 1024, + CELL_SAVEDATA_SYSP_LPARAM_SIZE = 8, + + // CellSaveDataSortType + CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME = 0, + CELL_SAVEDATA_SORTTYPE_SUBTITLE = 1, + + // CellSaveDataSortOrder + CELL_SAVEDATA_SORTORDER_DESCENT = 0, + CELL_SAVEDATA_SORTORDER_ASCENT = 1, +}; + + +// Datatypes +struct CellSaveDataSetList +{ + be_t sortType; + be_t sortOrder; + be_t dirNamePrefix_addr; // char* +}; + +struct CellSaveDataSetBuf +{ + be_t dirListMax; + be_t fileListMax; + be_t reserved[6]; + be_t bufSize; + be_t buf_addr; // void* +}; + +struct CellSaveDataNewDataIcon +{ + be_t title_addr; // char* + be_t iconBufSize; + be_t iconBuf_addr; // void* +}; + +struct CellSaveDataListNewData +{ + be_t iconPosition; + be_t dirName_addr; // char* + be_t icon_addr; // CellSaveDataNewDataIcon* +}; + +struct CellSaveDataDirList +{ + s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE]; + s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE]; +}; + +struct CellSaveDataListGet +{ + be_t dirNum; + be_t dirListNum; + be_t dirList_addr; // CellSaveDataDirList* +}; + +struct CellSaveDataListSet +{ + be_t focusPosition; + be_t focusDirName_addr; // char* + be_t fixedListNum; + be_t fixedList_addr; // CellSaveDataDirList* + be_t newData_addr; // CellSaveDataListNewData* +}; + +struct CellSaveDataFixedSet +{ + be_t dirName_addr; // char* + be_t newIcon_addr; // CellSaveDataNewDataIcon* + be_t option; +}; + +struct CellSaveDataSystemFileParam +{ + s8 title[CELL_SAVEDATA_SYSP_TITLE_SIZE]; + s8 subTitle[CELL_SAVEDATA_SYSP_SUBTITLE_SIZE]; + s8 detail[CELL_SAVEDATA_SYSP_DETAIL_SIZE]; + be_t attribute; + s8 reserved2[4]; + s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE]; + s8 reserved[256]; +}; + +struct CellSaveDataDirStat +{ + be_t st_atime_; + be_t st_mtime_; + be_t st_ctime_; + s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE]; +}; + +struct CellSaveDataFileStat +{ + be_t fileType; + u8 reserved1[4]; + be_t st_size; + be_t st_atime_; + be_t st_mtime_; + be_t st_ctime_; + u8 fileName[CELL_SAVEDATA_FILENAME_SIZE]; + u8 reserved2[3]; +}; + +struct CellSaveDataStatGet +{ + be_t hddFreeSizeKB; + be_t isNewData; + CellSaveDataDirStat dir; + CellSaveDataSystemFileParam getParam; + be_t bind; + be_t sizeKB; + be_t sysSizeKB; + be_t fileNum; + be_t fileListNum; + be_t fileList_addr; // CellSaveDataFileStat* +}; + +struct CellSaveDataAutoIndicator +{ + be_t dispPosition; + be_t dispMode; + be_t dispMsg_addr; // char* + be_t picBufSize; + be_t picBuf_addr; // void* +}; + +struct CellSaveDataStatSet +{ + be_t setParam_addr; // CellSaveDataSystemFileParam* + be_t reCreateMode; + be_t indicator_addr; // CellSaveDataAutoIndicator* +}; + +struct CellSaveDataFileGet +{ + be_t excSize; +}; + +struct CellSaveDataFileSet +{ + be_t fileOperation; + be_t reserved_addr; // void* + be_t fileType; + u8 secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE]; + be_t fileName_addr; // char* + be_t fileOffset; + be_t fileSize; + be_t fileBufSize; + be_t fileBuf_addr; // void* +}; + +struct CellSaveDataCBResult +{ + be_t result; + be_t progressBarInc; + be_t errNeedSizeKB; + be_t invalidMsg_addr; // char* + be_t userdata_addr; // void* +}; + +struct CellSaveDataDoneGet +{ + be_t excResult; + s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE]; + be_t sizeKB; + be_t hddFreeSizeKB; +}; + + +// Callback Functions +typedef void (*CellSaveDataFixedCallback)(mem_ptr_t cbResult, mem_ptr_t get, mem_ptr_t set); +typedef void (*CellSaveDataListCallback) (mem_ptr_t cbResult, mem_ptr_t get, mem_ptr_t set); +typedef void (*CellSaveDataStatCallback) (mem_ptr_t cbResult, mem_ptr_t get, mem_ptr_t set); +typedef void (*CellSaveDataFileCallback) (mem_ptr_t cbResult, mem_ptr_t get, mem_ptr_t set); +typedef void (*CellSaveDataDoneCallback) (mem_ptr_t cbResult, mem_ptr_t get); + + +// Auxiliary Structs +struct SaveDataListEntry +{ + std::string dirName; + std::string listParam; + std::string title; + std::string subtitle; + std::string details; + u32 sizeKb; + u64 timestamp; + void* iconBuffer; +}; + + +// Function declarations +int cellSaveDataListSave2(u32 version, mem_ptr_t setList, mem_ptr_t setBuf, + mem_func_ptr_t funcList, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, + u32 container, u32 userdata_addr); + +int cellSaveDataListLoad2(u32 version, mem_ptr_t setList, mem_ptr_t setBuf, + mem_func_ptr_t funcList, mem_func_ptr_t funcStat, mem_func_ptr_t funcFile, + u32 container, u32 userdata_addr); diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index a76a583acc..f37f2f1723 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -50,9 +50,10 @@ int sdata_unpack(wxString packed_file, wxString unpacked_file) char buffer [10200]; packed_stream->Read(buffer, 256); - if (re32(*(u32*)&buffer[0]) != 0x4E504400) // "NPD\x00" + u32 format = re32(*(u32*)&buffer[0]); + if (format != 0x4E504400) // "NPD\x00" { - printf("ERROR: illegal format."); + sys_fs.Error("Illegal format. Expected 0x4E504400, but got 0x%08x", format); return CELL_EFSSPECIFIC; } diff --git a/rpcs3/Emu/SysCalls/Static.cpp b/rpcs3/Emu/SysCalls/Static.cpp index d13bfa5273..073bf0dad5 100644 --- a/rpcs3/Emu/SysCalls/Static.cpp +++ b/rpcs3/Emu/SysCalls/Static.cpp @@ -9,6 +9,9 @@ void StaticAnalyse(void* ptr, u32 size, u32 base) { u32* data = (u32*)ptr; size /= 4; + if(!Ini.HLEHookStFunc.GetValue()) + return; + // TODO: optimize search for (u32 i = 0; i < size; i++) { diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Spinlock.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Spinlock.cpp index 56bad1cf88..c866677099 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Spinlock.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Spinlock.cpp @@ -44,10 +44,9 @@ void sys_spinlock_unlock(mem_ptr_t lock) { sys_spinlock.Log("sys_spinlock_unlock(lock_addr=0x%x)", lock.GetAddr()); -again: - switch (lock->mutex.unlock(lock->mutex.GetOwner())) + while(true) { - case SMR_PERMITTED: goto again; - default: break; + if (lock->mutex.unlock(lock->mutex.GetOwner()) != SMR_PERMITTED) + break; } } \ No newline at end of file diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index dbcf783118..8450c81208 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -47,7 +47,7 @@ void GameViewer::LoadGames() void GameViewer::LoadPSF() { - m_game_data.Clear(); + m_game_data.clear(); for(uint i=0; i& game_data) + void Update(std::vector& game_data) { m_col_name->data.Clear(); m_col_serial->data.Clear(); @@ -100,9 +100,8 @@ public: if(m_columns.GetCount() == 0) return; - for(uint i=0; idata.Add(game.name); m_col_serial->data.Add(game.serial); m_col_fw->data.Add(game.fw); @@ -218,7 +217,7 @@ class GameViewer : public wxListView { wxString m_path; wxArrayString m_games; - ArrayF m_game_data; + std::vector m_game_data; ColumnsArr m_columns; public: diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 269cfd0ce4..c405b9ad9d 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -313,8 +313,6 @@ void MainFrame::SendOpenCloseSysMenu(wxCommandEvent& event) void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) { - //TODO - bool paused = false; if(Emu.IsRunning()) @@ -324,54 +322,75 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) } wxDialog diag(this, wxID_ANY, "Settings", wxDefaultPosition); + static const u32 height = 400; + static const u32 width = 385; - wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL)); - wxBoxSizer* s_subpanel1(new wxBoxSizer(wxVERTICAL)); - wxBoxSizer* s_subpanel2(new wxBoxSizer(wxVERTICAL)); - wxBoxSizer* s_subpanel3(new wxBoxSizer(wxVERTICAL)); + // Settings panels + wxNotebook* nb_config = new wxNotebook(&diag, wxID_ANY, wxPoint(6,6), wxSize(width, height)); + wxPanel* p_system = new wxPanel(nb_config, wxID_ANY); + wxPanel* p_cpu = new wxPanel(nb_config, wxID_ANY); + wxPanel* p_graphics = new wxPanel(nb_config, wxID_ANY); + wxPanel* p_audio = new wxPanel(nb_config, wxID_ANY); + wxPanel* p_io = new wxPanel(nb_config, wxID_ANY); + wxPanel* p_hle = new wxPanel(nb_config, wxID_ANY); - wxStaticBoxSizer* s_round_cpu( new wxStaticBoxSizer( wxVERTICAL, &diag, _("CPU") ) ); - wxStaticBoxSizer* s_round_cpu_decoder( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Decoder") ) ); + nb_config->AddPage(p_cpu, wxT("Core")); + nb_config->AddPage(p_graphics, wxT("Graphics")); + nb_config->AddPage(p_audio, wxT("Audio")); + nb_config->AddPage(p_io, wxT("Input / Output")); + nb_config->AddPage(p_hle, wxT("HLE / Misc.")); + nb_config->AddPage(p_system, wxT("System")); - wxStaticBoxSizer* s_round_gs( new wxStaticBoxSizer( wxVERTICAL, &diag, _("GS") ) ); - wxStaticBoxSizer* s_round_gs_render( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Render") ) ); - wxStaticBoxSizer* s_round_gs_res( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Default resolution") ) ); - wxStaticBoxSizer* s_round_gs_aspect( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Default aspect ratio") ) ); + wxBoxSizer* s_subpanel_system(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel_cpu(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel_graphics(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel_audio(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel_io(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel_hle(new wxBoxSizer(wxVERTICAL)); - wxStaticBoxSizer* s_round_io( new wxStaticBoxSizer( wxVERTICAL, &diag, _("IO") ) ); - wxStaticBoxSizer* s_round_io_pad_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Pad Handler") ) ); - wxStaticBoxSizer* s_round_io_keyboard_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Keyboard Handler") ) ); - wxStaticBoxSizer* s_round_io_mouse_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Mouse Handler") ) ); + // CPU settings + wxStaticBoxSizer* s_round_cpu_decoder( new wxStaticBoxSizer( wxVERTICAL, p_cpu, _("Decoder") ) ); + + // Graphics + wxStaticBoxSizer* s_round_gs_render( new wxStaticBoxSizer( wxVERTICAL, p_graphics, _("Render") ) ); + wxStaticBoxSizer* s_round_gs_res( new wxStaticBoxSizer( wxVERTICAL, p_graphics, _("Default resolution") ) ); + wxStaticBoxSizer* s_round_gs_aspect( new wxStaticBoxSizer( wxVERTICAL, p_graphics, _("Default aspect ratio") ) ); + + // Input / Output + wxStaticBoxSizer* s_round_io_pad_handler( new wxStaticBoxSizer( wxVERTICAL, p_io, _("Pad Handler") ) ); + wxStaticBoxSizer* s_round_io_keyboard_handler( new wxStaticBoxSizer( wxVERTICAL, p_io, _("Keyboard Handler") ) ); + wxStaticBoxSizer* s_round_io_mouse_handler( new wxStaticBoxSizer( wxVERTICAL, p_io, _("Mouse Handler") ) ); - wxStaticBoxSizer* s_round_audio( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Audio") ) ); - wxStaticBoxSizer* s_round_audio_out( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Audio Out") ) ); + // Audio + wxStaticBoxSizer* s_round_audio_out( new wxStaticBoxSizer( wxVERTICAL, p_audio, _("Audio Out") ) ); - wxStaticBoxSizer* s_round_hle( new wxStaticBoxSizer( wxVERTICAL, &diag, _("HLE / Misc.") ) ); - wxStaticBoxSizer* s_round_hle_log_lvl( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Log lvl") ) ); + // HLE / Misc. + wxStaticBoxSizer* s_round_hle_log_lvl( new wxStaticBoxSizer( wxVERTICAL, p_hle, _("Log lvl") ) ); - wxStaticBoxSizer* s_round_sys( new wxStaticBoxSizer( wxVERTICAL, &diag, _("System") ) ); - wxStaticBoxSizer* s_round_sys_lang( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Language") ) ); + // System + wxStaticBoxSizer* s_round_sys_lang( new wxStaticBoxSizer( wxVERTICAL, p_system, _("Language") ) ); - wxComboBox* cbox_cpu_decoder = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_gs_render = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_gs_resolution = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_gs_aspect = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_pad_handler = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_keyboard_handler = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_mouse_handler = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_audio_out = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_hle_loglvl = new wxComboBox(&diag, wxID_ANY); - wxComboBox* cbox_sys_lang = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_cpu_decoder = new wxComboBox(p_cpu, wxID_ANY); + wxComboBox* cbox_gs_render = new wxComboBox(p_graphics, wxID_ANY); + wxComboBox* cbox_gs_resolution = new wxComboBox(p_graphics, wxID_ANY); + wxComboBox* cbox_gs_aspect = new wxComboBox(p_graphics, wxID_ANY); + wxComboBox* cbox_pad_handler = new wxComboBox(p_io, wxID_ANY); + wxComboBox* cbox_keyboard_handler = new wxComboBox(p_io, wxID_ANY); + wxComboBox* cbox_mouse_handler = new wxComboBox(p_io, wxID_ANY); + wxComboBox* cbox_audio_out = new wxComboBox(p_audio, wxID_ANY); + wxComboBox* cbox_hle_loglvl = new wxComboBox(p_hle, wxID_ANY); + wxComboBox* cbox_sys_lang = new wxComboBox(p_system, wxID_ANY); - wxCheckBox* chbox_cpu_ignore_rwerrors = new wxCheckBox(&diag, wxID_ANY, "Ignore Read/Write errors"); - wxCheckBox* chbox_gs_log_prog = new wxCheckBox(&diag, wxID_ANY, "Log vertex/fragment programs"); - wxCheckBox* chbox_gs_dump_depth = new wxCheckBox(&diag, wxID_ANY, "Write Depth Buffer"); - wxCheckBox* chbox_gs_dump_color = new wxCheckBox(&diag, wxID_ANY, "Write Color Buffers"); - wxCheckBox* chbox_gs_vsync = new wxCheckBox(&diag, wxID_ANY, "VSync"); - wxCheckBox* chbox_audio_dump = new wxCheckBox(&diag, wxID_ANY, "Dump to file"); - wxCheckBox* chbox_hle_logging = new wxCheckBox(&diag, wxID_ANY, "Log all SysCalls"); - wxCheckBox* chbox_hle_savetty = new wxCheckBox(&diag, wxID_ANY, "Save TTY output to file"); - wxCheckBox* chbox_hle_exitonstop = new wxCheckBox(&diag, wxID_ANY, "Exit RPCS3 when process finishes"); + wxCheckBox* chbox_cpu_ignore_rwerrors = new wxCheckBox(p_cpu, wxID_ANY, "Ignore Read/Write errors"); + wxCheckBox* chbox_gs_log_prog = new wxCheckBox(p_graphics, wxID_ANY, "Log vertex/fragment programs"); + wxCheckBox* chbox_gs_dump_depth = new wxCheckBox(p_graphics, wxID_ANY, "Write Depth Buffer"); + wxCheckBox* chbox_gs_dump_color = new wxCheckBox(p_graphics, wxID_ANY, "Write Color Buffers"); + wxCheckBox* chbox_gs_vsync = new wxCheckBox(p_graphics, wxID_ANY, "VSync"); + wxCheckBox* chbox_audio_dump = new wxCheckBox(p_audio, wxID_ANY, "Dump to file"); + wxCheckBox* chbox_hle_logging = new wxCheckBox(p_hle, wxID_ANY, "Log all SysCalls"); + wxCheckBox* chbox_hle_hook_stfunc = new wxCheckBox(p_hle, wxID_ANY, "Hook static functions"); + wxCheckBox* chbox_hle_savetty = new wxCheckBox(p_hle, wxID_ANY, "Save TTY output to file"); + wxCheckBox* chbox_hle_exitonstop = new wxCheckBox(p_hle, wxID_ANY, "Exit RPCS3 when process finishes"); //cbox_cpu_decoder->Append("DisAsm"); cbox_cpu_decoder->Append("Interpreter & DisAsm"); @@ -429,6 +448,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) cbox_sys_lang->Append("Polish"); cbox_sys_lang->Append("English (UK)"); + + // Get values from .ini chbox_cpu_ignore_rwerrors->SetValue(Ini.CPUIgnoreRWErrors.GetValue()); chbox_gs_log_prog->SetValue(Ini.GSLogPrograms.GetValue()); chbox_gs_dump_depth->SetValue(Ini.GSDumpDepthBuffer.GetValue()); @@ -436,13 +457,10 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) chbox_gs_vsync->SetValue(Ini.GSVSyncEnable.GetValue()); chbox_audio_dump->SetValue(Ini.AudioDumpToFile.GetValue()); chbox_hle_logging->SetValue(Ini.HLELogging.GetValue()); + chbox_hle_hook_stfunc->SetValue(Ini.HLEHookStFunc.GetValue()); chbox_hle_savetty->SetValue(Ini.HLESaveTTY.GetValue()); chbox_hle_exitonstop->SetValue(Ini.HLEExitOnStop.GetValue()); - chbox_audio_dump->Enable(Emu.IsStopped()); - //cbox_audio_out->Enable(Emu.IsStopped()); - chbox_hle_logging->Enable(Emu.IsStopped()); - cbox_cpu_decoder->SetSelection(Ini.CPUDecoderMode.GetValue() ? Ini.CPUDecoderMode.GetValue() - 1 : 0); cbox_gs_render->SetSelection(Ini.GSRenderMode.GetValue()); cbox_gs_resolution->SetSelection(ResolutionIdToNum(Ini.GSResolution.GetValue()) - 1); @@ -453,63 +471,78 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) cbox_audio_out->SetSelection(Ini.AudioOutMode.GetValue()); cbox_hle_loglvl->SetSelection(Ini.HLELogLvl.GetValue()); cbox_sys_lang->SetSelection(Ini.SysLanguage.GetValue()); + + + // Enable / Disable parameters + chbox_audio_dump->Enable(Emu.IsStopped()); + chbox_hle_logging->Enable(Emu.IsStopped()); + chbox_hle_hook_stfunc->Enable(Emu.IsStopped()); + s_round_cpu_decoder->Add(cbox_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_cpu->Add(s_round_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_cpu->Add(chbox_cpu_ignore_rwerrors, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_gs_render->Add(cbox_gs_render, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_gs_res->Add(cbox_gs_resolution, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_gs_aspect->Add(cbox_gs_aspect, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_gs->Add(s_round_gs_render, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_gs->Add(s_round_gs_res, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_gs->Add(s_round_gs_aspect, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_gs->Add(chbox_gs_log_prog, wxSizerFlags().Border(wxALL, 5)); - s_round_gs->Add(chbox_gs_dump_depth, wxSizerFlags().Border(wxALL, 5)); - s_round_gs->Add(chbox_gs_dump_color, wxSizerFlags().Border(wxALL, 5)); - s_round_gs->Add(chbox_gs_vsync, wxSizerFlags().Border(wxALL, 5)); s_round_io_pad_handler->Add(cbox_pad_handler, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_io_keyboard_handler->Add(cbox_keyboard_handler, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_io_mouse_handler->Add(cbox_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_io->Add(s_round_io_pad_handler, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_io->Add(s_round_io_keyboard_handler, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_io->Add(s_round_io_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_audio_out->Add(cbox_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_audio_out->Add(chbox_audio_dump, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_audio->Add(s_round_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_hle_log_lvl->Add(cbox_hle_loglvl, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_hle->Add(s_round_hle_log_lvl, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_hle->Add(chbox_hle_logging, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_hle->Add(chbox_hle_savetty, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_hle->Add(chbox_hle_exitonstop, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_sys_lang->Add(cbox_sys_lang, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_sys->Add(s_round_sys_lang, wxSizerFlags().Border(wxALL, 5).Expand()); - wxBoxSizer* s_b_panel(new wxBoxSizer(wxHORIZONTAL)); + // Core + s_subpanel_cpu->Add(s_round_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_cpu->Add(chbox_cpu_ignore_rwerrors, wxSizerFlags().Border(wxALL, 5).Expand()); - s_b_panel->Add(new wxButton(&diag, wxID_OK), wxSizerFlags().Border(wxALL, 5).Center()); - s_b_panel->Add(new wxButton(&diag, wxID_CANCEL), wxSizerFlags().Border(wxALL, 5).Center()); + // Graphics + s_subpanel_graphics->Add(s_round_gs_render, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_graphics->Add(s_round_gs_res, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_graphics->Add(s_round_gs_aspect, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_graphics->Add(chbox_gs_log_prog, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_graphics->Add(chbox_gs_dump_depth, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_graphics->Add(chbox_gs_dump_color, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_graphics->Add(chbox_gs_vsync, wxSizerFlags().Border(wxALL, 5).Expand()); - //wxBoxSizer* s_conf_panel(new wxBoxSizer(wxHORIZONTAL)); + // Input - Output + s_subpanel_io->Add(s_round_io_pad_handler, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_io->Add(s_round_io_keyboard_handler, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_io->Add(s_round_io_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand()); - s_subpanel1->Add(s_round_cpu, wxSizerFlags().Border(wxALL, 5).Expand()); - s_subpanel1->Add(s_round_gs, wxSizerFlags().Border(wxALL, 5).Expand()); - s_subpanel1->Add(s_b_panel, wxSizerFlags().Border(wxALL, 8).Expand()); - s_subpanel2->Add(s_round_io, wxSizerFlags().Border(wxALL, 5).Expand()); - s_subpanel2->Add(s_round_audio, wxSizerFlags().Border(wxALL, 5).Expand()); - s_subpanel2->Add(s_round_hle, wxSizerFlags().Border(wxALL, 5).Expand()); - s_subpanel3->Add(s_round_sys, wxSizerFlags().Border(wxALL, 5).Expand()); + // Audio + s_subpanel_audio->Add(s_round_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_audio->Add(chbox_audio_dump, wxSizerFlags().Border(wxALL, 5).Expand()); - s_panel->Add(s_subpanel1, wxSizerFlags().Border(wxALL, 5).Expand()); - s_panel->Add(s_subpanel2, wxSizerFlags().Border(wxALL, 5).Expand()); - s_panel->Add(s_subpanel3, wxSizerFlags().Border(wxALL, 5).Expand()); + // HLE / Misc. + s_subpanel_hle->Add(s_round_hle_log_lvl, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_hle->Add(chbox_hle_logging, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_hle->Add(chbox_hle_hook_stfunc, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_hle->Add(chbox_hle_savetty, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_hle->Add(chbox_hle_exitonstop, wxSizerFlags().Border(wxALL, 5).Expand()); - diag.SetSizerAndFit( s_panel ); + // System + s_subpanel_system->Add(s_round_sys_lang, wxSizerFlags().Border(wxALL, 5).Expand()); + // Buttons + wxBoxSizer* s_b_panel(new wxBoxSizer(wxHORIZONTAL)); + s_b_panel->Add(new wxButton(&diag, wxID_OK), wxSizerFlags().Border(wxALL, 5).Bottom()); + s_b_panel->Add(new wxButton(&diag, wxID_CANCEL), wxSizerFlags().Border(wxALL, 5).Bottom()); + + // Resize panels + diag.SetSizerAndFit(s_subpanel_cpu, false); + diag.SetSizerAndFit(s_subpanel_graphics, false); + diag.SetSizerAndFit(s_subpanel_io, false); + diag.SetSizerAndFit(s_subpanel_audio, false); + diag.SetSizerAndFit(s_subpanel_hle, false); + diag.SetSizerAndFit(s_subpanel_system, false); + diag.SetSizerAndFit(s_b_panel, false); + + diag.SetSize(width+26, height+80); + if(diag.ShowModal() == wxID_OK) { Ini.CPUDecoderMode.SetValue(cbox_cpu_decoder->GetSelection() + 1); @@ -527,6 +560,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) Ini.AudioOutMode.SetValue(cbox_audio_out->GetSelection()); Ini.AudioDumpToFile.SetValue(chbox_audio_dump->GetValue()); Ini.HLELogging.SetValue(chbox_hle_logging->GetValue()); + Ini.HLEHookStFunc.SetValue(chbox_hle_hook_stfunc->GetValue()); Ini.HLESaveTTY.SetValue(chbox_hle_savetty->GetValue()); Ini.HLEExitOnStop.SetValue(chbox_hle_exitonstop->GetValue()); Ini.HLELogLvl.SetValue(cbox_hle_loglvl->GetSelection()); diff --git a/rpcs3/Gui/VFSManager.cpp b/rpcs3/Gui/VFSManager.cpp index 9b61daf0c5..594063645a 100644 --- a/rpcs3/Gui/VFSManager.cpp +++ b/rpcs3/Gui/VFSManager.cpp @@ -2,15 +2,15 @@ #include "VFSManager.h" VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry& entry) - : wxDialog(parent, wxID_ANY, "Mount configuration", wxDefaultPosition) + : wxDialog(parent, wxID_ANY, "Mount configuration") , m_entry(entry) { - m_tctrl_dev_path = new wxTextCtrl(this, wxID_ANY); - m_btn_select_dev_path = new wxButton(this, wxID_ANY, "..."); - m_tctrl_path = new wxTextCtrl(this, wxID_ANY); - m_btn_select_path = new wxButton(this, wxID_ANY, "..."); - m_tctrl_mount = new wxTextCtrl(this, wxID_ANY); - m_ch_type = new wxChoice(this, wxID_ANY); + m_tctrl_dev_path = new wxTextCtrl(this, wxID_ANY); + m_btn_select_dev_path = new wxButton(this, wxID_ANY, "..."); + m_tctrl_path = new wxTextCtrl(this, wxID_ANY); + m_btn_select_path = new wxButton(this, wxID_ANY, "..."); + m_tctrl_mount = new wxTextCtrl(this, wxID_ANY); + m_ch_type = new wxChoice(this, wxID_ANY); wxBoxSizer& s_type(*new wxBoxSizer(wxHORIZONTAL)); s_type.Add(m_ch_type, 1, wxEXPAND); @@ -48,10 +48,10 @@ VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry m_ch_type->Append(i); } - Connect(m_ch_type->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectType)); - Connect(m_btn_select_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectPath)); - Connect(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath)); - Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk)); + Connect(m_ch_type->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectType)); + Connect(m_btn_select_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectPath)); + Connect(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath)); + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk)); m_tctrl_dev_path->SetValue(m_entry.device_path); m_tctrl_path->SetValue(m_entry.path); @@ -111,7 +111,7 @@ enum }; VFSManagerDialog::VFSManagerDialog(wxWindow* parent) - : wxDialog(parent, wxID_ANY, "Virtual File System Manager", wxDefaultPosition) + : wxDialog(parent, wxID_ANY, "Virtual File System Manager") { m_list = new wxListView(this); @@ -126,11 +126,11 @@ VFSManagerDialog::VFSManagerDialog(wxWindow* parent) m_list->InsertColumn(2, "Path to Device"); m_list->InsertColumn(3, "Device"); - Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); - Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VFSManagerDialog::OnRightClick)); - Connect(id_add, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnAdd)); - Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnRemove)); - Connect(id_config, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); + Connect(m_list->GetId(), wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); + Connect(m_list->GetId(), wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(VFSManagerDialog::OnRightClick)); + Connect(id_add, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnAdd)); + Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnRemove)); + Connect(id_config, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VFSManagerDialog::OnEntryConfig)); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VFSManagerDialog::OnClose)); LoadEntries(); @@ -141,7 +141,7 @@ void VFSManagerDialog::UpdateList() { m_list->Freeze(); m_list->DeleteAllItems(); - for(uint i=0; iInsertItem(i, m_entries[i].mount); m_list->SetItem(i, 1, m_entries[i].path); @@ -171,18 +171,19 @@ void VFSManagerDialog::OnRightClick(wxCommandEvent& event) int idx = m_list->GetFirstSelected(); menu->Append(id_add, "Add"); - menu->Append(id_remove, "Remove")->Enable(idx != wxNOT_FOUND); + menu->Append(id_remove, "Remove")->Enable(idx != wxNOT_FOUND); menu->AppendSeparator(); - menu->Append(id_config, "Config")->Enable(idx != wxNOT_FOUND); + menu->Append(id_config, "Config")->Enable(idx != wxNOT_FOUND); PopupMenu( menu ); } void VFSManagerDialog::OnAdd(wxCommandEvent& event) { - u32 idx = m_entries.Move(new VFSManagerEntry()); + m_entries.emplace_back(VFSManagerEntry()); UpdateList(); + u32 idx = m_entries.size() - 1; for(int i=0; iGetItemCount(); ++i) { m_list->SetItemState(i, i == idx ? wxLIST_STATE_SELECTED : ~wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); @@ -196,7 +197,7 @@ void VFSManagerDialog::OnRemove(wxCommandEvent& event) { for(int sel = m_list->GetNextSelected(-1), offs = 0; sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel), --offs) { - m_entries.RemoveAt(sel + offs); + m_entries.erase(m_entries.begin() + (sel + offs)); } UpdateList(); @@ -210,7 +211,7 @@ void VFSManagerDialog::OnClose(wxCloseEvent& event) void VFSManagerDialog::LoadEntries() { - m_entries.Clear(); + m_entries.clear(); Emu.GetVFS().SaveLoadDevices(m_entries, true); } diff --git a/rpcs3/Gui/VFSManager.h b/rpcs3/Gui/VFSManager.h index e46f4911af..a14358ae42 100644 --- a/rpcs3/Gui/VFSManager.h +++ b/rpcs3/Gui/VFSManager.h @@ -21,7 +21,7 @@ public: class VFSManagerDialog : public wxDialog { wxListView* m_list; - Array m_entries; + std::vector m_entries; public: VFSManagerDialog(wxWindow* parent); diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index 2bef4ef0d2..d8f7e55f9c 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -107,6 +107,7 @@ public: IniEntry AudioOutMode; IniEntry AudioDumpToFile; IniEntry HLELogging; + IniEntry HLEHookStFunc; IniEntry HLESaveTTY; IniEntry HLEExitOnStop; IniEntry HLELogLvl; @@ -176,6 +177,7 @@ public: path = DefPath + "/" + "HLE"; HLELogging.Init("HLELogging", path); + HLEHookStFunc.Init("HLEHookStFunc", path); HLESaveTTY.Init("HLESaveTTY", path); HLEExitOnStop.Init("HLEExitOnStop", path); HLELogLvl.Init("HLELogLvl", path); @@ -201,6 +203,7 @@ public: AudioOutMode.Load(1); AudioDumpToFile.Load(0); HLELogging.Load(false); + HLEHookStFunc.Load(false); HLESaveTTY.Load(false); HLEExitOnStop.Load(false); HLELogLvl.Load(0); @@ -241,6 +244,7 @@ public: AudioOutMode.Save(); AudioDumpToFile.Save(); HLELogging.Save(); + HLEHookStFunc.Save(); HLESaveTTY.Save(); HLEExitOnStop.Save(); HLELogLvl.Save(); diff --git a/rpcs3/Loader/PSF.cpp b/rpcs3/Loader/PSF.cpp index efe900fc2b..83053cc942 100644 --- a/rpcs3/Loader/PSF.cpp +++ b/rpcs3/Loader/PSF.cpp @@ -5,12 +5,12 @@ PSFLoader::PSFLoader(vfsStream& f) : psf_f(f) { } -PsfEntry* PSFLoader::SearchEntry(const std::string& key) +PSFEntry* PSFLoader::SearchEntry(const std::string& key) { - for(uint i=0; iFormat(); - if(PsfEntry* entry = SearchEntry("TITLE")) m_info.name = entry->Format(); - if(PsfEntry* entry = SearchEntry("APP_VER")) m_info.app_ver = entry->Format(); - if(PsfEntry* entry = SearchEntry("CATEGORY")) m_info.category = entry->Format(); - if(PsfEntry* entry = SearchEntry("PS3_SYSTEM_VER")) m_info.fw = entry->Format(); - if(PsfEntry* entry = SearchEntry("SOUND_FORMAT")) m_info.sound_format = entry->FormatInteger(); - if(PsfEntry* entry = SearchEntry("RESOLUTION")) m_info.resolution = entry->FormatInteger(); - if(PsfEntry* entry = SearchEntry("PARENTAL_LEVEL")) m_info.parental_lvl = entry->FormatInteger(); - - - if(m_info.serial.Length() == 9) - { - m_info.serial = m_info.serial(0, 4) + "-" + m_info.serial(4, 5); - } - return true; } + +const char* PSFLoader::GetString(const std::string& key) +{ + if(PSFEntry* entry = SearchEntry(key)) + return entry->FormatString(); + else + return ""; +} + +u32 PSFLoader::GetInteger(const std::string& key) +{ + if(PSFEntry* entry = SearchEntry(key)) + return entry->FormatInteger(); + else + return 0; +} diff --git a/rpcs3/Loader/PSF.h b/rpcs3/Loader/PSF.h index b8eca706cc..8b2cb799f3 100644 --- a/rpcs3/Loader/PSF.h +++ b/rpcs3/Loader/PSF.h @@ -1,7 +1,7 @@ #pragma once #include "Loader.h" -struct PsfHeader +struct PSFHeader { u32 psf_magic; u32 psf_version; @@ -12,7 +12,7 @@ struct PsfHeader bool CheckMagic() const { return psf_magic == *(u32*)"\0PSF"; } }; -struct PsfDefTbl +struct PSFDefTbl { u16 psf_key_table_offset; u16 psf_param_fmt; @@ -21,23 +21,22 @@ struct PsfDefTbl u32 psf_data_tbl_offset; }; -struct PsfEntry +struct PSFEntry { char name[128]; u16 fmt; char param[4096]; - std::string Format() const + const char* FormatString() const { switch(fmt) { default: case 0x0400: case 0x0402: - return FormatString(); - + return (const char*)param; case 0x0404: - return wxString::Format("0x%x", FormatInteger()).ToStdString(); + return (const char*)wxString::Format("0x%x", FormatInteger()).mb_str(); } } @@ -45,34 +44,27 @@ struct PsfEntry { return *(u32*)param; } - - char* FormatString() const - { - return (char*)param; - } }; class PSFLoader { vfsStream& psf_f; + + PSFHeader m_header; + std::vector m_psfindxs; + std::vector m_entries; bool m_show_log; + bool LoadHeader(); + bool LoadKeyTable(); + bool LoadDataTable(); + public: PSFLoader(vfsStream& f); - - Array m_entries; - - PsfEntry* SearchEntry(const std::string& key); - - //wxArrayString m_table; - GameInfo m_info; - PsfHeader psfhdr; - Array m_psfindxs; virtual bool Load(bool show = true); virtual bool Close(); -private: - bool LoadHdr(); - bool LoadKeyTable(); - bool LoadDataTable(); + PSFEntry* SearchEntry(const std::string& key); + const char* GetString(const std::string& key); + u32 GetInteger(const std::string& key); }; \ No newline at end of file diff --git a/rpcs3/Loader/TROPUSR.cpp b/rpcs3/Loader/TROPUSR.cpp index fc5a8fd0d3..03483701e9 100644 --- a/rpcs3/Loader/TROPUSR.cpp +++ b/rpcs3/Loader/TROPUSR.cpp @@ -19,6 +19,7 @@ bool TROPUSRLoader::Load(const std::string& filepath, const std::string& configp if (m_file) Close(); + // TODO: This seems to be always true... A bug in ExistsFile() ? if (!Emu.GetVFS().ExistsFile(filepath)) Generate(filepath, configpath); diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index 5d0c941318..b58fd00f5e 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -7,6 +7,10 @@ #include #endif +#ifdef __UNIX__ +#include +#endif + const wxEventType wxEVT_DBG_COMMAND = wxNewEventType(); IMPLEMENT_APP(Rpcs3App) @@ -66,6 +70,12 @@ void Rpcs3App::SendDbgCommand(DbgCommand id, CPUThread* thr) AddPendingEvent(event); } +Rpcs3App::Rpcs3App() +{ + #ifdef __UNIX__ + XInitThreads(); + #endif +} /* CPUThread& GetCPU(const u8 core) { diff --git a/rpcs3/rpcs3.h b/rpcs3/rpcs3.h index 3a247b5bec..d68d3d03d5 100644 --- a/rpcs3/rpcs3.h +++ b/rpcs3/rpcs3.h @@ -58,6 +58,8 @@ public: virtual void OnArguments(); // Handle arguments: Rpcs3App::argc, Rpcs3App::argv virtual void Exit(); + Rpcs3App(); + void SendDbgCommand(DbgCommand id, CPUThread* thr=nullptr); }; diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 383acdad94..2ae058702f 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -301,12 +301,12 @@ - + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 01ebc7bc58..9450c462e2 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -472,10 +472,10 @@ Loader - + Emu\SysCalls\Modules - + Emu\SysCalls\Modules diff --git a/rpcs3/rpcs3qt/glviewer.cpp b/rpcs3/rpcs3qt/glviewer.cpp index 48106fbeba..22128e5c72 100644 --- a/rpcs3/rpcs3qt/glviewer.cpp +++ b/rpcs3/rpcs3qt/glviewer.cpp @@ -83,8 +83,6 @@ QSGNode* GLViewer::updatePaintNode(QSGNode* node, UpdatePaintNodeData* data) void GLViewer::cleanup() { this->killTimer(m_timerID); m_timerID = 0; - if (m_fbo) { - delete m_fbo; - m_fbo = 0; - } + delete m_fbo; + m_fbo = nullptr; }