Add CSND::AcquireSoundChannels

This commit is contained in:
wheremyfoodat 2023-09-10 18:50:45 +03:00
parent db50054128
commit 8ac22e35e9
2 changed files with 14 additions and 0 deletions

View file

@ -19,6 +19,7 @@ class CSNDService {
std::optional<Handle> csndMutex = std::nullopt;
// Service functions
void acquireSoundChannels(u32 messagePointer);
void initialize(u32 messagePointer);
public:

View file

@ -7,6 +7,7 @@
namespace CSNDCommands {
enum : u32 {
Initialize = 0x00010140,
AcquireSoundChannels = 0x00050000,
};
}
@ -19,6 +20,7 @@ void CSNDService::handleSyncRequest(u32 messagePointer) {
const u32 command = mem.read32(messagePointer);
switch (command) {
case CSNDCommands::AcquireSoundChannels: acquireSoundChannels(messagePointer); break;
case CSNDCommands::Initialize: initialize(messagePointer); break;
default:
@ -28,6 +30,17 @@ void CSNDService::handleSyncRequest(u32 messagePointer) {
}
}
void CSNDService::acquireSoundChannels(u32 messagePointer) {
log("CSND::AcquireSoundChannels\n");
// The CSND service talks to the DSP using the DSP FIFO to negotiate what CSND channels are allocated to the DSP, and this seems to be channels 0-7 (usually). The rest are dedicated to CSND services.
// https://www.3dbrew.org/wiki/CSND_Services
constexpr u32 csndChannelMask = 0xFFFFFF00;
mem.write32(messagePointer, IPC::responseHeader(0x5, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, csndChannelMask);
}
void CSNDService::initialize(u32 messagePointer) {
u32 blockSize = mem.read32(messagePointer + 4);
const u32 offset0 = mem.read32(messagePointer + 8);