Fix RTC to report the correct system time in Wii and GC titles as reported in Issue 1817
Modify GetLocalTimeSinceJan1970 to account for DST. GetGCTime() returns only GC epoch time(used by most Wii titles.) IPL-DEV subtracts Wii bias before copying to m_RTC(mostly used by homebrew.) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6133 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
d082f50c34
commit
aae0e96682
|
@ -174,15 +174,23 @@ u64 Timer::GetTimeSinceJan1970()
|
||||||
|
|
||||||
u64 Timer::GetLocalTimeSinceJan1970()
|
u64 Timer::GetLocalTimeSinceJan1970()
|
||||||
{
|
{
|
||||||
time_t sysTime, tzDiff;
|
time_t sysTime, tzDiff, tzDST;
|
||||||
struct tm * gmTime;
|
struct tm * gmTime;
|
||||||
|
|
||||||
time(&sysTime);
|
time(&sysTime);
|
||||||
|
|
||||||
|
// Account for DST where needed
|
||||||
|
gmTime = localtime(&sysTime);
|
||||||
|
if(gmTime->tm_isdst == 1)
|
||||||
|
tzDST = 3600;
|
||||||
|
else
|
||||||
|
tzDST = 0;
|
||||||
|
|
||||||
// Lazy way to get local time in sec
|
// Lazy way to get local time in sec
|
||||||
gmTime = gmtime(&sysTime);
|
gmTime = gmtime(&sysTime);
|
||||||
tzDiff = sysTime - mktime(gmTime);
|
tzDiff = sysTime - mktime(gmTime);
|
||||||
|
|
||||||
return (u64)(sysTime + tzDiff);
|
return (u64)(sysTime + tzDiff + tzDST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the current time formatted as Minutes:Seconds:Milliseconds
|
// Return the current time formatted as Minutes:Seconds:Milliseconds
|
||||||
|
|
|
@ -254,6 +254,9 @@ bool CEXIIPL::IsPresent()
|
||||||
|
|
||||||
void CEXIIPL::TransferByte(u8& _uByte)
|
void CEXIIPL::TransferByte(u8& _uByte)
|
||||||
{
|
{
|
||||||
|
// Seconds between 1.1.2000 and 4.1.2008 16:00:38
|
||||||
|
const u32 cWiiBias = 0x0F1114A6;
|
||||||
|
|
||||||
// The first 4 bytes must be the address
|
// The first 4 bytes must be the address
|
||||||
// If we haven't read it, do it now
|
// If we haven't read it, do it now
|
||||||
if (m_uPosition < 4)
|
if (m_uPosition < 4)
|
||||||
|
@ -267,7 +270,8 @@ void CEXIIPL::TransferByte(u8& _uByte)
|
||||||
if (m_uPosition == 3)
|
if (m_uPosition == 3)
|
||||||
{
|
{
|
||||||
// Get the time ...
|
// Get the time ...
|
||||||
u32 GCTime = CEXIIPL::GetGCTime();
|
// Subtract Wii bias
|
||||||
|
u32 GCTime = CEXIIPL::GetGCTime() - cWiiBias;
|
||||||
u8* pGCTime = (u8*)&GCTime;
|
u8* pGCTime = (u8*)&GCTime;
|
||||||
for (int i=0; i<4; i++)
|
for (int i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
|
@ -405,8 +409,7 @@ void CEXIIPL::TransferByte(u8& _uByte)
|
||||||
u32 CEXIIPL::GetGCTime()
|
u32 CEXIIPL::GetGCTime()
|
||||||
{
|
{
|
||||||
u64 ltime = 0;
|
u64 ltime = 0;
|
||||||
const u32 cJanuary2000 = 0x386D42C0; // Seconds between 1.1.1970 and 1.1.2000
|
const u32 cJanuary2000 = 0x386D4380; // Seconds between 1.1.1970 and 1.1.2000
|
||||||
const u32 cWiiBias = 0x0F111566; // Seconds between 1.1.2000 and 5.1.2008 (Wii epoch)
|
|
||||||
|
|
||||||
#if defined(HAVE_WX) && HAVE_WX
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
// hack in some netplay stuff
|
// hack in some netplay stuff
|
||||||
|
@ -415,10 +418,7 @@ u32 CEXIIPL::GetGCTime()
|
||||||
if (0 == ltime)
|
if (0 == ltime)
|
||||||
ltime = Common::Timer::GetLocalTimeSinceJan1970();
|
ltime = Common::Timer::GetLocalTimeSinceJan1970();
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
return ((u32)ltime - cJanuary2000);
|
||||||
return ((u32)ltime - cJanuary2000 - cWiiBias/* + 32434790*/);
|
|
||||||
else
|
|
||||||
return ((u32)ltime - cJanuary2000);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// (mb2): I think we can get rid of the IPL bias.
|
// (mb2): I think we can get rid of the IPL bias.
|
||||||
|
|
Loading…
Reference in New Issue