From 81cdaa883a72190ee892fb35c32456de9ee6320d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Wed, 2 Apr 2014 19:53:44 +0200 Subject: [PATCH] cellPngDec fixes and some rewritings * This commit solves the cellPngDec GetMemFromAddr(0x0) error when loading PNGs from files. * cellVideoOutGetResolution, cellRtc* syscalls rewritten to use the use the mem*_t data types. * Replaced int/uint with s32/u32 in some syscall arguments and structs. --- rpcs3/Emu/GS/sysutil_video.h | 10 +- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellPamf.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp | 10 +- rpcs3/Emu/SysCalls/Modules/cellPngDec.h | 40 +- rpcs3/Emu/SysCalls/Modules/cellRtc.cpp | 548 +++++++++++---------- rpcs3/Emu/SysCalls/Modules/cellRtc.h | 16 +- rpcs3/Emu/SysCalls/Modules/cellSpurs.h | 18 +- rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp | 20 +- rpcs3/Emu/SysCalls/Modules/cellSysutil.h | 8 +- rpcs3/Emu/SysCalls/SysCalls.h | 2 +- rpcs3/Gui/MainFrame.cpp | 2 +- 12 files changed, 344 insertions(+), 334 deletions(-) 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/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..fb431e1fd2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -38,7 +38,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; @@ -94,8 +94,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; } @@ -148,8 +148,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; } 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/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index e40cff1124..29101d6ea2 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/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");