pipe.cpp 1.7 KB

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