mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-30 19:24:23 +01:00
Add a mechanism to restore event callback ptrs.
Ugh, more duplicates. Maybe can find a good way to refactor.
This commit is contained in:
1 parent
570e8c812b
commit
fbe4fd396e
5 files changed
+37
-4
No files matched your search
+20
-4
@@ -36,6 +36,11 @@ namespace CoreTiming
|
||||
|
||||
struct EventType
|
||||
{
|
||||
EventType() {}
|
||||
|
||||
EventType(TimedCallback cb, const char *n)
|
||||
: callback(cb), name(n) {}
|
||||
|
||||
TimedCallback callback;
|
||||
const char *name;
|
||||
};
|
||||
@@ -125,13 +130,24 @@ void FreeTsEvent(Event* ev)
|
||||
|
||||
int RegisterEvent(const char *name, TimedCallback callback)
|
||||
{
|
||||
EventType type;
|
||||
type.name = name;
|
||||
type.callback = callback;
|
||||
event_types.push_back(type);
|
||||
event_types.push_back(EventType(callback, name));
|
||||
return (int)event_types.size() - 1;
|
||||
}
|
||||
|
||||
void AntiCrashCallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
ERROR_LOG(CPU, "Savestate broken: an unregistered event was called.");
|
||||
Core_Halt("invalid timing events");
|
||||
}
|
||||
|
||||
void RestoreEvent(int event_type, const char *name, TimedCallback callback)
|
||||
{
|
||||
if (event_type >= event_types.size())
|
||||
event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT"));
|
||||
|
||||
event_types[event_type] = EventType(callback, name);
|
||||
}
|
||||
|
||||
void UnregisterAllEvents()
|
||||
{
|
||||
if (first)
|
||||
|
||||
Reference in new issue
Block a user