From 76c39482bccb5e24d10a0b8dfaf9e9c747bc4ecb Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Mon, 27 Dec 2021 03:42:31 +0000 Subject: [PATCH] contchannelreset OK (#428) * contchannelreset OK * Add to functions.h * Rename argument --- include/functions.h | 2 +- src/libultra/io/contchannelreset.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/functions.h b/include/functions.h index 921e974b97..6502f1f92e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -381,7 +381,7 @@ void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); // void osVoiceInit(void); -// void __osContChannelReset(void); +s32 __osContChannelReset(OSMesgQueue* mq, s32 channel); // void __osVoiceSetADConverter(void); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); diff --git a/src/libultra/io/contchannelreset.c b/src/libultra/io/contchannelreset.c index 841dad7386..5a66274a96 100644 --- a/src/libultra/io/contchannelreset.c +++ b/src/libultra/io/contchannelreset.c @@ -1,3 +1,27 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/contchannelreset/__osContChannelReset.s") +s32 __osContChannelReset(OSMesgQueue* mq, s32 channel) { + s32 i; + s32 ret; + u8* bufptr = (u8*)&__osPfsPifRam; + + __osSiGetAccess(); + + __osPfsPifRam.pifstatus = 1; + + for (i = 0; i < channel; i++) { + *bufptr++ = 0; + } + + *bufptr++ = 0xFD; + *bufptr = CONT_CMD_END; + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + __osSiRelAccess(); + + return ret; +}