diff --git a/Source/Core/Core/HW/HSP/HSP.cpp b/Source/Core/Core/HW/HSP/HSP.cpp index 87fccd34f9..d53d0d2d26 100644 --- a/Source/Core/Core/HW/HSP/HSP.cpp +++ b/Source/Core/Core/HW/HSP/HSP.cpp @@ -16,54 +16,49 @@ HSPManager::~HSPManager() = default; void HSPManager::Init() { - AddDevice(Config::Get(Config::MAIN_HSP_DEVICE)); + SetDevice(Config::Get(Config::MAIN_HSP_DEVICE)); } void HSPManager::Shutdown() { - RemoveDevice(); + m_device.reset(); } u64 HSPManager::Read(u32 address) { DEBUG_LOG_FMT(HSP, "HSP read from 0x{:08x}", address); - if (m_device) - return m_device->Read(address); - return 0; + + return m_device->Read(address); } void HSPManager::Write(u32 address, u64 value) { DEBUG_LOG_FMT(HSP, "HSP write to 0x{:08x}: 0x{:016x}", address, value); - if (m_device) - m_device->Write(address, value); + + m_device->Write(address, value); } void HSPManager::DoState(PointerWrap& p) { - HSPDeviceType type = m_device->GetDeviceType(); - p.Do(type); + const HSPDeviceType current_type = m_device->GetDeviceType(); + auto state_type = current_type; + p.Do(state_type); // If the type doesn't match, switch to the right device type - if (type != m_device->GetDeviceType()) - AddDevice(type); + if (state_type != current_type) + SetDevice(state_type); m_device->DoState(p); } -void HSPManager::AddDevice(std::unique_ptr device) +void HSPManager::SetDevice(std::unique_ptr device) { - // Set the new one m_device = std::move(device); } -void HSPManager::AddDevice(const HSPDeviceType device) +void HSPManager::SetDevice(const HSPDeviceType device) { - AddDevice(HSPDevice_Create(device)); + SetDevice(HSPDevice_Create(device)); } -void HSPManager::RemoveDevice() -{ - m_device.reset(); -} } // namespace HSP diff --git a/Source/Core/Core/HW/HSP/HSP.h b/Source/Core/Core/HW/HSP/HSP.h index 5882e4b912..b588d26624 100644 --- a/Source/Core/Core/HW/HSP/HSP.h +++ b/Source/Core/Core/HW/HSP/HSP.h @@ -32,9 +32,8 @@ public: void DoState(PointerWrap& p); - void RemoveDevice(); - void AddDevice(std::unique_ptr device); - void AddDevice(HSPDeviceType device); + void SetDevice(std::unique_ptr device); + void SetDevice(HSPDeviceType device); private: std::unique_ptr m_device;