diff --git a/config/disasm_overrides.yml b/config/disasm_overrides.yml index a8a46532..e5db3a93 100644 --- a/config/disasm_overrides.yml +++ b/config/disasm_overrides.yml @@ -11,7 +11,7 @@ symbol_aligns: 0x80026400: 32 0x80031d80: 32 0x8001ada0: 32 - 0x8002cd20: 32 + 0x8002cfe0: 32 0x8018f1a8: 8 0x80207458: 8 # align RunQueue to 0x001251d8 0x800b9140: 32 # align gam_win_moji1_tex to 32 bytes diff --git a/config/dol_slices.yml b/config/dol_slices.yml index d889bc92..7a23d418 100644 --- a/config/dol_slices.yml +++ b/config/dol_slices.yml @@ -121,6 +121,9 @@ jaudio_NES/internal/dspboot.c: .rodata: [0x800aa780, 0x800aa7a0] .data: [0x800d3b00, 0x800d5500] .sdata2: [0x80218f08, 0x80218f10] +jaudio_NES/internal/dspproc.c: + .text: [0x8002cd20, 0x8002cfe0] + .sdata: [0x80217c18, 0x80217c20] jaudio_NES/internal/random.c: .text: [0x80031ce0, 0x80031d80] .sdata: [0x80217c38, 0x80217c40] diff --git a/src/static/jaudio_NES/internal/dspproc.c b/src/static/jaudio_NES/internal/dspproc.c new file mode 100644 index 00000000..8f97c5ed --- /dev/null +++ b/src/static/jaudio_NES/internal/dspproc.c @@ -0,0 +1,92 @@ +#include "jaudio_NES/dspproc.h" +#include "dolphin/dsp.h" + +static u16 DSP_MIXERLEVEL = 0x4000; + +extern s32 DSPSendCommands(u32* commands, u32 count) { + if (DSPCheckMailToDSP() != 0) { + return -1; + } + if (DSPCheckMailFromDSP() != 0) { + return -1; + } + + int i; + + for (i = 0; i < count; i++) { + DSPSendMailToDSP(commands[i]); + + while (DSPCheckMailToDSP() != 0); + } + + return 0; +} + +extern u32 DSPReleaseHalt() { + while (DSPCheckMailToDSP() != 0); + DSPSendMailToDSP(0); + if (DSPCheckMailFromDSP() != 0) { + DSPReadMailFromDSP(); + } + + return 0x88881357; +} + +extern void DSPWaitFinish() { + do { + while (DSPCheckMailFromDSP() == 0); + } while ((DSPReadMailFromDSP() + 0x77780000) == 0x1357); +} + +extern void DsetupTable(u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4) { + u32 commands[5]; + + commands[0] = (arg0 & 0xFFFF) | 0x81000000; + commands[1] = arg1; + commands[2] = arg2; + commands[3] = arg3; + commands[4] = arg4; + + DSPSendCommands(commands, ARRAY_COUNT(commands)); + DSPWaitFinish(); +} + +extern void DsyncFrame(u32 subframes, u32 dspbuf_start, u32 dspbuf_end){ + u32 commands[3]; + + commands[0] = (subframes << 16 & 0xFF0000) | 0x82000000 | DSP_MIXERLEVEL; + commands[1] = dspbuf_start; + commands[2] = dspbuf_end; + + DSPSendCommands(commands, ARRAY_COUNT(commands)); + DSPWaitFinish(); +} + +extern void DwaitFrame(){ + u32 commands[1]; + + commands[0] = 0x80000000; + DSPSendCommands(commands, ARRAY_COUNT(commands)); + DSPWaitFinish(); +} + +extern void DiplSec(u32 arg0){ + u32 commands[2]; + + commands[0] = 0x8B000008; + commands[1] = arg0; + DSPSendCommands(commands, ARRAY_COUNT(commands)); + DSPWaitFinish(); +} + +extern void DagbSec(u32 arg0){ + u32 commands[2]; + + commands[0] = 0x8C000008; + commands[1] = arg0; + DSPSendCommands(commands, ARRAY_COUNT(commands)); + DSPWaitFinish(); +} + + +