From 616d6f2558a20da2bf93fbe276c36c95729b0faf Mon Sep 17 00:00:00 2001 From: Alejandro Javier Asenjo Nitti Date: Sat, 14 Oct 2023 06:30:16 -0300 Subject: [PATCH] Decompile osPiStartDma --- src/libultra/io/pidma.c | 43 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/libultra/io/pidma.c b/src/libultra/io/pidma.c index 3f6d49ee..d50931ab 100644 --- a/src/libultra/io/pidma.c +++ b/src/libultra/io/pidma.c @@ -1,3 +1,42 @@ -#include "common.h" +#include "global.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/io/pidma/osPiStartDma.s") +typedef struct { + s16 unk0; + s8 unk2; + s8 pad; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; +} test; + +extern s32 __osPiDevMgr; + +s32 osPiStartDma(test* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { + register s32 result; + + if (__osPiDevMgr == 0) { + return -1; + } + + if (arg2 == 0) { + arg0->unk0 = 0xB; + } else { + arg0->unk0 = 0xC; + } + + arg0->unk2 = (s8) arg1; + arg0->unk4 = arg6; + arg0->unk8 = arg4; + arg0->unkC = arg3; + arg0->unk10 = arg5; + arg0->unk14 = 0; + + if (arg1 == 1) { + result = osJamMesg(osPiGetCmdQueue(), arg0, 0); + } else { + result = osSendMesg(osPiGetCmdQueue(), arg0, 0); + } + return result; +}