diff --git a/Source/Core/Core/HW/HSP/HSP_Device.cpp b/Source/Core/Core/HW/HSP/HSP_Device.cpp index 7a75afc79c..6140eb17d5 100644 --- a/Source/Core/Core/HW/HSP/HSP_Device.cpp +++ b/Source/Core/Core/HW/HSP/HSP_Device.cpp @@ -12,20 +12,12 @@ namespace HSP { -IHSPDevice::IHSPDevice(HSPDeviceType device_type) : m_device_type(device_type) -{ -} - -HSPDeviceType IHSPDevice::GetDeviceType() const -{ - return m_device_type; -} +IHSPDevice::~IHSPDevice() = default; void IHSPDevice::DoState(PointerWrap& p) { } -// F A C T O R Y std::unique_ptr HSPDevice_Create(const HSPDeviceType device) { auto& system = Core::System::GetInstance(); @@ -33,12 +25,12 @@ std::unique_ptr HSPDevice_Create(const HSPDeviceType device) switch (device) { case HSPDeviceType::ARAMExpansion: - return std::make_unique(device); + return std::make_unique(); case HSPDeviceType::GBPlayer: - return std::make_unique(system, device); + return std::make_unique(system); case HSPDeviceType::None: default: - return std::make_unique(device); + return std::make_unique(); } } } // namespace HSP diff --git a/Source/Core/Core/HW/HSP/HSP_Device.h b/Source/Core/Core/HW/HSP/HSP_Device.h index baf8fc025e..faca30f2b9 100644 --- a/Source/Core/Core/HW/HSP/HSP_Device.h +++ b/Source/Core/Core/HW/HSP/HSP_Device.h @@ -21,19 +21,15 @@ enum class HSPDeviceType : int class IHSPDevice { public: - explicit IHSPDevice(HSPDeviceType device_type); - virtual ~IHSPDevice() = default; + virtual ~IHSPDevice(); - HSPDeviceType GetDeviceType() const; + virtual HSPDeviceType GetDeviceType() const = 0; virtual void Write(u32 address, u64 value) = 0; virtual u64 Read(u32 address) = 0; // Savestate support virtual void DoState(PointerWrap& p); - -protected: - HSPDeviceType m_device_type; }; std::unique_ptr HSPDevice_Create(HSPDeviceType device); diff --git a/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.cpp b/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.cpp index 34fdc1b613..a182d6b932 100644 --- a/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.cpp +++ b/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.cpp @@ -14,7 +14,7 @@ namespace HSP { -CHSPDevice_ARAMExpansion::CHSPDevice_ARAMExpansion(HSPDeviceType device) : IHSPDevice(device) +CHSPDevice_ARAMExpansion::CHSPDevice_ARAMExpansion() { m_size = MathUtil::NextPowerOf2(Config::Get(Config::MAIN_ARAM_EXPANSION_SIZE)); m_mask = m_size - 1; diff --git a/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.h b/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.h index 8efa766286..b584e4118b 100644 --- a/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.h +++ b/Source/Core/Core/HW/HSP/HSP_DeviceARAMExpansion.h @@ -7,12 +7,14 @@ namespace HSP { -class CHSPDevice_ARAMExpansion : public IHSPDevice +class CHSPDevice_ARAMExpansion final : public IHSPDevice { public: - explicit CHSPDevice_ARAMExpansion(HSPDeviceType device); + explicit CHSPDevice_ARAMExpansion(); ~CHSPDevice_ARAMExpansion() override; + HSPDeviceType GetDeviceType() const override { return HSPDeviceType::ARAMExpansion; } + void Write(u32 address, u64 value) override; u64 Read(u32 address) override; diff --git a/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.cpp b/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.cpp index 470ba38a23..20a9998e15 100644 --- a/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.cpp +++ b/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.cpp @@ -53,7 +53,7 @@ constexpr u8 CONTROL_MASK_IRQ = 0x10; constexpr u32 COMMAND_ADDRESS_MASK = 0x1f; constexpr u32 AV_ADDRESS_MASK = 0xff8; -class CGBPlayer_Dummy : public HSP::IGBPlayer +class CGBPlayer_Dummy final : public HSP::IGBPlayer { public: using IGBPlayer::IGBPlayer; @@ -89,7 +89,7 @@ enum class CHSPDevice_GBPlayer::IRQ : int #if defined(HAS_LIBMGBA) -class CGBPlayer_mGBA : public IGBPlayer +class CGBPlayer_mGBA final : public IGBPlayer { public: CGBPlayer_mGBA(Core::System&, CHSPDevice_GBPlayer*); @@ -389,8 +389,7 @@ void CGBPlayer_mGBA::UpdateVideo(u32 scanline_index, s64 cycles_late) #endif -CHSPDevice_GBPlayer::CHSPDevice_GBPlayer(Core::System& system, HSPDeviceType device) - : IHSPDevice(device), m_system{system} +CHSPDevice_GBPlayer::CHSPDevice_GBPlayer(Core::System& system) : m_system{system} { #if defined(HAS_LIBMGBA) m_gbp = std::make_unique(m_system, this); diff --git a/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.h b/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.h index ba93412de0..18f096e640 100644 --- a/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.h +++ b/Source/Core/Core/HW/HSP/HSP_DeviceGBPlayer.h @@ -50,12 +50,14 @@ protected: CHSPDevice_GBPlayer* const m_player; }; -class CHSPDevice_GBPlayer : public IHSPDevice +class CHSPDevice_GBPlayer final : public IHSPDevice { public: enum class IRQ : int; - CHSPDevice_GBPlayer(Core::System& system, HSPDeviceType device); + explicit CHSPDevice_GBPlayer(Core::System& system); + + HSPDeviceType GetDeviceType() const override { return HSPDeviceType::GBPlayer; } void Write(u32 address, u64 value) override; u64 Read(u32 address) override; diff --git a/Source/Core/Core/HW/HSP/HSP_DeviceNull.cpp b/Source/Core/Core/HW/HSP/HSP_DeviceNull.cpp index 3527ecc778..e11586f97f 100644 --- a/Source/Core/Core/HW/HSP/HSP_DeviceNull.cpp +++ b/Source/Core/Core/HW/HSP/HSP_DeviceNull.cpp @@ -3,13 +3,8 @@ #include "Core/HW/HSP/HSP_DeviceNull.h" -#include "Core/HW/HSP/HSP.h" - namespace HSP { -CHSPDevice_Null::CHSPDevice_Null(HSPDeviceType device) : IHSPDevice(device) -{ -} u64 CHSPDevice_Null::Read(u32 address) { diff --git a/Source/Core/Core/HW/HSP/HSP_DeviceNull.h b/Source/Core/Core/HW/HSP/HSP_DeviceNull.h index afadddd475..62b500215b 100644 --- a/Source/Core/Core/HW/HSP/HSP_DeviceNull.h +++ b/Source/Core/Core/HW/HSP/HSP_DeviceNull.h @@ -8,10 +8,10 @@ namespace HSP { -class CHSPDevice_Null : public IHSPDevice +class CHSPDevice_Null final : public IHSPDevice { public: - explicit CHSPDevice_Null(HSPDeviceType device); + HSPDeviceType GetDeviceType() const override { return HSPDeviceType::None; } void Write(u32 address, u64 value) override; u64 Read(u32 address) override;