diff --git a/Core/HLE/HLETables.cpp b/Core/HLE/HLETables.cpp index f3546d8f69..53143d0c6a 100644 --- a/Core/HLE/HLETables.cpp +++ b/Core/HLE/HLETables.cpp @@ -104,8 +104,8 @@ const HLEFunction sceRtc[] = {0x34885E0D, 0, "sceRtcConvertUtcToLocalTime"}, {0x779242A2, 0, "sceRtcConvertLocalTimeToUTC"}, {0x42307A17, 0, "sceRtcIsLeapYear"}, - {0x05ef322c, 0, "sceRtcGetDaysInMonth"}, - {0x57726bc1, 0, "sceRtcGetDayOfWeek"}, + {0x05ef322c, &WrapU_UU, "sceRtcGetDaysInMonth"}, + {0x57726bc1, &WrapU_UUU, "sceRtcGetDayOfWeek"}, {0x4B1B5E82, 0, "sceRtcCheckValid"}, {0x3a807cc8, 0, "sceRtcSetTime_t"}, {0x27c4594c, 0, "sceRtcGetTime_t"}, diff --git a/Core/HLE/sceKernelTime.cpp b/Core/HLE/sceKernelTime.cpp index 47eee10720..c88f6966eb 100644 --- a/Core/HLE/sceKernelTime.cpp +++ b/Core/HLE/sceKernelTime.cpp @@ -150,6 +150,42 @@ void sceRtcGetTick() RETURN(0); } +u32 sceRtcGetDayOfWeek(u32 year, u32 month, u32 day) +{ + static u32 t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; + + year -= month < 3; + return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; +} + +u32 sceRtcGetDaysInMonth(u32 year, u32 month) +{ + DEBUG_LOG(HLE,"0=sceRtcGetDaysInMonth()"); + u32 numberOfDays; + + switch (month) + { + case 4: + case 6: + case 9: + case 11: + numberOfDays = 30; + break; + case 2: + if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) + numberOfDays = 29; + else + numberOfDays = 28; + break; + + default: + numberOfDays = 31; + break; + } + + return numberOfDays; +} + void sceRtcGetTickResolution() { DEBUG_LOG(HLE,"100=sceRtcGetTickResolution()"); diff --git a/Core/HLE/sceKernelTime.h b/Core/HLE/sceKernelTime.h index 0905a61a6b..6eaf4b5e5a 100644 --- a/Core/HLE/sceKernelTime.h +++ b/Core/HLE/sceKernelTime.h @@ -29,3 +29,5 @@ void sceKernelSysClock2USecWide(); void sceRtcGetCurrentClockLocalTime(); void sceRtcGetTickResolution(); void sceRtcGetTick(); +u32 sceRtcGetDaysInMonth(u32 year, u32 month); +u32 sceRtcGetDayOfWeek(u32 year, u32 month, u32 day); \ No newline at end of file diff --git a/test.py b/test.py index 9b87789165..c1d3cc04df 100644 --- a/test.py +++ b/test.py @@ -26,6 +26,7 @@ tests_good = [ "string/string", "gpu/callbacks/ge_callbacks", "threads/mbx/mbx", + "rtc/rtc", ] # These are the next tests up for fixing. @@ -44,7 +45,6 @@ tests_next = [ "mstick/mstick", "modules/loadexec/loader", "power/power", - "rtc/rtc", "sysmem/sysmem", "threads/events/events", "threads/fpl/fpl",