From a249398660d31edb54ca6bbcc4d23e51032d6bab Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Mon, 4 Apr 2022 14:22:34 +0200 Subject: [PATCH] split rvlAxOut (#169) --- pack/dol_objects.txt | 12 +- pack/dol_slices.csv | 2 + pack/symbols.txt | 97 ++++- source/gamespy/md5c.c | 4 +- source/nw4r/lyt/lyt_init.cpp | 4 +- source/rvl/ax/rvlAxDspCode.c | 8 + source/rvl/ax/rvlAxDspCode.h | 18 + source/rvl/ax/rvlAxOut.c | 752 +++++++++++++++++++++++++++++++++++ source/rvl/ax/rvlAxOut.h | 38 ++ sources.py | 1 + 10 files changed, 909 insertions(+), 27 deletions(-) create mode 100644 source/rvl/ax/rvlAxDspCode.c create mode 100644 source/rvl/ax/rvlAxDspCode.h create mode 100644 source/rvl/ax/rvlAxOut.c create mode 100644 source/rvl/ax/rvlAxOut.h diff --git a/pack/dol_objects.txt b/pack/dol_objects.txt index 1e46c97f2..ce879ed69 100644 --- a/pack/dol_objects.txt +++ b/pack/dol_objects.txt @@ -234,19 +234,23 @@ out/rvlAx.o out/dol/data_8027e7bf_8027e860.o out/rvlAxComp.o out/dol/data_8027f820_802826a0.o -out/dol/sdata_803857fc_80385920.o +out/dol/sdata_803857fc_80385800.o +out/rvlAxDspCode.o +out/dol/sdata_80385806_80385920.o out/dol/sbss_8038648c_80386490.o out/rvlAxAlloc.o out/dol/bss_802f41c0_802f7340.o out/dol/sbss_80386494_80386498.o out/rvlAxAux.o out/rvlAxCl.o -out/dol/text_80126638_8012e564.o +out/dol/bss_802f7440_803457e0.o +out/dol/sbss_803864fc_80386500.o +out/rvlAxOut.o +out/dol/text_80126e30_8012e564.o out/ppcArch.o out/dol/text_8012e6d4_80169bcc.o out/dol/data_802826d7_8028e998.o -out/dol/bss_802f7440_803457e0.o -out/dol/sbss_803864fc_80386770.o +out/dol/sbss_8038653c_80386770.o out/fs.o out/dol/text_8016b49c_80192f7c.o out/dol/sdata_80385930_80385990.o diff --git a/pack/dol_slices.csv b/pack/dol_slices.csv index abda1ecd0..e6b44c4b5 100644 --- a/pack/dol_slices.csv +++ b/pack/dol_slices.csv @@ -96,7 +96,9 @@ enabled,strip,name,initStart,initEnd,extabStart,extabEnd,extabindexStart,extabin 1,,source/rvl/ax/rvlAxAlloc.c,,,,,,,0x80124edc,0x80125394,,,,,,,,,0x802f40c0,0x802f41c0,,,0x80386490,0x80386494,,,, 1,,source/rvl/ax/rvlAxAux.c,,,,,,,0x80125394,0x80125bac,,,,,,,,,,,,,0x80386498,0x803864e0,,,, 1,,source/rvl/ax/rvlAxCl.c,,,,,,,0x80125bac,0x80126638,,,,,,,,,0x802f7340,0x802f7440,,,0x803864e0,0x803864fc,,,, +1,,source/rvl/ax/rvlAxOut.c,,,,,,,0x80126638,0x80126e30,,,,,,,,,,,,,0x80386500,0x8038653c,,,, 1,,source/rvl/ax/rvlAxComp.c,,,,,,,,,,,,,,,0x8027e860,0x8027f820,,,,,,,,,, +1,,source/rvl/ax/rvlAxDspCode.c,,,,,,,,,,,,,,,,,,,0x80385800,0x80385806,,,,,, 1,,source/rvl/base/ppcArch.c,,,,,,,0x8012e564,0x8012e6d4,,,,,,,0x802826a0,0x802826d7,,,,,,,,,, 1,,source/rvl/fs/fs.c,,,,,,,0x80169bcc,0x8016b49c,,,,,,,,,,,0x80385920,0x80385930,0x80386770,0x80386788,,,, 1,,source/rvl/ipc/ipcMain.c,,,,,,,0x80192f7c,0x80193048,,,,,,,,,,,,,0x803867e8,0x803867fc,,,, diff --git a/pack/symbols.txt b/pack/symbols.txt index 3851a30ec..da4db5eff 100644 --- a/pack/symbols.txt +++ b/pack/symbols.txt @@ -4251,10 +4251,10 @@ 0x80123d6c sakeiGetRandomRecordFillSoapRequest 0x80123e4c sakeiGetRandomRecordProcessSoapResponse 0x80123ed8 sakeiGetRandomRecordFreeData -0x80123f88 unk_80123f88 -0x80123fcc unk_80123fcc -0x80124048 unk_80124048 -0x8012405c unk_8012405c +0x80123f88 AIRegisterDMACallback +0x80123fcc AIInitDMA +0x80124048 AIStartDMA +0x8012405c AIGetDMABytesLeft 0x8012406c unk_8012406c 0x80124084 unk_80124084 0x80124094 unk_80124094 @@ -4321,27 +4321,27 @@ 0x80126620 AXSetAuxAReturnVolume 0x80126628 AXSetAuxBReturnVolume 0x80126630 AXSetAuxCReturnVolume -0x80126638 unk_80126638 -0x80126898 unk_80126898 -0x80126948 unk_80126948 -0x80126954 unk_80126954 -0x801269a8 unk_801269a8 -0x801269b8 unk_801269b8 -0x801269bc unk_801269bc +0x80126638 __AXOutNewFrame +0x80126898 __AXOutAiCallback +0x80126948 __AXDSPInitCallback +0x80126954 __AXDSPResumeCallback +0x801269a8 __AXDSPDoneCallback +0x801269b8 __AXDSPRequestCallback +0x801269bc __AXOutInitDSP 0x80126aac __AXOutInit -0x80126ca4 unk_80126ca4 -0x80126ce8 unk_80126ce8 -0x80126d14 unk_80126d14 -0x80126dd8 unk_80126dd8 +0x80126ca4 AXRegisterCallback +0x80126ce8 AXRmtGetSamplesLeft +0x80126d14 AXRmtGetSamples +0x80126dd8 AXRmtAdvancePtr 0x80126e30 __AXGetStudio 0x80126e3c unk_80126e3c 0x80126ea8 unk_80126ea8 -0x80126f14 unk_80126f14 +0x80126f14 __AXPrintStudio 0x8012708c __AXSPBInit 0x801270e4 unk_801270e4 -0x80127250 unk_80127250 +0x80127250 __AXGetNumVoices 0x80127258 unk_80127258 -0x801277a8 unk_801277a8 +0x801277a8 __AXSyncPBs 0x80127ab8 __AXGetPBs 0x80127ac0 __AXSetPBDefault 0x80127b00 __AXVPBInit @@ -4350,7 +4350,7 @@ 0x80127f20 unk_80127f20 0x80127fdc unk_80127fdc 0x80127fe4 unk_80127fe4 -0x80127fec unk_80127fec +0x80127fec __AXGetCurrentProfile 0x8012802c unk_8012802c 0x80128090 unk_80128090 0x801280b8 unk_801280b8 @@ -8758,10 +8758,27 @@ 0x80244cc8 unk_80244cc8 0x80244d30 unk_80244d30 0x80244d3c unk_80244d3c +0x80244de0 __init_cpp_exceptions_reference +0x80244ea0 __destroy_global_chain_reference +0x80244ea4 __fini_cpp_exceptions_reference +0x80245088 sSystemResources__Q26System8Resource +0x80248010 gSinCosTbl__Q34nw4r4math6detail 0x80252dd0 PADClampRegionV1 0x80252ddc PADClampRegionV2 +0x802582e0 gRMO_Ntsc_640x456IntDf_4x3__Q23EGG22@unnamed@eggVideo_cpp@ +0x8025831c gRMO_Ntsc_640x456Prog_4x3__Q23EGG22@unnamed@eggVideo_cpp@ +0x80258358 gRMO_Pal50_640x456IntDf_4x3__Q23EGG22@unnamed@eggVideo_cpp@ +0x80258394 gRMO_Pal60_640x456IntDf_4x3__Q23EGG22@unnamed@eggVideo_cpp@ +0x802583d0 gRMO_Pal60_640x456Prog_4x3__Q23EGG22@unnamed@eggVideo_cpp@ +0x8025840c gRMO_Ntsc_640x456IntDf_16x9__Q23EGG22@unnamed@eggVideo_cpp@ +0x80258448 gRMO_Ntsc_640x456Prog_16x9__Q23EGG22@unnamed@eggVideo_cpp@ +0x80258484 gRMO_Pal50_640x456IntDf_16x9__Q23EGG22@unnamed@eggVideo_cpp@ +0x802584c0 gRMO_Pal60_640x456IntDf_16x9__Q23EGG22@unnamed@eggVideo_cpp@ +0x802584fc gRMO_Pal60_640x456Prog_16x9__Q23EGG22@unnamed@eggVideo_cpp@ +0x80258538 StandardRenderModesTable__Q23EGG22@unnamed@eggVideo_cpp@ 0x80270fd0 __ctype_mapC 0x80271148 _current_locale +0x80274148 sArcTanTbl__Q34nw4r4math28@unnamed@mathTriangular_cpp@ 0x80274318 __vt__Q34nw4r3snd15DvdSoundArchive 0x80274c40 __vt__Q34nw4r2ut13DvdFileStream 0x80274ca8 __vt__Q34nw4r2ut19DvdLockedFileStream @@ -8770,12 +8787,18 @@ 0x80274e74 __vt__Q44nw4r2ut6detail11ResFontBase 0x80274ed0 __vt__Q34nw4r2ut7ResFont 0x80274f30 __RFL_VERSION +0x8027aca0 MD5_PADDING +0x8027ae48 GS_XML_SOAP_DEFAULT_NAMESPACES 0x8027b4d0 GPConnectionManagerHostname 0x8027bd30 GPIInfoCacheFilename 0x8027bee8 GPSearchManagerHostname +0x8027c2c8 GT2ChallengeKey +0x8027c2f0 static_qr2_rec 0x8027d300 qr2_registered_key_list 0x8027e860 __AXCompressorTable 0x80290600 OSInterruptPrioTable +0x8029ccc8 PAD_ResetFunctionInfo +0x802a2360 NET_RM_SOCK 0x802a2668 __vt__Q23EGG9Allocator 0x802a2680 __vt__Q23EGG7Archive 0x802a2a08 __vt__Q23EGG7CntFile @@ -8805,6 +8828,11 @@ 0x802f7d20 __AXOutBuffer 0x802f81a0 __AXDSPTask 0x802f8200 __AXDramImage +0x80345810 kpad_inside_status +0x80346cf0 MEM_RootList +0x80346d00 MEM_GlobalLock +0x80348200 PAD_AltStatus +0x80357220 soWork 0x803832d8 sArchiveList__Q23EGG7Archive 0x80383500 gCntFileList__3EGG 0x80384190 sDvdList__Q23EGG7DvdFile @@ -8815,21 +8843,37 @@ 0x80384bb8 ex__Q23EGG8Vector3f 0x80384bd0 ey__Q23EGG8Vector3f 0x80384be8 ez__Q23EGG8Vector3f +0x80384d90 VERSION__Q24nw4r3lyt 0x80385520 NNMagicData +0x803855d8 ghiThrottleBufferSize +0x803855dc ghiThrottleTimeDelay 0x80385800 axDspInitVector 0x80385802 axDspResumeVector 0x80385804 axDspSlaveLength 0x80385a98 __OSCurrentHeap 0x80385aa0 __OSMEM1ArenaLo 0x80385aa4 __OSMEM2ArenaLo +0x80385b08 __PAD_VERSION 0x80385b0c PADResetChan 0x80385b10 PAD_StickXResetBit 0x80385b14 PAD_AnalogMode +0x80385b1c PAD_MakeStatus +0x80385ee0 __SO_VERSION +0x80385ee4 soBufAddrCheck +0x80385ee8 __SOCKET_VERSION +0x80385f88 sErrorRetry__Q23EGG9DvdRipper +0x803860ac __global_destructor_chain 0x80386240 typeInfo__Q34nw4r2ut8IOStream 0x80386248 typeInfo__Q34nw4r2ut10FileStream 0x80386250 typeInfo__Q34nw4r2ut13DvdFileStream 0x80386258 typeInfo__Q34nw4r2ut19DvdLockedFileStream +0x80386260 sThreadQueue__Q34nw4r2ut19DvdLockedFileStream +0x80386268 sInitialized__Q34nw4r2ut19DvdLockedFileStream +0x80386270 typeInfo__Q34nw4r2ut14NandFileStream +0x803862a8 stDwcLastError +0x803862ac stDwcErrorCode 0x80386354 GSIRevolutionErrno +0x80386358 __GSIACResult 0x80386370 ghiProxyPort 0x80386374 ghiProxyAddress 0x80386378 ghiNextUniqueID @@ -8837,6 +8881,12 @@ 0x80386380 ghiConnectionsLen 0x80386384 ghiConnections 0x80386388 ghiReferenceCount +0x803863b8 g_buckets +0x803863c0 g_statsgame +0x80386430 g_SBRefStrList +0x80386438 SBNullServer +0x80386440 SBOverrideMasterServer +0x80386444 g_sortserverlist 0x80386500 __AXExceedCallback 0x80386504 __AXRmtCpuPtr 0x80386508 __AXRmtDspPtr @@ -8855,6 +8905,7 @@ 0x803867f0 IPCBufferHi 0x803867f4 IPCAltBufferLo 0x803867f8 IPCAltBufferHi +0x80386838 MEM_RootListInitialized 0x803868a8 OS_AllocArenaStop 0x803868ac OS_AllocArenaStart 0x803868b0 OS_AllocNumHeaps @@ -8865,6 +8916,14 @@ 0x803868ec __OSLastInterrupt 0x803868f0 __OSLastInterruptTime 0x803868f8 OSInterruptHandlerTable +0x8038699c PAD_SamplingCallback +0x803869a0 PAD_Spec +0x803869b8 PADResetBits +0x803869bc PADEnabledBits +0x803869c0 PADInitialized +0x803869f4 __PADFixBits +0x80386d30 soState +0x80386d34 soError 0x80386d80 sIsArchiveListInitialized__Q23EGG7Archive 0x80386dc8 gCurrentCntFile__3EGG 0x80386e18 sIsInitialized__Q23EGG7DvdFile diff --git a/source/gamespy/md5c.c b/source/gamespy/md5c.c index 77b37bd68..c61b6b377 100644 --- a/source/gamespy/md5c.c +++ b/source/gamespy/md5c.c @@ -56,7 +56,7 @@ static void Decode PROTO_LIST((UINT4*, unsigned char*, unsigned int)); static void MD5_memcpy PROTO_LIST((POINTER, POINTER, unsigned int)); static void MD5_memset PROTO_LIST((POINTER, int, unsigned int)); -static unsigned char PADDING[64] = { +static unsigned char MD5_PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -166,7 +166,7 @@ inline void MD5Final(unsigned char digest[16], /* message digest */ */ index = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update(context, PADDING, padLen); + MD5Update(context, MD5_PADDING, padLen); /* Append length (before padding) */ MD5Update(context, bits, 8); diff --git a/source/nw4r/lyt/lyt_init.cpp b/source/nw4r/lyt/lyt_init.cpp index a99c42e06..46f497703 100644 --- a/source/nw4r/lyt/lyt_init.cpp +++ b/source/nw4r/lyt/lyt_init.cpp @@ -5,11 +5,11 @@ namespace nw4r { namespace lyt { -static const char* NW4R_LYT_VERSION_STRING = +static const char* VERSION = "<< NW4R - LYT final build: Mar 8 2008 20:59:41 (0x4201_127) >>"; void LytInit() { - OSRegisterVersion(NW4R_LYT_VERSION_STRING); + OSRegisterVersion(VERSION); OSInitFastCast(); } diff --git a/source/rvl/ax/rvlAxDspCode.c b/source/rvl/ax/rvlAxDspCode.c new file mode 100644 index 000000000..9aaa2cf51 --- /dev/null +++ b/source/rvl/ax/rvlAxDspCode.c @@ -0,0 +1,8 @@ +#include "rvlAxDspCode.h" + +// PAL: 0x80385800 +u16 axDspInitVector = 0x10; +// PAL: 0x80385802 +u16 axDspResumeVector = 0x37; +// PAL: 0x80385804 +u16 axDspSlaveLength = 0x2000; diff --git a/source/rvl/ax/rvlAxDspCode.h b/source/rvl/ax/rvlAxDspCode.h new file mode 100644 index 000000000..006397060 --- /dev/null +++ b/source/rvl/ax/rvlAxDspCode.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// PAL: 0x80385800 +extern u16 axDspInitVector; +// PAL: 0x80385802 +extern u16 axDspResumeVector; +// PAL: 0x80385804 +extern u16 axDspSlaveLength; + +#ifdef __cplusplus +} +#endif diff --git a/source/rvl/ax/rvlAxOut.c b/source/rvl/ax/rvlAxOut.c new file mode 100644 index 000000000..b8c421ec6 --- /dev/null +++ b/source/rvl/ax/rvlAxOut.c @@ -0,0 +1,752 @@ +#include "rvlAxOut.h" + +#include +#include +#include +#include + +// Extern function references. +// PAL: 0x80123f88 +extern UNKNOWN_FUNCTION(AIRegisterDMACallback); +// PAL: 0x80123fcc +extern UNKNOWN_FUNCTION(AIInitDMA); +// PAL: 0x80124048 +extern UNKNOWN_FUNCTION(AIStartDMA); +// PAL: 0x8012405c +extern UNKNOWN_FUNCTION(AIGetDMABytesLeft); +// PAL: 0x80124ef0 +extern UNKNOWN_FUNCTION(__AXServiceCallbackStack); +// PAL: 0x80125698 +extern UNKNOWN_FUNCTION(__AXProcessAux); +// PAL: 0x80125bb4 +extern UNKNOWN_FUNCTION(__AXGetCommandListAddress); +// PAL: 0x80125be4 +extern UNKNOWN_FUNCTION(__AXNextFrame); +// PAL: 0x80126f14 +extern UNKNOWN_FUNCTION(__AXPrintStudio); +// PAL: 0x80127250 +extern UNKNOWN_FUNCTION(__AXGetNumVoices); +// PAL: 0x801277a8 +extern UNKNOWN_FUNCTION(__AXSyncPBs); +// PAL: 0x80127fec +extern UNKNOWN_FUNCTION(__AXGetCurrentProfile); +// PAL: 0x8015d3fc +extern UNKNOWN_FUNCTION(DSPCheckMailToDSP); +// PAL: 0x8015d430 +extern UNKNOWN_FUNCTION(DSPSendMailToDSP); +// PAL: 0x8015d444 +extern UNKNOWN_FUNCTION(DSPInit); +// PAL: 0x8015d504 +extern UNKNOWN_FUNCTION(DSPCheckInit); +// PAL: 0x8015d50c +extern UNKNOWN_FUNCTION(DSPAddTask); +// PAL: 0x8015d57c +extern UNKNOWN_FUNCTION(DSPAssertTask); + +typedef struct AXPROFILE { + char content[56]; +} AXPROFILE; + +typedef struct DSPTaskInfo { + char content[80]; +} DSPTaskInfo; + +// PAL: 0x802f7d20..0x802f81a0 +extern s16 __AXOutBuffer[3][192] __attribute__((aligned(32))); +// PAL: 0x802f7a20..0x802f7d20 +extern s32 __AXOutSBuffer[192] __attribute__((aligned(32))); + +volatile u32 __AXOutFrame; +volatile u32 __AXAiDmaFrame; +volatile u32 __AXOutDspReady; +u32 __AXUserFrameCallback; + +// PAL: 0x802f7440..0x802f7480 +extern AXPROFILE __AXLocalProfile; + +volatile int __AXDSPInitFlag; +volatile int __AXDSPDoneFlag; +volatile u32 __AXDebugSteppingMode; +OSThreadQueue __AXOutThreadQueue; +u32 __AXOutputBufferMode; + +// PAL: 0x802f7480..0x802f7a20 +extern s16 __AXRmtOutBuffer[4][180] __attribute__((aligned(32))); +s32 __AXRmtBuffLen; +s32 __AXRmtDspPtr; +s32 __AXRmtCpuPtr; +u32 __AXExceedCallback; + +extern u16 axDspInitVector; +extern u16 axDspResumeVector; +extern u16 axDspSlave[]; +extern u16 axDspSlaveLength; + +extern u8 __AXDramImage[64] __attribute__((aligned(32))); +extern DSPTaskInfo __AXDSPTask; + +// Symbol: __AXOutNewFrame +// Function signatgure is unknown. +// PAL: 0x80126638..0x80126898 +MARK_BINARY_BLOB(__AXOutNewFrame, 0x80126638, 0x80126898); +asm UNKNOWN_FUNCTION(__AXOutNewFrame) { + // clang-format off + nofralloc; + stwu r1, -0x30(r1); + mflr r0; + stw r0, 0x34(r1); + stw r31, 0x2c(r1); + lis r31, __AXLocalProfile@ha; + la r31, __AXLocalProfile@l(r31); + stw r30, 0x28(r1); + stw r29, 0x24(r1); + bl OSGetTime; + addi r5, r31, 0; + stw r3, 0(r31); + stw r4, 4(r5); + bl AIGetDMABytesLeft; + srwi r3, r3, 2; + lwz r0, __AXOutputBufferMode; + subfic r3, r3, 0x60; + cmplwi r0, 1; + mulli r30, r3, 0xed5; + bne lbl_80126690; + li r3, 0; + bl __AXSyncPBs; + b lbl_80126698; +lbl_80126690: + li r3, 0x5f50; + bl __AXSyncPBs; +lbl_80126698: + bl __AXPrintStudio; + bl __AXGetCommandListAddress; + lis r4, 0xbabe; + mr r29, r3; + addi r3, r4, 0x80; + bl DSPSendMailToDSP; +lbl_801266b0: + bl DSPCheckMailToDSP; + cmpwi r3, 0; + bne lbl_801266b0; + mr r3, r29; + bl DSPSendMailToDSP; +lbl_801266c4: + bl DSPCheckMailToDSP; + cmpwi r3, 0; + bne lbl_801266c4; + bl __AXServiceCallbackStack; + bl OSGetTime; + addi r29, r31, 0; + stw r4, 0xc(r29); + stw r3, 8(r29); + bl __AXProcessAux; + bl OSGetTime; + stw r4, 0x14(r29); + stw r3, 0x10(r29); + bl OSGetTime; + lwz r12, __AXUserFrameCallback; + stw r4, 0x1c(r29); + cmpwi r12, 0; + stw r3, 0x18(r29); + beq lbl_80126714; + mtctr r12; + bctrl; +lbl_80126714: + bl OSGetTime; + lwz r7, __AXRmtDspPtr; + addi r8, r31, 0; + addi r5, r31, 0x40; + lwz r0, __AXRmtBuffLen; + slwi r6, r7, 1; + addi r7, r7, 0x12; + add r6, r5, r6; + stw r4, 0x24(r8); + addi r5, r6, 0x168; + cmpw r7, r0; + addi r4, r6, 0x2d0; + addi r0, r6, 0x438; + stw r3, 0x20(r8); + stw r6, 8(r1); + stw r5, 0xc(r1); + stw r4, 0x10(r1); + stw r0, 0x14(r1); + blt lbl_80126764; + li r7, 0; +lbl_80126764: + lwz r4, __AXRmtCpuPtr; + lwz r3, __AXRmtDspPtr; + cmpw r4, r3; + blt lbl_80126784; + addi r0, r3, 0x12; + cmpw r4, r0; + bge lbl_80126784; + stw r7, __AXRmtCpuPtr; +lbl_80126784: + lwz r0, __AXOutFrame; + addi r29, r31, 0x8e0; + stw r7, __AXRmtDspPtr; + addi r3, r31, 0x5e0; + mulli r0, r0, 0x180; + addi r5, r1, 8; + add r4, r29, r0; + bl __AXNextFrame; + lwz r3, __AXOutFrame; + lwz r0, __AXOutputBufferMode; + addi r3, r3, 1; + cmplwi r0, 1; + stw r3, __AXOutFrame; + bne lbl_801267e0; + lis r3, 0xaaab; + lwz r4, __AXOutFrame; + addi r0, r3, -21845; + mulhwu r0, r0, r4; + srwi r0, r0, 1; + mulli r0, r0, 3; + subf r0, r0, r4; + stw r0, __AXOutFrame; + b lbl_80126800; +lbl_801267e0: + lwz r0, __AXOutFrame; + li r4, 0x180; + clrlwi r0, r0, 0x1f; + stw r0, __AXOutFrame; + lwz r0, __AXOutFrame; + mulli r0, r0, 0x180; + add r3, r29, r0; + bl AIInitDMA; +lbl_80126800: + bl OSGetTime; + addi r29, r31, 0; + stw r4, 0x2c(r29); + stw r3, 0x28(r29); + bl __AXGetNumVoices; + stw r3, 0x30(r29); + bl __AXGetCurrentProfile; + cmpwi r3, 0; + beq lbl_80126878; + li r0, 7; + mtctr r0; +lbl_8012682c: + lbz r0, 0(r29); + stb r0, 0(r3); + lbz r0, 1(r29); + stb r0, 1(r3); + lbz r0, 2(r29); + stb r0, 2(r3); + lbz r0, 3(r29); + stb r0, 3(r3); + lbz r0, 4(r29); + stb r0, 4(r3); + lbz r0, 5(r29); + stb r0, 5(r3); + lbz r0, 6(r29); + stb r0, 6(r3); + lbz r0, 7(r29); + addi r29, r29, 8; + stb r0, 7(r3); + addi r3, r3, 8; + bdnz lbl_8012682c; +lbl_80126878: + mr r3, r30; + lwz r31, 0x2c(r1); + lwz r30, 0x28(r1); + lwz r29, 0x24(r1); + lwz r0, 0x34(r1); + mtlr r0; + addi r1, r1, 0x30; + blr; + // clang-format on +} + +// Symbol: __AXOutAiCallback +// Function signature is unknown. +// PAL: 0x80126898..0x80126948 +MARK_BINARY_BLOB(__AXOutAiCallback, 0x80126898, 0x80126948); +asm UNKNOWN_FUNCTION(__AXOutAiCallback) { + // clang-format off + nofralloc; + stwu r1, -0x10(r1); + mflr r0; + stw r0, 0x14(r1); + lwz r0, __AXDSPDoneFlag; + cmpwi r0, 1; + beq lbl_80126938; + lwz r0, __AXOutDspReady; + cmplwi r0, 1; + bne lbl_801268cc; + li r0, 0; + stw r0, __AXOutDspReady; + bl __AXOutNewFrame; + b lbl_801268e0; +lbl_801268cc: + li r0, 2; + lis r3, 0x8030; + stw r0, __AXOutDspReady; + addi r3, r3, -32352; + bl DSPAssertTask; +lbl_801268e0: + lwz r0, __AXOutputBufferMode; + cmplwi r0, 1; + bne lbl_80126938; + lwz r0, __AXAiDmaFrame; + lis r3, __AXOutBuffer@ha; + la r3, __AXOutBuffer@l(r3); + li r4, 0x180; + mulli r0, r0, 0x180; + add r3, r3, r0; + bl AIInitDMA; + lwz r4, __AXAiDmaFrame; + lis r3, 0xaaab; + addi r3, r3, -21845; + lwz r0, __AXOutFrame; + addi r4, r4, 1; + mulhwu r3, r3, r4; + srwi r3, r3, 1; + mulli r3, r3, 3; + subf r4, r3, r4; + cmplw r4, r0; + beq lbl_80126938; + stw r4, __AXAiDmaFrame; +lbl_80126938: + lwz r0, 0x14(r1); + mtlr r0; + addi r1, r1, 0x10; + blr; + // clang-format on +} + +// Symbol: __AXDSPInitCallback +// Function signature is unknown. +// PAL: 0x80126948..0x80126954 +MARK_BINARY_BLOB(__AXDSPInitCallback, 0x80126948, 0x80126954); +asm UNKNOWN_FUNCTION(__AXDSPInitCallback) { + // clang-format off + nofralloc; + li r0, 1; + stw r0, __AXDSPInitFlag; + blr; + // clang-format on +} + +// Symbol: __AXDSPResumeCallback +// Function signature is unknown. +// PAL: 0x80126954..0x801269a8 +MARK_BINARY_BLOB(__AXDSPResumeCallback, 0x80126954, 0x801269a8); +asm UNKNOWN_FUNCTION(__AXDSPResumeCallback) { + // clang-format off + nofralloc; + stwu r1, -0x10(r1); + mflr r0; + stw r0, 0x14(r1); + lwz r0, __AXOutDspReady; + cmplwi r0, 2; + bne lbl_80126990; + li r0, 0; + stw r0, __AXOutDspReady; + bl __AXOutNewFrame; + lwz r12, __AXExceedCallback; + cmpwi r12, 0; + beq lbl_80126998; + mtctr r12; + bctrl; + b lbl_80126998; +lbl_80126990: + li r0, 1; + stw r0, __AXOutDspReady; +lbl_80126998: + lwz r0, 0x14(r1); + mtlr r0; + addi r1, r1, 0x10; + blr; + // clang-format on +} + +// Symbol: __AXDSPDoneCallback +// Function signature is unknown. +// PAL: 0x801269a8..0x801269b8 +MARK_BINARY_BLOB(__AXDSPDoneCallback, 0x801269a8, 0x801269b8); +asm UNKNOWN_FUNCTION(__AXDSPDoneCallback) { + // clang-format off + nofralloc; + li r0, 1; + la r3, __AXOutThreadQueue; + stw r0, __AXDSPDoneFlag; + b OSWakeupThread; + // clang-format on +} + +// Symbol: __AXDSPRequestCallback +// Function signature is unknown. +// PAL: 0x801269b8..0x801269bc +MARK_BINARY_BLOB(__AXDSPRequestCallback, 0x801269b8, 0x801269bc); +asm UNKNOWN_FUNCTION(__AXDSPRequestCallback) { + // clang-format off + nofralloc; + blr; + // clang-format on +} + +// Symbol: __AXOutInitDSP +// Function signature is unknown. +// PAL: 0x801269bc..0x80126aac +MARK_BINARY_BLOB(__AXOutInitDSP, 0x801269bc, 0x80126aac); +asm UNKNOWN_FUNCTION(__AXOutInitDSP) { + // clang-format off + nofralloc; + stwu r1, -0x20(r1); + mflr r0; + lis r11, 0x8030; + lis r7, 0x8012; + stw r0, 0x24(r1); + lis r6, 0x8012; + lis r5, 0x8012; + lis r4, 0x8012; + stw r31, 0x1c(r1); + li r12, 0; + addi r11, r11, -32256; + addi r7, r7, 0x6948; + stw r30, 0x18(r1); + lis r30, 0x8030; + addi r30, r30, -32352; // 80307e60 + addi r6, r6, 0x6954; + stw r29, 0x14(r1); + lis r29, 0x8028; // 80280e70 + addi r29, r29, -2016; + addi r5, r5, 0x69a8; + lhz r31, axDspSlaveLength; + addi r4, r4, 0x69b8; + lhz r8, axDspInitVector; + li r10, 0x40; + lhz r0, axDspResumeVector; + li r9, 0xcd2; + stw r12, 4(r30); + la r3, __AXOutThreadQueue; + stw r12, __AXDSPInitFlag; + stw r29, 0xc(r30); + stw r31, 0x10(r30); + stw r12, 0x14(r30); + stw r11, 0x18(r30); + stw r10, 0x1c(r30); + stw r9, 0x20(r30); + sth r8, 0x24(r30); + sth r0, 0x26(r30); + stw r7, 0x28(r30); + stw r6, 0x2c(r30); + stw r5, 0x30(r30); + stw r4, 0x34(r30); + stw r12, __AXDSPDoneFlag; + bl OSInitThreadQueue; + bl DSPCheckInit; + cmpwi r3, 0; + bne lbl_80126a78; + bl DSPInit; +lbl_80126a78: + lis r3, 0x8030; + addi r3, r3, -32352; + bl DSPAddTask; +lbl_80126a84: + lwz r0, __AXDSPInitFlag; + cmpwi r0, 0; + beq lbl_80126a84; + lwz r0, 0x24(r1); + lwz r31, 0x1c(r1); + lwz r30, 0x18(r1); + lwz r29, 0x14(r1); + mtlr r0; + addi r1, r1, 0x20; + blr; + // clang-format on +} + +// Symbol: __AXOutInit +// Function signature is unknown. +// PAL: 0x80126aac..0x80126ca4 +MARK_BINARY_BLOB(__AXOutInit, 0x80126aac, 0x80126ca4); +asm UNKNOWN_FUNCTION(__AXOutInit) { + // clang-format off + nofralloc; + stwu r1, -0x20(r1); + mflr r0; + li r4, 0; + stw r0, 0x24(r1); + li r0, 0x20; + stw r31, 0x1c(r1); + lis r31, __AXLocalProfile@ha; + la r31, __AXLocalProfile@l(r31); + stw r4, __AXOutFrame; + addi r5, r31, 0x8e0; + stw r4, __AXAiDmaFrame; + stw r3, __AXOutputBufferMode; + stw r4, __AXDebugSteppingMode; + mtctr r0; +lbl_80126ae4: + stw r4, 0(r5); + stw r4, 4(r5); + stw r4, 8(r5); + stw r4, 0xc(r5); + stw r4, 0x10(r5); + stw r4, 0x14(r5); + stw r4, 0x18(r5); + stw r4, 0x1c(r5); + stw r4, 0x20(r5); + addi r5, r5, 0x24; + bdnz lbl_80126ae4; + addi r3, r31, 0x8e0; + li r4, 0x480; + bl DCFlushRange; + li r0, 0x18; + addi r4, r31, 0x5e0; + li r3, 0; + mtctr r0; +lbl_80126b2c: + stw r3, 0(r4); + stw r3, 4(r4); + stw r3, 8(r4); + stw r3, 0xc(r4); + stw r3, 0x10(r4); + stw r3, 0x14(r4); + stw r3, 0x18(r4); + stw r3, 0x1c(r4); + addi r4, r4, 0x20; + bdnz lbl_80126b2c; + addi r3, r31, 0x5e0; + li r4, 0x300; + bl DCFlushRange; + li r0, 0x24; + addi r4, r31, 0x40; + li r3, 0; + mtctr r0; +lbl_80126b70: + stw r3, 0(r4); + stw r3, 4(r4); + stw r3, 8(r4); + stw r3, 0xc(r4); + stw r3, 0x10(r4); + stw r3, 0x14(r4); + stw r3, 0x18(r4); + stw r3, 0x1c(r4); + stw r3, 0x20(r4); + stw r3, 0x24(r4); + addi r4, r4, 0x28; + bdnz lbl_80126b70; + addi r3, r31, 0x40; + li r4, 0x5a0; + bl DCFlushRange; + bl __AXOutInitDSP; + lis r3, 0x8012; + addi r3, r3, 0x6898; + bl AIRegisterDMACallback; + lwz r0, __AXOutputBufferMode; + addi r8, r31, 0x40; + li r4, 0x12; + li r3, 0xb4; + addi r7, r8, 0x168; + addi r6, r8, 0x2d0; + addi r5, r8, 0x438; + cmplwi r0, 1; + stw r8, 8(r1); + stw r7, 0xc(r1); + stw r6, 0x10(r1); + stw r5, 0x14(r1); + stw r4, __AXRmtCpuPtr; + stw r4, __AXRmtDspPtr; + stw r3, __AXRmtBuffLen; + bne lbl_80126c14; + addi r4, r31, 0x8e0; + addi r3, r31, 0x5e0; + addi r4, r4, 0x300; + addi r5, r1, 8; + bl __AXNextFrame; + b lbl_80126c28; +lbl_80126c14: + addi r4, r31, 0x8e0; + addi r3, r31, 0x5e0; + addi r4, r4, 0x180; + addi r5, r1, 8; + bl __AXNextFrame; +lbl_80126c28: + lwz r0, __AXOutputBufferMode; + li r4, 1; + li r3, 0; + stw r4, __AXOutDspReady; + cmplwi r0, 1; + stw r3, __AXUserFrameCallback; + bne lbl_80126c6c; + lwz r3, __AXAiDmaFrame; + addi r0, r31, 0x8e0; + li r4, 0x180; + mulli r3, r3, 0x180; + add r3, r0, r3; + bl AIInitDMA; + lwz r3, __AXAiDmaFrame; + addi r0, r3, 1; + stw r0, __AXAiDmaFrame; + b lbl_80126c84; +lbl_80126c6c: + lwz r3, __AXOutFrame; + addi r0, r31, 0x8e0; + li r4, 0x180; + mulli r3, r3, 0x180; + add r3, r0, r3; + bl AIInitDMA; +lbl_80126c84: + bl AIStartDMA; + li r0, 0; + stw r0, __AXExceedCallback; + lwz r31, 0x1c(r1); + lwz r0, 0x24(r1); + mtlr r0; + addi r1, r1, 0x20; + blr; + // clang-format on +} + +// Symbol: AXRegisterCallback +// Function signature is unknown. +// PAL: 0x80126ca4..0x80126ce8 +MARK_BINARY_BLOB(AXRegisterCallback, 0x80126ca4, 0x80126ce8); +asm UNKNOWN_FUNCTION(AXRegisterCallback) { + // clang-format off + nofralloc; + stwu r1, -0x10(r1); + mflr r0; + stw r0, 0x14(r1); + stw r31, 0xc(r1); + stw r30, 8(r1); + mr r30, r3; + lwz r31, __AXUserFrameCallback; + bl OSDisableInterrupts; + stw r30, __AXUserFrameCallback; + bl OSRestoreInterrupts; + mr r3, r31; + lwz r31, 0xc(r1); + lwz r30, 8(r1); + lwz r0, 0x14(r1); + mtlr r0; + addi r1, r1, 0x10; + blr; + // clang-format on +} + +// Symbol: AXRmtGetSamplesLeft +// Function signature is unknown. +// PAL: 0x80126ce8..0x80126d14 +MARK_BINARY_BLOB(AXRmtGetSamplesLeft, 0x80126ce8, 0x80126d14); +asm UNKNOWN_FUNCTION(AXRmtGetSamplesLeft) { + // clang-format off + nofralloc; + lwz r3, __AXRmtDspPtr; + addic. r3, r3, -36; + bge lbl_80126cfc; + lwz r0, __AXRmtBuffLen; + add r3, r3, r0; +lbl_80126cfc: + lwz r0, __AXRmtCpuPtr; + subf. r3, r0, r3; + bgelr; + lwz r0, __AXRmtBuffLen; + add r3, r3, r0; + blr; + // clang-format on +} + +// Symbol: AXRmtGetSamples +// Function signature is unknown. +// PAL: 0x80126d14..0x80126dd8 +MARK_BINARY_BLOB(AXRmtGetSamples, 0x80126d14, 0x80126dd8); +asm UNKNOWN_FUNCTION(AXRmtGetSamples) { + // clang-format off + nofralloc; + stwu r1, -0x10(r1); + mflr r0; + stw r0, 0x14(r1); + stw r31, 0xc(r1); + lwz r6, __AXRmtDspPtr; + addic. r31, r6, -36; + bge lbl_80126d38; + lwz r0, __AXRmtBuffLen; + add r31, r31, r0; +lbl_80126d38: + lwz r0, __AXRmtCpuPtr; + subf. r31, r0, r31; + bge lbl_80126d4c; + lwz r0, __AXRmtBuffLen; + add r31, r31, r0; +lbl_80126d4c: + cmpw r5, r31; + ble lbl_80126d58; + b lbl_80126d5c; +lbl_80126d58: + mr r31, r5; +lbl_80126d5c: + mulli r0, r3, 0x168; + lis r5, __AXRmtOutBuffer@ha; + lwz r7, __AXRmtCpuPtr; + la r5, __AXRmtOutBuffer@l(r5); + add r5, r5, r0; + mtctr r31; + cmpwi r31, 0; + ble lbl_80126da4; +lbl_80126d7c: + slwi r6, r7, 1; + addi r7, r7, 1; + lhax r0, r6, r5; + sth r0, 0(r4); + addi r4, r4, 2; + lwz r0, __AXRmtBuffLen; + cmpw r7, r0; + blt lbl_80126da0; + li r7, 0; +lbl_80126da0: + bdnz lbl_80126d7c; +lbl_80126da4: + mulli r5, r3, 0x168; + lwz r0, __AXRmtBuffLen; + lis r3, 0x802f; + slwi r4, r0, 1; + addi r3, r3, 0x7480; + add r3, r3, r5; + bl DCInvalidateRange; + mr r3, r31; + lwz r31, 0xc(r1); + lwz r0, 0x14(r1); + mtlr r0; + addi r1, r1, 0x10; + blr; + // clang-format on +} + +// Symbol: AXRmtAdvancePtr +// Function signature is unknown. +// PAL: 0x80126dd8..0x80126e30 +MARK_BINARY_BLOB(AXRmtAdvancePtr, 0x80126dd8, 0x80126e30); +asm UNKNOWN_FUNCTION(AXRmtAdvancePtr) { + // clang-format off + nofralloc; + lwz r4, __AXRmtDspPtr; + addic. r4, r4, -36; + bge lbl_80126dec; + lwz r0, __AXRmtBuffLen; + add r4, r4, r0; +lbl_80126dec: + lwz r0, __AXRmtCpuPtr; + subf. r4, r0, r4; + bge lbl_80126e00; + lwz r0, __AXRmtBuffLen; + add r4, r4, r0; +lbl_80126e00: + cmpw r3, r4; + ble lbl_80126e0c; + mr r3, r4; +lbl_80126e0c: + lwz r0, __AXRmtCpuPtr; + lwz r4, __AXRmtBuffLen; + add r0, r0, r3; + cmpw r0, r4; + stw r0, __AXRmtCpuPtr; + bltlr; + subf r0, r4, r0; + stw r0, __AXRmtCpuPtr; + blr; + // clang-format on +} diff --git a/source/rvl/ax/rvlAxOut.h b/source/rvl/ax/rvlAxOut.h new file mode 100644 index 000000000..03c22427f --- /dev/null +++ b/source/rvl/ax/rvlAxOut.h @@ -0,0 +1,38 @@ +#pragma once + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// PAL: 0x80126638..0x80126898 +UNKNOWN_FUNCTION(__AXOutNewFrame); +// PAL: 0x80126898..0x80126948 +UNKNOWN_FUNCTION(__AXOutAiCallback); +// PAL: 0x80126948..0x80126954 +UNKNOWN_FUNCTION(__AXDSPInitCallback); +// PAL: 0x80126954..0x801269a8 +UNKNOWN_FUNCTION(__AXDSPResumeCallback); +// PAL: 0x801269a8..0x801269b8 +UNKNOWN_FUNCTION(__AXDSPDoneCallback); +// PAL: 0x801269b8..0x801269bc +UNKNOWN_FUNCTION(__AXDSPRequestCallback); +// PAL: 0x801269bc..0x80126aac +UNKNOWN_FUNCTION(__AXOutInitDSP); +// PAL: 0x80126aac..0x80126ca4 +UNKNOWN_FUNCTION(__AXOutInit); +// PAL: 0x80126ca4..0x80126ce8 +UNKNOWN_FUNCTION(AXRegisterCallback); +// PAL: 0x80126ce8..0x80126d14 +UNKNOWN_FUNCTION(AXRmtGetSamplesLeft); +// PAL: 0x80126d14..0x80126dd8 +UNKNOWN_FUNCTION(AXRmtGetSamples); +// PAL: 0x80126dd8..0x80126e30 +UNKNOWN_FUNCTION(AXRmtAdvancePtr); + +#ifdef __cplusplus +} +#endif diff --git a/sources.py b/sources.py index 8b512b994..d57f5a316 100644 --- a/sources.py +++ b/sources.py @@ -62,6 +62,7 @@ class Source: Source(src="source/rvl/ax/rvlAxAux.c", cc='4199_60831', opts=RVL_OPTS), Source(src="source/rvl/ax/rvlAxCl.c", cc='4199_60831', opts=RVL_OPTS), Source(src="source/rvl/ax/rvlAxComp.c", cc='4199_60831', opts=RVL_OPTS), + Source(src="source/rvl/ax/rvlAxOut.c", cc='4199_60831', opts=RVL_OPTS), ] SOURCES_RVL_BASE = [ Source(src="source/rvl/base/ppcArch.c", cc='4199_60831', opts=RVL_OPTS),