diff --git a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp index e74e741a95..2f236bdd37 100644 --- a/rpcs3/Emu/Cell/PPUProgramCompiler.cpp +++ b/rpcs3/Emu/Cell/PPUProgramCompiler.cpp @@ -12,7 +12,7 @@ InstrBase* GetInstruction(T* list, const std::string& str) if(instr) { - if(instr->GetName().compare(str) == 0) + if(instr->GetName() == str) { return instr; } @@ -59,7 +59,7 @@ s64 FindOp(const std::string& text, const std::string& op, s64 from) return -1; } -ArrayF sections_list; +std::vector sections_list; u32 section_name_offs = 0; u32 section_offs = 0; @@ -68,7 +68,8 @@ SectionInfo::SectionInfo(const std::string& _name) name = _name; memset(&shdr, 0, sizeof(Elf64_Shdr)); - section_num = sections_list.Add(this); + sections_list.push_back(this); + section_num = sections_list.size() - 1; shdr.sh_offset = section_offs; shdr.sh_name = section_name_offs; @@ -81,37 +82,37 @@ void SectionInfo::SetDataSize(u32 size, u32 align) if(align) shdr.sh_addralign = align; if(shdr.sh_addralign) size = Memory.AlignAddr(size, shdr.sh_addralign); - if(code.GetCount()) + if(!code.empty()) { - for(u32 i=section_num + 1; ishdr.sh_offset -= code.size(); } - section_offs -= code.GetCount(); + section_offs -= code.size(); } - code.SetCount(size); + code.resize(size); section_offs += size; - for(u32 i=section_num + 1; ishdr.sh_offset += size; } } SectionInfo::~SectionInfo() { - sections_list.RemoveFAt(section_num); + sections_list.erase(sections_list.begin() + section_num); - for(u32 i=section_num + 1; ishdr.sh_offset -= code.size(); + sections_list[i]->shdr.sh_name -= name.length(); } - section_offs -= code.GetCount(); + section_offs -= code.size(); section_name_offs -= name.length(); } @@ -371,9 +372,9 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) if(str.length() > 1) { - for(u32 i=0; i= 32) { @@ -417,7 +417,7 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) return; } - switch((char)str[0]) + switch(str[0]) { case 'r': arg.type = ARG_REG_R; break; case 'f': arg.type = ARG_REG_F; break; @@ -426,8 +426,9 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) } arg.value = reg; + } return; - + case 'c': if(str.length() > 2 && str[1] == 'r') { @@ -475,7 +476,8 @@ void CompilePPUProgram::DetectArgInfo(Arg& arg) return; } - if(str.length() > 2 && str.substr(0, 2).compare("0x") == 0) + // Hex numbers + if(str.length() > 2 && str.substr(0, 2) == "0x") { for(u32 i=2; i 0; + m_end_args = m_args.size() > 0; } -u32 CompilePPUProgram::GetBranchValue(const std::string& branch) +u32 CompilePPUProgram::GetBranchValue(const std::string& branch_name) { - for(u32 i=0; i= 0) return m_text_addr + m_branches[i].m_pos * 4; - return m_branches[i].m_addr; + if(branch.m_pos >= 0) + return m_text_addr + branch.m_pos * 4; + + return branch.m_addr; } return 0; @@ -548,7 +547,7 @@ bool CompilePPUProgram::SetNextArgType(u32 types, bool show_err) { if(m_error) return false; - if(m_cur_arg >= m_args.GetCount()) + if(m_cur_arg >= m_args.size()) { if(show_err) { @@ -581,7 +580,7 @@ bool CompilePPUProgram::SetNextArgBranch(u8 aa, bool show_err) const u32 pos = m_cur_arg; const bool ret = SetNextArgType(ARG_BRANCH | ARG_IMM, show_err); - if(!aa && pos < m_args.GetCount()) + if(!aa && pos < m_args.size()) { switch(m_args[pos].type) { @@ -665,11 +664,12 @@ bool CompilePPUProgram::IsSpOp(const std::string& op) CompilePPUProgram::Branch& CompilePPUProgram::GetBranch(const std::string& name) { - for(u32 i=0; iClear(); } - m_code.Clear(); - - for(u32 i=0; i m_imports; + std::vector m_imports; Module(const std::string& name, u32 import) : m_name(name) { @@ -1024,17 +1021,17 @@ void CompilePPUProgram::Compile() void Add(u32 import) { - m_imports.AddCpy(import); + m_imports.push_back(import); } void Clear() { m_name.clear(); - m_imports.Clear(); + m_imports.clear(); } }; - Array modules; + std::vector modules; FirstChar(); while(!IsEnd()) @@ -1049,9 +1046,9 @@ void CompilePPUProgram::Compile() while(p > 0 && m_asm[(size_t)p] != '[') p--; p++; - std::string module, name, id; + std::string module_name, name, id; - if(!GetArg(module)) + if(!GetArg(module_name)) { WriteError("module not found. style: [module, name, id]"); m_error = true; @@ -1059,7 +1056,7 @@ void CompilePPUProgram::Compile() continue; } - Arg a_module(module); + Arg a_module(module_name); DetectArgInfo(a_module); if(~ARG_ERR & a_module.type) @@ -1118,26 +1115,28 @@ void CompilePPUProgram::Compile() if(!CheckEnd()) continue; - m_branches.Move(new Branch(name, a_id.value, 0)); //TODO: HACK: new and free() mixed - const u32 import = m_branches.GetCount() - 1; + m_branches.emplace_back(name, a_id.value, 0); + const u32 import = m_branches.size() - 1; bool founded = false; - for(u32 i=0; i args; - args.SetCount(m_args.GetCount()); + args.SetCount(m_args.size()); for(uint i=0; iThaw(); diff --git a/rpcs3/Emu/Cell/PPUProgramCompiler.h b/rpcs3/Emu/Cell/PPUProgramCompiler.h index 2581754c78..6312331876 100644 --- a/rpcs3/Emu/Cell/PPUProgramCompiler.h +++ b/rpcs3/Emu/Cell/PPUProgramCompiler.h @@ -1,20 +1,21 @@ #pragma once +#include #include "PPUInstrTable.h" #include "Loader/ELF64.h" enum ArgType { - ARG_ERR = 0, - ARG_NUM = 1 << 0, - ARG_NUM16 = 1 << 1, - ARG_TXT = 1 << 2, - ARG_REG_R = 1 << 3, - ARG_REG_F = 1 << 4, - ARG_REG_V = 1 << 5, - ARG_REG_CR = 1 << 6, - ARG_BRANCH = 1 << 7, - ARG_INSTR = 1 << 8, - ARG_IMM = ARG_NUM | ARG_NUM16 | ARG_BRANCH, + ARG_ERR = 0, + ARG_NUM = 1 << 0, + ARG_NUM16 = 1 << 1, + ARG_TXT = 1 << 2, + ARG_REG_R = 1 << 3, + ARG_REG_F = 1 << 4, + ARG_REG_V = 1 << 5, + ARG_REG_CR = 1 << 6, + ARG_BRANCH = 1 << 7, + ARG_INSTR = 1 << 8, + ARG_IMM = ARG_NUM | ARG_NUM16 | ARG_BRANCH, }; struct Arg @@ -35,7 +36,7 @@ struct SectionInfo { Elf64_Shdr shdr; std::string name; - Array code; + std::vector code; u32 section_num; SectionInfo(const std::string& name); @@ -46,14 +47,13 @@ struct SectionInfo struct ProgramInfo { - Array code; + std::vector code; Elf64_Phdr phdr; bool is_preload; ProgramInfo() { is_preload = false; - code.Clear(); memset(&phdr, 0, sizeof(Elf64_Phdr)); } }; @@ -92,9 +92,9 @@ class CompilePPUProgram wxTextCtrl* m_hex_list; wxTextCtrl* m_err_list; bool m_error; - Array m_code; + std::vector m_code; bool m_end_args; - Array m_branches; + std::vector m_branches; s32 m_branch_pos; u32 m_text_addr; std::string m_file_path; @@ -111,8 +111,8 @@ class CompilePPUProgram } }; - Array m_sp_string; - Array m_args; + std::vector m_sp_string; + std::vector m_args; u32 m_cur_arg; public: diff --git a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp index 65d86ffd58..6b5addd742 100644 --- a/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLFragmentProgram.cpp @@ -290,8 +290,8 @@ void GLFragmentDecompilerThread::Task() //case 0x12: break; // KIL //case 0x13: break; // PK4 //case 0x14: break; // UP4 - case 0x15: AddCode("ddx(" + GetSRC(src0) + ")"); break; // DDX - case 0x16: AddCode("ddy(" + GetSRC(src0) + ")"); break; // DDY + case 0x15: AddCode("dFdx(" + GetSRC(src0) + ")"); break; // DDX + case 0x16: AddCode("dFdy(" + GetSRC(src0) + ")"); break; // DDY case 0x17: AddCode("texture(" + AddTex() + ", " + GetSRC(src0) + ".xy)"); break; //TEX //case 0x18: break; // TXP //case 0x19: break; // TXD diff --git a/rpcs3/Emu/GS/sysutil_video.h b/rpcs3/Emu/GS/sysutil_video.h index 630106116e..fe70b1a0ef 100644 --- a/rpcs3/Emu/GS/sysutil_video.h +++ b/rpcs3/Emu/GS/sysutil_video.h @@ -137,9 +137,9 @@ struct CellVideoOutColorInfo struct CellVideoOutKSVList { - u8 ksv[32*5]; - u8 reserved[4]; - u32 count; + u8 ksv[32*5]; + u8 reserved[4]; + u32 count; }; enum CellVideoOutDisplayConversion @@ -165,8 +165,8 @@ struct CellVideoOutDisplayMode struct CellVideoOutResolution { - u16 width; - u16 height; + be_t width; + be_t height; }; struct CellVideoOutDeviceInfo diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index ea68e5b871..08af230f60 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -101,7 +101,7 @@ u32 cellGcmGetDefaultSegmentWordSize() return 0x100; } -int cellGcmInitDefaultFifoMode(int mode) +int cellGcmInitDefaultFifoMode(s32 mode) { cellGcmSys.Warning("cellGcmInitDefaultFifoMode(mode=%d)", mode); return CELL_OK; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index b86104187c..ec8d9c6d41 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -23,6 +23,8 @@ int cellGifDecExtCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam, u int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_ptr_t src, mem_ptr_t openInfo) { + if (!subHandle.IsGood() || !src.IsGood()) + return CELL_GIFDEC_ERROR_ARG; /* vfsStream* stream; @@ -73,6 +75,9 @@ int cellGifDecOpen(u32 mainHandle, mem32_t subHandle, const mem_ptr_t info) { + if (!info.IsGood()) + return CELL_GIFDEC_ERROR_ARG; + CellGifDecSubHandle* subHandle_data; if(!cellGifDec.CheckId(subHandle, subHandle_data)) return CELL_GIFDEC_ERROR_FATAL; @@ -111,6 +116,9 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t inParam, mem_ptr_t outParam) { + if (!inParam.IsGood() || !outParam.IsGood()) + return CELL_GIFDEC_ERROR_ARG; + CellGifDecSubHandle* subHandle_data; if(!cellGifDec.CheckId(subHandle, subHandle_data)) return CELL_GIFDEC_ERROR_FATAL; @@ -138,6 +146,9 @@ int cellGifDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t dataCtrlParam, mem_ptr_t dataOutInfo) { + if (!data.IsGood() || !dataCtrlParam.IsGood() || !dataOutInfo.IsGood()) + return CELL_GIFDEC_ERROR_ARG; + dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP; CellGifDecSubHandle* subHandle_data; diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index 45e3ac79fb..7bd25271c9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -30,6 +30,9 @@ int cellJpgDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t s cellJpgDec.Warning("cellJpgDecOpen(mainHandle=0x%x, subHandle=0x%x, src_addr=0x%x, openInfo=0x%x)", mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo); + if (!subHandle.IsGood() || !src.IsGood() || !openInfo.IsGood()) + return CELL_JPGDEC_ERROR_ARG; + CellJpgDecSubHandle *current_subHandle = new CellJpgDecSubHandle; // Get file descriptor @@ -65,6 +68,10 @@ int cellJpgDecClose(u32 mainHandle, u32 subHandle) int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t info) { cellJpgDec.Log("cellJpgDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%llx)", mainHandle, subHandle, info.GetAddr()); + + if (!info.IsGood()) + return CELL_JPGDEC_ERROR_ARG; + CellJpgDecSubHandle* subHandle_data; if(!cellJpgDec.CheckId(subHandle, subHandle_data)) return CELL_JPGDEC_ERROR_FATAL; @@ -121,6 +128,9 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t dataCtrlParam, mem_ptr_t dataOutInfo) { + if (!data.IsGood() || !dataCtrlParam.IsGood() || !dataOutInfo.IsGood()) + return CELL_JPGDEC_ERROR_ARG; + dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_STOP; CellJpgDecSubHandle* subHandle_data; if(!cellJpgDec.CheckId(subHandle, subHandle_data)) @@ -185,6 +195,9 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m int cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t inParam, mem_ptr_t outParam) { + if (!inParam.IsGood() || !outParam.IsGood()) + return CELL_JPGDEC_ERROR_ARG; + CellJpgDecSubHandle* subHandle_data; if(!cellJpgDec.CheckId(subHandle, subHandle_data)) return CELL_JPGDEC_ERROR_FATAL; diff --git a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp index 6f5284e061..0d0b5de06e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp @@ -524,7 +524,7 @@ int cellPamfEpIteratorGetEp(mem_ptr_t pIt, mem_ptr_t pIt, int steps, mem_ptr_t pEp) +int cellPamfEpIteratorMove(mem_ptr_t pIt, s32 steps, mem_ptr_t pEp) { cellPamf.Error("cellPamfEpIteratorMove(pIt_addr=0x%x, steps=%d, pEp_addr=0x%x)", pIt.GetAddr(), steps, pEp.GetAddr()); //TODO: diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index ed4c70514b..f2d925218c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -24,6 +24,9 @@ int cellPngDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t s cellPngDec.Warning("cellPngDecOpen(mainHandle=0x%x, subHandle=0x%x, src_addr=0x%x, openInfo=0x%x)", mainHandle, subHandle.GetAddr(), src.GetAddr(), openInfo); + if (!subHandle.IsGood() || !src.IsGood()) + return CELL_PNGDEC_ERROR_ARG; + CellPngDecSubHandle *current_subHandle = new CellPngDecSubHandle; current_subHandle->fd = NULL; @@ -38,7 +41,7 @@ int cellPngDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t s case const_se_t::value: // Get file descriptor MemoryAllocator> fd; - int ret = cellFsOpen(src->fileName, 0, fd, NULL, 0); + int ret = cellFsOpen(src->fileName_addr, 0, fd.GetAddr(), NULL, 0); current_subHandle->fd = fd->ToLE(); if(ret != CELL_OK) return CELL_PNGDEC_ERROR_OPEN_FILE; @@ -72,6 +75,9 @@ int cellPngDecClose(u32 mainHandle, u32 subHandle) int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t info) { + if (!info.IsGood()) + return CELL_PNGDEC_ERROR_ARG; + cellPngDec.Warning("cellPngDecReadHeader(mainHandle=0x%x, subHandle=0x%x, info_addr=0x%llx)", mainHandle, subHandle, info.GetAddr()); CellPngDecSubHandle* subHandle_data; if(!cellPngDec.CheckId(subHandle, subHandle_data)) @@ -94,8 +100,8 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_tsrc.streamPtr.ToLE(), buffer.GetSize()); break; case CELL_PNGDEC_FILE: - cellFsLseek(fd, 0, CELL_SEEK_SET, pos); - cellFsRead(fd, buffer.GetAddr(), buffer.GetSize(), nread); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); + cellFsRead(fd, buffer.GetAddr(), buffer.GetSize(), nread.GetAddr()); break; } @@ -129,6 +135,9 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t dataCtrlParam, mem_ptr_t dataOutInfo) { + if (!data.IsGood() || !dataCtrlParam.IsGood() || !dataOutInfo.IsGood()) + return CELL_PNGDEC_ERROR_ARG; + dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_STOP; CellPngDecSubHandle* subHandle_data; if(!cellPngDec.CheckId(subHandle, subHandle_data)) @@ -148,8 +157,8 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m Memory.Copy(png.GetAddr(), subHandle_data->src.streamPtr.ToLE(), png.GetSize()); break; case CELL_PNGDEC_FILE: - cellFsLseek(fd, 0, CELL_SEEK_SET, pos); - cellFsRead(fd, png.GetAddr(), png.GetSize(), nread); + cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr()); + cellFsRead(fd, png.GetAddr(), png.GetSize(), nread.GetAddr()); break; } @@ -234,6 +243,9 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m int cellPngDecSetParameter(u32 mainHandle, u32 subHandle, const mem_ptr_t inParam, mem_ptr_t outParam) { + if (!inParam.IsGood() || !outParam.IsGood()) + return CELL_PNGDEC_ERROR_ARG; + CellPngDecSubHandle* subHandle_data; if(!cellPngDec.CheckId(subHandle, subHandle_data)) return CELL_PNGDEC_ERROR_FATAL; diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.h b/rpcs3/Emu/SysCalls/Modules/cellPngDec.h index 68a5d4113f..dec65eabe5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.h @@ -37,6 +37,19 @@ enum CellPngDecStreamSrcSel CELL_PNGDEC_BUFFER = 1, }; +enum CellPngDecInterlaceMode +{ + CELL_PNGDEC_NO_INTERLACE = 0, + CELL_PNGDEC_ADAM7_INTERLACE = 1, +}; + +enum CellPngDecOutputMode +{ + CELL_PNGDEC_TOP_TO_BOTTOM = 0, + CELL_PNGDEC_BOTTOM_TO_TOP = 1, +}; + +// Structs struct CellPngDecDataOutInfo { be_t chunkInformation; @@ -55,31 +68,31 @@ struct CellPngDecInfo be_t imageWidth; be_t imageHeight; be_t numComponents; - be_t colorSpace; // CellPngDecColorSpace + be_t colorSpace; // CellPngDecColorSpace be_t bitDepth; - be_t interlaceMethod; // CellPngDecInterlaceMode + be_t interlaceMethod; // CellPngDecInterlaceMode be_t chunkInformation; }; struct CellPngDecSrc { - be_t srcSelect; // CellPngDecStreamSrcSel - be_t fileName; // const char* - be_t fileOffset; // int64_t + be_t srcSelect; // CellPngDecStreamSrcSel + be_t fileName_addr; // const char* + be_t fileOffset; be_t fileSize; be_t streamPtr; be_t streamSize; - be_t spuThreadEnable; // CellPngDecSpuThreadEna + be_t spuThreadEnable; // CellPngDecSpuThreadEna }; struct CellPngDecInParam { be_t commandPtr; - be_t outputMode; // CellPngDecOutputMode - be_t outputColorSpace; // CellPngDecColorSpace + be_t outputMode; // CellPngDecOutputMode + be_t outputColorSpace; // CellPngDecColorSpace be_t outputBitDepth; - be_t outputPackFlag; // CellPngDecPackFlag - be_t outputAlphaSelect; // CellPngDecAlphaSelect + be_t outputPackFlag; // CellPngDecPackFlag + be_t outputAlphaSelect; // CellPngDecAlphaSelect be_t outputColorAlpha; }; @@ -90,12 +103,13 @@ struct CellPngDecOutParam be_t outputHeight; be_t outputComponents; be_t outputBitDepth; - be_t outputMode; // CellPngDecOutputMode - be_t outputColorSpace; // CellPngDecColorSpace + be_t outputMode; // CellPngDecOutputMode + be_t outputColorSpace; // CellPngDecColorSpace be_t useMemorySpace; }; -struct CellPngDecSubHandle //Custom struct +//Custom structs +struct CellPngDecSubHandle { u32 fd; u64 fileSize; diff --git a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp index 9b2798fc0f..1e440fe59a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellRtc.cpp @@ -20,460 +20,468 @@ u64 convertToWin32FILETIME(u16 seconds, u16 minutes, u16 hours, u16 days, int ye return win32filetime; } -int cellRtcGetCurrentTick(mem64_t tick) +int cellRtcGetCurrentTick(mem_ptr_t pTick) { - cellRtc.Log("cellRtcGetCurrentTick(tick_addr=0x%x)", tick.GetAddr()); + cellRtc.Log("cellRtcGetCurrentTick(pTick=0x%x)", pTick.GetAddr()); + + if (!pTick.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + wxDateTime unow = wxDateTime::UNow(); - tick = unow.GetTicks(); + pTick->tick = unow.GetTicks(); return CELL_OK; } -int cellRtcGetCurrentClock(u32 clock_addr, int time_zone) +int cellRtcGetCurrentClock(mem_ptr_t pClock, s32 iTimeZone) { - cellRtc.Log("cellRtcGetCurrentClock(clock_addr=0x%x, time_zone=%d)", clock_addr, time_zone); + cellRtc.Log("cellRtcGetCurrentClock(pClock=0x%x, time_zone=%d)", pClock.GetAddr(), iTimeZone); + + if (!pClock.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + wxDateTime unow = wxDateTime::UNow(); // Add time_zone as offset in minutes. - wxTimeSpan tz = wxTimeSpan::wxTimeSpan(0, (long) time_zone, 0, 0); + wxTimeSpan tz = wxTimeSpan::wxTimeSpan(0, (long) iTimeZone, 0, 0); unow.Add(tz); - Memory.Write16(clock_addr, unow.GetYear(wxDateTime::TZ::UTC)); - Memory.Write16(clock_addr + 2, unow.GetMonth(wxDateTime::TZ::UTC)); - Memory.Write16(clock_addr + 4, unow.GetDay(wxDateTime::TZ::UTC)); - Memory.Write16(clock_addr + 6, unow.GetHour(wxDateTime::TZ::UTC)); - Memory.Write16(clock_addr + 8, unow.GetMinute(wxDateTime::TZ::UTC)); - Memory.Write16(clock_addr + 10, unow.GetSecond(wxDateTime::TZ::UTC)); - Memory.Write32(clock_addr + 12, unow.GetMillisecond(wxDateTime::TZ::UTC) * 1000); + pClock->year = unow.GetYear(wxDateTime::TZ::UTC); + pClock->month = unow.GetMonth(wxDateTime::TZ::UTC); + pClock->day = unow.GetDay(wxDateTime::TZ::UTC); + pClock->hour = unow.GetHour(wxDateTime::TZ::UTC); + pClock->minute = unow.GetMinute(wxDateTime::TZ::UTC); + pClock->second = unow.GetSecond(wxDateTime::TZ::UTC); + pClock->microsecond = unow.GetMillisecond(wxDateTime::TZ::UTC) * 1000; return CELL_OK; } -int cellRtcGetCurrentClockLocalTime(u32 clock_addr) +int cellRtcGetCurrentClockLocalTime(mem_ptr_t pClock) { - cellRtc.Log("cellRtcGetCurrentClockLocalTime(clock_addr=0x%x)", clock_addr); + cellRtc.Log("cellRtcGetCurrentClockLocalTime(pClock=0x%x)", pClock.GetAddr()); + + if (!pClock.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + wxDateTime unow = wxDateTime::UNow(); - Memory.Write16(clock_addr, unow.GetYear(wxDateTime::TZ::Local)); - Memory.Write16(clock_addr + 2, unow.GetMonth(wxDateTime::TZ::Local)); - Memory.Write16(clock_addr + 4, unow.GetDay(wxDateTime::TZ::Local)); - Memory.Write16(clock_addr + 6, unow.GetHour(wxDateTime::TZ::Local)); - Memory.Write16(clock_addr + 8, unow.GetMinute(wxDateTime::TZ::Local)); - Memory.Write16(clock_addr + 10, unow.GetSecond(wxDateTime::TZ::Local)); - Memory.Write32(clock_addr + 12, unow.GetMillisecond(wxDateTime::TZ::Local) * 1000); + pClock->year = unow.GetYear(wxDateTime::TZ::Local); + pClock->month = unow.GetMonth(wxDateTime::TZ::Local); + pClock->day = unow.GetDay(wxDateTime::TZ::Local); + pClock->hour = unow.GetHour(wxDateTime::TZ::Local); + pClock->minute = unow.GetMinute(wxDateTime::TZ::Local); + pClock->second = unow.GetSecond(wxDateTime::TZ::Local); + pClock->microsecond = unow.GetMillisecond(wxDateTime::TZ::Local) * 1000; return CELL_OK; } -int cellRtcFormatRfc2822(u32 rfc_addr, u32 tick_addr, int time_zone) +int cellRtcFormatRfc2822(u32 pszDateTime_addr, mem_ptr_t pUtc, s32 iTimeZone) { - cellRtc.Log("cellRtcFormatRfc2822(rfc_addr=0x%x, tick_addr=0x%x, time_zone=%d)", rfc_addr, tick_addr, time_zone); - CellRtcTick current_tick; - current_tick.tick = Memory.Read64(tick_addr); + cellRtc.Log("cellRtcFormatRfc2822(pszDateTime_addr=0x%x, pUtc=0x%x, time_zone=%d)", pszDateTime_addr, pUtc.GetAddr(), iTimeZone); + + if (!pUtc.IsGood() || !Memory.IsGoodAddr(pszDateTime_addr)) + return CELL_RTC_ERROR_INVALID_POINTER; // Add time_zone as offset in minutes. - wxTimeSpan tz = wxTimeSpan::wxTimeSpan(0, (long) time_zone, 0, 0); + wxTimeSpan tz = wxTimeSpan::wxTimeSpan(0, (long) iTimeZone, 0, 0); // Get date from ticks + tz. - wxDateTime date = wxDateTime::wxDateTime((time_t)current_tick.tick); + wxDateTime date = wxDateTime::wxDateTime((time_t)pUtc->tick); date.Add(tz); // Format date string in RFC2822 format (e.g.: Mon, 01 Jan 1990 12:00:00 +0000). const std::string& str = fmt::ToUTF8(date.Format("%a, %d %b %Y %T %z", wxDateTime::TZ::UTC)); - Memory.WriteString(rfc_addr, str); + Memory.WriteString(pszDateTime_addr, str); return CELL_OK; } -int cellRtcFormatRfc2822LocalTime(u32 rfc_addr, u32 tick_addr) +int cellRtcFormatRfc2822LocalTime(u32 pszDateTime_addr, mem_ptr_t pUtc) { - cellRtc.Log("cellRtcFormatRfc2822LocalTime(rfc_addr=0x%x, tick_addr=0x%x)", rfc_addr, tick_addr); - CellRtcTick current_tick; - current_tick.tick = Memory.Read64(tick_addr); + cellRtc.Log("cellRtcFormatRfc2822LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.GetAddr()); + + if (!pUtc.IsGood() || !Memory.IsGoodAddr(pszDateTime_addr)) + return CELL_RTC_ERROR_INVALID_POINTER; // Get date from ticks. - wxDateTime date = wxDateTime::wxDateTime((time_t)current_tick.tick); + wxDateTime date = wxDateTime::wxDateTime((time_t)pUtc->tick); // Format date string in RFC2822 format (e.g.: Mon, 01 Jan 1990 12:00:00 +0000). const std::string& str = fmt::ToUTF8(date.Format("%a, %d %b %Y %T %z", wxDateTime::TZ::Local)); - Memory.WriteString(rfc_addr, str); + Memory.WriteString(pszDateTime_addr, str); return CELL_OK; } -int cellRtcFormatRfc3339(u32 rfc_addr, u32 tick_addr, int time_zone) +int cellRtcFormatRfc3339(u32 pszDateTime_addr, mem_ptr_t pUtc, s32 iTimeZone) { - cellRtc.Log("cellRtcFormatRfc3339(rfc_addr=0x%x, tick_addr=0x%x, time_zone=%d)", rfc_addr, tick_addr, time_zone); - CellRtcTick current_tick; - current_tick.tick = Memory.Read64(tick_addr); + cellRtc.Log("cellRtcFormatRfc3339(pszDateTime_addr=0x%x, pUtc=0x%x, iTimeZone=%d)", pszDateTime_addr, pUtc.GetAddr(), iTimeZone); + + if (!pUtc.IsGood() || !Memory.IsGoodAddr(pszDateTime_addr)) + return CELL_RTC_ERROR_INVALID_POINTER; // Add time_zone as offset in minutes. - wxTimeSpan tz = wxTimeSpan::wxTimeSpan(0, (long) time_zone, 0, 0); + wxTimeSpan tz = wxTimeSpan::wxTimeSpan(0, (long) iTimeZone, 0, 0); // Get date from ticks + tz. - wxDateTime date = wxDateTime::wxDateTime((time_t)current_tick.tick); + wxDateTime date = wxDateTime::wxDateTime((time_t)pUtc->tick); date.Add(tz); // Format date string in RFC3339 format (e.g.: 1990-01-01T12:00:00.00Z). const std::string& str = fmt::ToUTF8(date.Format("%FT%T.%zZ", wxDateTime::TZ::UTC)); - Memory.WriteString(rfc_addr, str); + Memory.WriteString(pszDateTime_addr, str); return CELL_OK; } -int cellRtcFormatRfc3339LocalTime(u32 rfc_addr, u32 tick_addr) +int cellRtcFormatRfc3339LocalTime(u32 pszDateTime_addr, mem_ptr_t pUtc) { - cellRtc.Log("cellRtcFormatRfc3339LocalTime(rfc_addr=0x%x, tick_addr=0x%x)", rfc_addr, tick_addr); - CellRtcTick current_tick; - current_tick.tick = Memory.Read64(tick_addr); + cellRtc.Log("cellRtcFormatRfc3339LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.GetAddr()); + + if (!pUtc.IsGood() || !Memory.IsGoodAddr(pszDateTime_addr)) + return CELL_RTC_ERROR_INVALID_POINTER; // Get date from ticks. - wxDateTime date = wxDateTime::wxDateTime((time_t)current_tick.tick); + wxDateTime date = wxDateTime::wxDateTime((time_t) pUtc->tick); // Format date string in RFC3339 format (e.g.: 1990-01-01T12:00:00.00Z). const std::string& str = fmt::ToUTF8(date.Format("%FT%T.%zZ", wxDateTime::TZ::Local)); - Memory.WriteString(rfc_addr, str); + Memory.WriteString(pszDateTime_addr, str); return CELL_OK; } -int cellRtcParseDateTime(mem64_t tick, u32 datetime_addr) +int cellRtcParseDateTime(mem_ptr_t pUtc, u32 pszDateTime_addr) { - cellRtc.Log("cellRtcParseDateTime(tick_addr=0x%x, datetime_addr=0x%x)", tick.GetAddr(), datetime_addr); - - const std::string& format = Memory.ReadString(datetime_addr); + cellRtc.Log("cellRtcParseDateTime(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.GetAddr(), pszDateTime_addr); + if (!pUtc.IsGood() || !Memory.IsGoodAddr(pszDateTime_addr)) + return CELL_RTC_ERROR_INVALID_POINTER; + // Get date from formatted string. wxDateTime date; + const std::string& format = Memory.ReadString(pszDateTime_addr); date.ParseDateTime(fmt::FromUTF8(format)); - tick = date.GetTicks(); + pUtc->tick = date.GetTicks(); return CELL_OK; } -int cellRtcParseRfc3339(mem64_t tick, u32 datetime_addr) +int cellRtcParseRfc3339(mem_ptr_t pUtc, u32 pszDateTime_addr) { - cellRtc.Log("cellRtcParseRfc3339(tick_addr=0x%x, datetime_addr=0x%x)", tick.GetAddr(), datetime_addr); + cellRtc.Log("cellRtcParseRfc3339(pUtc=0x%x, pszDateTime_addr=0x%x)", pUtc.GetAddr(), pszDateTime_addr); - const std::string& format = Memory.ReadString(datetime_addr); + if (!pUtc.IsGood() || !Memory.IsGoodAddr(pszDateTime_addr)) + return CELL_RTC_ERROR_INVALID_POINTER; // Get date from RFC3339 formatted string. wxDateTime date; + const std::string& format = Memory.ReadString(pszDateTime_addr); date.ParseDateTime(fmt::FromUTF8(format)); - tick = date.GetTicks(); + pUtc->tick = date.GetTicks(); return CELL_OK; } -int cellRtcGetTick(u32 clock_addr, mem64_t tick) +int cellRtcGetTick(mem_ptr_t pTime, mem_ptr_t pTick) { - cellRtc.Log("cellRtcGetTick(clock_addr=0x%x, tick_addr=0x%x)", clock_addr, tick.GetAddr()); + cellRtc.Log("cellRtcGetTick(pTime=0x%x, pTick=0x%x)", pTime.GetAddr(), pTick.GetAddr()); - CellRtcDateTime clock; - clock.year = Memory.Read16(clock_addr); - clock.month = Memory.Read16(clock_addr + 2); - clock.day = Memory.Read16(clock_addr + 4); - clock.hour = Memory.Read16(clock_addr + 6); - clock.minute = Memory.Read16(clock_addr + 8); - clock.second = Memory.Read16(clock_addr + 10); - clock.microsecond = Memory.Read32(clock_addr + 12); + if (!pTime.IsGood() || !pTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; - wxDateTime datetime = wxDateTime::wxDateTime(clock.day, (wxDateTime::Month)clock.month, clock.year, clock.hour, clock.minute, clock.second, (clock.microsecond / 1000)); - tick = datetime.GetTicks(); + wxDateTime datetime = wxDateTime::wxDateTime(pTime->day, (wxDateTime::Month)pTime->month.ToLE(), pTime->year, pTime->hour, pTime->minute, pTime->second, (pTime->microsecond / 1000)); + pTick->tick = datetime.GetTicks(); return CELL_OK; } -int cellRtcSetTick(u32 clock_addr, u32 tick_addr) +int cellRtcSetTick(mem_ptr_t pTime, mem_ptr_t pTick) { - cellRtc.Log("cellRtcSetTick(clock_addr=0x%x, tick_addr=0x%x)", clock_addr, tick_addr); - CellRtcTick current_tick; - current_tick.tick = Memory.Read64(tick_addr); - - wxDateTime date = wxDateTime::wxDateTime((time_t)current_tick.tick); - - CellRtcDateTime clock; - clock.year = date.GetYear(wxDateTime::TZ::UTC); - clock.month = date.GetMonth(wxDateTime::TZ::UTC); - clock.day = date.GetDay(wxDateTime::TZ::UTC); - clock.hour = date.GetHour(wxDateTime::TZ::UTC); - clock.minute = date.GetMinute(wxDateTime::TZ::UTC); - clock.second = date.GetSecond(wxDateTime::TZ::UTC); - clock.microsecond = date.GetMillisecond(wxDateTime::TZ::UTC) * 1000; - - Memory.Write16(clock_addr, clock.year); - Memory.Write16(clock_addr + 2, clock.month); - Memory.Write16(clock_addr + 4, clock.day); - Memory.Write16(clock_addr + 6, clock.hour); - Memory.Write16(clock_addr + 8, clock.minute); - Memory.Write16(clock_addr + 10, clock.second); - Memory.Write32(clock_addr + 12, clock.microsecond); - - return CELL_OK; -} - -int cellRtcTickAddTicks(mem64_t tick, u32 tick_add_addr, long add) -{ - cellRtc.Log("cellRtcTickAddTicks(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); - tick = Memory.Read64(tick_add_addr) + add; - - return CELL_OK; -} - -int cellRtcTickAddMicroseconds(mem64_t tick, u32 tick_add_addr, long add) -{ - cellRtc.Log("cellRtcTickAddMicroseconds(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcSetTick(pTime=0x%x, pTick=0x%x)", pTime.GetAddr(), pTick.GetAddr()); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxTimeSpan microseconds = wxTimeSpan::wxTimeSpan(0, 0, 0, add / 1000); + if (!pTime.IsGood() || !pTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick->tick); + + pTime->year = date.GetYear(wxDateTime::TZ::UTC); + pTime->month = date.GetMonth(wxDateTime::TZ::UTC); + pTime->day = date.GetDay(wxDateTime::TZ::UTC); + pTime->hour = date.GetHour(wxDateTime::TZ::UTC); + pTime->minute = date.GetMinute(wxDateTime::TZ::UTC); + pTime->second = date.GetSecond(wxDateTime::TZ::UTC); + pTime->microsecond = date.GetMillisecond(wxDateTime::TZ::UTC) * 1000; + + return CELL_OK; +} + +int cellRtcTickAddTicks(mem_ptr_t pTick0, mem_ptr_t pTick1, s64 lAdd) +{ + cellRtc.Log("cellRtcTickAddTicks(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd); + + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + pTick0->tick = pTick1->tick + lAdd; + return CELL_OK; +} + +int cellRtcTickAddMicroseconds(mem_ptr_t pTick0, mem_ptr_t pTick1, s64 lAdd) +{ + cellRtc.Log("cellRtcTickAddMicroseconds(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd); + + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxTimeSpan microseconds = wxTimeSpan::wxTimeSpan(0, 0, 0, lAdd / 1000); date.Add(microseconds); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcTickAddSeconds(mem64_t tick, u32 tick_add_addr, long add) +int cellRtcTickAddSeconds(mem_ptr_t pTick0, mem_ptr_t pTick1, s64 lAdd) { - cellRtc.Log("cellRtcTickAddSeconds(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcTickAddSeconds(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxTimeSpan seconds = wxTimeSpan::wxTimeSpan(0, 0, add, 0); + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxTimeSpan seconds = wxTimeSpan::wxTimeSpan(0, 0, lAdd, 0); date.Add(seconds); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcTickAddMinutes(mem64_t tick, u32 tick_add_addr, long add) +int cellRtcTickAddMinutes(mem_ptr_t pTick0, mem_ptr_t pTick1, s64 lAdd) { - cellRtc.Log("cellRtcTickAddMinutes(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcTickAddMinutes(pTick0=0x%x, pTick1=0x%x, lAdd=%lld)", pTick0.GetAddr(), pTick1.GetAddr(), lAdd); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxTimeSpan minutes = wxTimeSpan::wxTimeSpan(0, add, 0, 0); + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxTimeSpan minutes = wxTimeSpan::wxTimeSpan(0, lAdd, 0, 0); date.Add(minutes); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcTickAddHours(mem64_t tick, u32 tick_add_addr, int add) +int cellRtcTickAddHours(mem_ptr_t pTick0, mem_ptr_t pTick1, s32 iAdd) { - cellRtc.Log("cellRtcTickAddHours(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcTickAddHours(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxTimeSpan hours = wxTimeSpan::wxTimeSpan(add, 0, 0, 0); + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxTimeSpan hours = wxTimeSpan::wxTimeSpan(iAdd, 0, 0, 0); date.Add(hours); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcTickAddDays(mem64_t tick, u32 tick_add_addr, int add) +int cellRtcTickAddDays(mem_ptr_t pTick0, mem_ptr_t pTick1, s32 iAdd) { - cellRtc.Log("cellRtcTickAddDays(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcTickAddDays(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxDateSpan days = wxDateSpan::wxDateSpan(0, 0, 0, add); + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxDateSpan days = wxDateSpan::wxDateSpan(0, 0, 0, iAdd); date.Add(days); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcTickAddWeeks(mem64_t tick, u32 tick_add_addr, int add) +int cellRtcTickAddWeeks(mem_ptr_t pTick0, mem_ptr_t pTick1, s32 iAdd) { - cellRtc.Log("cellRtcTickAddWeeks(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcTickAddWeeks(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxDateSpan weeks = wxDateSpan::wxDateSpan(0, 0, add, 0); + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxDateSpan weeks = wxDateSpan::wxDateSpan(0, 0, iAdd, 0); date.Add(weeks); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcTickAddMonths(mem64_t tick, u32 tick_add_addr, int add) +int cellRtcTickAddMonths(mem_ptr_t pTick0, mem_ptr_t pTick1, s32 iAdd) { - cellRtc.Log("cellRtcTickAddMonths(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcTickAddMonths(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxDateSpan months = wxDateSpan::wxDateSpan(0, add, 0, 0); + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxDateSpan months = wxDateSpan::wxDateSpan(0, iAdd, 0, 0); date.Add(months); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcTickAddYears(mem64_t tick, u32 tick_add_addr, int add) +int cellRtcTickAddYears(mem_ptr_t pTick0, mem_ptr_t pTick1, s32 iAdd) { - cellRtc.Log("cellRtcTickAddYears(tick_addr=0x%x, tick_add_addr=0x%x, add=%l)", tick.GetAddr(), tick_add_addr, add); + cellRtc.Log("cellRtcTickAddYears(pTick0=0x%x, pTick1=0x%x, iAdd=%d)", pTick0.GetAddr(), pTick1.GetAddr(), iAdd); - wxDateTime date = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_add_addr)); - wxDateSpan years = wxDateSpan::wxDateSpan(add, 0, 0, 0); + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime date = wxDateTime::wxDateTime((time_t)pTick1->tick); + wxDateSpan years = wxDateSpan::wxDateSpan(iAdd, 0, 0, 0); date.Add(years); - tick = date.GetTicks(); + pTick0->tick = date.GetTicks(); return CELL_OK; } -int cellRtcConvertUtcToLocalTime(u32 tick_utc_addr, mem64_t tick_local) +int cellRtcConvertUtcToLocalTime(mem_ptr_t pUtc, mem_ptr_t pLocalTime) { - cellRtc.Log("cellRtcConvertUtcToLocalTime(tick_utc_addr=0x%x, tick_local_addr=0x%x)", tick_utc_addr, tick_local.GetAddr()); - wxDateTime time = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_utc_addr)); + cellRtc.Log("cellRtcConvertUtcToLocalTime(pUtc=0x%x, pLocalTime=0x%x)", pUtc.GetAddr(), pLocalTime.GetAddr()); + + if (!pUtc.IsGood() || !pLocalTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime time = wxDateTime::wxDateTime((time_t)pUtc->tick); wxDateTime local_time = time.FromUTC(false); - tick_local = local_time.GetTicks(); + pLocalTime->tick = local_time.GetTicks(); return CELL_OK; } -int cellRtcConvertLocalTimeToUtc(u32 tick_local_addr, mem64_t tick_utc) +int cellRtcConvertLocalTimeToUtc(mem_ptr_t pLocalTime, mem_ptr_t pUtc) { - cellRtc.Log("cellRtcConvertLocalTimeToUtc(tick_local_addr=0x%x, tick_utc_addr=0x%x)", tick_local_addr, tick_utc.GetAddr()); - wxDateTime time = wxDateTime::wxDateTime((time_t)Memory.Read64(tick_local_addr)); + cellRtc.Log("cellRtcConvertLocalTimeToUtc(pLocalTime=0x%x, pUtc=0x%x)", pLocalTime.GetAddr(), pUtc.GetAddr()); + + if (!pLocalTime.IsGood() || !pUtc.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + wxDateTime time = wxDateTime::wxDateTime((time_t)pLocalTime->tick); wxDateTime utc_time = time.ToUTC(false); - tick_utc = utc_time.GetTicks(); + pUtc->tick = utc_time.GetTicks(); return CELL_OK; } -int cellRtcGetDosTime(u32 datetime_addr, mem64_t dos_time) +int cellRtcGetDosTime(mem_ptr_t pDateTime, mem32_t puiDosTime) { - cellRtc.Log("cellRtcGetDosTime(datetime_addr=0x%x, dos_time_addr=0x%x)", datetime_addr, dos_time.GetAddr()); - CellRtcDateTime datetime; - datetime.year = Memory.Read16(datetime_addr); - datetime.month = Memory.Read16(datetime_addr + 2); - datetime.day = Memory.Read16(datetime_addr + 4); - datetime.hour = Memory.Read16(datetime_addr + 6); - datetime.minute = Memory.Read16(datetime_addr + 8); - datetime.second = Memory.Read16(datetime_addr + 10); - datetime.microsecond = Memory.Read32(datetime_addr + 12); + cellRtc.Log("cellRtcGetDosTime(pDateTime=0x%x, puiDosTime=0x%x)", pDateTime.GetAddr(), puiDosTime.GetAddr()); + + if (!pDateTime.IsGood() || !puiDosTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; // Convert to DOS time. - wxDateTime date_time = wxDateTime::wxDateTime(datetime.day, (wxDateTime::Month)datetime.month, datetime.year, datetime.hour, datetime.minute, datetime.second, (datetime.microsecond / 1000)); - dos_time = date_time.GetAsDOS(); + wxDateTime date_time = wxDateTime::wxDateTime(pDateTime->day, (wxDateTime::Month)pDateTime->month.ToLE(), pDateTime->year, pDateTime->hour, pDateTime->minute, pDateTime->second, (pDateTime->microsecond / 1000)); + puiDosTime = date_time.GetAsDOS(); return CELL_OK; } -int cellRtcGetTime_t(u32 datetime_addr, mem64_t posix_time) +int cellRtcGetTime_t(mem_ptr_t pDateTime, mem64_t piTime) { - cellRtc.Log("cellRtcGetTime_t(datetime_addr=0x%x, posix_time_addr=0x%x)", datetime_addr, posix_time.GetAddr()); - CellRtcDateTime datetime; - datetime.year = Memory.Read16(datetime_addr); - datetime.month = Memory.Read16(datetime_addr + 2); - datetime.day = Memory.Read16(datetime_addr + 4); - datetime.hour = Memory.Read16(datetime_addr + 6); - datetime.minute = Memory.Read16(datetime_addr + 8); - datetime.second = Memory.Read16(datetime_addr + 10); - datetime.microsecond = Memory.Read32(datetime_addr + 12); + cellRtc.Log("cellRtcGetTime_t(pDateTime=0x%x, piTime=0x%x)", pDateTime.GetAddr(), piTime.GetAddr()); + + if (!pDateTime.IsGood() || !piTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; // Convert to POSIX time_t. - wxDateTime date_time = wxDateTime::wxDateTime(datetime.day, (wxDateTime::Month)datetime.month, datetime.year, datetime.hour, datetime.minute, datetime.second, (datetime.microsecond / 1000)); - posix_time = convertToUNIXTime(date_time.GetSecond(wxDateTime::TZ::UTC), date_time.GetMinute(wxDateTime::TZ::UTC), + wxDateTime date_time = wxDateTime::wxDateTime(pDateTime->day, (wxDateTime::Month)pDateTime->month.ToLE(), pDateTime->year, pDateTime->hour, pDateTime->minute, pDateTime->second, (pDateTime->microsecond / 1000)); + piTime = convertToUNIXTime(date_time.GetSecond(wxDateTime::TZ::UTC), date_time.GetMinute(wxDateTime::TZ::UTC), date_time.GetHour(wxDateTime::TZ::UTC), date_time.GetDay(wxDateTime::TZ::UTC), date_time.GetYear(wxDateTime::TZ::UTC)); return CELL_OK; } -int cellRtcGetWin32FileTime(u32 datetime_addr, mem64_t win32_time) +int cellRtcGetWin32FileTime(mem_ptr_t pDateTime, mem64_t pulWin32FileTime) { - cellRtc.Log("cellRtcGetWin32FileTime(datetime_addr=0x%x, win32_time_addr=0x%x)", datetime_addr, win32_time.GetAddr()); - CellRtcDateTime datetime; - datetime.year = Memory.Read16(datetime_addr); - datetime.month = Memory.Read16(datetime_addr + 2); - datetime.day = Memory.Read16(datetime_addr + 4); - datetime.hour = Memory.Read16(datetime_addr + 6); - datetime.minute = Memory.Read16(datetime_addr + 8); - datetime.second = Memory.Read16(datetime_addr + 10); - datetime.microsecond = Memory.Read32(datetime_addr + 12); + cellRtc.Log("cellRtcGetWin32FileTime(pDateTime=0x%x, pulWin32FileTime=0x%x)", pDateTime.GetAddr(), pulWin32FileTime.GetAddr()); + + if (!pDateTime.IsGood() || !pulWin32FileTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; // Convert to WIN32 FILETIME. - wxDateTime date_time = wxDateTime::wxDateTime(datetime.day, (wxDateTime::Month)datetime.month, datetime.year, datetime.hour, datetime.minute, datetime.second, (datetime.microsecond / 1000)); - win32_time = convertToWin32FILETIME(date_time.GetSecond(wxDateTime::TZ::UTC), date_time.GetMinute(wxDateTime::TZ::UTC), + wxDateTime date_time = wxDateTime::wxDateTime(pDateTime->day, (wxDateTime::Month)pDateTime->month.ToLE(), pDateTime->year, pDateTime->hour, pDateTime->minute, pDateTime->second, (pDateTime->microsecond / 1000)); + pulWin32FileTime = convertToWin32FILETIME(date_time.GetSecond(wxDateTime::TZ::UTC), date_time.GetMinute(wxDateTime::TZ::UTC), date_time.GetHour(wxDateTime::TZ::UTC), date_time.GetDay(wxDateTime::TZ::UTC), date_time.GetYear(wxDateTime::TZ::UTC)); return CELL_OK; } -int cellRtcSetDosTime(u32 datetime_addr, u32 dos_time_addr) +int cellRtcSetDosTime(mem_ptr_t pDateTime, u32 uiDosTime) { - cellRtc.Log("cellRtcSetDosTime(datetime_addr=0x%x, dos_time_addr=0x%x)", datetime_addr, dos_time_addr); + cellRtc.Log("cellRtcSetDosTime(pDateTime=0x%x, uiDosTime=0x%x)", pDateTime.GetAddr(), uiDosTime); + if (!pDateTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + wxDateTime date_time; - wxDateTime dos_time = date_time.SetFromDOS(Memory.Read32(dos_time_addr)); + wxDateTime dos_time = date_time.SetFromDOS(uiDosTime); - CellRtcDateTime datetime; - datetime.year = dos_time.GetYear(wxDateTime::TZ::UTC); - datetime.month = dos_time.GetMonth(wxDateTime::TZ::UTC); - datetime.day = dos_time.GetDay(wxDateTime::TZ::UTC); - datetime.hour = dos_time.GetHour(wxDateTime::TZ::UTC); - datetime.minute = dos_time.GetMinute(wxDateTime::TZ::UTC); - datetime.second = dos_time.GetSecond(wxDateTime::TZ::UTC); - datetime.microsecond = dos_time.GetMillisecond(wxDateTime::TZ::UTC) * 1000; - - Memory.Write16(datetime_addr, datetime.year); - Memory.Write16(datetime_addr + 2, datetime.month); - Memory.Write16(datetime_addr + 4, datetime.day); - Memory.Write16(datetime_addr + 6, datetime.hour); - Memory.Write16(datetime_addr + 8, datetime.minute); - Memory.Write16(datetime_addr + 10, datetime.second); - Memory.Write32(datetime_addr + 12, datetime.microsecond); + pDateTime->year = dos_time.GetYear(wxDateTime::TZ::UTC); + pDateTime->month = dos_time.GetMonth(wxDateTime::TZ::UTC); + pDateTime->day = dos_time.GetDay(wxDateTime::TZ::UTC); + pDateTime->hour = dos_time.GetHour(wxDateTime::TZ::UTC); + pDateTime->minute = dos_time.GetMinute(wxDateTime::TZ::UTC); + pDateTime->second = dos_time.GetSecond(wxDateTime::TZ::UTC); + pDateTime->microsecond = dos_time.GetMillisecond(wxDateTime::TZ::UTC) * 1000; return CELL_OK; } -int cellRtcSetTime_t(u32 datetime_addr, u32 posix_time_addr) +int cellRtcSetTime_t(mem_ptr_t pDateTime, u64 iTime) { - cellRtc.Log("cellRtcSetTime_t(datetime_addr=0x%x, posix_time_addr=0x%x)", datetime_addr, posix_time_addr); + cellRtc.Log("cellRtcSetTime_t(pDateTime=0x%x, iTime=0x%llx)", pDateTime.GetAddr(), iTime); - wxDateTime date_time = wxDateTime::wxDateTime((time_t)Memory.Read64(posix_time_addr)); - - CellRtcDateTime datetime; - datetime.year = date_time.GetYear(wxDateTime::TZ::UTC); - datetime.month = date_time.GetMonth(wxDateTime::TZ::UTC); - datetime.day = date_time.GetDay(wxDateTime::TZ::UTC); - datetime.hour = date_time.GetHour(wxDateTime::TZ::UTC); - datetime.minute = date_time.GetMinute(wxDateTime::TZ::UTC); - datetime.second = date_time.GetSecond(wxDateTime::TZ::UTC); - datetime.microsecond = date_time.GetMillisecond(wxDateTime::TZ::UTC) * 1000; + if (!pDateTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; - Memory.Write16(datetime_addr, datetime.year); - Memory.Write16(datetime_addr + 2, datetime.month); - Memory.Write16(datetime_addr + 4, datetime.day); - Memory.Write16(datetime_addr + 6, datetime.hour); - Memory.Write16(datetime_addr + 8, datetime.minute); - Memory.Write16(datetime_addr + 10, datetime.second); - Memory.Write32(datetime_addr + 12, datetime.microsecond); + wxDateTime date_time = wxDateTime::wxDateTime((time_t)iTime); + + pDateTime->year = date_time.GetYear(wxDateTime::TZ::UTC); + pDateTime->month = date_time.GetMonth(wxDateTime::TZ::UTC); + pDateTime->day = date_time.GetDay(wxDateTime::TZ::UTC); + pDateTime->hour = date_time.GetHour(wxDateTime::TZ::UTC); + pDateTime->minute = date_time.GetMinute(wxDateTime::TZ::UTC); + pDateTime->second = date_time.GetSecond(wxDateTime::TZ::UTC); + pDateTime->microsecond = date_time.GetMillisecond(wxDateTime::TZ::UTC) * 1000; return CELL_OK; } -int cellRtcSetWin32FileTime(u32 datetime_addr, u32 win32_time_addr) +int cellRtcSetWin32FileTime(mem_ptr_t pDateTime, u64 ulWin32FileTime) { - cellRtc.Log("cellRtcSetWin32FileTime(datetime_addr=0x%x, win32_time_addr=0x%x)", datetime_addr, win32_time_addr); + cellRtc.Log("cellRtcSetWin32FileTime(pDateTime=0x%x, ulWin32FileTime=0x%llx)", pDateTime, ulWin32FileTime); - wxDateTime date_time = wxDateTime::wxDateTime((time_t)Memory.Read64(win32_time_addr)); - - CellRtcDateTime datetime; - datetime.year = date_time.GetYear(wxDateTime::TZ::UTC); - datetime.month = date_time.GetMonth(wxDateTime::TZ::UTC); - datetime.day = date_time.GetDay(wxDateTime::TZ::UTC); - datetime.hour = date_time.GetHour(wxDateTime::TZ::UTC); - datetime.minute = date_time.GetMinute(wxDateTime::TZ::UTC); - datetime.second = date_time.GetSecond(wxDateTime::TZ::UTC); - datetime.microsecond = date_time.GetMillisecond(wxDateTime::TZ::UTC) * 1000; + if (!pDateTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; - Memory.Write16(datetime_addr, datetime.year); - Memory.Write16(datetime_addr + 2, datetime.month); - Memory.Write16(datetime_addr + 4, datetime.day); - Memory.Write16(datetime_addr + 6, datetime.hour); - Memory.Write16(datetime_addr + 8, datetime.minute); - Memory.Write16(datetime_addr + 10, datetime.second); - Memory.Write32(datetime_addr + 12, datetime.microsecond); + wxDateTime date_time = wxDateTime::wxDateTime((time_t)ulWin32FileTime); + + pDateTime->year = date_time.GetYear(wxDateTime::TZ::UTC); + pDateTime->month = date_time.GetMonth(wxDateTime::TZ::UTC); + pDateTime->day = date_time.GetDay(wxDateTime::TZ::UTC); + pDateTime->hour = date_time.GetHour(wxDateTime::TZ::UTC); + pDateTime->minute = date_time.GetMinute(wxDateTime::TZ::UTC); + pDateTime->second = date_time.GetSecond(wxDateTime::TZ::UTC); + pDateTime->microsecond = date_time.GetMillisecond(wxDateTime::TZ::UTC) * 1000; return CELL_OK; } -int cellRtcIsLeapYear(int year) +int cellRtcIsLeapYear(s32 year) { cellRtc.Log("cellRtcIsLeapYear(year=%d)", year); @@ -481,7 +489,7 @@ int cellRtcIsLeapYear(int year) return datetime.IsLeapYear(year, wxDateTime::Gregorian); } -int cellRtcGetDaysInMonth(int year, int month) +int cellRtcGetDaysInMonth(s32 year, s32 month) { cellRtc.Log("cellRtcGetDaysInMonth(year=%d, month=%d)", year, month); @@ -489,7 +497,7 @@ int cellRtcGetDaysInMonth(int year, int month) return datetime.GetNumberOfDays((wxDateTime::Month) month, year, wxDateTime::Gregorian); } -int cellRtcGetDayOfWeek(int year, int month, int day) +int cellRtcGetDayOfWeek(s32 year, s32 month, s32 day) { cellRtc.Log("cellRtcGetDayOfWeek(year=%d, month=%d, day=%d)", year, month, day); @@ -498,36 +506,32 @@ int cellRtcGetDayOfWeek(int year, int month, int day) return datetime.GetWeekDay(); } -int cellRtcCheckValid(u32 datetime_addr) +int cellRtcCheckValid(mem_ptr_t pTime) { - cellRtc.Log("cellRtcCheckValid(datetime_addr=0x%x)", datetime_addr); - CellRtcDateTime datetime; - datetime.year = Memory.Read16(datetime_addr); - datetime.month = Memory.Read16(datetime_addr + 2); - datetime.day = Memory.Read16(datetime_addr + 4); - datetime.hour = Memory.Read16(datetime_addr + 6); - datetime.minute = Memory.Read16(datetime_addr + 8); - datetime.second = Memory.Read16(datetime_addr + 10); - datetime.microsecond = Memory.Read32(datetime_addr + 12); + cellRtc.Log("cellRtcCheckValid(pTime=0x%x)", pTime.GetAddr()); - if((datetime.year < 1) || (datetime.year > 9999)) return CELL_RTC_ERROR_INVALID_YEAR; - else if((datetime.month < 1) || (datetime.month > 12)) return CELL_RTC_ERROR_INVALID_MONTH; - else if((datetime.day < 1) || (datetime.day > 31)) return CELL_RTC_ERROR_INVALID_DAY; - else if((datetime.hour < 0) || (datetime.hour > 23)) return CELL_RTC_ERROR_INVALID_HOUR; - else if((datetime.minute < 0) || (datetime.minute > 59)) return CELL_RTC_ERROR_INVALID_MINUTE; - else if((datetime.second < 0) || (datetime.second > 59)) return CELL_RTC_ERROR_INVALID_SECOND; - else if((datetime.microsecond < 0) || (datetime.microsecond > 999999)) return CELL_RTC_ERROR_INVALID_MICROSECOND; + if (!pTime.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + if ((pTime->year < 1) || (pTime->year > 9999)) return CELL_RTC_ERROR_INVALID_YEAR; + else if ((pTime->month < 1) || (pTime->month > 12)) return CELL_RTC_ERROR_INVALID_MONTH; + else if ((pTime->day < 1) || (pTime->day > 31)) return CELL_RTC_ERROR_INVALID_DAY; + else if ((pTime->hour < 0) || (pTime->hour > 23)) return CELL_RTC_ERROR_INVALID_HOUR; + else if ((pTime->minute < 0) || (pTime->minute > 59)) return CELL_RTC_ERROR_INVALID_MINUTE; + else if ((pTime->second < 0) || (pTime->second > 59)) return CELL_RTC_ERROR_INVALID_SECOND; + else if ((pTime->microsecond < 0) || (pTime->microsecond > 999999)) return CELL_RTC_ERROR_INVALID_MICROSECOND; else return CELL_OK; } -int cellRtcCompareTick(u32 tick_addr_1, u32 tick_addr_2) +int cellRtcCompareTick(mem_ptr_t pTick0, mem_ptr_t pTick1) { - cellRtc.Log("cellRtcCompareTick(tick_addr_1=0x%x, tick_addr_2=0x%x)", tick_addr_1, tick_addr_2); - u64 tick1 = Memory.Read64(tick_addr_1); - u64 tick2 = Memory.Read64(tick_addr_2); + cellRtc.Log("cellRtcCompareTick(pTick0=0x%x, pTick1=0x%x)", pTick0.GetAddr(), pTick1.GetAddr()); - if(tick1 < tick2) return -1; - else if(tick1 > tick2) return 1; + if (!pTick0.IsGood() || !pTick1.IsGood()) + return CELL_RTC_ERROR_INVALID_POINTER; + + if (pTick0->tick < pTick1->tick) return -1; + else if (pTick0->tick > pTick1->tick) return 1; else return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellRtc.h b/rpcs3/Emu/SysCalls/Modules/cellRtc.h index 5e9483c917..3863de0b01 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRtc.h +++ b/rpcs3/Emu/SysCalls/Modules/cellRtc.h @@ -21,16 +21,16 @@ enum struct CellRtcTick { - u64 tick; + be_t tick; }; struct CellRtcDateTime { - u16 year; - u16 month; - u16 day; - u16 hour; - u16 minute; - u16 second; - u32 microsecond; + be_t year; + be_t month; + be_t day; + be_t hour; + be_t minute; + be_t second; + be_t microsecond; }; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.h b/rpcs3/Emu/SysCalls/Modules/cellSpurs.h index c18732669e..d13ed3d523 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.h @@ -51,9 +51,9 @@ struct CellSpursAttribute struct CellSpursInfo { - be_t nSpus; - be_t spuThreadGroupPriority; - be_t ppuThreadPriority; + be_t nSpus; + be_t spuThreadGroupPriority; + be_t ppuThreadPriority; bool exitIfNoWork; bool spurs2; be_t traceBuffer_addr; //void *traceBuffer; @@ -63,7 +63,7 @@ struct CellSpursInfo be_t spuThreads[8]; //typedef u32 sys_spu_thread_t; be_t spursHandlerThread0; be_t spursHandlerThread1; - char namePrefix[CELL_SPURS_NAME_MAX_LENGTH+1]; + s8 namePrefix[CELL_SPURS_NAME_MAX_LENGTH+1]; be_t namePrefixLength; be_t deadlineMissCounter; be_t deadlineMeetCounter; @@ -125,7 +125,7 @@ struct CellSpursTracePacket struct start_struct { - char module[4]; + s8 module[4]; be_t level; be_t ls; } start; @@ -143,17 +143,17 @@ struct CellSpursTaskset // Exception handlers. typedef void (*CellSpursGlobalExceptionEventHandler)(mem_ptr_t spurs, const mem_ptr_t info, - uint id, mem_ptr_t arg); + u32 id, mem_ptr_t arg); typedef void (*CellSpursTasksetExceptionEventHandler)(mem_ptr_t spurs, mem_ptr_t taskset, - uint idTask, const mem_ptr_t info, mem_ptr_t arg); + u32 idTask, const mem_ptr_t info, mem_ptr_t arg); struct CellSpursTasksetInfo { //CellSpursTaskInfo taskInfo[CELL_SPURS_MAX_TASK]; be_t argument; - be_t idWorkload; - be_t idLastScheduledTask; //typedef unsigned CellSpursTaskId + be_t idWorkload; + be_t idLastScheduledTask; //typedef unsigned CellSpursTaskId be_t name_addr; CellSpursTasksetExceptionEventHandler exceptionEventHandler; be_t exceptionEventHandlerArgument_addr; //void *exceptionEventHandlerArgument diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index fdbe6b0a4f..c261d848e9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -174,28 +174,20 @@ int cellVideoOutGetState(u32 videoOut, u32 deviceIndex, u32 state_addr) return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT; } -int cellVideoOutGetResolution(u32 resolutionId, u32 resolution_addr) +int cellVideoOutGetResolution(u32 resolutionId, mem_ptr_t resolution) { cellSysutil.Log("cellVideoOutGetResolution(resolutionId=%d, resolution_addr=0x%x)", - resolutionId, resolution_addr); + resolutionId, resolution.GetAddr()); - if(!Memory.IsGoodAddr(resolution_addr, sizeof(CellVideoOutResolution))) - { - return CELL_EFAULT; - } + if (!resolution.IsGood()) + return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER; u32 num = ResolutionIdToNum(resolutionId); - if(!num) - { return CELL_EINVAL; - } - CellVideoOutResolution res; - re(res.width, ResolutionTable[num].width); - re(res.height, ResolutionTable[num].height); - - Memory.WriteData(resolution_addr, res); + resolution->width = ResolutionTable[num].width; + resolution->height = ResolutionTable[num].height; return CELL_VIDEO_OUT_SUCCEEDED; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.h b/rpcs3/Emu/SysCalls/Modules/cellSysutil.h index b606438b50..134c496cf4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.h @@ -215,14 +215,14 @@ struct CellHddGameStatGet struct CellHddGameStatSet { - CellHddGameSystemFileParam *setParam; - u32 reserved_addr; // void* + mem_beptr_t setParam; + be_t reserved_addr; // void* }; struct CellHddGameCBResult { be_t result; be_t errNeedSizeKB; - u8 *invalidMsg; - u32 reserved_addr; // void* + be_t invalidMsg_addr; // char* + be_t reserved_addr; // void* }; diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index d14f440b24..ec37e7592b 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -73,6 +73,36 @@ int sceNpDrmIsAvailable(u32 k_licensee_addr, u32 drm_path_addr) return CELL_OK; } +int sceNpDrmIsAvailable2(u32 k_licensee_addr, u32 drm_path_addr) +{ + UNIMPLEMENTED_FUNC(sceNp); + return CELL_OK; +} + +int sceNpDrmVerifyUpgradeLicense(u32 content_id_addr) +{ + UNIMPLEMENTED_FUNC(sceNp); + return CELL_OK; +} + +int sceNpDrmVerifyUpgradeLicense2(u32 content_id_addr) +{ + UNIMPLEMENTED_FUNC(sceNp); + return CELL_OK; +} + +int sceNpDrmExecuteGamePurchase() +{ + UNIMPLEMENTED_FUNC(sceNp); + return CELL_OK; +} + +int sceNpDrmGetTimelimit(u32 drm_path_addr, mem64_t time_remain_usec) +{ + UNIMPLEMENTED_FUNC(sceNp); + return CELL_OK; +} + int sceNpManagerGetStatus(mem32_t status) { sceNp.Log("sceNpManagerGetStatus(status_addr=0x%x)", status.GetAddr()); @@ -91,5 +121,10 @@ void sceNp_init() sceNp.AddFunc(0xbd28fdbf, sceNpInit); sceNp.AddFunc(0x4885aa18, sceNpTerm); sceNp.AddFunc(0xad218faf, sceNpDrmIsAvailable); + sceNp.AddFunc(0xf042b14f, sceNpDrmIsAvailable2); + sceNp.AddFunc(0x2ecd48ed, sceNpDrmVerifyUpgradeLicense); + sceNp.AddFunc(0xbe0e3ee2, sceNpDrmVerifyUpgradeLicense2); + sceNp.AddFunc(0xf283c143, sceNpDrmExecuteGamePurchase); + sceNp.AddFunc(0xcf51864b, sceNpDrmGetTimelimit); sceNp.AddFunc(0xa7bff757, sceNpManagerGetStatus); } diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index 595e1597b9..958b69a7f3 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -4,10 +4,10 @@ #include "SC_FUNC.h" namespace detail{ -template<> bool CheckId(u32 id, ID*& _id,const std::string &name) -{ - return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == name; -} + template<> bool CheckId(u32 id, ID*& _id,const std::string &name) + { + return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == name; + } } void default_syscall(); @@ -15,105 +15,211 @@ static func_caller *null_func = bind_func(default_syscall); static func_caller* sc_table[1024] = { - null_func, bind_func(sys_process_getpid), null_func, bind_func(sys_process_exit), null_func, //4 - null_func, null_func, null_func, null_func, null_func, //9 - null_func, null_func, bind_func(sys_process_get_number_of_object), bind_func(sys_process_get_id), null_func, //14 - null_func, null_func, null_func, bind_func(sys_process_getppid), null_func, //19 - null_func, null_func, bind_func(sys_process_exit), null_func, null_func, //24 - null_func, null_func, null_func, null_func, null_func, //29 - bind_func(sys_process_get_paramsfo), null_func, null_func, null_func, null_func, //34 - null_func, null_func, null_func, null_func, null_func, //39 - null_func, //40 (0x028) - bind_func(sys_ppu_thread_exit), //41 (0x029) - null_func, //42 (0x02A) - bind_func(sys_ppu_thread_yield), //43 (0x02B) - bind_func(sys_ppu_thread_join), //44 (0x02C) - bind_func(sys_ppu_thread_detach), //45 (0x02D) - bind_func(sys_ppu_thread_get_join_state), //46 (0x02E) - bind_func(sys_ppu_thread_set_priority), //47 (0x02F) - bind_func(sys_ppu_thread_get_priority), //48 (0x030) - bind_func(sys_ppu_thread_get_stack_information), //49 (0x031) - bind_func(sys_ppu_thread_stop), //50 (0x032) - bind_func(sys_ppu_thread_restart), //51 (0x033) - bind_func(sys_ppu_thread_create), //52 (0x034) - null_func, //53 (0x035) - null_func, //54 (0x036) - null_func, null_func, null_func, null_func, null_func, //59 - bind_func(sys_trace_create), //60 (0x03C) - bind_func(sys_trace_start), //61 (0x03D) - bind_func(sys_trace_stop), //62 (0x03E) - bind_func(sys_trace_update_top_index), //63 (0x03F) - bind_func(sys_trace_destroy), //64 (0x040) - bind_func(sys_trace_drain), //65 (0x041) - bind_func(sys_trace_attach_process), //66 (0x042) - bind_func(sys_trace_allocate_buffer), //67 (0x043) - bind_func(sys_trace_free_buffer), //68 (0x044) - bind_func(sys_trace_create2), //69 (0x045) - bind_func(sys_timer_create), //70 (0x046) - bind_func(sys_timer_destroy), //71 (0x047) - bind_func(sys_timer_get_information), //72 (0x048) - bind_func(sys_timer_start), //73 (0x049) - bind_func(sys_timer_stop), //74 (0x04A) - bind_func(sys_timer_connect_event_queue), //75 (0x04B) - bind_func(sys_timer_disconnect_event_queue), //76 (0x04C) - null_func, //77 (0x04D) - null_func, //78 (0x04E) - null_func, //79 (0x04F) - null_func, null_func, bind_func(sys_event_flag_create), bind_func(sys_event_flag_destroy), null_func, //84 - bind_func(sys_event_flag_wait), bind_func(sys_event_flag_trywait), bind_func(sys_event_flag_set), null_func, null_func, //89 - bind_func(sys_semaphore_create), //90 (0x05A) - bind_func(sys_semaphore_destroy), //91 (0x05B) - bind_func(sys_semaphore_wait), //92 (0x05C) - bind_func(sys_semaphore_trywait), //93 (0x05D) - bind_func(sys_semaphore_post), //94 (0x05E) - bind_func(sys_lwmutex_create), //95 (0x05F) - bind_func(sys_lwmutex_destroy), //96 (0x060) - bind_func(sys_lwmutex_lock), //97 (0x061) - bind_func(sys_lwmutex_trylock), //98 (0x062) - bind_func(sys_lwmutex_unlock), //99 (0x063) - bind_func(sys_mutex_create), //100 (0x064) - bind_func(sys_mutex_destroy), //101 (0x065) - bind_func(sys_mutex_lock), //102 (0x066) - bind_func(sys_mutex_trylock), //103 (0x067) - bind_func(sys_mutex_unlock), //104 (0x068) - bind_func(sys_cond_create), //105 (0x069) - bind_func(sys_cond_destroy), //106 (0x06A) - bind_func(sys_cond_wait), //107 (0x06B) - bind_func(sys_cond_signal), //108 (0x06C) - bind_func(sys_cond_signal_all), //109 (0x06D) - bind_func(sys_cond_signal_to), null_func, null_func, null_func, //113 (0x071) + null_func, + bind_func(sys_process_getpid), //1 (0x001) + null_func,//bind_func(sys_process_wait_for_child), //2 (0x002) ROOT + bind_func(sys_process_exit), //3 (0x003) + null_func,//bind_func(sys_process_get_status), //4 (0x004) DBG + null_func,//bind_func(sys_process_detach_child), //5 (0x005) DBG + + // Unused: 6-11 + null_func, null_func, null_func, null_func, null_func, null_func, + + bind_func(sys_process_get_number_of_object), //12 (0x00B) + bind_func(sys_process_get_id), //13 (0x00C) + null_func,//bind_func(sys_process_is_spu_lock_line_reservation_address), //14 (0x00D) + + // Unused: 15-17 + null_func, null_func, null_func, + + bind_func(sys_process_getppid), //18 (0x012) + null_func,//bind_func(sys_process_kill), //19 (0x013) + null_func, // + null_func,//bind_func(_sys_process_spawn), //21 (0x015) DBG + bind_func(sys_process_exit), //22 (0x016) + null_func,//bind_func(sys_process_wait_for_child2), //23 (0x017) DBG + null_func,//bind_func(), //24 (0x018) DBG + null_func,//bind_func(sys_process_get_sdk_version), //25 (0x019) + null_func,//bind_func(_sys_process_exit), //26 (0x01A) + null_func,//bind_func(), //27 (0x01B) DBG + null_func,//bind_func(_sys_process_get_number_of_object)//28 (0x01C) ROOT + null_func,//bind_func(sys_process_get_id), //29 (0x01D) ROOT + bind_func(sys_process_get_paramsfo), //30 (0x01E) + null_func,//bind_func(sys_process_get_ppu_guid), //31 (0x01F) + + // Unused: 32-40 + null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, + + bind_func(sys_ppu_thread_exit), //41 (0x029) + null_func, // + bind_func(sys_ppu_thread_yield), //43 (0x02B) + bind_func(sys_ppu_thread_join), //44 (0x02C) + bind_func(sys_ppu_thread_detach), //45 (0x02D) + bind_func(sys_ppu_thread_get_join_state), //46 (0x02E) + bind_func(sys_ppu_thread_set_priority), //47 (0x02F) DBG + bind_func(sys_ppu_thread_get_priority), //48 (0x030) + bind_func(sys_ppu_thread_get_stack_information), //49 (0x031) + bind_func(sys_ppu_thread_stop), //50 (0x032) ROOT + bind_func(sys_ppu_thread_restart), //51 (0x033) ROOT + bind_func(sys_ppu_thread_create), //52 (0x034) DBG + null_func,//bind_func(sys_ppu_thread_start), //53 (0x035) + null_func,//bind_func(), //54 (0x036) ROOT + null_func,//bind_func(), //55 (0x037) ROOT + null_func,//bind_func(sys_ppu_thread_rename), //56 (0x038) + null_func,//bind_func(sys_ppu_thread_recover_page_fault)//57 (0x039) + null_func,//bind_func(sys_ppu_thread_get_page_fault_context),//58 (0x03A) + + // Unused: 59 + null_func, + + bind_func(sys_trace_create), //60 (0x03C) + bind_func(sys_trace_start), //61 (0x03D) + bind_func(sys_trace_stop), //62 (0x03E) + bind_func(sys_trace_update_top_index), //63 (0x03F) + bind_func(sys_trace_destroy), //64 (0x040) + bind_func(sys_trace_drain), //65 (0x041) + bind_func(sys_trace_attach_process), //66 (0x042) + bind_func(sys_trace_allocate_buffer), //67 (0x043) + bind_func(sys_trace_free_buffer), //68 (0x044) + bind_func(sys_trace_create2), //69 (0x045) + bind_func(sys_timer_create), //70 (0x046) + bind_func(sys_timer_destroy), //71 (0x047) + bind_func(sys_timer_get_information), //72 (0x048) + bind_func(sys_timer_start), //73 (0x049) + bind_func(sys_timer_stop), //74 (0x04A) + bind_func(sys_timer_connect_event_queue), //75 (0x04B) + bind_func(sys_timer_disconnect_event_queue), //76 (0x04C) + null_func,//bind_func(sys_trace_create2_in_cbepm), //77 (0x04D) + null_func,//bind_func() //78 (0x04E) + + // Unused: 79 + null_func, + + null_func,//bind_func(sys_interrupt_tag_create) //80 (0x050) + null_func,//bind_func(sys_interrupt_tag_destroy) //81 (0x051) + bind_func(sys_event_flag_create), //82 (0x052) + bind_func(sys_event_flag_destroy), //83 (0x053) + null_func,//bind_func(sys_interrupt_thread_establish) //84 (0x054) + bind_func(sys_event_flag_wait), //85 (0x055) + bind_func(sys_event_flag_trywait), //86 (0x056) + bind_func(sys_event_flag_set), //87 (0x057) + null_func,//bind_func(sys_interrupt_thread_eoi) //88 (0x058) + null_func,//bind_func(sys_interrupt_thread_disestablish)//89 (0x059) + bind_func(sys_semaphore_create), //90 (0x05A) + bind_func(sys_semaphore_destroy), //91 (0x05B) + bind_func(sys_semaphore_wait), //92 (0x05C) + bind_func(sys_semaphore_trywait), //93 (0x05D) + bind_func(sys_semaphore_post), //94 (0x05E) + bind_func(sys_lwmutex_create), //95 (0x05F) + bind_func(sys_lwmutex_destroy), //96 (0x060) + bind_func(sys_lwmutex_lock), //97 (0x061) + bind_func(sys_lwmutex_trylock), //98 (0x062) + bind_func(sys_lwmutex_unlock), //99 (0x063) + bind_func(sys_mutex_create), //100 (0x064) + bind_func(sys_mutex_destroy), //101 (0x065) + bind_func(sys_mutex_lock), //102 (0x066) + bind_func(sys_mutex_trylock), //103 (0x067) + bind_func(sys_mutex_unlock), //104 (0x068) + bind_func(sys_cond_create), //105 (0x069) + bind_func(sys_cond_destroy), //106 (0x06A) + bind_func(sys_cond_wait), //107 (0x06B) + bind_func(sys_cond_signal), //108 (0x06C) + bind_func(sys_cond_signal_all), //109 (0x06D) + bind_func(sys_cond_signal_to), //110 (0x06E) + null_func,//bind_func(sys_lwcond_create) //111 (0x06F) + null_func,//bind_func(sys_lwcond_destroy) //112 (0x070) + null_func,//bind_func(sys_lwcond_queue_wait) //113 (0x071) bind_func(sys_semaphore_get_value), //114 (0x072) - null_func, null_func, null_func, bind_func(sys_event_flag_clear), null_func, //119 (0x077) - bind_func(sys_rwlock_create), //120 (0x078) - bind_func(sys_rwlock_destroy), //121 (0x079) - bind_func(sys_rwlock_rlock), //122 (0x07A) - bind_func(sys_rwlock_tryrlock), //123 (0x07B) - bind_func(sys_rwlock_runlock), //124 (0x07C) - bind_func(sys_rwlock_wlock), //125 (0x07D) - bind_func(sys_rwlock_trywlock), //126 (0x07E) - bind_func(sys_rwlock_wunlock), //127 (0x07F) - bind_func(sys_event_queue_create), //128 (0x080) - bind_func(sys_event_queue_destroy), //129 (0x081) - bind_func(sys_event_queue_receive), bind_func(sys_event_queue_tryreceive), // 131 - bind_func(sys_event_flag_cancel), bind_func(sys_event_queue_drain), bind_func(sys_event_port_create), //134 - bind_func(sys_event_port_destroy), bind_func(sys_event_port_connect_local), //136 - bind_func(sys_event_port_disconnect), bind_func(sys_event_port_send), bind_func(sys_event_flag_get), //139 - null_func, bind_func(sys_timer_usleep), bind_func(sys_timer_sleep), null_func, bind_func(sys_time_get_timezone), //144 - bind_func(sys_time_get_current_time), bind_func(sys_time_get_system_time), bind_func(sys_time_get_timebase_frequency), null_func, null_func, //149 - null_func, null_func, null_func, null_func, null_func, //154 - null_func, bind_func(sys_spu_image_open), null_func, null_func, null_func, //159 - bind_func(sys_raw_spu_create), null_func, null_func, null_func, null_func, //164 - bind_func(sys_spu_thread_get_exit_status), bind_func(sys_spu_thread_set_argument), null_func, null_func, bind_func(sys_spu_initialize), //169 - bind_func(sys_spu_thread_group_create), bind_func(sys_spu_thread_group_destroy), bind_func(sys_spu_thread_initialize), //172 - bind_func(sys_spu_thread_group_start), bind_func(sys_spu_thread_group_suspend), //174 - bind_func(sys_spu_thread_group_resume), null_func, null_func, bind_func(sys_spu_thread_group_join), null_func, //179 - null_func, bind_func(sys_spu_thread_write_ls), bind_func(sys_spu_thread_read_ls), null_func, bind_func(sys_spu_thread_write_snr), //184 - bind_func(sys_spu_thread_group_connect_event), bind_func(sys_spu_thread_group_disconnect_event), //186 - bind_func(sys_spu_thread_set_spu_cfg), bind_func(sys_spu_thread_get_spu_cfg), null_func, //189 - bind_func(sys_spu_thread_write_spu_mb), bind_func(sys_spu_thread_connect_event), bind_func(sys_spu_thread_disconnect_event), //192 - bind_func(sys_spu_thread_bind_queue), bind_func(sys_spu_thread_unbind_queue), //194 - null_func, null_func, null_func, null_func, null_func, //199 - null_func, null_func, null_func, null_func, null_func, //204 + null_func,//bind_func() //115 (0x073) + null_func,//bind_func() //116 (0x074) + null_func,//bind_func() //117 (0x075) + bind_func(sys_event_flag_clear), //118 (0x076) + null_func,//bind_func() //119 (0x077) ROOT + bind_func(sys_rwlock_create), //120 (0x078) + bind_func(sys_rwlock_destroy), //121 (0x079) + bind_func(sys_rwlock_rlock), //122 (0x07A) + bind_func(sys_rwlock_tryrlock), //123 (0x07B) + bind_func(sys_rwlock_runlock), //124 (0x07C) + bind_func(sys_rwlock_wlock), //125 (0x07D) + bind_func(sys_rwlock_trywlock), //126 (0x07E) + bind_func(sys_rwlock_wunlock), //127 (0x07F) + bind_func(sys_event_queue_create), //128 (0x080) + bind_func(sys_event_queue_destroy), //129 (0x081) + bind_func(sys_event_queue_receive), //130 (0x082) + bind_func(sys_event_queue_tryreceive), //131 (0x083) + bind_func(sys_event_flag_cancel), //132 (0x084) + bind_func(sys_event_queue_drain), //133 (0x085) + bind_func(sys_event_port_create), //134 (0x086) + bind_func(sys_event_port_destroy), //135 (0x087) + bind_func(sys_event_port_connect_local), //136 (0x088) + bind_func(sys_event_port_disconnect), //137 (0x089) + bind_func(sys_event_port_send), //138 (0x08A) + bind_func(sys_event_flag_get), //139 (0x08B) + null_func,//bind_func(sys_event_port_connect_ipc) //140 (0x08C) + bind_func(sys_timer_usleep), //141 (0x08D) + bind_func(sys_timer_sleep), //142 (0x08E) + null_func,//bind_func(sys_time_set_timezone) //143 (0x08F) ROOT + bind_func(sys_time_get_timezone), //144 (0x090) + bind_func(sys_time_get_current_time), //145 (0x091) + bind_func(sys_time_get_system_time), //146 (0x092) ROOT + bind_func(sys_time_get_timebase_frequency), //147 (0x093) + null_func,//bind_func(sys_rwlock_trywlock) //148 (0x094) + + // Unused: 149 + null_func, + + null_func,//bind_func(sys_raw_spu_create_interrupt_tag) //150 (0x096) + null_func,//bind_func(sys_raw_spu_set_int_mask) //151 (0x097) + null_func,//bind_func(sys_raw_spu_get_int_mask) //152 (0x098) + null_func,//bind_func(sys_raw_spu_set_int_stat) //153 (0x099) + null_func,//bind_func(sys_raw_spu_get_int_stat) //154 (0x09A) + null_func,//bind_func(sys_spu_image_get_information?) //155 (0x09B) + bind_func(sys_spu_image_open), //156 (0x09C) + null_func,//bind_func(sys_spu_image_import) //157 (0x09D) + null_func,//bind_func(sys_spu_image_close) //158 (0x09E) + null_func,//bind_func(sys_raw_spu_load) //159 (0x09F) + bind_func(sys_raw_spu_create), //160 (0x0A0) + null_func,//bind_func(sys_raw_spu_destroy) //161 (0x0A1) + null_func, // + null_func,//bind_func(sys_raw_spu_read_puint_mb) //163 (0x0A3) + null_func, // + bind_func(sys_spu_thread_get_exit_status), //165 (0x0A5) + bind_func(sys_spu_thread_set_argument), //166 (0x0A6) + null_func,//bind_func(sys_spu_thread_group_start_on_exit)//167(0x0A7) + null_func, // + bind_func(sys_spu_initialize), //169 (0x0A9) + bind_func(sys_spu_thread_group_create), //170 (0x0AA) + bind_func(sys_spu_thread_group_destroy), //171 (0x0AB) + bind_func(sys_spu_thread_initialize), //172 (0x0AC) + bind_func(sys_spu_thread_group_start), //173 (0x0AD) + bind_func(sys_spu_thread_group_suspend), //174 (0x0AE) + bind_func(sys_spu_thread_group_resume), //175 (0x0AF) + null_func,//bind_func(sys_spu_thread_group_yield) //176 (0x0B0) + null_func,//bind_func(sys_spu_thread_group_terminate) //177 (0x0B1) + bind_func(sys_spu_thread_group_join), //178 (0x0B2) + null_func,//bind_func(sys_spu_thread_group_set_priority)//179 (0x0B3) + null_func,//bind_func(sys_spu_thread_group_get_priority)//180 (0x0B4) + bind_func(sys_spu_thread_write_ls), //181 (0x0B5) + bind_func(sys_spu_thread_read_ls), //182 (0x0B6) + null_func, // + bind_func(sys_spu_thread_write_snr), //184 (0x0B8) + bind_func(sys_spu_thread_group_connect_event), //185 (0x0B9) + bind_func(sys_spu_thread_group_disconnect_event), //186 (0x0BA) + bind_func(sys_spu_thread_set_spu_cfg), //187 (0x0BB) + bind_func(sys_spu_thread_get_spu_cfg), //188 (0x0BC) + null_func, // + bind_func(sys_spu_thread_write_spu_mb), //190 (0x0BE) + bind_func(sys_spu_thread_connect_event), //191 (0x0BF) + bind_func(sys_spu_thread_disconnect_event), //192 (0x0C0) + bind_func(sys_spu_thread_bind_queue), //193 (0x0C1) + bind_func(sys_spu_thread_unbind_queue), //194 (0x0C2) + null_func, // + null_func,//bind_func(sys_raw_spu_set_spu_cfg) //196 (0x0C4) + null_func,//bind_func(sys_raw_spu_get_spu_cfg) //197 (0x0C5) + null_func,//bind_func(sys_spu_thread_recover_page_fault)//198 (0x0C6) + null_func,//bind_func(sys_raw_spu_recover_page_fault) //199 (0x0C7) + + null_func, null_func, null_func, null_func, null_func, //204(0x104) null_func, null_func, null_func, null_func, null_func, //209 null_func, null_func, null_func, null_func, null_func, //214 null_func, null_func, null_func, null_func, null_func, //219 @@ -123,9 +229,19 @@ static func_caller* sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //239 null_func, null_func, null_func, null_func, null_func, //244 null_func, null_func, null_func, null_func, null_func, //249 - null_func, bind_func(sys_spu_thread_group_connect_event_all_threads), bind_func(sys_spu_thread_group_disconnect_event_all_threads), null_func, null_func, //254 - null_func, null_func, null_func, null_func, null_func, //259 - null_func, null_func, null_func, null_func, null_func, //264 + null_func, //250 + + bind_func(sys_spu_thread_group_connect_event_all_threads),//251 (0x0FB) + bind_func(sys_spu_thread_group_disconnect_event_all_threads),//252 (0x0FC) + null_func,//bind_func() //253 (0x0FD) + null_func,//bind_func(sys_spu_thread_group_log) //254 (0x0FE) + + // Unused: 255-259 + null_func, null_func, null_func, null_func, null_func, + + null_func,//bind_func(sys_spu_image_open_by_fd) //260 (0x104) + + null_func, null_func, null_func, null_func, //264 null_func, null_func, null_func, null_func, null_func, //269 null_func, null_func, null_func, null_func, null_func, //274 null_func, null_func, null_func, null_func, null_func, //279 @@ -133,6 +249,7 @@ static func_caller* sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //289 null_func, null_func, null_func, null_func, null_func, //294 null_func, null_func, null_func, null_func, null_func, //299 + bind_func(sys_vm_memory_map), //300 (0x12C) bind_func(sys_vm_unmap), //301 (0x12D) bind_func(sys_vm_append_memory), //302 (0x12E) @@ -146,32 +263,56 @@ static func_caller* sc_table[1024] = bind_func(sys_vm_sync), //310 (0x136) bind_func(sys_vm_test), //311 (0x137) bind_func(sys_vm_get_statistics), //312 (0x138) - null_func, null_func, //314 - null_func, null_func, null_func, null_func, null_func, //319 - null_func, null_func, null_func, null_func, //323 - bind_func(sys_memory_container_create), //324 - bind_func(sys_memory_container_destroy), //325 - bind_func(sys_mmapper_allocate_fixed_address), //326 - bind_func(sys_mmapper_enable_page_fault_notification), //327 - null_func, null_func, //329 - bind_func(sys_mmapper_allocate_address), //330 - bind_func(sys_mmapper_free_address), //331 - null_func, null_func, null_func, null_func, //335 - bind_func(sys_mmapper_change_address_access_right), //336 - bind_func(sys_mmapper_search_and_map), //337 - null_func, null_func, null_func, //340 - bind_func(sys_memory_container_create), //341 - bind_func(sys_memory_container_destroy), //342 - bind_func(sys_memory_container_get_size), //343 - null_func, null_func, null_func, null_func, //347 - bind_func(sys_memory_allocate), //348 - bind_func(sys_memory_free), //349 - bind_func(sys_memory_allocate_from_container), //350 - bind_func(sys_memory_get_page_attribute), //351 - bind_func(sys_memory_get_user_memory_size), //352 - null_func, null_func, //354 - null_func, null_func, null_func, null_func, null_func, //359 - null_func, null_func, null_func, null_func, null_func, //364 + null_func,//bind_func() //313 (0x139) + null_func,//bind_func() //314 (0x13A) + null_func,//bind_func() //315 (0x13B) + + // Unused: 316-323 + null_func, null_func, null_func, null_func, null_func, null_func, null_func, null_func, + + bind_func(sys_memory_container_create), //324 (0x144) + bind_func(sys_memory_container_destroy), //325 (0x145) + bind_func(sys_mmapper_allocate_fixed_address), //326 (0x146) + bind_func(sys_mmapper_enable_page_fault_notification), //327 (0x147) + null_func,//bind_func() //328 (0x148) + null_func,//bind_func(sys_mmapper_free_shared_memory) //329 (0x149) + bind_func(sys_mmapper_allocate_address), //330 (0x14A) + bind_func(sys_mmapper_free_address), //331 (0x14B) + null_func,//bind_func(sys_mmapper_allocate_shared_memory)//332(0x14C) + null_func,//bind_func(sys_mmapper_set_shared_memory_flag)//333(0x14D) + null_func,//bind_func(sys_mmapper_map_shared_memory) //334 (0x14E) + null_func,//bind_func(sys_mmapper_unmap_shared_memory) //335 (0x14F) + bind_func(sys_mmapper_change_address_access_right), //336 (0x150) + bind_func(sys_mmapper_search_and_map), //337 (0x151) + null_func,//bind_func(sys_mmapper_get_shared_memory_attribute) //338 (0x152) + null_func,//bind_func() //339 (0x153) + null_func,//bind_func() //340 (0x154) + bind_func(sys_memory_container_create), //341 (0x155) + bind_func(sys_memory_container_destroy), //342 (0x156) + bind_func(sys_memory_container_get_size), //343 (0x157) + null_func,//bind_func(sys_memory_budget_set) //344 (0x158) + null_func,//bind_func() //345 (0x159) + null_func,//bind_func() //346 (0x15A) + null_func, // + bind_func(sys_memory_allocate), //348 (0x15C) + bind_func(sys_memory_free), //349 (0x15D) + bind_func(sys_memory_allocate_from_container), //350 (0x15E) + bind_func(sys_memory_get_page_attribute), //351 (0x15F) + bind_func(sys_memory_get_user_memory_size), //352 (0x160) + null_func,//bind_func(sys_memory_get_user_memory_stat) //353 (0x161) + null_func,//bind_func() //354 (0x162) + null_func,//bind_func() //355 (0x163) + null_func,//bind_func(sys_memory_allocate_colored) //356 (0x164) + null_func,//bind_func() //357 (0x165) + null_func,//bind_func() //358 (0x166) + null_func,//bind_func() //359 (0x167) + null_func,//bind_func() //360 (0x168) + null_func,//bind_func(sys_memory_allocate_from_container_colored) //361 (0x169) + null_func,//bind_func(sys_mmapper_allocate_memory_from_container) //362 (0x16A) + null_func,//bind_func() //363 (0x16B) + null_func,//bind_func() //364 (0x16C) + + null_func, null_func, null_func, null_func, null_func, //369 null_func, null_func, null_func, null_func, null_func, //374 null_func, null_func, null_func, null_func, null_func, //379 @@ -232,21 +373,23 @@ static func_caller* sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //654 null_func, null_func, null_func, null_func, null_func, //659 null_func, null_func, null_func, null_func, null_func, //664 - null_func, //665 (0x299) - bind_func(sys_rsx_device_open), //666 (0x29A) - bind_func(sys_rsx_device_close), //667 (0x29B) - bind_func(sys_rsx_memory_allocate), //668 (0x29C) - bind_func(sys_rsx_memory_free), //669 (0x29D) - bind_func(sys_rsx_context_allocate), //670 (0x29E) - bind_func(sys_rsx_context_free), //671 (0x29F) - bind_func(sys_rsx_context_iomap), //672 (0x2A0) - bind_func(sys_rsx_context_iounmap), //673 (0x2A1) - bind_func(sys_rsx_context_attribute), //674 (0x2A2) - bind_func(sys_rsx_device_map), //675 (0x2A3) - bind_func(sys_rsx_device_unmap), //676 (0x2A4) - bind_func(sys_rsx_attribute), //677 (0x2A5) - null_func, //678 (0x2A6) - null_func, //679 (0x2A7) + null_func, //665 + + bind_func(sys_rsx_device_open), //666 (0x29A) + bind_func(sys_rsx_device_close), //667 (0x29B) + bind_func(sys_rsx_memory_allocate), //668 (0x29C) + bind_func(sys_rsx_memory_free), //669 (0x29D) + bind_func(sys_rsx_context_allocate), //670 (0x29E) + bind_func(sys_rsx_context_free), //671 (0x29F) + bind_func(sys_rsx_context_iomap), //672 (0x2A0) + bind_func(sys_rsx_context_iounmap), //673 (0x2A1) + bind_func(sys_rsx_context_attribute), //674 (0x2A2) + bind_func(sys_rsx_device_map), //675 (0x2A3) + bind_func(sys_rsx_device_unmap), //676 (0x2A4) + bind_func(sys_rsx_attribute), //677 (0x2A5) + null_func, //678 (0x2A6) + null_func, //679 (0x2A7) ROOT + null_func, null_func, null_func, null_func, null_func, //684 null_func, null_func, null_func, null_func, null_func, //689 null_func, null_func, null_func, null_func, null_func, //694 @@ -271,28 +414,57 @@ static func_caller* sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //789 null_func, null_func, null_func, null_func, null_func, //794 null_func, null_func, null_func, null_func, null_func, //799 - null_func, //800 (0x320) - bind_func(cellFsOpen), //801 (0x321) - bind_func(cellFsRead), //802 (0x322) - bind_func(cellFsWrite), //803 (0x323) - bind_func(cellFsClose), //804 (0x324) - bind_func(cellFsOpendir), //805 (0x325) - bind_func(cellFsReaddir), //806 (0x326) - bind_func(cellFsClosedir), //807 (0x327) - bind_func(cellFsStat), //808 (0x328) - bind_func(cellFsFstat), //809 (0x329) - null_func, //810 (0x32A) - bind_func(cellFsMkdir), //811 (0x32B) - bind_func(cellFsRename), //812 (0x32C) - bind_func(cellFsRmdir), //813 (0x32D) - bind_func(cellFsUnlink), //814 (0x32E) - null_func, null_func, null_func, bind_func(cellFsLseek), null_func, //819 - null_func, null_func, null_func, null_func, null_func, //824 - null_func, null_func, null_func, null_func, null_func, //829 - null_func, null_func, null_func, null_func, null_func, //834 - null_func, null_func, null_func, null_func, null_func, //839 - null_func, null_func, null_func, null_func, null_func, //844 - null_func, null_func, null_func, null_func, null_func, //849 + + null_func,//bind_func(sys_fs_test), //800 (0x320) + bind_func(cellFsOpen), //801 (0x321) + bind_func(cellFsRead), //802 (0x322) + bind_func(cellFsWrite), //803 (0x323) + bind_func(cellFsClose), //804 (0x324) + bind_func(cellFsOpendir), //805 (0x325) + bind_func(cellFsReaddir), //806 (0x326) + bind_func(cellFsClosedir), //807 (0x327) + bind_func(cellFsStat), //808 (0x328) + bind_func(cellFsFstat), //809 (0x329) + null_func,//bind_func(sys_fs_link), //810 (0x32A) + bind_func(cellFsMkdir), //811 (0x32B) + bind_func(cellFsRename), //812 (0x32C) + bind_func(cellFsRmdir), //813 (0x32D) + bind_func(cellFsUnlink), //814 (0x32E) + null_func,//bind_func(cellFsUtime), //815 (0x32F) + null_func,//bind_func(sys_fs_access), //816 (0x330) + null_func,//bind_func(sys_fs_fcntl), //817 (0x331) + bind_func(cellFsLseek), //818 (0x332) + null_func,//bind_func(sys_fs_fdatasync), //819 (0x333) + null_func,//bind_func(cellFsFsync), //820 (0x334) + bind_func(cellFsFGetBlockSize), //821 (0x335) + bind_func(cellFsGetBlockSize), //822 (0x336) + null_func,//bind_func(sys_fs_acl_read), //823 (0x337) + null_func,//bind_func(sys_fs_acl_write), //824 (0x338) + null_func,//bind_func(sys_fs_lsn_get_cda_size), //825 (0x339) + null_func,//bind_func(sys_fs_lsn_get_cda), //826 (0x33A) + null_func,//bind_func(sys_fs_lsn_lock), //827 (0x33B) + null_func,//bind_func(sys_fs_lsn_unlock), //828 (0x33C) + null_func,//bind_func(sys_fs_lsn_read), //829 (0x33D) + null_func,//bind_func(sys_fs_lsn_write), //830 (0x33E) + bind_func(cellFsTruncate), //831 (0x33F) + bind_func(cellFsFtruncate), //832 (0x340) + null_func,//bind_func(sys_fs_symbolic_link), //833 (0x341) + null_func,//bind_func(cellFsChmod), //834 (0x342) + null_func,//bind_func(sys_fs_chown), //835 (0x343) + null_func,//bind_func(sys_fs_newfs), //836 (0x344) + null_func,//bind_func(sys_fs_mount), //837 (0x345) + null_func,//bind_func(sys_fs_unmount), //838 (0x346) + null_func,//bind_func(sys_fs_sync), //839 (0x347) + null_func,//bind_func(sys_fs_disk_free), //840 (0x348) + null_func,//bind_func(sys_fs_get_mount_info_size), //841 (0x349) + null_func,//bind_func(sys_fs_get_mount_info), //842 (0x34A) + null_func,//bind_func(sys_fs_get_fs_info_size), //843 (0x34B) + null_func,//bind_func(sys_fs_get_fs_info), //844 (0x34C) + null_func,//bind_func(sys_fs_mapped_allocate), //845 (0x34D) + null_func,//bind_func(sys_fs_mapped_free), //846 (0x34E) + null_func,//bind_func(sys_fs_truncate2), //847 (0x34F) + + null_func, null_func, //849 null_func, null_func, null_func, null_func, null_func, //854 null_func, null_func, null_func, null_func, null_func, //859 null_func, null_func, null_func, null_func, null_func, //864 @@ -327,7 +499,7 @@ static func_caller* sc_table[1024] = null_func, null_func, null_func, null_func, null_func, //1009 null_func, null_func, null_func, null_func, null_func, //1014 null_func, null_func, null_func, null_func, null_func, //1019 - null_func, null_func, null_func, bind_func(cellGcmCallback), //1024 + null_func, null_func, null_func, bind_func(cellGcmCallback), //1024 }; void default_syscall() diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index ef929bf25a..481dbae878 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -294,7 +294,7 @@ extern int cellFsStReadWaitCallback(u32 fd, u64 size, mem_func_ptr_t resolution); extern int cellVideoOutConfigure(u32 videoOut, u32 config_addr, u32 option_addr, u32 waitForEvent); extern int cellVideoOutGetConfiguration(u32 videoOut, u32 config_addr, u32 option_addr); extern int cellVideoOutGetNumberOfDevice(u32 videoOut); diff --git a/rpcs3/Gui/ConLog.cpp b/rpcs3/Gui/ConLog.cpp index 094c91c2a7..4bb1c7a252 100644 --- a/rpcs3/Gui/ConLog.cpp +++ b/rpcs3/Gui/ConLog.cpp @@ -212,19 +212,24 @@ void LogFrame::Task() const LogPacket item = LogBuffer.Pop(); - while(m_log.GetItemCount() > max_item_count) + wxListView& m_log = this->m_log; //makes m_log capturable by the lambda + //queue adding the log message to the gui element in the main thread + wxTheApp->GetTopWindow()->GetEventHandler()->CallAfter([item, &m_log]() { - m_log.DeleteItem(0); - wxThread::Yield(); - } + while (m_log.GetItemCount() > max_item_count) + { + m_log.DeleteItem(0); + wxThread::Yield(); + } - const int cur_item = m_log.GetItemCount(); + const int cur_item = m_log.GetItemCount(); - m_log.InsertItem(cur_item, fmt::FromUTF8(item.m_prefix)); - m_log.SetItem(cur_item, 1, fmt::FromUTF8(item.m_text)); - m_log.SetItemTextColour(cur_item, fmt::FromUTF8(item.m_colour)); - m_log.SetColumnWidth(0, -1); // crashes on exit - m_log.SetColumnWidth(1, -1); + m_log.InsertItem(cur_item, fmt::FromUTF8(item.m_prefix)); + m_log.SetItem(cur_item, 1, fmt::FromUTF8(item.m_text)); + m_log.SetItemTextColour(cur_item, fmt::FromUTF8(item.m_colour)); + m_log.SetColumnWidth(0, -1); + m_log.SetColumnWidth(1, -1); + }); #ifdef _WIN32 ::SendMessage((HWND)m_log.GetHWND(), WM_VSCROLL, SB_BOTTOM, 0); diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 691c8a825a..85a5a83a33 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -398,7 +398,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) for(int i=1; iAppend(wxString::Format("%dx%d", ResolutionTable[i].width, ResolutionTable[i].height)); + cbox_gs_resolution->Append(wxString::Format("%dx%d", ResolutionTable[i].width.ToLE(), ResolutionTable[i].height.ToLE())); } cbox_gs_aspect->Append("4:3");