diff options
Diffstat (limited to 'src/audio_core/hle/pipe.cpp')
| -rw-r--r-- | src/audio_core/hle/pipe.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/audio_core/hle/pipe.cpp b/src/audio_core/hle/pipe.cpp new file mode 100644 index 000000000..6542c760c --- /dev/null +++ b/src/audio_core/hle/pipe.cpp | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <array> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "audio_core/hle/pipe.h" | ||
| 9 | |||
| 10 | #include "common/common_types.h" | ||
| 11 | #include "common/logging/log.h" | ||
| 12 | |||
| 13 | namespace DSP { | ||
| 14 | namespace HLE { | ||
| 15 | |||
| 16 | static size_t pipe2position = 0; | ||
| 17 | |||
| 18 | void ResetPipes() { | ||
| 19 | pipe2position = 0; | ||
| 20 | } | ||
| 21 | |||
| 22 | std::vector<u8> PipeRead(u32 pipe_number, u32 length) { | ||
| 23 | if (pipe_number != 2) { | ||
| 24 | LOG_WARNING(Audio_DSP, "pipe_number = %u (!= 2), unimplemented", pipe_number); | ||
| 25 | return {}; // We currently don't handle anything other than the audio pipe. | ||
| 26 | } | ||
| 27 | |||
| 28 | // Canned DSP responses that games expect. These were taken from HW by 3dmoo team. | ||
| 29 | // TODO: Our implementation will actually use a slightly different response than this one. | ||
| 30 | // TODO: Use offsetof on DSP structures instead for a proper response. | ||
| 31 | static const std::array<u8, 32> canned_response {{ | ||
| 32 | 0x0F, 0x00, 0xFF, 0xBF, 0x8E, 0x9E, 0x80, 0x86, 0x8E, 0xA7, 0x30, 0x94, 0x00, 0x84, 0x40, 0x85, | ||
| 33 | 0x8E, 0x94, 0x10, 0x87, 0x10, 0x84, 0x0E, 0xA9, 0x0E, 0xAA, 0xCE, 0xAA, 0x4E, 0xAC, 0x58, 0xAC | ||
| 34 | }}; | ||
| 35 | |||
| 36 | // TODO: Move this into dsp::DSP service since it happens on the service side. | ||
| 37 | // Hardware observation: No data is returned if requested length reads beyond the end of the data in-pipe. | ||
| 38 | if (pipe2position + length > canned_response.size()) { | ||
| 39 | return {}; | ||
| 40 | } | ||
| 41 | |||
| 42 | std::vector<u8> ret; | ||
| 43 | for (size_t i = 0; i < length; i++, pipe2position++) { | ||
| 44 | ret.emplace_back(canned_response[pipe2position]); | ||
| 45 | } | ||
| 46 | |||
| 47 | return ret; | ||
| 48 | } | ||
| 49 | |||
| 50 | void PipeWrite(u32 pipe_number, const std::vector<u8>& buffer) { | ||
| 51 | // TODO: proper pipe behaviour | ||
| 52 | } | ||
| 53 | |||
| 54 | } // namespace HLE | ||
| 55 | } // namespace DSP | ||