mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-01-23 13:35:11 +03:00
In my nightmares, I see audio_synthesis (#146)
* heapsort * suff * load init * split * split data * begone asm * names * names and cleanup * let's try this * woo macros * general * bgm macro * names * audio_thread * Update Torch * I think it's time to move on * Merge remote-tracking branch 'upstream/master' into play --------- Co-authored-by: Alejandro Javier Asenjo Nitti <alejandro.asenjo88@gmail.com>
This commit is contained in:
parent
f23e2efc05
commit
7e99fe712d
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
@ -66,7 +66,20 @@
|
||||
"i5.h": "c",
|
||||
"ast_warp_zone.h": "c",
|
||||
"sf64audio_provisional.h": "c",
|
||||
"fox_enmy_assets.h": "c"
|
||||
"fox_enmy_assets.h": "c",
|
||||
"audiothread_cmd.h": "c",
|
||||
"span": "c",
|
||||
"string_span": "c",
|
||||
"array": "c",
|
||||
"bitset": "c",
|
||||
"string_view": "c",
|
||||
"initializer_list": "c",
|
||||
"regex": "c",
|
||||
"utility": "c",
|
||||
"valarray": "c",
|
||||
"util": "c",
|
||||
"variant": "c",
|
||||
"chrono": "c"
|
||||
},
|
||||
"C_Cpp_Runner.msvcBatchPath": ""
|
||||
}
|
2
Makefile
2
Makefile
@ -262,7 +262,7 @@ build/src/main/audio_playback.o: OPTFLAGS := -O2 -g0
|
||||
build/src/main/audio_load.o: OPTFLAGS := -O2 -g0
|
||||
build/src/main/audio_general.o: OPTFLAGS := -O2 -g0
|
||||
build/src/main/audio_heap.o: OPTFLAGS := -O2 -g0
|
||||
build/src/main/audio_thread.o: OPTFLAGS := -O1 -g0
|
||||
build/src/main/audio_thread.o: OPTFLAGS := -O2 -g0
|
||||
build/src/main/sys_sprintf.o: OPTFLAGS := -O2 -g0
|
||||
build/src/main/sys_math64.o: OPTFLAGS := -O2 -g0
|
||||
|
||||
|
415
include/PR/abi.h
415
include/PR/abi.h
@ -1,58 +1,39 @@
|
||||
#ifndef _ABI_H_
|
||||
#define _ABI_H_
|
||||
|
||||
/**************************************************************************
|
||||
* *
|
||||
* Copyright (C) 1994, Silicon Graphics, Inc. *
|
||||
* *
|
||||
* These coded instructions, statements, and computer programs contain *
|
||||
* unpublished proprietary information of Silicon Graphics, Inc., and *
|
||||
* are protected by Federal copyright law. They may not be disclosed *
|
||||
* to third parties or copied or duplicated in any form, in whole or *
|
||||
* in part, without the prior written consent of Silicon Graphics, Inc. *
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* $Revision: 1.32 $
|
||||
* $Date: 1997/02/11 08:16:37 $
|
||||
* $Source: /disk6/Master/cvsmdev2/PR/include/abi.h,v $
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Header file for the Audio Binary Interface.
|
||||
* This is included in the Media Binary Interface file
|
||||
* mbi.h.
|
||||
*
|
||||
* This file follows the framework used for graphics.
|
||||
*
|
||||
*/
|
||||
#ifndef ULTRA64_ABI_H
|
||||
#define ULTRA64_ABI_H
|
||||
|
||||
/* Audio commands: */
|
||||
#define A_SPNOOP 0
|
||||
#define A_ADPCM 1
|
||||
#define A_CLEARBUFF 2
|
||||
#define A_ENVMIXER 3
|
||||
#define A_LOADBUFF 4
|
||||
#define A_UNK3 3
|
||||
#define A_ADDMIXER 4
|
||||
#define A_RESAMPLE 5
|
||||
#define A_SAVEBUFF 6
|
||||
#define A_SEGMENT 7
|
||||
#define A_RESAMPLE_ZOH 6
|
||||
#define A_FILTER 7
|
||||
#define A_SETBUFF 8
|
||||
#define A_SETVOL 9
|
||||
// #define A_DUPLICATE 9
|
||||
#define A_DMEMMOVE 10
|
||||
#define A_LOADADPCM 11
|
||||
#define A_MIXER 12
|
||||
#define A_INTERLEAVE 13
|
||||
#define A_POLEF 14
|
||||
// #define A_HILOGAIN 14
|
||||
#define A_SETLOOP 15
|
||||
#define A_INTERL 17
|
||||
#define A_ENVSETUP1 18
|
||||
#define A_ENVMIXER 19
|
||||
#define A_LOADBUFF 20
|
||||
#define A_SAVEBUFF 21
|
||||
#define A_ENVSETUP2 22
|
||||
#define A_S8DEC 23
|
||||
#define A_HILOGAIN 24
|
||||
#define A_UNK19 25
|
||||
#define A_DUPLICATE 26
|
||||
|
||||
#define ACMD_SIZE 32
|
||||
|
||||
/*
|
||||
* Audio flags
|
||||
*/
|
||||
|
||||
#define A_INIT 0x01
|
||||
#define A_CONTINUE 0x00
|
||||
#define A_LOOP 0x02
|
||||
@ -66,144 +47,139 @@
|
||||
#define A_MAIN 0x00
|
||||
#define A_MIX 0x10
|
||||
|
||||
/*
|
||||
* BEGIN C-specific section: (typedef's)
|
||||
*/
|
||||
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
|
||||
|
||||
/*
|
||||
* Data Structures.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int gain:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 gain : 16;
|
||||
u32 addr;
|
||||
} Aadpcm;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int gain:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 gain : 16;
|
||||
u32 addr;
|
||||
} Apolef;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int pad1:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 pad1 : 16;
|
||||
u32 addr;
|
||||
} Aenvelope;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:8;
|
||||
unsigned int dmem:16;
|
||||
unsigned int pad2:16;
|
||||
unsigned int count:16;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 8;
|
||||
u32 dmem : 16;
|
||||
u32 pad2 : 16;
|
||||
u32 count : 16;
|
||||
} Aclearbuff;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:8;
|
||||
unsigned int pad2:16;
|
||||
unsigned int inL:16;
|
||||
unsigned int inR:16;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 8;
|
||||
u32 pad2 : 16;
|
||||
u32 inL : 16;
|
||||
u32 inR : 16;
|
||||
} Ainterleave;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:24;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 24;
|
||||
u32 addr;
|
||||
} Aloadbuff;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int pad1:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 pad1 : 16;
|
||||
u32 addr;
|
||||
} Aenvmixer;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int gain:16;
|
||||
unsigned int dmemi:16;
|
||||
unsigned int dmemo:16;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 gain : 16;
|
||||
u32 dmemi : 16;
|
||||
u32 dmemo : 16;
|
||||
} Amixer;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int dmem2:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 dmem2 : 16;
|
||||
u32 addr;
|
||||
} Apan;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int pitch:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 pitch : 16;
|
||||
u32 addr;
|
||||
} Aresample;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int pad1:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 pad1 : 16;
|
||||
u32 addr;
|
||||
} Areverb;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:24;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 24;
|
||||
u32 addr;
|
||||
} Asavebuff;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:24;
|
||||
unsigned int pad2:2;
|
||||
unsigned int number:4;
|
||||
unsigned int base:24;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 24;
|
||||
u32 pad2 : 2;
|
||||
u32 number : 4;
|
||||
u32 base : 24;
|
||||
} Asegment;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int dmemin:16;
|
||||
unsigned int dmemout:16;
|
||||
unsigned int count:16;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 dmemin : 16;
|
||||
u32 dmemout : 16;
|
||||
u32 count : 16;
|
||||
} Asetbuff;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int flags:8;
|
||||
unsigned int vol:16;
|
||||
unsigned int voltgt:16;
|
||||
unsigned int volrate:16;
|
||||
u32 cmd : 8;
|
||||
u32 flags : 8;
|
||||
u32 vol : 16;
|
||||
u32 voltgt : 16;
|
||||
u32 volrate : 16;
|
||||
} Asetvol;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:8;
|
||||
unsigned int dmemin:16;
|
||||
unsigned int dmemout:16;
|
||||
unsigned int count:16;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 8;
|
||||
u32 dmemin : 16;
|
||||
u32 dmemout : 16;
|
||||
u32 count : 16;
|
||||
} Admemmove;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:8;
|
||||
unsigned int count:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 8;
|
||||
u32 count : 16;
|
||||
u32 addr;
|
||||
} Aloadadpcm;
|
||||
|
||||
typedef struct {
|
||||
unsigned int cmd:8;
|
||||
unsigned int pad1:8;
|
||||
unsigned int pad2:16;
|
||||
unsigned int addr;
|
||||
u32 cmd : 8;
|
||||
u32 pad1 : 8;
|
||||
u32 pad2 : 16;
|
||||
u32 addr;
|
||||
} Asetloop;
|
||||
|
||||
/*
|
||||
@ -211,8 +187,8 @@ typedef struct {
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned int w0;
|
||||
unsigned int w1;
|
||||
u32 w0;
|
||||
u32 w1;
|
||||
} Awords;
|
||||
|
||||
typedef union {
|
||||
@ -274,7 +250,7 @@ typedef short ENVMIX_STATE[40];
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \
|
||||
_a->words.w1 = (unsigned int)(s); \
|
||||
_a->words.w1 = (u32)(s); \
|
||||
}
|
||||
|
||||
#define aPoleFilter(pkt, f, g, s) \
|
||||
@ -283,48 +259,109 @@ typedef short ENVMIX_STATE[40];
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \
|
||||
_SHIFTL(g, 0, 16)); \
|
||||
_a->words.w1 = (unsigned int)(s); \
|
||||
_a->words.w1 = (u32)(s); \
|
||||
}
|
||||
|
||||
#define aClearBuffer(pkt, d, c) \
|
||||
#define aHiLoGain(pkt, gain, count, dmem, a4) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \
|
||||
_a->words.w1 = (unsigned int)(c); \
|
||||
_a->words.w0 = (_SHIFTL(A_HILOGAIN, 24, 8) | \
|
||||
_SHIFTL(gain, 16, 8) | _SHIFTL(count, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(dmem, 16, 16) | _SHIFTL(a4, 0, 16); \
|
||||
}
|
||||
|
||||
#define aEnvMixer(pkt, f, s) \
|
||||
#define aUnkCmd3(pkt, a1, a2, a3) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \
|
||||
_a->words.w1 = (unsigned int)(s); \
|
||||
_a->words.w0 = _SHIFTL(A_UNK3, 24, 8) | _SHIFTL(a3, 0, 16); \
|
||||
_a->words.w1 = _SHIFTL(a1, 16, 16) | _SHIFTL(a2, 0, 16); \
|
||||
}
|
||||
|
||||
#define aInterleave(pkt, l, r) \
|
||||
#define aUnkCmd19(pkt, a1, a2, a3, a4) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \
|
||||
_a->words.w0 = (_SHIFTL(A_UNK19, 24, 8) | _SHIFTL(a1, 16, 8) | \
|
||||
_SHIFTL(a2, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(a3, 16, 16) | _SHIFTL(a4, 0, 16); \
|
||||
}
|
||||
|
||||
#define aS8Dec(pkt, a1, a2) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_S8DEC, 24, 8) | _SHIFTL(a1, 16, 8); \
|
||||
_a->words.w1 = (u32)(a2); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears DMEM by writing zeros.
|
||||
*
|
||||
* @param pkt pointer to an Acmd buffer
|
||||
* @param dmem DMEM address to clear
|
||||
* @param size number of bytes to clear (rounded up to the next multiple of 16)
|
||||
*/
|
||||
#define aClearBuffer(pkt, dmem, size) \
|
||||
{ \
|
||||
Acmd* _a = (Acmd*)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(dmem, 0, 24); \
|
||||
_a->words.w1 = (uintptr_t)(size); \
|
||||
}
|
||||
|
||||
#define aEnvMixer(pkt, dmemi, count, swapLR, x0, x1, x2, x3, m) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(dmemi >> 4, 16, 8) | \
|
||||
_SHIFTL(count, 8, 8) | _SHIFTL(swapLR, 4, 1) | \
|
||||
_SHIFTL(x0, 3, 1) | _SHIFTL(x1, 2, 1) | \
|
||||
_SHIFTL(x2, 1, 1) | _SHIFTL(x3, 0, 1)); \
|
||||
_a->words.w1 = (u32)(m); \
|
||||
}
|
||||
|
||||
#define aInterleave(pkt, o, l, r, c) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_INTERLEAVE, 24, 8) | \
|
||||
_SHIFTL(c >> 4, 16, 8) | _SHIFTL(o, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \
|
||||
}
|
||||
|
||||
#define aLoadBuffer(pkt, s) \
|
||||
#define aInterl(pkt, dmemi, dmemo, count) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
Acmd *_a = (Acmd*)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \
|
||||
_a->words.w1 = (unsigned int)(s); \
|
||||
_a->words.w0 = (_SHIFTL(A_INTERL, 24, 8) | _SHIFTL(count, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads a buffer to DMEM from any physical source address, KSEG0, or KSEG1
|
||||
*
|
||||
* @param pkt pointer to an Acmd buffer
|
||||
* @param addrSrc Any physical source address, KSEG0, or KSEG1
|
||||
* @param dmemDest DMEM destination address
|
||||
* @param size number of bytes to copy (rounded down to the next multiple of 16)
|
||||
*/
|
||||
#define aLoadBuffer(pkt, addrSrc, dmemDest, size) \
|
||||
{ \
|
||||
Acmd* _a = (Acmd*)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemDest, 0, 16)); \
|
||||
_a->words.w1 = (uintptr_t)(addrSrc); \
|
||||
}
|
||||
|
||||
#define aMix(pkt, f, g, i, o) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \
|
||||
_SHIFTL(g, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(i,16, 16) | _SHIFTL(o, 0, 16); \
|
||||
_a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \
|
||||
}
|
||||
|
||||
#define aPan(pkt, f, d, s) \
|
||||
@ -333,25 +370,33 @@ typedef short ENVMIX_STATE[40];
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \
|
||||
_SHIFTL(d, 0, 16)); \
|
||||
_a->words.w1 = (unsigned int)(s); \
|
||||
_a->words.w1 = (u32)(s); \
|
||||
}
|
||||
|
||||
#define aResample(pkt, f, p, s) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) |\
|
||||
_SHIFTL(p, 0, 16)); \
|
||||
_a->words.w1 = (unsigned int)(s); \
|
||||
_a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | \
|
||||
_SHIFTL(f, 16, 8) | _SHIFTL(p, 0, 16)); \
|
||||
_a->words.w1 = (u32)(s); \
|
||||
}
|
||||
|
||||
#define aSaveBuffer(pkt, s) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
/*
|
||||
* Stores a buffer from DMEM to any physical source address, KSEG0, or KSEG1
|
||||
*
|
||||
* @param pkt pointer to an Acmd buffer
|
||||
* @param dmemSrc DMEM source address
|
||||
* @param addrDest Any physical source address, KSEG0, or KSEG1
|
||||
* @param size number of bytes to copy (rounded down to the next multiple of 16)
|
||||
*/
|
||||
#define aSaveBuffer(pkt, dmemSrc, addrDest, size) \
|
||||
{ \
|
||||
Acmd* _a = (Acmd*)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \
|
||||
_a->words.w1 = (unsigned int)(s); \
|
||||
}
|
||||
_a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \
|
||||
_a->words.w1 = (uintptr_t)(addrDest); \
|
||||
}
|
||||
|
||||
#define aSegment(pkt, s, b) \
|
||||
{ \
|
||||
@ -376,14 +421,24 @@ typedef short ENVMIX_STATE[40];
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \
|
||||
_SHIFTL(v, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \
|
||||
_a->words.w1 = _SHIFTL(r, 0, 16) | _SHIFTL(t, 16, 16); \
|
||||
}
|
||||
|
||||
#define aSetVolume32(pkt, f, v, tr) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \
|
||||
_SHIFTL(v, 0, 16)); \
|
||||
_a->words.w1 = (u32)(tr); \
|
||||
}
|
||||
|
||||
#define aSetLoop(pkt, a) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \
|
||||
_a->words.w1 = (unsigned int)(a); \
|
||||
_a->words.w1 = (u32)(a); \
|
||||
}
|
||||
|
||||
#define aDMEMMove(pkt, i, o, c) \
|
||||
@ -399,12 +454,68 @@ typedef short ENVMIX_STATE[40];
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \
|
||||
_a->words.w1 = (unsigned int) d; \
|
||||
_a->words.w1 = (u32)d; \
|
||||
}
|
||||
|
||||
#endif /* _LANGUAGE_C */
|
||||
#define aEnvSetup1(pkt, a, b, c, d) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_ENVSETUP1, 24, 8) | \
|
||||
_SHIFTL(a, 16, 8) | _SHIFTL(b, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(c, 16, 16) | _SHIFTL(d, 0, 16); \
|
||||
}
|
||||
|
||||
#endif /* !_ABI_H_ */
|
||||
#define aEnvSetup2(pkt, volLeft, volRight) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); \
|
||||
_a->words.w1 = (_SHIFTL(volLeft, 16, 16) | \
|
||||
_SHIFTL(volRight, 0, 16)); \
|
||||
}
|
||||
|
||||
#define aFilter(pkt, f, countOrBuf, addr) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_FILTER, 24, 8) | _SHIFTL(f, 16, 8) | \
|
||||
_SHIFTL(countOrBuf, 0, 16)); \
|
||||
_a->words.w1 = (u32)(addr); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Duplicates 128 bytes of data a specified number of times.
|
||||
*
|
||||
* @param pkt pointer to an Acmd buffer
|
||||
* @param numCopies number of times to duplicate 128 bytes from src
|
||||
* @param dmemSrc DMEM source address
|
||||
* @param dmemDest DMEM destination address for the duplicates, size 128 * numCopies
|
||||
*/
|
||||
#define aDuplicate(pkt, numCopies, dmemSrc, dmemDest) \
|
||||
{ \
|
||||
Acmd* _a = (Acmd*)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(numCopies, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(dmemDest, 16, 16) | _SHIFTL(0x80, 0, 16); \
|
||||
}
|
||||
|
||||
#define aAddMixer(pkt, count, dmemi, dmemo, a4) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_ADDMIXER, 24, 8) | \
|
||||
_SHIFTL(count >> 4, 16, 8) | _SHIFTL(a4, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \
|
||||
}
|
||||
|
||||
#define aResampleZoh(pkt, pitch, pitchAccu) \
|
||||
{ \
|
||||
Acmd *_a = (Acmd *)pkt; \
|
||||
\
|
||||
_a->words.w0 = (_SHIFTL(A_RESAMPLE_ZOH, 24, 8) | \
|
||||
_SHIFTL(pitch, 0, 16)); \
|
||||
_a->words.w1 = _SHIFTL(pitchAccu, 0, 16); \
|
||||
}
|
||||
|
||||
#endif /* ULTRA64_ABI_H */
|
||||
|
@ -1,11 +1,9 @@
|
||||
#ifndef AUDIOTHREAD_CMD_H
|
||||
#define AUDIOTHREAD_CMD_H
|
||||
|
||||
|
||||
void AudioThread_QueueCmd(u32, void**);
|
||||
void AudioThread_QueueCmdF32(u32, f32);
|
||||
void AudioThread_QueueCmdS32(u32, u32);
|
||||
void AudioThread_QueueCmdS8(u32, s8);
|
||||
void AudioThread_QueueCmdF32(u32 opArgs, f32 val);
|
||||
void AudioThread_QueueCmdS32(u32 opArgs, u32 val);
|
||||
void AudioThread_QueueCmdS8(u32 opArgs, s8 val);
|
||||
|
||||
/**
|
||||
* Audio thread commands to safely transfer information/requests/data
|
||||
@ -247,8 +245,8 @@ typedef enum {
|
||||
* @param ioPort the index of the array to store the input-output value
|
||||
* @param ioData (s8) the value that's written to the input-output array
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_SET_IO(seqPlayerIndex, unk, ioPort, ioData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_IO, seqPlayerIndex, unk, ioPort), ioData)
|
||||
#define AUDIOCMD_SEQPLAYER_SET_IO(seqPlayerIndex, unk, ioData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_IO, seqPlayerIndex, unk, 0), ioData)
|
||||
|
||||
/**
|
||||
* Set the tempo (bpm) of a sequence on a given seqPlayer
|
||||
@ -344,8 +342,8 @@ typedef enum {
|
||||
* @param seqId the id of the sequence to play, see `SeqId`
|
||||
* @param fadeInTimer (s32) number of ticks to fade in the sequence to the requested volume
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_INIT_SEQPLAYER(seqPlayerIndex, seqId, fadeInTimer) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER, seqPlayerIndex, seqId, 0), fadeInTimer)
|
||||
#define AUDIOCMD_GLOBAL_INIT_SEQPLAYER(seqPlayerIndex, seqId, arg2, fadeInTimer) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER, seqPlayerIndex, seqId, arg2), fadeInTimer)
|
||||
|
||||
/**
|
||||
* Disable a sequence player
|
||||
@ -456,8 +454,8 @@ typedef enum {
|
||||
* @param sampleBankId the id of the samplebank to load
|
||||
* @param retData return data from `externalLoadQueue`
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_ASYNC_LOAD_SAMPLE_BANK(sampleBankId, retData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK, sampleBankId, 0, retData), 0)
|
||||
#define AUDIOCMD_GLOBAL_ASYNC_LOAD_SAMPLE_BANK(sampleBankId, nChunks, retData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK, sampleBankId, nChunks, retData), 0)
|
||||
|
||||
/**
|
||||
* Asynchronously load a font
|
||||
@ -465,8 +463,8 @@ typedef enum {
|
||||
* @param fontId the id of the soundfont to load
|
||||
* @param retData return data from `externalLoadQueue`
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_ASYNC_LOAD_FONT(fontId, unk, retData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT, fontId, unk, retData), 0)
|
||||
#define AUDIOCMD_GLOBAL_ASYNC_LOAD_FONT(fontId, nChunks, retData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT, fontId, nChunks, retData), 0)
|
||||
|
||||
/**
|
||||
* Discard sequence fonts
|
||||
|
@ -134,8 +134,8 @@ void AudioLoad_Init(void);
|
||||
void func_80016A50(void);
|
||||
void Audio_InitSounds(void);
|
||||
void Audio_Update(void);
|
||||
SPTask* func_8001DF50(void);
|
||||
void func_8001EE00(void);
|
||||
SPTask* AudioThread_CreateTask(void);
|
||||
void AudioThread_PreNMIReset(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -262,7 +262,7 @@ typedef struct {
|
||||
/* 0x005 */ s8 unk_05;
|
||||
/* 0x006 */ u16 windowSize;
|
||||
/* 0x008 */ u16 unk_08;
|
||||
/* 0x00A */ s16 unk_0A;
|
||||
/* 0x00A */ u16 unk_0A;
|
||||
/* 0x00C */ u16 decayRatio; // determines how much reverb persists
|
||||
/* 0x00E */ u16 unk_0E;
|
||||
/* 0x010 */ s32 nextRingBufPos;
|
||||
@ -302,7 +302,7 @@ typedef struct {
|
||||
/* 0x004 */ u8 seqId;
|
||||
/* 0x005 */ u8 defaultFont;
|
||||
/* 0x006 */ u8 unk_06[1];
|
||||
/* 0x007 */ s8 playerIdx;
|
||||
/* 0x007 */ s8 unk_07[1]; // indexed like an array, but that can't be
|
||||
/* 0x008 */ u16 tempo; // seqTicks per minute
|
||||
/* 0x00A */ u16 tempoAcc; // tempo accumulation, used in a discretized algorithm to apply tempo.
|
||||
/* 0x00C */ u16 tempoChange; // Used to adjust the tempo without altering the base tempo.
|
||||
@ -318,14 +318,14 @@ typedef struct {
|
||||
/* 0x02C */ f32 fadeVolumeMod;
|
||||
/* 0x030 */ f32 appliedFadeVolume;
|
||||
// /* 0x034 */ f32 bend;
|
||||
/* 0x038 */ struct SequenceChannel* channels[16];
|
||||
/* 0x078 */ SeqScriptState scriptState;
|
||||
/* 0x094 */ u8* shortNoteVelocityTable;
|
||||
/* 0x098 */ u8* shortNoteGateTimeTable;
|
||||
/* 0x09C */ NotePool notePool;
|
||||
/* 0x0DC */ s32 skipTicks;
|
||||
/* 0x0E0 */ u32 scriptCounter;
|
||||
/* 0x0E4 */ char
|
||||
/* 0x034 */ struct SequenceChannel* channels[16];
|
||||
/* 0x074 */ SeqScriptState scriptState;
|
||||
/* 0x090 */ u8* shortNoteVelocityTable;
|
||||
/* 0x094 */ u8* shortNoteGateTimeTable;
|
||||
/* 0x098 */ NotePool notePool;
|
||||
/* 0x0D8 */ s32 skipTicks;
|
||||
/* 0x0DC */ u32 scriptCounter;
|
||||
/* 0x0E0 */ char
|
||||
padE4[0x6C]; // unused struct members for sequence/sound font dma management, according to sm64 decomp
|
||||
} SequencePlayer; // size = 0x14C
|
||||
|
||||
@ -476,14 +476,28 @@ typedef struct SequenceLayer {
|
||||
/* 0x7C */ char pad7C[4];
|
||||
} SequenceLayer; //size = 0x80
|
||||
|
||||
typedef struct UnkStruct_800097A8 {
|
||||
/* 0x00 */ s16* unk_0;
|
||||
/* 0x04 */ s32 unk_4;
|
||||
/* 0x08 */ s32 unk_8;
|
||||
/* 0x0C */ s16* unk_C;
|
||||
/* 0x10 */ char pad10[4];
|
||||
/* 0x14 */ struct SampleDma* unk_14;
|
||||
/* 0x18 */ s16 unk18;
|
||||
/* 0x1A */ char pad1A[6];
|
||||
} UnkStruct_800097A8; /* size = 0x20 */
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ s16 adpcmdecState[16];
|
||||
/* 0x020 */ s16 finalResampleState[16];
|
||||
/* 0x040 */ s16 mixEnvelopeState[32];
|
||||
/* 0x080 */ s16 unusedState[16];
|
||||
/* 0x0A0 */ s16 haasEffectDelayState[32];
|
||||
/* 0x0E0 */ s16 combFilterState[128];
|
||||
} NoteSynthesisBuffers; // size = 0x1E0
|
||||
/* 0x040 */ UnkStruct_800097A8 unk_40;
|
||||
/* 0x060 */ char pad[0x20];
|
||||
/* 0x080 */ s16 panSamplesBuffer[0x20];
|
||||
// /* 0x040 */ s16 mixEnvelopeState[32];
|
||||
// /* 0x080 */ s16 unusedState[16];
|
||||
// /* 0x0A0 */ s16 haasEffectDelayState[32];
|
||||
// /* 0x0E0 */ s16 combFilterState[128];
|
||||
} NoteSynthesisBuffers; // size = 0xC0
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 restart;
|
||||
@ -547,13 +561,19 @@ typedef struct {
|
||||
} bitField0;
|
||||
struct {
|
||||
/* 0x01 */ u8 reverbIndex : 3;
|
||||
/* 0x01 */ u8 bookOffset : 2;
|
||||
/* 0x01 */ u8 bookOffset : 3;
|
||||
// /* 0x01 */ u8 isSyntheticWave : 1;
|
||||
/* 0x01 */ u8 isSyntheticWave : 1;
|
||||
/* 0x01 */ u8 hasTwoParts : 1;
|
||||
/* 0x01 */ u8 useHaasEffect : 1;
|
||||
} bitField1;
|
||||
/* 0x02 */ u8 pad2[0xA];
|
||||
/* 0x0C*/ s16* waveSampleAddr;
|
||||
/* 0x02 */ u8 unk_02;
|
||||
/* 0x03 */ u8 unk_03;
|
||||
/* 0x04 */ u8 unk_04;
|
||||
/* 0x05 */ u8 unk_05;
|
||||
/* 0x06 */ u16 unk_06;
|
||||
/* 0x08 */ u16 unk_08;
|
||||
/* 0x0A */ u16 unk_0A;
|
||||
/* 0x0C */ s16* waveSampleAddr;
|
||||
} NoteSubEu; // size = 0x10
|
||||
|
||||
typedef struct Note {
|
||||
@ -781,7 +801,7 @@ typedef struct {
|
||||
/* 0x10 */ AudioTableEntry entries[1]; // (dynamic size)
|
||||
} AudioTable; // size >= 0x20
|
||||
|
||||
typedef struct {
|
||||
typedef struct SampleDma {
|
||||
/* 0x00 */ u8* ramAddr;
|
||||
/* 0x04 */ u32 devAddr;
|
||||
/* 0x08 */ u16 sizeUnused;
|
||||
@ -998,6 +1018,19 @@ typedef struct {
|
||||
((bit10)<<21)|((bit11)<<20)|((bit12)<<19)|((bit13)<<18))
|
||||
|
||||
void func_80008780(f32 *, s32, f32 *);
|
||||
void func_80009A2C(s32 updateIndex, s32 noteIndex);
|
||||
void func_80009AAC(s32 updateIndex);
|
||||
Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synthState, s16* aiBuf, s32 aiBufLen, Acmd* aList, s32 updateIndex);
|
||||
Acmd* func_8000A25C(s16* aiBuf, s32 aiBufLen, Acmd* aList, s32 updateIndex);
|
||||
Acmd* func_800098DC(Acmd* aList, u16 dmem, u16 startPos, s32 size, s32 reverbIndex);
|
||||
Acmd* func_80009984(Acmd* aList, u16 dmem, u16 startPos, s32 size, s32 reverbIndex);
|
||||
Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen);
|
||||
Acmd* func_80009D78(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s16 updateIndex);
|
||||
Acmd* func_8000A128(Acmd* aList, s16 reverbIndex, s16 updateIndex);
|
||||
Acmd* func_8000B3F0(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthState, s32 numSamplesToLoad);
|
||||
Acmd* func_8000B480(Acmd* aList, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, u32 resampleFlags);
|
||||
Acmd* func_8000B51C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthState, s32 aiBufLen, u16 dmemSrc, s32 delaySide, s32 flags);
|
||||
Acmd* func_8000B98C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthState, s32 size, s32 flags, s32 delaySide);
|
||||
|
||||
void AudioHeap_ResetLoadStatus(void);
|
||||
void AudioHeap_DiscardFont(s32 fontId);
|
||||
@ -1039,12 +1072,12 @@ void* AudioLoad_DmaSampleData(u32 devAddr, u32 size, u32 arg2, u8* dmaIndexRef,
|
||||
void AudioLoad_InitSampleDmaBuffers(s32 numNotes);
|
||||
void AudioLoad_InitTable(AudioTable* table, u8* romAddr, u16 unkMediumParam);
|
||||
void* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outFontId);
|
||||
void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1);
|
||||
void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 flags);
|
||||
s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId);
|
||||
s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId);
|
||||
void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue);
|
||||
void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue);
|
||||
void* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts);
|
||||
void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 nChunks, s32 retData, OSMesgQueue* retQueue);
|
||||
void AudioLoad_AsyncLoadSeq(s32 seqId, s32 nChunks, s32 retData, OSMesgQueue* retQueue);
|
||||
u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts);
|
||||
void AudioLoad_DiscardSeqFonts(s32 seqId);
|
||||
s32 AudioLoad_DiscardFont(s32 fontId);
|
||||
void AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2);
|
||||
@ -1116,19 +1149,20 @@ void func_800132E8(void);
|
||||
|
||||
void func_800144E4(SequencePlayer*);
|
||||
void func_800145BC(AudioListItem*, AudioListItem*);
|
||||
void func_8001678C(s32);
|
||||
void func_80016804(s32);
|
||||
void func_800168BC(void);
|
||||
|
||||
|
||||
|
||||
SPTask* func_8001DF50(void);
|
||||
void func_8001E920(void);
|
||||
OSMesg func_8001ECAC(s32 *);
|
||||
void* func_8001ED14(s32 seqId, u32* outNumFonts);
|
||||
SPTask* AudioThread_CreateTask(void);
|
||||
void AudioThread_ScheduleProcessCmds(void);
|
||||
u32 AudioThread_GetAsyncLoadStatus(u32 *);
|
||||
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts);
|
||||
s32 func_8001ED34(void);
|
||||
void func_8001ED8C(OSMesg);
|
||||
void func_8001EE00(void);
|
||||
void func_8001EE3C(void);
|
||||
void AudioThread_ResetAudioHeap(s32);
|
||||
void AudioThread_PreNMIReset(void);
|
||||
void AudioThread_Init(void);
|
||||
|
||||
|
||||
|
||||
@ -1197,14 +1231,14 @@ extern u16 gSampleBankMedium;
|
||||
|
||||
|
||||
|
||||
extern s8 gThreadCmdWritePos;
|
||||
extern s8 gThreadCmdReadPos;
|
||||
// extern u8 gThreadCmdWritePos;
|
||||
// extern u8 gThreadCmdReadPos;
|
||||
extern OSMesgQueue* gAudioTaskStartQueue;
|
||||
extern OSMesgQueue* gThreadCmdProcQueue;
|
||||
extern OSMesgQueue* gAudioUnkQueue;
|
||||
extern OSMesgQueue* gAudioResetQueue;
|
||||
extern s32 gMaxAbiCmdCnt;
|
||||
extern AudioTask* gWaitingAudioTask;
|
||||
extern SPTask* gWaitingAudioTask;
|
||||
extern s32 D_800C7C70;
|
||||
extern u8 gCurCmdReadPos;
|
||||
extern u8 gThreadCmdQueueFinished;
|
||||
@ -1344,14 +1378,14 @@ extern volatile s32 gAudioTaskCountQ;
|
||||
extern s32 gCurAudioFrameDmaCount;
|
||||
extern s32 gAudioTaskIndexQ;
|
||||
extern s32 gCurAiBuffIndex;
|
||||
extern void* gAbiCmdBuffs[2];
|
||||
extern Acmd* gCurAiCmdBuffer;
|
||||
extern AudioTask* gAudioCurTask;
|
||||
extern AudioTask gAudioRspTasks[2];
|
||||
extern Acmd* gAbiCmdBuffs[2];
|
||||
extern Acmd* gCurAbiCmdBuffer;
|
||||
extern SPTask* gAudioCurTask;
|
||||
extern SPTask gAudioRspTasks[2];
|
||||
extern f32 gMaxTempoTvTypeFactors;
|
||||
extern s32 gRefreshRate;
|
||||
extern u16* gAiBuffers[3];
|
||||
extern u16 gAiBuffLengths[3];
|
||||
extern s16* gAiBuffers[3];
|
||||
extern s16 gAiBuffLengths[3];
|
||||
extern u32 gAudioRandom;
|
||||
extern UNK_TYPE D_80155D88;
|
||||
extern volatile u32 gResetTimer;
|
||||
|
@ -198,7 +198,7 @@ gCurAudioFrameDmaCount = 0x80155CAC;
|
||||
gAudioTaskIndexQ = 0x80155CB0;
|
||||
gCurAiBuffIndex = 0x80155CB4;
|
||||
gAbiCmdBuffs = 0x80155CB8;//size:0x8
|
||||
gCurAiCmdBuffer = 0x80155CC0;
|
||||
gCurAbiCmdBuffer = 0x80155CC0;
|
||||
gAudioCurTask = 0x80155CC4;
|
||||
gAudioRspTasks = 0x80155CC8;//size:0xA0
|
||||
gMaxTempoTvTypeFactors = 0x80155D68;
|
||||
@ -505,21 +505,21 @@ Audio_Update = 0x8001DECC;
|
||||
|
||||
|
||||
|
||||
func_8001DF50 = 0x8001DF50;
|
||||
func_8001E444 = 0x8001E444;
|
||||
func_8001E720 = 0x8001E720;
|
||||
func_8001E778 = 0x8001E778;
|
||||
func_8001E7C8 = 0x8001E7C8;
|
||||
AudioThread_CreateTask = 0x8001DF50;
|
||||
AudioThread_ProcessGlobalCmd = 0x8001E444;
|
||||
AudioThread_SetFadeOutTimer = 0x8001E720;
|
||||
AudioThread_SetFadeInTimer = 0x8001E778;
|
||||
AudioThread_InitQueues = 0x8001E7C8;
|
||||
AudioThread_QueueCmd = 0x8001E850;
|
||||
AudioThread_QueueCmdF32 = 0x8001E8A8;
|
||||
AudioThread_QueueCmdS32 = 0x8001E8CC;
|
||||
AudioThread_QueueCmdS8 = 0x8001E8F0;
|
||||
func_8001E920 = 0x8001E920;
|
||||
func_8001E998 = 0x8001E998;
|
||||
func_8001E9AC = 0x8001E9AC;
|
||||
func_8001ECAC = 0x8001ECAC;
|
||||
func_8001ED14 = 0x8001ED14;
|
||||
AudioThread_ScheduleProcessCmds = 0x8001E920;
|
||||
AudioThread_ResetCmdQueue = 0x8001E998;
|
||||
AudioThread_ProcessCmds = 0x8001E9AC;
|
||||
AudioThread_GetAsyncLoadStatus = 0x8001ECAC;
|
||||
AudioThread_GetFontsForSequence = 0x8001ED14;
|
||||
func_8001ED34 = 0x8001ED34;
|
||||
func_8001ED8C = 0x8001ED8C;
|
||||
func_8001EE00 = 0x8001EE00;
|
||||
func_8001EE3C = 0x8001EE3C;
|
||||
AudioThread_ResetAudioHeap = 0x8001ED8C;
|
||||
AudioThread_PreNMIReset = 0x8001EE00;
|
||||
AudioThread_Init = 0x8001EE3C;
|
||||
|
@ -90,14 +90,14 @@ volatile s32 gAudioTaskCountQ;
|
||||
s32 gCurAudioFrameDmaCount;
|
||||
s32 gAudioTaskIndexQ;
|
||||
s32 gCurAiBuffIndex;
|
||||
void* gAbiCmdBuffs[2];
|
||||
Acmd* gCurAiCmdBuffer;
|
||||
AudioTask* gAudioCurTask;
|
||||
AudioTask gAudioRspTasks[2];
|
||||
Acmd* gAbiCmdBuffs[2];
|
||||
Acmd* gCurAbiCmdBuffer;
|
||||
SPTask* gAudioCurTask;
|
||||
SPTask gAudioRspTasks[2];
|
||||
f32 gMaxTempoTvTypeFactors;
|
||||
s32 gRefreshRate;
|
||||
u16* gAiBuffers[3];
|
||||
u16 gAiBuffLengths[3];
|
||||
s16* gAiBuffers[3];
|
||||
s16 gAiBuffLengths[3];
|
||||
u32 gAudioRandom;
|
||||
UNK_TYPE D_80155D88;
|
||||
volatile u32 gResetTimer;
|
||||
|
@ -870,7 +870,7 @@ void Audio_StartSequence(u8 seqPlayId, u8 seqId, u8 seqArgs, u16 fadeInTime) {
|
||||
s32 pad;
|
||||
|
||||
if (!gStartSeqDisabled || (seqPlayId == SEQ_PLAYER_SFX)) {
|
||||
AUDIOCMD_GLOBAL_INIT_SEQPLAYER((u32) seqPlayId, (u32) seqId, fadeInTime);
|
||||
AUDIOCMD_GLOBAL_INIT_SEQPLAYER((u32) seqPlayId, (u32) seqId, 0, fadeInTime);
|
||||
gActiveSequences[seqPlayId].prevSeqId = gActiveSequences[seqPlayId].seqId = seqId | ((seqArgs) << 8);
|
||||
if (gActiveSequences[seqPlayId].mainVolume.mod != 1.0f) {
|
||||
AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE((u32) seqPlayId, gActiveSequences[seqPlayId].mainVolume.mod);
|
||||
@ -930,8 +930,8 @@ void Audio_ProcessSeqCmd(u32 seqCmd) {
|
||||
gActiveSequences[seqPlayId].isWaitingForFonts = 1;
|
||||
Audio_StopSequence(seqPlayId, 1);
|
||||
if (gActiveSequences[seqPlayId].prevSeqId != 0xFFFF) {
|
||||
tempptr = func_8001ED14(seqNumber, &sp4C);
|
||||
tempPtr2 = func_8001ED14(gActiveSequences[seqPlayId].prevSeqId & 0xFF, &sp4C);
|
||||
tempptr = AudioThread_GetFontsForSequence(seqNumber, &sp4C);
|
||||
tempPtr2 = AudioThread_GetFontsForSequence(gActiveSequences[seqPlayId].prevSeqId & 0xFF, &sp4C);
|
||||
if (tempptr[0] != tempPtr2[0]) {
|
||||
AUDIOCMD_GLOBAL_DISCARD_SEQ_FONTS(seqNumber);
|
||||
}
|
||||
@ -1061,8 +1061,8 @@ void Audio_ProcessSeqCmd(u32 seqCmd) {
|
||||
break;
|
||||
case 7:
|
||||
val = seqCmd & 0xFF;
|
||||
ioPort = ((seqCmd & 0xFF0000) >> 0x10);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(seqPlayId, ioPort, 0, val);
|
||||
ioPort = ((seqCmd & 0xFF0000) >> 0x10); // may be misnamed
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(seqPlayId, ioPort, val);
|
||||
// AudioThread_QueueCmdS8(((seqPlayId & 0xFF) << 0x10) | 0x46000000 | (temp3 << 8), temp4);
|
||||
break;
|
||||
case 8:
|
||||
@ -1127,7 +1127,7 @@ void Audio_ProcessSeqCmd(u32 seqCmd) {
|
||||
sp61 = sNewAudioSpecId;
|
||||
sNewAudioSpecId = specId;
|
||||
if (sp61 != sNewAudioSpecId) {
|
||||
func_8001ED8C((OSMesg) (u32) sNewAudioSpecId);
|
||||
AudioThread_ResetAudioHeap(sNewAudioSpecId);
|
||||
func_8001DE1C(sp61);
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
} else {
|
||||
@ -1224,17 +1224,17 @@ void Audio_UpdateActiveSequences(void) {
|
||||
s32 temp;
|
||||
u32 cmd;
|
||||
f32 fadeMod;
|
||||
s32 sp70;
|
||||
u32 sp70;
|
||||
s32 pad1;
|
||||
s32 pad2;
|
||||
|
||||
for (seqPlayId = 0; seqPlayId < 4; seqPlayId++) {
|
||||
if ((gActiveSequences[seqPlayId].isWaitingForFonts != 0)) {
|
||||
switch ((s32) func_8001ECAC(&sp70)) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
switch ((s32) AudioThread_GetAsyncLoadStatus(&sp70)) {
|
||||
case SEQ_PLAYER_BGM + 1:
|
||||
case SEQ_PLAYER_FANFARE + 1:
|
||||
case SEQ_PLAYER_SFX + 1:
|
||||
case SEQ_PLAYER_VOICE + 1:
|
||||
gActiveSequences[seqPlayId].isWaitingForFonts = 0;
|
||||
Audio_ProcessSeqCmd(gActiveSequences[seqPlayId].startSeqCmd);
|
||||
break;
|
||||
@ -1433,7 +1433,7 @@ u8 func_80018FA4(void) {
|
||||
if (D_800C5D58 == 1) {
|
||||
if (func_8001ED34() == 1) {
|
||||
D_800C5D58 = 0;
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, 0, gSfxChannelLayout);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout);
|
||||
func_8001DD40();
|
||||
}
|
||||
} else if (D_800C5D58 == 2) {
|
||||
@ -1441,7 +1441,7 @@ u8 func_80018FA4(void) {
|
||||
;
|
||||
}
|
||||
D_800C5D58 = 0;
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, 0, gSfxChannelLayout);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout);
|
||||
func_8001DD40();
|
||||
}
|
||||
}
|
||||
@ -2953,7 +2953,7 @@ void func_8001DD40(void) {
|
||||
func_80017550();
|
||||
SEQCMD_SET_SEQPLAYER_VOLUME(SEQ_PLAYER_SFX, 0, 127);
|
||||
SEQCMD_SET_SEQPLAYER_VOLUME(SEQ_PLAYER_VOICE, 0, 127);
|
||||
func_8001E920();
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
@ -2989,7 +2989,7 @@ void Audio_Update(void) {
|
||||
func_8001AF50();
|
||||
Audio_UpdateActiveSequences();
|
||||
Audio_UpdateDelayedSeqCmds();
|
||||
func_8001E920();
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
}
|
||||
gAudioFrameCounter++;
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ s32 AudioHeap_ResetStep(void) {
|
||||
}
|
||||
}
|
||||
|
||||
gResetFadeoutFramesLeft = 0x10 / sp24;
|
||||
gResetFadeoutFramesLeft = 16 / sp24;
|
||||
gResetStatus--;
|
||||
}
|
||||
break;
|
||||
|
@ -252,15 +252,15 @@ void* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outFontId) {
|
||||
return soundFontData;
|
||||
}
|
||||
|
||||
void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1) {
|
||||
void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 flags) {
|
||||
s32 pad;
|
||||
u32 fontId;
|
||||
|
||||
seqId = AudioLoad_GetLoadTableIndex(0, seqId);
|
||||
if (arg1 & 2) {
|
||||
if (flags & 2) {
|
||||
AudioLoad_SyncLoadSeqFonts(seqId, &fontId);
|
||||
}
|
||||
if (arg1 & 1) {
|
||||
if (flags & 1) {
|
||||
AudioLoad_SyncLoadSeq(seqId);
|
||||
}
|
||||
}
|
||||
@ -309,22 +309,22 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) {
|
||||
}
|
||||
}
|
||||
|
||||
void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue) {
|
||||
if (AudioLoad_AsyncLoadInner(2, AudioLoad_GetLoadTableIndex(2, sampleBankId), arg1, retData, retQueue) == NULL) {
|
||||
void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 nChunks, s32 retData, OSMesgQueue* retQueue) {
|
||||
if (AudioLoad_AsyncLoadInner(2, AudioLoad_GetLoadTableIndex(2, sampleBankId), nChunks, retData, retQueue) == NULL) {
|
||||
osSendMesg(retQueue, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue) {
|
||||
void AudioLoad_AsyncLoadSeq(s32 seqId, s32 nChunks, s32 retData, OSMesgQueue* retQueue) {
|
||||
s32 index = ((u16*) gSeqFontTable)[AudioLoad_GetLoadTableIndex(0, seqId)];
|
||||
s32 fontsLeft = gSeqFontTable[index++];
|
||||
|
||||
for (fontsLeft; fontsLeft > 0; fontsLeft--) {
|
||||
AudioLoad_AsyncLoadInner(1, AudioLoad_GetLoadTableIndex(1, gSeqFontTable[index++]), arg1, retData, retQueue);
|
||||
AudioLoad_AsyncLoadInner(1, AudioLoad_GetLoadTableIndex(1, gSeqFontTable[index++]), nChunks, retData, retQueue);
|
||||
}
|
||||
}
|
||||
|
||||
void* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
|
||||
u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
|
||||
s32 index = ((u16*) gSeqFontTable)[AudioLoad_GetLoadTableIndex(0, seqId)];
|
||||
|
||||
*outNumFonts = gSeqFontTable[index++];
|
||||
@ -838,21 +838,21 @@ void AudioLoad_Init(void) {
|
||||
*clearContext++ = 0;
|
||||
}
|
||||
switch (osTvType) {
|
||||
case 0:
|
||||
case OS_TV_PAL:
|
||||
gMaxTempoTvTypeFactors = 20.03042f;
|
||||
gRefreshRate = 0x32;
|
||||
gRefreshRate = 50;
|
||||
break;
|
||||
case 2:
|
||||
case OS_TV_MPAL:
|
||||
gMaxTempoTvTypeFactors = 16.546f;
|
||||
gRefreshRate = 0x3C;
|
||||
gRefreshRate = 60;
|
||||
break;
|
||||
default:
|
||||
case 1:
|
||||
case OS_TV_NTSC:
|
||||
gMaxTempoTvTypeFactors = 16.713f;
|
||||
gRefreshRate = 0x3C;
|
||||
gRefreshRate = 60;
|
||||
break;
|
||||
}
|
||||
func_8001EE3C();
|
||||
AudioThread_Init();
|
||||
for (i = 0; i < 3; i++) {
|
||||
gAiBuffLengths[i] = 0xA0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,12 @@
|
||||
#include "sys.h"
|
||||
#include "sf64audio_provisional.h"
|
||||
#include "audiothread_cmd.h"
|
||||
|
||||
void AudioThread_ProcessCmds(u32 msg);
|
||||
void AudioThread_SetFadeOutTimer(s32 seqPlayId, s32 fadeTime);
|
||||
void AudioThread_SetFadeInTimer(s32 seqPlayId, s32 fadeTime);
|
||||
|
||||
extern AudioTable gSampleBankTableInit;
|
||||
|
||||
OSMesgQueue sAudioTaskStartQueue;
|
||||
OSMesgQueue sThreadCmdProcQueue;
|
||||
@ -11,27 +18,230 @@ OSMesg sThreadCmdProcMsg[4];
|
||||
OSMesg sAudioUnkMsg[1];
|
||||
OSMesg sAudioResetMsg[1];
|
||||
|
||||
s8 gThreadCmdWritePos = 0;
|
||||
s8 gThreadCmdReadPos = 0;
|
||||
u8 gThreadCmdWritePos = 0;
|
||||
u8 gThreadCmdReadPos = 0;
|
||||
OSMesgQueue* gAudioTaskStartQueue = &sAudioTaskStartQueue;
|
||||
OSMesgQueue* gThreadCmdProcQueue = &sThreadCmdProcQueue;
|
||||
OSMesgQueue* gAudioUnkQueue = &sAudioUnkQueue;
|
||||
OSMesgQueue* gAudioResetQueue = &sAudioResetQueue;
|
||||
s32 gMaxAbiCmdCnt = 128;
|
||||
AudioTask* gWaitingAudioTask = NULL;
|
||||
s32 D_800C7C70 = 0;
|
||||
u8 gCurCmdReadPos = 0;
|
||||
u8 gThreadCmdQueueFinished = 0;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001DF50.s")
|
||||
static const char devstr0[] = "DAC:Lost 1 Frame.\n";
|
||||
static const char devstr1[] = "DMA: Request queue over.( %d )\n";
|
||||
static const char devstr2[] = "Spec Change Override. %d -> %d\n";
|
||||
static const char devstr3[] = "Audio:now-max tasklen is %d / %d\n";
|
||||
static const char devstr4[] = "Audio:Warning:ABI Tasklist length over (%d)\n";
|
||||
static const char devstr5[] = "BGLOAD Start %d\n";
|
||||
static const char devstr6[] = "Error: OverFlow Your Request\n";
|
||||
static const char devstr7[] = "---AudioSending (%d->%d) \n";
|
||||
static const char devstr8[] = "AudioSend: %d -> %d (%d)\n";
|
||||
static const char devstr9[] = "Continue Port\n";
|
||||
static const char devstr10[] = "%d -> %d\n";
|
||||
static const char devstr11[] = "Sync-Frame Break. (Remain %d)\n";
|
||||
static const char devstr12[] = "Undefined Port Command %d\n";
|
||||
static const char devstr13[] = "specchg conjunction error (Msg:%d Cur:%d)\n";
|
||||
static const char devstr14[] = "Error : Queue is not empty ( %x ) \n";
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001E444.s")
|
||||
SPTask* AudioThread_CreateTask(void) {
|
||||
static s32 gMaxAbiCmdCnt = 128;
|
||||
static SPTask* gWaitingAudioTask = NULL;
|
||||
u32 sp54;
|
||||
s32 sp50;
|
||||
s32 sp4C;
|
||||
s32 pad48;
|
||||
OSTask_t* task;
|
||||
u16* sp40;
|
||||
s32 pad3C;
|
||||
u32 sp38;
|
||||
u32 sp34;
|
||||
s32 pad30;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001E720.s")
|
||||
gAudioTaskCountQ++;
|
||||
if ((gAudioTaskCountQ % gAudioBufferParams.specUnk4) != 0) {
|
||||
return gWaitingAudioTask;
|
||||
}
|
||||
osSendMesg(gAudioTaskStartQueue, (OSMesg) gAudioTaskCountQ, 0);
|
||||
gAudioTaskIndexQ ^= 1;
|
||||
gCurAiBuffIndex++;
|
||||
gCurAiBuffIndex %= 3;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001E778.s")
|
||||
sp4C = (gCurAiBuffIndex + 1) % 3;
|
||||
sp54 = osAiGetLength() >> 2;
|
||||
if ((gResetTimer < 16) && (gAiBuffLengths[sp4C] != 0)) {
|
||||
osAiSetNextBuffer(gAiBuffers[sp4C], gAiBuffLengths[sp4C] * 4);
|
||||
}
|
||||
if (gCurAudioFrameDmaCount && gCurAudioFrameDmaCount) {}
|
||||
gCurAudioFrameDmaCount = 0;
|
||||
AudioLoad_DecreaseSampleDmaTtls();
|
||||
AudioLoad_ProcessLoads(gResetStatus);
|
||||
if (osRecvMesg(gAudioUnkQueue, (OSMesg) &sp38, 0) != -1) {
|
||||
if (gResetStatus == 0) {
|
||||
gResetStatus = 5;
|
||||
}
|
||||
gAudioSpecId = sp38;
|
||||
}
|
||||
if ((gResetStatus != 0) && (AudioHeap_ResetStep() == 0)) {
|
||||
if (gResetStatus == 0) {
|
||||
osSendMesg(gAudioResetQueue, (OSMesg) (s32) gAudioSpecId, 0);
|
||||
}
|
||||
gWaitingAudioTask = NULL;
|
||||
return NULL;
|
||||
}
|
||||
if (gResetTimer > 16) {
|
||||
return NULL;
|
||||
}
|
||||
if (gResetTimer != 0) {
|
||||
gResetTimer++;
|
||||
}
|
||||
gAudioCurTask = &gAudioRspTasks[gAudioTaskIndexQ];
|
||||
gCurAbiCmdBuffer = gAbiCmdBuffs[gAudioTaskIndexQ];
|
||||
sp4C = gCurAiBuffIndex;
|
||||
sp40 = gAiBuffers[sp4C];
|
||||
gAiBuffLengths[sp4C] = ((gAudioBufferParams.samplesPerFrameTarget - sp54 + 0x80) & ~0xF) + 0x10;
|
||||
|
||||
void func_8001E7C8(void) {
|
||||
if (gAiBuffLengths[sp4C] < gAudioBufferParams.minAiBufferLength) {
|
||||
gAiBuffLengths[sp4C] = gAudioBufferParams.minAiBufferLength;
|
||||
}
|
||||
if (gAiBuffLengths[sp4C] > gAudioBufferParams.maxAiBufferLength) {
|
||||
gAiBuffLengths[sp4C] = gAudioBufferParams.maxAiBufferLength;
|
||||
}
|
||||
while (osRecvMesg(gThreadCmdProcQueue, (OSMesg) &sp34, 0) != -1) {
|
||||
AudioThread_ProcessCmds(sp34);
|
||||
}
|
||||
gCurAbiCmdBuffer = func_80009B64(gCurAbiCmdBuffer, &sp50, sp40, gAiBuffLengths[sp4C]);
|
||||
gAudioRandom = osGetCount() * (gAudioRandom + gAudioTaskCountQ);
|
||||
gAudioRandom = gAiBuffers[sp4C][gAudioTaskCountQ & 0xFF] + gAudioRandom;
|
||||
|
||||
sp4C = gAudioTaskIndexQ;
|
||||
|
||||
gAudioCurTask->msgQueue = NULL;
|
||||
gAudioCurTask->msg = NULL;
|
||||
|
||||
task = &gAudioCurTask->task.t;
|
||||
|
||||
task->type = 2;
|
||||
task->flags = 0;
|
||||
task->ucode_boot = rspbootTextStart;
|
||||
task->ucode_boot_size = (uintptr_t) rspbootTextEnd - (uintptr_t) rspbootTextStart;
|
||||
|
||||
task->ucode = aspMainTextStart;
|
||||
task->ucode_data = aspMainDataStart;
|
||||
task->ucode_size = SP_UCODE_SIZE;
|
||||
task->ucode_data_size = (aspMainDataEnd - aspMainDataStart) * 8;
|
||||
|
||||
task->dram_stack = NULL;
|
||||
task->dram_stack_size = 0;
|
||||
|
||||
task->output_buff = NULL;
|
||||
task->output_buff_size = NULL;
|
||||
if (1) {}
|
||||
task->data_ptr = (u64*) gAbiCmdBuffs[sp4C];
|
||||
task->data_size = sp50 * sizeof(Acmd);
|
||||
|
||||
task->yield_data_ptr = NULL;
|
||||
task->yield_data_size = 0;
|
||||
|
||||
if (gMaxAbiCmdCnt < sp50) {
|
||||
gMaxAbiCmdCnt = sp50;
|
||||
}
|
||||
|
||||
if (gAudioBufferParams.specUnk4 == 1) {
|
||||
return gAudioCurTask;
|
||||
} else {
|
||||
gWaitingAudioTask = gAudioCurTask;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) {
|
||||
s32 i;
|
||||
|
||||
switch (cmd->op) {
|
||||
case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS:
|
||||
AudioLoad_SyncLoadSeqParts(cmd->arg1, 3);
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER:
|
||||
case 0x88:
|
||||
AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2);
|
||||
AudioThread_SetFadeInTimer(cmd->arg0, cmd->data);
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER:
|
||||
if (gSeqPlayers[cmd->arg0].enabled) {
|
||||
if (cmd->asInt == 0) {
|
||||
func_800144E4(&gSeqPlayers[cmd->arg0]);
|
||||
} else {
|
||||
AudioThread_SetFadeOutTimer(cmd->arg0, cmd->asInt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x84:
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE:
|
||||
gAudioSoundMode = cmd->asUInt;
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_MUTE:
|
||||
for (i = 0; i < 4; i++) {
|
||||
SequencePlayer* seqplayer = &gSeqPlayers[i];
|
||||
|
||||
seqplayer->muted = true;
|
||||
seqplayer->recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_UNMUTE:
|
||||
if (cmd->asUInt == 1) {
|
||||
for (i = 0; i < gNumNotes; i++) {
|
||||
Note* note = &gNotes[i];
|
||||
NoteSubEu* noteSub = ¬e->noteSubEu;
|
||||
|
||||
if ((noteSub->bitField0.enabled) && (note->playbackState.unk_04 == 0) &&
|
||||
(note->playbackState.parentLayer != NO_LAYER) &&
|
||||
(note->playbackState.parentLayer->channel->muteBehavior & 8)) {
|
||||
noteSub->bitField0.finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
SequencePlayer* seqplayer = &gSeqPlayers[i];
|
||||
|
||||
seqplayer->muted = false;
|
||||
seqplayer->recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT:
|
||||
AudioLoad_SyncLoadInstrument(cmd->arg0, cmd->arg1, cmd->arg2);
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK:
|
||||
AudioLoad_AsyncLoadSampleBank(cmd->arg0, cmd->arg1, cmd->arg2, &gExternalLoadQueue);
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT:
|
||||
AudioLoad_AsyncLoadSeq(cmd->arg0, cmd->arg1, cmd->arg2, &gExternalLoadQueue);
|
||||
break;
|
||||
case AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS:
|
||||
AudioLoad_DiscardSeqFonts(cmd->arg1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_SetFadeOutTimer(s32 seqPlayId, s32 fadeTime) {
|
||||
if (fadeTime == 0) {
|
||||
fadeTime = 1;
|
||||
}
|
||||
|
||||
gSeqPlayers[seqPlayId].state = 2;
|
||||
gSeqPlayers[seqPlayId].fadeTimer = fadeTime;
|
||||
gSeqPlayers[seqPlayId].fadeVelocity = -(gSeqPlayers[seqPlayId].fadeVolume / fadeTime);
|
||||
}
|
||||
|
||||
void AudioThread_SetFadeInTimer(s32 seqPlayId, s32 fadeTime) {
|
||||
if (fadeTime != 0) {
|
||||
gSeqPlayers[seqPlayId].state = 1;
|
||||
gSeqPlayers[seqPlayId].fadeTimerUnkEu = fadeTime;
|
||||
gSeqPlayers[seqPlayId].fadeTimer = fadeTime;
|
||||
gSeqPlayers[seqPlayId].fadeVolume = 0.0f;
|
||||
gSeqPlayers[seqPlayId].fadeVelocity = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_InitQueues(void) {
|
||||
gThreadCmdWritePos = 0;
|
||||
gThreadCmdReadPos = 0;
|
||||
osCreateMesgQueue(gAudioTaskStartQueue, sAudioTaskStartMsg, 1);
|
||||
@ -40,30 +250,187 @@ void func_8001E7C8(void) {
|
||||
osCreateMesgQueue(gAudioResetQueue, sAudioResetMsg, 1);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/AudioThread_QueueCmd.s")
|
||||
void AudioThread_QueueCmd(u32 opArgs, void** data) {
|
||||
AudioCmd* audioCmd = &gThreadCmdBuffer[gThreadCmdWritePos & 0xFF];
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/AudioThread_QueueCmdF32.s")
|
||||
audioCmd->opArgs = opArgs;
|
||||
audioCmd->data = *data;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/AudioThread_QueueCmdS32.s")
|
||||
gThreadCmdWritePos++;
|
||||
if (gThreadCmdWritePos == gThreadCmdReadPos) {
|
||||
gThreadCmdWritePos--;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/AudioThread_QueueCmdS8.s")
|
||||
void AudioThread_QueueCmdF32(u32 opArgs, f32 val) {
|
||||
AudioThread_QueueCmd(opArgs, (void**) &val);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001E920.s")
|
||||
void AudioThread_QueueCmdS32(u32 opArgs, u32 val) {
|
||||
AudioThread_QueueCmd(opArgs, (void**) &val);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001E998.s")
|
||||
void AudioThread_QueueCmdS8(u32 opArgs, s8 val) {
|
||||
s32 data = val << 0x18;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001E9AC.s")
|
||||
AudioThread_QueueCmd(opArgs, (void**) &data);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001ECAC.s")
|
||||
void AudioThread_ScheduleProcessCmds(void) {
|
||||
static s32 D_800C7C70 = 0;
|
||||
s32 msg;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001ED14.s")
|
||||
if (D_800C7C70 < (u8) (gThreadCmdWritePos - gThreadCmdReadPos + 0x100)) {
|
||||
D_800C7C70 = (u8) (gThreadCmdWritePos - gThreadCmdReadPos + 0x100);
|
||||
}
|
||||
msg = (((gThreadCmdReadPos & 0xFF) << 8) | (gThreadCmdWritePos & 0xFF));
|
||||
osSendMesg(gThreadCmdProcQueue, (OSMesg) msg, 0);
|
||||
gThreadCmdReadPos = gThreadCmdWritePos;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001ED34.s")
|
||||
void AudioThread_ResetCmdQueue(void) {
|
||||
gThreadCmdReadPos = gThreadCmdWritePos;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001ED8C.s")
|
||||
void AudioThread_ProcessCmds(u32 msg) {
|
||||
static u8 gCurCmdReadPos = 0;
|
||||
static u8 gThreadCmdQueueFinished = false;
|
||||
AudioCmd* cmd;
|
||||
SequenceChannel* channel;
|
||||
SequencePlayer* player;
|
||||
u8 writePos;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001EE00.s")
|
||||
if (!gThreadCmdQueueFinished) {
|
||||
gCurCmdReadPos = (msg >> 8) & 0xFF;
|
||||
}
|
||||
writePos = msg & 0xFF;
|
||||
while (true) {
|
||||
if (gCurCmdReadPos == writePos) {
|
||||
gThreadCmdQueueFinished = 0;
|
||||
break;
|
||||
}
|
||||
cmd = &gThreadCmdBuffer[gCurCmdReadPos & 0xFF];
|
||||
gCurCmdReadPos++;
|
||||
if (cmd->op == AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS) {
|
||||
gThreadCmdQueueFinished = true;
|
||||
break;
|
||||
}
|
||||
if ((cmd->op & 0xF0) == 0xF0) {
|
||||
AudioThread_ProcessGlobalCmd(cmd);
|
||||
} else if (cmd->arg0 < 4) {
|
||||
player = &gSeqPlayers[cmd->arg0];
|
||||
if (cmd->op & 0x80) {
|
||||
AudioThread_ProcessGlobalCmd(cmd);
|
||||
} else if (cmd->op & 0x40) {
|
||||
switch (cmd->op) {
|
||||
case AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE:
|
||||
if (player->fadeVolumeMod != cmd->asFloat) {
|
||||
player->fadeVolumeMod = cmd->asFloat;
|
||||
player->recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_TEMPO: /* switch 1 */
|
||||
player->tempo = cmd->asInt * 48;
|
||||
break;
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION: /* switch 1 */
|
||||
player->transposition = cmd->asSbyte;
|
||||
break;
|
||||
case 0x46: // AUDIOCMD_OP_SEQPLAYER_SET_IO?
|
||||
player->unk_07[cmd->arg2] = cmd->asSbyte;
|
||||
break;
|
||||
}
|
||||
} else if ((player->enabled) && (cmd->arg1 < 16)) {
|
||||
channel = player->channels[cmd->arg1];
|
||||
if (channel != &gSeqChannelNone) {
|
||||
switch (cmd->op) {
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE:
|
||||
if (channel->volumeMod != cmd->asFloat) {
|
||||
channel->volumeMod = cmd->asFloat;
|
||||
channel->changes.s.volume = true;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VOL:
|
||||
if (channel->volume != cmd->asFloat) {
|
||||
channel->volume = cmd->asFloat;
|
||||
channel->changes.s.volume = true;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_PAN:
|
||||
if (channel->newPan != cmd->asSbyte) {
|
||||
channel->newPan = cmd->asSbyte;
|
||||
channel->changes.s.pan = true;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE:
|
||||
if (channel->freqMod != cmd->asFloat) {
|
||||
channel->freqMod = cmd->asFloat;
|
||||
channel->changes.s.freqMod = true;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME:
|
||||
if (channel->targetReverbVol != cmd->asSbyte) {
|
||||
channel->targetReverbVol = cmd->asSbyte;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_IO:
|
||||
if (cmd->arg2 < 8) {
|
||||
channel->seqScriptIO[cmd->arg2] = cmd->asSbyte;
|
||||
}
|
||||
break;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_MUTE:
|
||||
channel->muted = cmd->asSbyte;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cmd->op = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/func_8001EE3C.s")
|
||||
u32 AudioThread_GetAsyncLoadStatus(u32* outData) {
|
||||
u32 sp1C;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/us/nonmatchings/main/audio_thread/D_800C90F0.s")
|
||||
if (osRecvMesg(&gExternalLoadQueue, (OSMesg*) &sp1C, 0) == -1) {
|
||||
*outData = 0;
|
||||
return 0;
|
||||
}
|
||||
*outData = sp1C & 0xFFFFFF;
|
||||
return sp1C >> 0x18;
|
||||
}
|
||||
|
||||
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
|
||||
return AudioLoad_GetFontsForSequence(seqId, outNumFonts);
|
||||
}
|
||||
|
||||
s32 func_8001ED34(void) {
|
||||
s32 pad;
|
||||
s32 sp18;
|
||||
|
||||
if (osRecvMesg(gAudioResetQueue, (OSMesg*) &sp18, 0) == -1) {
|
||||
return 0;
|
||||
}
|
||||
if (sp18 != gAudioSpecId) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AudioThread_ResetAudioHeap(s32 specId) {
|
||||
// clang-format off
|
||||
s32 m1 = -1;OSMesg sp28;do {} while (osRecvMesg(gAudioResetQueue, &sp28, 0) != m1);
|
||||
// clang-format on
|
||||
|
||||
AudioThread_ResetCmdQueue();
|
||||
osSendMesg(gAudioUnkQueue, (OSMesg) specId, 0);
|
||||
}
|
||||
|
||||
void AudioThread_PreNMIReset(void) {
|
||||
gResetTimer = 1;
|
||||
AudioThread_ResetAudioHeap(0);
|
||||
gResetStatus = 0;
|
||||
}
|
||||
|
||||
void AudioThread_Init(void) {
|
||||
AudioThread_InitQueues();
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ void Graphics_NMIWipe(void) {
|
||||
Graphics_FillRectangle(&gMasterDisp, SCREEN_WIDTH - 8 - MIN(304, D_800D4A80), 176, SCREEN_WIDTH - 8, 232, 0, 0, 0,
|
||||
255);
|
||||
if (D_800D4A80 == 0) {
|
||||
func_8001EE00();
|
||||
AudioThread_PreNMIReset();
|
||||
}
|
||||
D_800D4A80 += 45;
|
||||
if (D_800D4A80 >= 485) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "sys.h"
|
||||
|
||||
void AudioLoad_Init(void);
|
||||
SPTask* func_8001DF50(void);
|
||||
SPTask* AudioThread_CreateTask(void);
|
||||
void Audio_InitSounds(void);
|
||||
void Audio_Update(void);
|
||||
|
||||
@ -109,7 +109,7 @@ void Audio_ThreadEntry(void* arg0) {
|
||||
|
||||
AudioLoad_Init();
|
||||
Audio_InitSounds();
|
||||
task = func_8001DF50();
|
||||
task = AudioThread_CreateTask();
|
||||
if (task != NULL) {
|
||||
task->msgQueue = &gAudioTaskMsgQueue;
|
||||
task->msg = (OSMesg) TASK_MESG_1;
|
||||
@ -117,7 +117,7 @@ void Audio_ThreadEntry(void* arg0) {
|
||||
osSendMesg(&gTaskMsgQueue, task, OS_MESG_PRI_NORMAL);
|
||||
}
|
||||
while (1) {
|
||||
task = func_8001DF50();
|
||||
task = AudioThread_CreateTask();
|
||||
if (task != NULL) {
|
||||
task->msgQueue = &gAudioTaskMsgQueue;
|
||||
task->msg = (OSMesg) TASK_MESG_1;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 0fd8f658566f6269c1fbca297760e60e8e64cf0e
|
||||
Subproject commit cfd2ec35ce03a36c10b005b952f765f035c8b836
|
@ -26,6 +26,10 @@ compiler_type = "ido"
|
||||
"false" = "int"
|
||||
"DMG_.*" = "int"
|
||||
"AUDIOCMD_.*" = "void"
|
||||
"SEQCMD_.*" = "void"
|
||||
"a[A-Z].*" = "void"
|
||||
"ALIGN.*" = "int"
|
||||
"OS_K0_TO_PHYSICAL" = "int"
|
||||
|
||||
[decompme.compilers]
|
||||
"tools/ido-recomp/linux/cc" = "ido5.3"
|
Loading…
Reference in New Issue
Block a user