diff options
| -rw-r--r-- | src/core/hle/service/dsp_dsp.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp index 72be4c817..e89c8aae3 100644 --- a/src/core/hle/service/dsp_dsp.cpp +++ b/src/core/hle/service/dsp_dsp.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | namespace DSP_DSP { | 13 | namespace DSP_DSP { |
| 14 | 14 | ||
| 15 | static u32 read_pipe_count; | ||
| 15 | static Handle semaphore_event; | 16 | static Handle semaphore_event; |
| 16 | static Handle interrupt_event; | 17 | static Handle interrupt_event; |
| 17 | 18 | ||
| @@ -108,6 +109,48 @@ void WriteReg0x10(Service::Interface* self) { | |||
| 108 | DEBUG_LOG(KERNEL, "(STUBBED) called"); | 109 | DEBUG_LOG(KERNEL, "(STUBBED) called"); |
| 109 | } | 110 | } |
| 110 | 111 | ||
| 112 | /** | ||
| 113 | * DSP_DSP::ReadPipeIfPossible service function | ||
| 114 | * Inputs: | ||
| 115 | * 1 : Unknown | ||
| 116 | * 2 : Unknown | ||
| 117 | * 3 : Size in bytes of read (observed only lower half word used) | ||
| 118 | * 0x41 : Virtual address to read from DSP pipe to in memory | ||
| 119 | * Outputs: | ||
| 120 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 121 | * 2 : Number of bytes read from pipe | ||
| 122 | */ | ||
| 123 | void ReadPipeIfPossible(Service::Interface* self) { | ||
| 124 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 125 | |||
| 126 | u32 size = cmd_buff[3] & 0xFFFF;// Lower 16 bits are size | ||
| 127 | VAddr addr = cmd_buff[0x41]; | ||
| 128 | |||
| 129 | // Canned DSP responses that games expect. These were taken from HW by 3dmoo team. | ||
| 130 | // TODO: Remove this hack :) | ||
| 131 | static const std::array<u16, 16> canned_read_pipe = { | ||
| 132 | 0x000F, 0xBFFF, 0x9E8E, 0x8680, 0xA78E, 0x9430, 0x8400, 0x8540, | ||
| 133 | 0x948E, 0x8710, 0x8410, 0xA90E, 0xAA0E, 0xAACE, 0xAC4E, 0xAC58 | ||
| 134 | }; | ||
| 135 | |||
| 136 | u32 initial_size = read_pipe_count; | ||
| 137 | |||
| 138 | for (unsigned offset = 0; offset < size; offset += sizeof(u16)) { | ||
| 139 | if (read_pipe_count < canned_read_pipe.size()) { | ||
| 140 | Memory::Write16(addr + offset, canned_read_pipe[read_pipe_count]); | ||
| 141 | read_pipe_count++; | ||
| 142 | } else { | ||
| 143 | ERROR_LOG(KERNEL, "canned read pipe log exceeded!"); | ||
| 144 | break; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | cmd_buff[1] = 0; // No error | ||
| 149 | cmd_buff[2] = (read_pipe_count - initial_size) * sizeof(u16); | ||
| 150 | |||
| 151 | DEBUG_LOG(KERNEL, "(STUBBED) called size=0x%08X, buffer=0x%08X", size, addr); | ||
| 152 | } | ||
| 153 | |||
| 111 | const Interface::FunctionInfo FunctionTable[] = { | 154 | const Interface::FunctionInfo FunctionTable[] = { |
| 112 | {0x00010040, nullptr, "RecvData"}, | 155 | {0x00010040, nullptr, "RecvData"}, |
| 113 | {0x00020040, nullptr, "RecvDataIsReady"}, | 156 | {0x00020040, nullptr, "RecvDataIsReady"}, |
| @@ -119,7 +162,7 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 119 | {0x000B0000, nullptr, "CheckSemaphoreRequest"}, | 162 | {0x000B0000, nullptr, "CheckSemaphoreRequest"}, |
| 120 | {0x000C0040, ConvertProcessAddressFromDspDram, "ConvertProcessAddressFromDspDram"}, | 163 | {0x000C0040, ConvertProcessAddressFromDspDram, "ConvertProcessAddressFromDspDram"}, |
| 121 | {0x000D0082, nullptr, "WriteProcessPipe"}, | 164 | {0x000D0082, nullptr, "WriteProcessPipe"}, |
| 122 | {0x001000C0, nullptr, "ReadPipeIfPossible"}, | 165 | {0x001000C0, ReadPipeIfPossible, "ReadPipeIfPossible"}, |
| 123 | {0x001100C2, LoadComponent, "LoadComponent"}, | 166 | {0x001100C2, LoadComponent, "LoadComponent"}, |
| 124 | {0x00120000, nullptr, "UnloadComponent"}, | 167 | {0x00120000, nullptr, "UnloadComponent"}, |
| 125 | {0x00130082, nullptr, "FlushDataCache"}, | 168 | {0x00130082, nullptr, "FlushDataCache"}, |
| @@ -142,6 +185,7 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 142 | Interface::Interface() { | 185 | Interface::Interface() { |
| 143 | semaphore_event = Kernel::CreateEvent(RESETTYPE_ONESHOT, "DSP_DSP::semaphore_event"); | 186 | semaphore_event = Kernel::CreateEvent(RESETTYPE_ONESHOT, "DSP_DSP::semaphore_event"); |
| 144 | interrupt_event = 0; | 187 | interrupt_event = 0; |
| 188 | read_pipe_count = 0; | ||
| 145 | 189 | ||
| 146 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | 190 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); |
| 147 | } | 191 | } |