mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Add CoreTiming to save states.
I hope DoLinkedList works, seems like it should.
This commit is contained in:
+28
-8
@@ -24,6 +24,7 @@
|
||||
#include "CoreTiming.h"
|
||||
#include "Core.h"
|
||||
#include "HLE/sceKernelThread.h"
|
||||
#include "../Common/ChunkFile.h"
|
||||
|
||||
int CPU_HZ = 222000000;
|
||||
|
||||
@@ -55,12 +56,6 @@ struct BaseEvent
|
||||
// Event *next;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct LinkedListItem : public T
|
||||
{
|
||||
LinkedListItem<T> *next;
|
||||
};
|
||||
|
||||
typedef LinkedListItem<BaseEvent> Event;
|
||||
|
||||
Event *first;
|
||||
@@ -79,6 +74,7 @@ s64 idledCycles;
|
||||
|
||||
static std::recursive_mutex externalEventSection;
|
||||
|
||||
// Warning: not included in save state.
|
||||
void (*advanceCallback)(int cyclesExecuted) = NULL;
|
||||
|
||||
void SetClockFrequencyMHz(int cpuMhz)
|
||||
@@ -140,9 +136,9 @@ void AntiCrashCallback(u64 userdata, int cyclesLate)
|
||||
Core_Halt("invalid timing events");
|
||||
}
|
||||
|
||||
void RestoreEvent(int event_type, const char *name, TimedCallback callback)
|
||||
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback)
|
||||
{
|
||||
if (event_type >= event_types.size())
|
||||
if (event_type >= (int) event_types.size())
|
||||
event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT"));
|
||||
|
||||
event_types[event_type] = EventType(callback, name);
|
||||
@@ -311,6 +307,7 @@ u64 UnscheduleEvent(int event_type, u64 userdata)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Warning: not included in save state.
|
||||
void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted))
|
||||
{
|
||||
advanceCallback = callback;
|
||||
@@ -546,4 +543,27 @@ std::string GetScheduledEventsSummary()
|
||||
return text;
|
||||
}
|
||||
|
||||
void Event_DoState(PointerWrap &p, BaseEvent *ev)
|
||||
{
|
||||
p.Do(*ev);
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
size_t n = event_types.size();
|
||||
p.Do(n);
|
||||
// These (should) be filled in later by the modules.
|
||||
event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT"));
|
||||
|
||||
p.DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(first, (Event **) NULL);
|
||||
p.DoLinkedList<BaseEvent, GetNewTsEvent, FreeTsEvent, Event_DoState>(tsFirst, &tsLast);
|
||||
|
||||
p.Do(CPU_HZ);
|
||||
p.Do(downcount);
|
||||
p.Do(slicelength);
|
||||
p.Do(globalTimer);
|
||||
p.Do(idledCycles);
|
||||
p.DoMarker("CoreTiming");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
+5
-1
@@ -32,6 +32,7 @@
|
||||
// ScheduleEvent(periodInCycles - cyclesLate, callback, "whatever")
|
||||
|
||||
#include "../Globals.h"
|
||||
#include "../Common/ChunkFile.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -79,7 +80,7 @@ namespace CoreTiming
|
||||
// Returns the event_type identifier.
|
||||
int RegisterEvent(const char *name, TimedCallback callback);
|
||||
// For save states.
|
||||
void RestoreEvent(int event_type, const char *name, TimedCallback callback);
|
||||
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback);
|
||||
void UnregisterAllEvents();
|
||||
|
||||
// userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk,
|
||||
@@ -105,10 +106,13 @@ namespace CoreTiming
|
||||
|
||||
void LogPendingEvents();
|
||||
|
||||
// Warning: not included in save states.
|
||||
void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted));
|
||||
|
||||
std::string GetScheduledEventsSummary();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
void SetClockFrequencyMHz(int cpuMhz);
|
||||
int GetClockFrequencyMHz();
|
||||
extern int downcount;
|
||||
|
||||
+4
-4
@@ -55,15 +55,17 @@ namespace SaveState
|
||||
static std::vector<Operation> pending;
|
||||
static std::recursive_mutex mutex;
|
||||
|
||||
void Process(u64 userdata, int cyclesLate);
|
||||
|
||||
// This is where the magic happens.
|
||||
void SaveStart::DoState(PointerWrap &p)
|
||||
{
|
||||
// Gotta do CoreTiming first since we'll restore into it.
|
||||
// TODO CoreTiming
|
||||
CoreTiming::DoState(p);
|
||||
|
||||
// This save state even saves its own state.
|
||||
p.Do(timer);
|
||||
CoreTiming::RestoreEvent(timer, "SaveState", Process);
|
||||
CoreTiming::RestoreRegisterEvent(timer, "SaveState", Process);
|
||||
p.DoMarker("SaveState");
|
||||
|
||||
Memory::DoState(p);
|
||||
@@ -71,8 +73,6 @@ namespace SaveState
|
||||
__KernelDoState(p);
|
||||
}
|
||||
|
||||
void Process(u64 userdata, int cyclesLate);
|
||||
|
||||
void Enqueue(SaveState::Operation op)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(mutex);
|
||||
|
||||
Reference in New Issue
Block a user