From 7f4ef7454268de38228c71896d5270900ad778b8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Jan 2017 21:16:37 -0500 Subject: [PATCH] SI_Device: Move the null device implementation to its own source files --- Source/Core/Core/CMakeLists.txt | 1 + Source/Core/Core/Core.vcxproj | 2 ++ Source/Core/Core/Core.vcxproj.filters | 6 +++++ Source/Core/Core/HW/SI/SI_Device.cpp | 21 +---------------- Source/Core/Core/HW/SI/SI_DeviceNull.cpp | 29 ++++++++++++++++++++++++ Source/Core/Core/HW/SI/SI_DeviceNull.h | 19 ++++++++++++++++ 6 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 Source/Core/Core/HW/SI/SI_DeviceNull.cpp create mode 100644 Source/Core/Core/HW/SI/SI_DeviceNull.h diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 4187cb4716..f36564b0c3 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -118,6 +118,7 @@ set(SRCS ActionReplay.cpp HW/SI/SI_DeviceGCController.cpp HW/SI/SI_DeviceGCSteeringWheel.cpp HW/SI/SI_DeviceKeyboard.cpp + HW/SI/SI_DeviceNull.cpp HW/Sram.cpp HW/StreamADPCM.cpp HW/SystemTimers.cpp diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index f6aa9a95b7..42496fe3e0 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -149,6 +149,7 @@ + @@ -380,6 +381,7 @@ + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 1f052cda1f..f85e4e64db 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -472,6 +472,9 @@ HW %28Flipper/Hollywood%29\SI - Serial Interface + + HW %28Flipper/Hollywood%29\SI - Serial Interface + HW %28Flipper/Hollywood%29\VI - Video Interface @@ -1072,6 +1075,9 @@ HW %28Flipper/Hollywood%29\SI - Serial Interface + + HW %28Flipper/Hollywood%29\SI - Serial Interface + HW %28Flipper/Hollywood%29\VI - Video Interface diff --git a/Source/Core/Core/HW/SI/SI_Device.cpp b/Source/Core/Core/HW/SI/SI_Device.cpp index 925605121c..498930630a 100644 --- a/Source/Core/Core/HW/SI/SI_Device.cpp +++ b/Source/Core/Core/HW/SI/SI_Device.cpp @@ -16,8 +16,8 @@ #include "Core/HW/SI/SI_DeviceGCController.h" #include "Core/HW/SI/SI_DeviceGCSteeringWheel.h" #include "Core/HW/SI/SI_DeviceKeyboard.h" +#include "Core/HW/SI/SI_DeviceNull.h" -// --- interface ISIDevice --- int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength) { #ifdef _DEBUG @@ -49,25 +49,6 @@ int ISIDevice::TransferInterval() return 0; } -// Stub class for saying nothing is attached, and not having to deal with null pointers :) -class CSIDevice_Null : public ISIDevice -{ -public: - CSIDevice_Null(SIDevices device, int _iDeviceNumber) : ISIDevice(device, _iDeviceNumber) {} - virtual ~CSIDevice_Null() {} - int RunBuffer(u8* _pBuffer, int _iLength) override - { - reinterpret_cast(_pBuffer)[0] = SI_ERROR_NO_RESPONSE; - return 4; - } - bool GetData(u32& _Hi, u32& _Low) override - { - _Hi = 0x80000000; - return true; - } - void SendCommand(u32 _Cmd, u8 _Poll) override {} -}; - // Check if a device class is inheriting from CSIDevice_GCController // The goal of this function is to avoid special casing a long list of // device types when there is no "real" input device, e.g. when playing diff --git a/Source/Core/Core/HW/SI/SI_DeviceNull.cpp b/Source/Core/Core/HW/SI/SI_DeviceNull.cpp new file mode 100644 index 0000000000..18461487a7 --- /dev/null +++ b/Source/Core/Core/HW/SI/SI_DeviceNull.cpp @@ -0,0 +1,29 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "Core/HW/SI/SI_DeviceNull.h" + +#include + +CSIDevice_Null::CSIDevice_Null(SIDevices device, int device_number) + : ISIDevice{device, device_number} +{ +} + +int CSIDevice_Null::RunBuffer(u8* buffer, int length) +{ + constexpr u32 reply = SI_ERROR_NO_RESPONSE; + std::memcpy(buffer, &reply, sizeof(reply)); + return 4; +} + +bool CSIDevice_Null::GetData(u32& hi, u32& low) +{ + hi = 0x80000000; + return true; +} + +void CSIDevice_Null::SendCommand(u32 command, u8 poll) +{ +} diff --git a/Source/Core/Core/HW/SI/SI_DeviceNull.h b/Source/Core/Core/HW/SI/SI_DeviceNull.h new file mode 100644 index 0000000000..a71d3db643 --- /dev/null +++ b/Source/Core/Core/HW/SI/SI_DeviceNull.h @@ -0,0 +1,19 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "Common/CommonTypes.h" +#include "Core/HW/SI/SI_Device.h" + +// Stub class for saying nothing is attached, and not having to deal with null pointers :) +class CSIDevice_Null final : public ISIDevice +{ +public: + CSIDevice_Null(SIDevices device, int device_number); + + int RunBuffer(u8* buffer, int length) override; + bool GetData(u32& hi, u32& low) override; + void SendCommand(u32 command, u8 poll) override; +};