From a0c3b9178525df5d192048d266e3e1d0f8c1e3ef Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Thu, 26 Dec 2019 17:56:44 +0000 Subject: [PATCH] Added CSND serialization --- TODO | 7 +++- src/core/hle/service/csnd/csnd_snd.cpp | 14 +++++++ src/core/hle/service/csnd/csnd_snd.h | 56 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 354e61a2f..e485f33a7 100644 --- a/TODO +++ b/TODO @@ -15,6 +15,7 @@ ☐ Settings ☐ Telemetry session ☐ Replace SERIALIZE_AS_POD with BOOST_IS_BITWISE_SERIALIZABLE +☐ Review constructor/initialization code ✔ HW @done(19-08-13 15:41) ✔ GPU regs @done(19-08-13 15:41) ✔ LCD regs @done(19-08-13 15:41) @@ -69,8 +70,10 @@ ☐ CAM @started(19-12-26 10:37) Need to check capture_result ☐ CECD - ☐ CGF - ☐ CSND + ☐ Archive backend / file handles + ☐ CFG + Also needs archive backend.. + ✔ CSND @started(19-12-26 17:51) @done(19-12-26 17:56) @lasted(5m30s) ☐ DLP ☐ DSP ☐ ERR diff --git a/src/core/hle/service/csnd/csnd_snd.cpp b/src/core/hle/service/csnd/csnd_snd.cpp index 5c9fa13e9..d011a1c66 100644 --- a/src/core/hle/service/csnd/csnd_snd.cpp +++ b/src/core/hle/service/csnd/csnd_snd.cpp @@ -3,11 +3,25 @@ // Refer to the license.txt file included. #include "common/alignment.h" +#include "common/archives.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/result.h" #include "core/hle/service/csnd/csnd_snd.h" +namespace boost::serialization { + template + void load_construct_data(Archive& ar, Service::CSND::CSND_SND* t, const unsigned int) + { + ::new(t)Service::CSND::CSND_SND(Core::Global()); + } + + template + void load_construct_data(iarchive& ar, Service::CSND::CSND_SND* t, const unsigned int); +} + +SERIALIZE_EXPORT_IMPL(Service::CSND::CSND_SND) + namespace Service::CSND { enum class CommandId : u16 { diff --git a/src/core/hle/service/csnd/csnd_snd.h b/src/core/hle/service/csnd/csnd_snd.h index afdc3b1a8..0e2dd8cd8 100644 --- a/src/core/hle/service/csnd/csnd_snd.h +++ b/src/core/hle/service/csnd/csnd_snd.h @@ -5,6 +5,8 @@ #pragma once #include +#include +#include #include "core/hle/kernel/mutex.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/service/service.h" @@ -33,6 +35,15 @@ enum class LoopMode : u8 { struct AdpcmState { s16 predictor = 0; u8 step_index = 0; + +private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & predictor; + ar & step_index; + } + friend class boost::serialization::access; }; struct Channel { @@ -52,6 +63,29 @@ struct Channel { LoopMode loop_mode = LoopMode::Manual; Encoding encoding = Encoding::Pcm8; u8 psg_duty = 0; + +private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & block1_address; + ar & block2_address; + ar & block1_size; + ar & block2_size; + ar & block1_adpcm_state; + ar & block2_adpcm_state; + ar & block2_adpcm_reload; + ar & left_channel_volume; + ar & right_channel_volume; + ar & left_capture_volume; + ar & right_capture_volume; + ar & sample_rate; + ar & linear_interpolation; + ar & loop_mode; + ar & encoding; + ar & psg_duty; + } + friend class boost::serialization::access; }; class CSND_SND final : public ServiceFramework { @@ -222,9 +256,31 @@ private: u32 type1_command_offset = 0; u32 acquired_channel_mask = 0; + + template + void serialize(Archive& ar, const unsigned int) + { + ar & mutex; + ar & shared_memory; + ar & capture_units; + ar & channels; + ar & master_state_offset; + ar & channel_state_offset; + ar & capture_state_offset; + ar & type1_command_offset; + ar & acquired_channel_mask; + } + friend class boost::serialization::access; }; /// Initializes the CSND_SND Service void InstallInterfaces(Core::System& system); } // namespace Service::CSND + +BOOST_CLASS_EXPORT_KEY(Service::CSND::CSND_SND) + +namespace boost::serialization { + template + void load_construct_data(Archive& ar, Service::CSND::CSND_SND* t, const unsigned int); +}