Initial commit

This commit is contained in:
Gericom
2025-11-22 17:21:45 +01:00
commit 5d6f67c612
517 changed files with 63025 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
#include "common.h"
#include <string.h>
#include <nds/disc_io.h>
#include "DldiIpcService.h"
extern FN_MEDIUM_STARTUP _DLDI_startup_ptr;
extern FN_MEDIUM_READSECTORS _DLDI_readSectors_ptr;
extern FN_MEDIUM_WRITESECTORS _DLDI_writeSectors_ptr;
void DldiIpcService::HandleMessage(u32 data)
{
auto cmd = reinterpret_cast<const dldi_ipc_cmd_t*>(data << 2);
switch (cmd->cmd)
{
case DLDI_IPC_CMD_SETUP:
SetupDldi(cmd);
break;
case DLDI_IPC_CMD_READ_SECTORS:
ReadSectors(cmd);
break;
case DLDI_IPC_CMD_WRITE_SECTORS:
WriteSectors(cmd);
break;
}
}
void DldiIpcService::SetupDldi(const dldi_ipc_cmd_t* cmd) const
{
memcpy((void*)0x037F8000, cmd->buffer, 16 * 1024);
bool result = _DLDI_startup_ptr();
SendResponseMessage(result);
}
void DldiIpcService::ReadSectors(const dldi_ipc_cmd_t* cmd) const
{
_DLDI_readSectors_ptr(cmd->sector, cmd->count, cmd->buffer);
SendResponseMessage(0);
}
void DldiIpcService::WriteSectors(const dldi_ipc_cmd_t* cmd) const
{
_DLDI_writeSectors_ptr(cmd->sector, cmd->count, cmd->buffer);
SendResponseMessage(0);
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "ipc/ThreadIpcService.h"
#include "dldiIpcCommand.h"
#include "ipcChannels.h"
class DldiIpcService : public ThreadIpcService
{
u32 _threadStack[128];
void SetupDldi(const dldi_ipc_cmd_t* cmd) const;
void ReadSectors(const dldi_ipc_cmd_t* cmd) const;
void WriteSectors(const dldi_ipc_cmd_t* cmd) const;
public:
DldiIpcService()
: ThreadIpcService(IPC_CHANNEL_DLDI, 6, _threadStack, sizeof(_threadStack)) { }
void HandleMessage(u32 data) override;
};

View File

@@ -0,0 +1,19 @@
#pragma once
#include "ipc/ThreadIpcService.h"
#include "dsiSdIpcCommand.h"
#include "ipcChannels.h"
class DsiSdIpcService : public ThreadIpcService
{
u32 _threadStack[128];
void ReadSectors(const dsisd_ipc_cmd_t* cmd) const;
void WriteSectors(const dsisd_ipc_cmd_t* cmd) const;
public:
DsiSdIpcService()
: ThreadIpcService(IPC_CHANNEL_DSI_SD, 5, _threadStack, sizeof(_threadStack)) { }
void Start() override;
void HandleMessage(u32 data) override;
};

View File

@@ -0,0 +1,36 @@
#include <nds/ndstypes.h>
#include "../mmc/sdmmc.h"
#include "DsiSdIpcService.h"
void DsiSdIpcService::Start()
{
pico_SDMMC_init(SDMMC_DEV_CARD);
ThreadIpcService::Start();
}
void DsiSdIpcService::HandleMessage(u32 data)
{
auto cmd = reinterpret_cast<const dsisd_ipc_cmd_t*>(data << 2);
switch (cmd->cmd)
{
case DSI_SD_IPC_CMD_READ_SECTORS:
ReadSectors(cmd);
break;
case DSI_SD_IPC_CMD_WRITE_SECTORS:
WriteSectors(cmd);
break;
}
}
void DsiSdIpcService::ReadSectors(const dsisd_ipc_cmd_t* cmd) const
{
pico_SDMMC_readSectors(SDMMC_DEV_CARD, cmd->sector, cmd->buffer, cmd->count);
SendResponseMessage(0);
}
void DsiSdIpcService::WriteSectors(const dsisd_ipc_cmd_t* cmd) const
{
pico_SDMMC_writeSectors(SDMMC_DEV_CARD, cmd->sector, cmd->buffer, cmd->count);
SendResponseMessage(0);
}

View File

@@ -0,0 +1,9 @@
#include "common.h"
#include <libtwl/sio/sioRtc.h>
#include "RtcIpcService.h"
void RtcIpcService::HandleMessage(u32 data)
{
rtc_readDateTime(reinterpret_cast<rtc_datetime_t*>(data << 2));
SendResponseMessage(1);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "ipc/ThreadIpcService.h"
#include "ipcChannels.h"
class RtcIpcService : public ThreadIpcService
{
u32 _threadStack[128];
public:
RtcIpcService()
: ThreadIpcService(IPC_CHANNEL_RTC, 10, _threadStack, sizeof(_threadStack)) { }
void HandleMessage(u32 data) override;
};

View File

@@ -0,0 +1,49 @@
#include "common.h"
#include <libtwl/sound/soundChannel.h>
#include "soundIpcCommand.h"
#include "SoundIpcService.h"
void SoundIpcService::OnMessageReceived(u32 data)
{
const u32* commandList = reinterpret_cast<const u32*>(data);
u32 cmdCount = *commandList++;
for (u32 i = 0; i < cmdCount; i++)
{
u32 cmdValue = *commandList++;
u32 cmd = cmdValue & 0xFF;
u32 cmdArg = cmdValue >> 8;
switch (cmd)
{
case SND_IPC_CMD_START_CHANNELS:
{
u32 channelsMask = cmdArg;
for (u32 j = 0; j < 16; j++)
{
if (channelsMask & (1u << j))
snd_startChannel(j);
}
break;
}
case SND_IPC_CMD_STOP_CHANNELS:
{
u32 channelsMask = cmdArg;
for (u32 j = 0; j < 16; j++)
{
if (channelsMask & (1u << j))
snd_stopChannel(j);
}
break;
}
case SND_IPC_CMD_SETUP_CHANNEL:
{
u32 channel = cmdArg;
REG_SOUNDxSAD(channel) = *commandList++;
REG_SOUNDxTMR(channel) = *commandList++;
REG_SOUNDxPNT(channel) = *commandList++;
REG_SOUNDxLEN(channel) = *commandList++;
REG_SOUNDxCNT(channel) = *commandList++;
break;
}
}
}
}

View File

@@ -0,0 +1,12 @@
#pragma once
#include "ipc/IpcService.h"
#include "ipcChannels.h"
class SoundIpcService : public IpcService
{
public:
SoundIpcService()
: IpcService(IPC_CHANNEL_SOUND) { }
void OnMessageReceived(u32 data) override;
};