diff --git a/src/xenia/kernel/notify_listener.cc b/src/xenia/kernel/notify_listener.cc index 55f5cff8c..c9bf3eaf1 100644 --- a/src/xenia/kernel/notify_listener.cc +++ b/src/xenia/kernel/notify_listener.cc @@ -9,6 +9,7 @@ #include "xenia/kernel/notify_listener.h" +#include "xenia/base/byte_stream.h" #include "xenia/kernel/kernel_state.h" namespace xe { @@ -83,5 +84,39 @@ bool NotifyListener::DequeueNotification(XNotificationID id, return dequeued; } +bool NotifyListener::Save(ByteStream* stream) { + SaveObject(stream); + + stream->Write(mask_); + stream->Write(notification_count_); + if (notification_count_) { + for (auto pair : notifications_) { + stream->Write(pair.first); + stream->Write(pair.second); + } + } + + return true; +} + +object_ref NotifyListener::Restore(KernelState* kernel_state, + ByteStream* stream) { + auto notify = new NotifyListener(nullptr); + notify->kernel_state_ = kernel_state; + + notify->RestoreObject(stream); + notify->Initialize(stream->Read()); + + notify->notification_count_ = stream->Read(); + for (size_t i = 0; i < notify->notification_count_; i++) { + std::pair pair; + pair.first = stream->Read(); + pair.second = stream->Read(); + notify->notifications_.insert(pair); + } + + return object_ref(notify); +} + } // namespace kernel } // namespace xe diff --git a/src/xenia/kernel/notify_listener.h b/src/xenia/kernel/notify_listener.h index f341e659b..fb5bfd573 100644 --- a/src/xenia/kernel/notify_listener.h +++ b/src/xenia/kernel/notify_listener.h @@ -40,6 +40,10 @@ class NotifyListener : public XObject { return wait_handle_.get(); } + bool Save(ByteStream* stream) override; + static object_ref Restore(KernelState* kernel_state, + ByteStream* stream); + private: std::unique_ptr wait_handle_; xe::global_critical_region global_critical_region_;