mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
Merge pull request #123 from tmaul/master
Improve the sceRtcTickAddMonths method
This commit is contained in:
@@ -618,18 +618,30 @@ int sceRtcTickAddMonths(u32 destTickPtr, u32 srcTickPtr, int numMonths)
|
||||
{
|
||||
if (Memory::IsValidAddress(destTickPtr) && Memory::IsValidAddress(srcTickPtr))
|
||||
{
|
||||
s64 srcTick = (s64)Memory::Read_U64(srcTickPtr);
|
||||
u64 srcTick = Memory::Read_U64(srcTickPtr);
|
||||
|
||||
// slightly bodgy but we need to add months to a pt and then convert to ticks (untested and broken)
|
||||
// slightly bodgy but we need to add months to a pt and then convert to ticks
|
||||
ScePspDateTime pt;
|
||||
|
||||
int years = numMonths /12;
|
||||
int realmonths = numMonths % 12;
|
||||
memset(&pt, 0, sizeof(pt));
|
||||
pt.year = years;
|
||||
pt.month = realmonths;
|
||||
srcTick +=__RtcPspTimeToTicks(pt);
|
||||
|
||||
if (numMonths < 0)
|
||||
{
|
||||
numMonths = (numMonths^0xFFFFFFFF)+1;
|
||||
int years = numMonths /12;
|
||||
int realmonths = numMonths % 12;
|
||||
|
||||
pt.year = years;
|
||||
pt.month = realmonths;
|
||||
srcTick -=__RtcPspTimeToTicks(pt);
|
||||
}
|
||||
else
|
||||
{
|
||||
int years = numMonths /12;
|
||||
int realmonths = numMonths % 12;
|
||||
|
||||
pt.year = years;
|
||||
pt.month = realmonths;
|
||||
srcTick +=__RtcPspTimeToTicks(pt);
|
||||
}
|
||||
Memory::Write_U64(srcTick, destTickPtr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user