Added the fake decrementer to the save state.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6880 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
skidau 2011-01-19 08:13:15 +00:00
parent f4dc56d553
commit 5aa34d0483
4 changed files with 69 additions and 16 deletions

View File

@ -63,6 +63,11 @@ int maxSliceLength = MAX_SLICE_LENGTH;
s64 globalTimer;
s64 idledCycles;
u32 fakeDecStartValue;
u64 fakeDecStartTicks;
u64 fakeTBStartValue;
u64 fakeTBStartTicks;
Common::CriticalSection externalEventSection;
void (*advanceCallback)(int cyclesExecuted) = NULL;
@ -155,6 +160,10 @@ void DoState(PointerWrap &p)
p.Do(slicelength);
p.Do(globalTimer);
p.Do(idledCycles);
p.Do(fakeDecStartValue);
p.Do(fakeDecStartTicks);
p.Do(fakeTBStartValue);
p.Do(fakeTBStartTicks);
// OK, here we're gonna need to specialize depending on the mode.
// Should do something generic to serialize linked lists.
switch (p.GetMode()) {
@ -542,4 +551,44 @@ std::string GetScheduledEventsSummary()
return text;
}
u32 GetFakeDecStartValue()
{
return fakeDecStartValue;
}
void SetFakeDecStartValue(u32 val)
{
fakeDecStartValue = val;
}
u64 GetFakeDecStartTicks()
{
return fakeDecStartTicks;
}
void SetFakeDecStartTicks(u64 val)
{
fakeDecStartTicks = val;
}
u64 GetFakeTBStartValue()
{
return fakeTBStartValue;
}
void SetFakeTBStartValue(u64 val)
{
fakeTBStartValue = val;
}
u64 GetFakeTBStartTicks()
{
return fakeTBStartTicks;
}
void SetFakeTBStartTicks(u64 val)
{
fakeTBStartTicks = val;
}
} // namespace

View File

@ -83,6 +83,15 @@ void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted));
std::string GetScheduledEventsSummary();
u32 GetFakeDecStartValue();
void SetFakeDecStartValue(u32 val);
u64 GetFakeDecStartTicks();
void SetFakeDecStartTicks(u64 val);
u64 GetFakeTBStartValue();
void SetFakeTBStartValue(u64 val);
u64 GetFakeTBStartTicks();
void SetFakeTBStartTicks(u64 val);
extern int downcount;
extern int slicelength;

View File

@ -81,11 +81,6 @@ namespace SystemTimers
u32 CPU_CORE_CLOCK = 486000000u; // 486 mhz (its not 485, stop bugging me!)
u32 fakeDecStartValue;
u64 fakeDecStartTicks;
u64 fakeTBStartValue;
u64 fakeTBStartTicks;
/*
Gamecube MHz
flipper <-> ARAM bus: 81 (DSP)
@ -205,8 +200,8 @@ void DecrementerSet()
CoreTiming::RemoveEvent(et_Dec);
if ((decValue & 0x80000000) == 0)
{
fakeDecStartTicks = CoreTiming::GetTicks();
fakeDecStartValue = decValue;
CoreTiming::SetFakeDecStartTicks(CoreTiming::GetTicks());
CoreTiming::SetFakeDecStartValue(decValue);
CoreTiming::ScheduleEvent(decValue * TIMER_RATIO, et_Dec);
}
@ -214,18 +209,18 @@ void DecrementerSet()
u32 GetFakeDecrementer()
{
return (fakeDecStartValue - (u32)((CoreTiming::GetTicks() - fakeDecStartTicks) / TIMER_RATIO));
return (CoreTiming::GetFakeDecStartValue() - (u32)((CoreTiming::GetTicks() - CoreTiming::GetFakeDecStartTicks()) / TIMER_RATIO));
}
void TimeBaseSet()
{
fakeTBStartTicks = CoreTiming::GetTicks();
fakeTBStartValue = *((u64 *)&TL);
CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());
CoreTiming::SetFakeTBStartValue(*((u64 *)&TL));
}
u64 GetFakeTimeBase()
{
return fakeTBStartValue + ((CoreTiming::GetTicks() - fakeTBStartTicks) / TIMER_RATIO);
return CoreTiming::GetFakeTBStartValue() + ((CoreTiming::GetTicks() - CoreTiming::GetFakeTBStartTicks()) / TIMER_RATIO);
}
// For DC watchdog hack
@ -284,11 +279,11 @@ void Init()
Common::Timer::IncreaseResolution();
// store and convert localtime at boot to timebase ticks
fakeTBStartValue = (u64)(CPU_CORE_CLOCK / TIMER_RATIO) * (u64)CEXIIPL::GetGCTime();
fakeTBStartTicks = CoreTiming::GetTicks();
CoreTiming::SetFakeTBStartValue((u64)(CPU_CORE_CLOCK / TIMER_RATIO) * (u64)CEXIIPL::GetGCTime());
CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());
fakeDecStartValue = 0xFFFFFFFF;
fakeDecStartTicks = CoreTiming::GetTicks();
CoreTiming::SetFakeDecStartValue(0xFFFFFFFF);
CoreTiming::SetFakeDecStartTicks(CoreTiming::GetTicks());
et_Dec = CoreTiming::RegisterEvent("DecCallback", DecrementerCallback);
et_AI = CoreTiming::RegisterEvent("AICallback", AICallback);

View File

@ -73,7 +73,7 @@ static Common::Thread *saveThread = NULL;
// Don't forget to increase this after doing changes on the savestate system
#define STATE_VERSION 3
#define STATE_VERSION 4
void DoState(PointerWrap &p)