diff options
| author | Scott Mansell <phiren@gmail.com> | 2017-01-23 15:46:37 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-23 15:46:37 +1300 |
| commit | e41858232dd91cfdfb85df796cfd773680616248 (patch) | |
| tree | be2f19553bcc5c18d86ca8f3cf21c9ee221e727d /Source/Core | |
| parent | ba5c3f4c469b1a5d10c25dc17ad52fa4039f83cc (diff) | |
| parent | 7f4ef7454268de38228c71896d5270900ad778b8 (diff) | |
Merge pull request #4720 from lioncash/si-stub
SI_Device: Move the null device implementation to its own source files
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | Source/Core/Core/Core.vcxproj | 2 | ||||
| -rw-r--r-- | Source/Core/Core/Core.vcxproj.filters | 6 | ||||
| -rw-r--r-- | Source/Core/Core/HW/SI/SI_Device.cpp | 21 | ||||
| -rw-r--r-- | Source/Core/Core/HW/SI/SI_DeviceNull.cpp | 29 | ||||
| -rw-r--r-- | Source/Core/Core/HW/SI/SI_DeviceNull.h | 19 |
6 files changed, 58 insertions, 20 deletions
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 @@ <ClCompile Include="HW\SI\SI_DeviceGCController.cpp" /> <ClCompile Include="HW\SI\SI_DeviceGCSteeringWheel.cpp" /> <ClCompile Include="HW\SI\SI_DeviceKeyboard.cpp" /> + <ClCompile Include="HW\SI\SI_DeviceNull.cpp" /> <ClCompile Include="HW\Sram.cpp" /> <ClCompile Include="HW\StreamADPCM.cpp" /> <ClCompile Include="HW\SystemTimers.cpp" /> @@ -380,6 +381,7 @@ <ClInclude Include="HW\SI\SI_DeviceGCController.h" /> <ClInclude Include="HW\SI\SI_DeviceGCSteeringWheel.h" /> <ClInclude Include="HW\SI\SI_DeviceKeyboard.h" /> + <ClInclude Include="HW\SI\SI_DeviceNull.h" /> <ClInclude Include="HW\Sram.h" /> <ClInclude Include="HW\StreamADPCM.h" /> <ClInclude Include="HW\SystemTimers.h" /> 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 @@ <ClCompile Include="HW\SI\SI_DeviceKeyboard.cpp"> <Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter> </ClCompile> + <ClCompile Include="HW\SI\SI_DeviceNull.cpp"> + <Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter> + </ClCompile> <ClCompile Include="HW\VideoInterface.cpp"> <Filter>HW %28Flipper/Hollywood%29\VI - Video Interface</Filter> </ClCompile> @@ -1072,6 +1075,9 @@ <ClInclude Include="HW\SI\SI_DeviceKeyboard.h"> <Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter> </ClInclude> + <ClInclude Include="HW\SI\SI_DeviceNull.h"> + <Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter> + </ClInclude> <ClInclude Include="HW\VideoInterface.h"> <Filter>HW %28Flipper/Hollywood%29\VI - Video Interface</Filter> </ClInclude> 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<u32*>(_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 <cstring> + +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; +}; |
