diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index c53d70177..323c719aa 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -10312,7 +10312,7 @@ bool aiChrBeginOrEndTeleport(void) g_Vars.currentplayer->teleportcamerapad = 0; mainpri = osGetThreadPri(0); - audiopri = osGetThreadPri(&g_AudioThread); + audiopri = osGetThreadPri(&g_AudioManager.thread); osSetThreadPri(0, audiopri + 1); c = audioStart(var80095200, 0x0433, NULL, -1, -1, -1, -1, -1); @@ -10353,7 +10353,7 @@ bool aiIfChrTeleportFullWhite(void) } else { fvalue = 0.4; mainpri = osGetThreadPri(0); - audiopri = osGetThreadPri(&g_AudioThread); + audiopri = osGetThreadPri(&g_AudioManager.thread); osSetThreadPri(0, audiopri + 1); c = audioStart(var80095200, 0x8055, NULL, -1, -1, -1, -1, -1); diff --git a/src/game/game_0601b0.c b/src/game/game_0601b0.c index d7d50c2ff..527d39daf 100644 --- a/src/game/game_0601b0.c +++ b/src/game/game_0601b0.c @@ -521,10 +521,10 @@ glabel var7f1a9e50 /* f060ab8: 00002025 */ or $a0,$zero,$zero /* f060abc: 0c012230 */ jal osGetThreadPri /* f060ac0: afa3005c */ sw $v1,0x5c($sp) -/* f060ac4: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f060ac4: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f060ac8: afa2004c */ sw $v0,0x4c($sp) /* f060acc: 0c012230 */ jal osGetThreadPri -/* f060ad0: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f060ad0: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f060ad4: 00002025 */ or $a0,$zero,$zero /* f060ad8: 0c01210c */ jal osSetThreadPri /* f060adc: 24450001 */ addiu $a1,$v0,0x1 @@ -674,10 +674,10 @@ glabel var7f1a9e5c /* f060cc4: 8fa50064 */ lw $a1,0x64($sp) /* f060cc8: 0c012230 */ jal osGetThreadPri /* f060ccc: 00002025 */ or $a0,$zero,$zero -/* f060cd0: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f060cd0: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f060cd4: afa20050 */ sw $v0,0x50($sp) /* f060cd8: 0c012230 */ jal osGetThreadPri -/* f060cdc: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f060cdc: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f060ce0: 00002025 */ or $a0,$zero,$zero /* f060ce4: 0c01210c */ jal osSetThreadPri /* f060ce8: 24450001 */ addiu $a1,$v0,0x1 diff --git a/src/game/game_092610.c b/src/game/game_092610.c index 41e39af14..60538a057 100644 --- a/src/game/game_092610.c +++ b/src/game/game_092610.c @@ -1060,10 +1060,10 @@ glabel func0f093630 /* f09368c: 18400033 */ blez $v0,.L0f09375c /* f093690: 00128100 */ sll $s0,$s2,0x4 /* f093694: 02128023 */ subu $s0,$s0,$s2 -/* f093698: 3c158009 */ lui $s5,%hi(g_AudioThread) +/* f093698: 3c158009 */ lui $s5,%hi(g_AudioManager+0x18) /* f09369c: 3c138007 */ lui $s3,%hi(g_AudioChannels) /* f0936a0: 2673ae10 */ addiu $s3,$s3,%lo(g_AudioChannels) -/* f0936a4: 26b515e0 */ addiu $s5,$s5,%lo(g_AudioThread) +/* f0936a4: 26b515e0 */ addiu $s5,$s5,%lo(g_AudioManager+0x18) /* f0936a8: 001080c0 */ sll $s0,$s0,0x3 /* f0936ac: 2416ffff */ addiu $s6,$zero,-1 /* f0936b0: 8e6e0000 */ lw $t6,0x0($s3) @@ -1159,10 +1159,10 @@ glabel func0f093790 /* f0937e4: 18400035 */ blez $v0,.L0f0938bc /* f0937e8: 00139100 */ sll $s2,$s3,0x4 /* f0937ec: 02539023 */ subu $s2,$s2,$s3 -/* f0937f0: 3c168009 */ lui $s6,%hi(g_AudioThread) +/* f0937f0: 3c168009 */ lui $s6,%hi(g_AudioManager+0x18) /* f0937f4: 3c158007 */ lui $s5,%hi(g_AudioChannels) /* f0937f8: 26b5ae10 */ addiu $s5,$s5,%lo(g_AudioChannels) -/* f0937fc: 26d615e0 */ addiu $s6,$s6,%lo(g_AudioThread) +/* f0937fc: 26d615e0 */ addiu $s6,$s6,%lo(g_AudioManager+0x18) /* f093800: 001290c0 */ sll $s2,$s2,0x3 /* f093804: 8eae0000 */ lw $t6,0x0($s5) .L0f093808: @@ -1717,10 +1717,10 @@ glabel var7f1ab748 /* f093f80: 35cf0010 */ ori $t7,$t6,0x10 /* f093f84: 0c012230 */ jal osGetThreadPri /* f093f88: a60f0030 */ sh $t7,0x30($s0) -/* f093f8c: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f093f8c: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f093f90: afa200a8 */ sw $v0,0xa8($sp) /* f093f94: 0c012230 */ jal osGetThreadPri -/* f093f98: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f093f98: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f093f9c: 00002025 */ or $a0,$zero,$zero /* f093fa0: 0c01210c */ jal osSetThreadPri /* f093fa4: 24450001 */ addiu $a1,$v0,0x1 @@ -1734,10 +1734,10 @@ glabel var7f1ab748 .L0f093fc4: /* f093fc4: 0c012230 */ jal osGetThreadPri /* f093fc8: 00002025 */ or $a0,$zero,$zero -/* f093fcc: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f093fcc: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f093fd0: afa200a8 */ sw $v0,0xa8($sp) /* f093fd4: 0c012230 */ jal osGetThreadPri -/* f093fd8: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f093fd8: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f093fdc: 00002025 */ or $a0,$zero,$zero /* f093fe0: 0c01210c */ jal osSetThreadPri /* f093fe4: 24450001 */ addiu $a1,$v0,0x1 @@ -1967,12 +1967,12 @@ glabel var7f1ab748 // channel->flags |= AUDIOCHANNELFLAG_0010; // // prevpri = osGetThreadPri(0); -// osSetThreadPri(0, osGetThreadPri(&g_AudioThread) + 1); +// osSetThreadPri(0, osGetThreadPri(&g_AudioManager.thread) + 1); // func0f092c04(channel->channelnum); // osSetThreadPri(0, prevpri); // } else { // prevpri = osGetThreadPri(0); -// osSetThreadPri(0, osGetThreadPri(&g_AudioThread) + 1); +// osSetThreadPri(0, osGetThreadPri(&g_AudioManager.thread) + 1); // func0f092c04(channel->channelnum); // osSetThreadPri(0, prevpri); // } @@ -2104,7 +2104,7 @@ void audioPlayFromProp2(s32 channelnum, s32 soundnum, s16 padnum, struct prop *p if (!a1 || channel->unk1c == 0) { OSPri prevpri = osGetThreadPri(0); - osSetThreadPri(0, osGetThreadPri(&g_AudioThread) + 1); + osSetThreadPri(0, osGetThreadPri(&g_AudioManager.thread) + 1); func0f092c04(channelnum); osSetThreadPri(0, prevpri); } diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 5c760fe3c..2bbba30a6 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -3725,10 +3725,10 @@ glabel var7f1ac320 /* f09a9c0: 8fbf002c */ lw $ra,0x2c($sp) /* f09a9c4: 0c012230 */ jal osGetThreadPri /* f09a9c8: 00002025 */ or $a0,$zero,$zero -/* f09a9cc: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f09a9cc: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f09a9d0: afa20040 */ sw $v0,0x40($sp) /* f09a9d4: 0c012230 */ jal osGetThreadPri -/* f09a9d8: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f09a9d8: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f09a9dc: 00002025 */ or $a0,$zero,$zero /* f09a9e0: 0c01210c */ jal osSetThreadPri /* f09a9e4: 24450001 */ addiu $a1,$v0,0x1 @@ -5084,10 +5084,10 @@ glabel var7f1ac450 /* f09ba84: 00002025 */ or $a0,$zero,$zero /* f09ba88: 0c012230 */ jal osGetThreadPri /* f09ba8c: e7a40044 */ swc1 $f4,0x44($sp) -/* f09ba90: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f09ba90: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f09ba94: afa20040 */ sw $v0,0x40($sp) /* f09ba98: 0c012230 */ jal osGetThreadPri -/* f09ba9c: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f09ba9c: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f09baa0: 00002025 */ or $a0,$zero,$zero /* f09baa4: 0c01210c */ jal osSetThreadPri /* f09baa8: 24450001 */ addiu $a1,$v0,0x1 @@ -5120,10 +5120,10 @@ glabel var7f1ac450 /* f09bb10: 00002025 */ or $a0,$zero,$zero /* f09bb14: 0c012230 */ jal osGetThreadPri /* f09bb18: e7a80038 */ swc1 $f8,0x38($sp) -/* f09bb1c: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f09bb1c: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f09bb20: afa20034 */ sw $v0,0x34($sp) /* f09bb24: 0c012230 */ jal osGetThreadPri -/* f09bb28: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f09bb28: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f09bb2c: 00002025 */ or $a0,$zero,$zero /* f09bb30: 0c01210c */ jal osSetThreadPri /* f09bb34: 24450001 */ addiu $a1,$v0,0x1 @@ -6188,10 +6188,10 @@ glabel var7f1ac5ec /* f09c6e4: 00002025 */ or $a0,$zero,$zero /* f09c6e8: 0c012230 */ jal osGetThreadPri /* f09c6ec: e7a6004c */ swc1 $f6,0x4c($sp) -/* f09c6f0: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f09c6f0: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f09c6f4: afa20044 */ sw $v0,0x44($sp) /* f09c6f8: 0c012230 */ jal osGetThreadPri -/* f09c6fc: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f09c6fc: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f09c700: 00002025 */ or $a0,$zero,$zero /* f09c704: 0c01210c */ jal osSetThreadPri /* f09c708: 24450001 */ addiu $a1,$v0,0x1 @@ -6296,10 +6296,10 @@ glabel var7f1ac5ec /* f09c890: 00002025 */ or $a0,$zero,$zero /* f09c894: 0c012230 */ jal osGetThreadPri /* f09c898: e7a60040 */ swc1 $f6,0x40($sp) -/* f09c89c: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f09c89c: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f09c8a0: afa2003c */ sw $v0,0x3c($sp) /* f09c8a4: 0c012230 */ jal osGetThreadPri -/* f09c8a8: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f09c8a8: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f09c8ac: 00002025 */ or $a0,$zero,$zero /* f09c8b0: 0c01210c */ jal osSetThreadPri /* f09c8b4: 24450001 */ addiu $a1,$v0,0x1 @@ -6334,10 +6334,10 @@ glabel var7f1ac5ec /* f09c924: 00002025 */ or $a0,$zero,$zero /* f09c928: 0c012230 */ jal osGetThreadPri /* f09c92c: e7b00034 */ swc1 $f16,0x34($sp) -/* f09c930: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* f09c930: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* f09c934: afa20030 */ sw $v0,0x30($sp) /* f09c938: 0c012230 */ jal osGetThreadPri -/* f09c93c: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* f09c93c: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* f09c940: 00002025 */ or $a0,$zero,$zero /* f09c944: 0c01210c */ jal osSetThreadPri /* f09c948: 24450001 */ addiu $a1,$v0,0x1 diff --git a/src/game/game_0f09f0.c b/src/game/game_0f09f0.c index 6d375fa21..a9f7b3532 100644 --- a/src/game/game_0f09f0.c +++ b/src/game/game_0f09f0.c @@ -136,7 +136,7 @@ void menuPlaySound(s32 menusound) if (sound != -1) { s32 handle; OSPri prevpri = osGetThreadPri(NULL); - osSetThreadPri(0, osGetThreadPri(&g_AudioThread) + 1); + osSetThreadPri(0, osGetThreadPri(&g_AudioManager.thread) + 1); handle = audioStart(var80095200, sound, NULL, -1, -1, -1, -1, -1); diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index d7a228531..99e0b618f 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -4021,18 +4021,12 @@ u32 var80091558 = 0; u32 var8009155c = 0; u32 var80091560 = 0; u32 var80091564 = 0; -u32 var80091568 = 0; -u32 var8009156c = 0; -u32 var80091570 = 0; -u32 var80091574 = 0; -u32 var80091578 = 0; -u32 var8009157c = 0; -u32 var80091580 = 0; -u32 var80091584 = 0; -u32 var80091588 = 0; -u32 var8009158c = 0; -u32 var80091590 = 0; -u32 var80091594 = 0; +u64 var80091568 = 0; +u64 var80091570 = 0; +u64 var80091578 = 0; +u64 var80091580 = 0; +u64 var80091588 = 0; +u64 var80091590 = 0; u32 var80091598 = 0; u32 var8009159c = 0; u32 var800915a0 = 0; @@ -4045,59 +4039,11 @@ u32 var800915b8 = 0; u32 var800915bc = 0; u32 var800915c0 = 0; u32 var800915c4 = 0; -Acmd *var800915c8[2] = {0}; -u32 var800915d0 = 0; -u32 var800915d4 = 0; -u32 var800915d8 = 0; -u32 var800915dc = 0; -OSThread g_AudioThread = {0}; -u32 var80091790 = 0; -u32 var80091794 = 0; -u32 var80091798 = 0; -u32 var8009179c = 0; -u32 var800917a0 = 0; -u32 var800917a4 = 0; -u32 var800917a8 = 0; -u32 var800917ac = 0; -u32 var800917b0 = 0; -u32 var800917b4 = 0; -u32 var800917b8 = 0; -u32 var800917bc = 0; -u32 var800917c0 = 0; -u32 var800917c4 = 0; -u32 var800917c8 = 0; -u32 var800917cc = 0; -u32 var800917d0 = 0; -u32 var800917d4 = 0; -u32 var800917d8 = 0; -u32 var800917dc = 0; -u32 var800917e0 = 0; -u32 var800917e4 = 0; -u32 var800917e8 = 0; -u32 var800917ec = 0; -u32 var800917f0 = 0; -u32 var800917f4 = 0; -u32 var800917f8 = 0; -u32 var800917fc = 0; -u32 var80091800 = 0; -u32 var80091804 = 0; -u32 var80091808 = 0; -u32 var8009180c = 0; -u32 var80091810 = 0; -u32 var80091814 = 0; -u32 var80091818 = 0; -u32 var8009181c = 0; -u32 var80091820 = 0; -u32 var80091824 = 0; -u32 var80091828 = 0; -u32 var8009182c = 0; -u32 var80091830 = 0; -u32 var80091834 = 0; -u32 var80091838 = 0; -u32 var8009183c = 0; -u32 var80091840 = 0; -u32 var80091844 = 0; -OSMesgQueue var80091848 = {0}; +AMAudioMgr g_AudioManager = {0}; +u32 var80091850 = 0; +u32 var80091854 = 0; +u32 var80091858 = 0; +u32 var8009185c = 0; u32 var80091860 = 0; u32 var80091864 = 0; u32 var80091868 = 0; diff --git a/src/include/PR/libaudio.h b/src/include/PR/libaudio.h index c374a9ff3..164f46fa4 100644 --- a/src/include/PR/libaudio.h +++ b/src/include/PR/libaudio.h @@ -1,21 +1,916 @@ -#ifndef _ULTRA64_LIBAUDIO_H_ -#define _ULTRA64_LIBAUDIO_H_ +#ifndef __LIB_AUDIO__ +#define __LIB_AUDIO__ -#include "abi.h" +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif -typedef struct -{ - u8 *offset; - s32 len; +#include +#include + +/*********************************************************************** + * misc defines + ***********************************************************************/ +#ifndef _EMULATOR +# ifdef AUD_PROFILE + +#define PROFILE_AUD(num, cnt, max, min) \ +{ \ + u32 currCnt = osGetCount(); \ + currCnt -= lastCnt[cnt_index]; \ + cnt_index--; \ + cnt += currCnt; \ + num++; \ + \ + if ( currCnt > max ) max = currCnt; \ + if ( currCnt < min ) min = currCnt; \ +} + +# endif /* AUD_PROFILE */ +#endif /* EMULATOR */ + +#ifndef NULL +#define NULL 0 +#endif + +#define AL_FX_BUFFER_SIZE 8192 +#define AL_FRAME_INIT -1 +#define AL_USEC_PER_FRAME 16000 +#define AL_MAX_PRIORITY 127 +#define AL_GAIN_CHANGE_TIME 1000 + +typedef s32 ALMicroTime; +typedef u8 ALPan; + +#define AL_PAN_CENTER 64 +#define AL_PAN_LEFT 0 +#define AL_PAN_RIGHT 127 +#define AL_VOL_FULL 127 +#define AL_KEY_MIN 0 +#define AL_KEY_MAX 127 +#define AL_DEFAULT_FXMIX 0 +#define AL_SUSTAIN 63 + +/*********************************************************************** + * Error handling + ***********************************************************************/ + +#ifdef _DEBUG +#define ALFailIf(condition, error) \ + if (condition) { \ + __osError(error, 0); \ + return; } + +#else +#define ALFailIf(condition, error) \ + if (condition) { \ + return; } +#endif + +#ifdef _DEBUG +#define ALFlagFailIf(condition, flag, error) \ + if (condition) { \ + if(flag) __osError(error, 0); \ + return; } + +#else +#define ALFlagFailIf(condition, flag, error) \ + if (condition) { \ + return; } +#endif + +/*********************************************************************** + * Audio Library global routines + ***********************************************************************/ +typedef struct ALLink_s { + struct ALLink_s *next; + struct ALLink_s *prev; +} ALLink; + +void alUnlink(ALLink *element); +void alLink(ALLink *element, ALLink *after); + +typedef s32 (*ALDMAproc)(s32 addr, s32 len, void *state); +typedef ALDMAproc (*ALDMANew)(void *state); + +void alCopy(void *src, void *dest, s32 len); + +typedef struct { + u8 *base; + u8 *cur; + s32 len; + s32 count; +} ALHeap; + +#define AL_HEAP_DEBUG 1 +#define AL_HEAP_MAGIC 0x20736a73 +#define AL_HEAP_INIT 0 + +void alHeapInit(ALHeap *hp, u8 *base, s32 len); +void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); +s32 alHeapCheck(ALHeap *hp); + +#ifdef _DEBUG +#define alHeapAlloc(hp, elem ,size) alHeapDBAlloc((u8 *) __FILE__,__LINE__,(hp),(elem),(size)) +#else +#define alHeapAlloc(hp, elem ,size) alHeapDBAlloc(0, 0,(hp),(elem),(size)) +#endif + +/*********************************************************************** + * FX Stuff + ***********************************************************************/ +#define AL_FX_NONE 0 +#define AL_FX_SMALLROOM 1 +#define AL_FX_BIGROOM 2 +#define AL_FX_CHORUS 3 +#define AL_FX_FLANGE 4 +#define AL_FX_ECHO 5 +#define AL_FX_CUSTOM 6 + +typedef u8 ALFxId; +typedef void *ALFxRef; + +/*********************************************************************** + * data structures for sound banks + ***********************************************************************/ + +#define AL_BANK_VERSION 0x4231 /* 'B1' */ + +/* Possible wavetable types */ +enum {AL_ADPCM_WAVE = 0, + AL_RAW16_WAVE}; + +typedef struct { + s32 order; + s32 npredictors; + s16 book[1]; /* Actually variable size. Must be 8-byte aligned */ +} ALADPCMBook; + +typedef struct { + u32 start; + u32 end; + u32 count; + ADPCM_STATE state; +} ALADPCMloop; + +typedef struct { + u32 start; + u32 end; + u32 count; +} ALRawLoop; + +typedef struct { + ALMicroTime attackTime; + ALMicroTime decayTime; + ALMicroTime releaseTime; + u8 attackVolume; + u8 decayVolume; +} ALEnvelope; + +typedef struct { + u8 velocityMin; + u8 velocityMax; + u8 keyMin; + u8 keyMax; + u8 keyBase; + s8 detune; +} ALKeyMap; + +typedef struct { + ALADPCMloop *loop; + ALADPCMBook *book; +} ALADPCMWaveInfo; + +typedef struct { + ALRawLoop *loop; +} ALRAWWaveInfo; + +typedef struct ALWaveTable_s { + u8 *base; /* ptr to start of wave data */ + s32 len; /* length of data in bytes */ + u8 type; /* compression type */ + u8 flags; /* offset/address flags */ + union { + ALADPCMWaveInfo adpcmWave; + ALRAWWaveInfo rawWave; + } waveInfo; +} ALWaveTable; + +typedef struct ALSound_s { + ALEnvelope *envelope; + ALKeyMap *keyMap; + ALWaveTable *wavetable; /* offset to wavetable struct */ + ALPan samplePan; + u8 sampleVolume; + u8 flags; +} ALSound; + +typedef struct { + u8 volume; /* overall volume for this instrument */ + ALPan pan; /* 0 = hard left, 127 = hard right */ + u8 priority; /* voice priority for this instrument */ + u8 flags; + u8 tremType; /* the type of tremelo osc. to use */ + u8 tremRate; /* the rate of the tremelo osc. */ + u8 tremDepth; /* the depth of the tremelo osc */ + u8 tremDelay; /* the delay for the tremelo osc */ + u8 vibType; /* the type of tremelo osc. to use */ + u8 vibRate; /* the rate of the tremelo osc. */ + u8 vibDepth; /* the depth of the tremelo osc */ + u8 vibDelay; /* the delay for the tremelo osc */ + s16 bendRange; /* pitch bend range in cents */ + s16 soundCount; /* number of sounds in this array */ + ALSound *soundArray[1]; +} ALInstrument; + +typedef struct ALBank_s { + s16 instCount; /* number of programs in this bank */ + u8 flags; + u8 pad; + s32 sampleRate; /* e.g. 44100, 22050, etc... */ + ALInstrument *percussion; /* default percussion for GM */ + ALInstrument *instArray[1]; /* ARRAY of instruments */ +} ALBank; + +typedef struct { /* Note: sizeof won't be correct */ + s16 revision; /* format revision of this file */ + s16 bankCount; /* number of banks */ + ALBank *bankArray[1]; /* ARRAY of bank offsets */ +} ALBankFile; + +void alBnkfNew(ALBankFile *f, u8 *table); + +/*********************************************************************** + * Sequence Files + ***********************************************************************/ +#define AL_SEQBANK_VERSION 'S1' + +typedef struct { + u8 *offset; + s32 len; } ALSeqData; -typedef struct -{ - s16 revision; - s16 seqCount; - ALSeqData seqArray[1]; +typedef struct { /* Note: sizeof won't be correct */ + s16 revision; /* format revision of this file */ + s16 seqCount; /* number of sequences */ + ALSeqData seqArray[1]; /* ARRAY of sequence info */ } ALSeqFile; -void alSeqFileNew(ALSeqFile *f, u8 *base); +void alSeqFileNew(ALSeqFile *f, u8 *base); +/*********************************************************************** + * Synthesis driver stuff + ***********************************************************************/ +typedef ALMicroTime (*ALVoiceHandler)(void *); + +typedef struct { + s32 maxVVoices; /* obsolete */ + s32 maxPVoices; + s32 maxUpdates; + s32 maxFXbusses; + void *dmaproc; + ALHeap *heap; + s32 outputRate; /* output sample rate */ + ALFxId fxType; + s32 *params; +} ALSynConfig; + +typedef struct ALPlayer_s { + struct ALPlayer_s *next; + void *clientData; /* storage for client callback */ + ALVoiceHandler handler; /* voice handler for player */ + ALMicroTime callTime; /* usec requested callback */ + s32 samplesLeft; /* usec remaining to callback */ +} ALPlayer; + +typedef struct ALVoice_s { + ALLink node; + struct PVoice_s *pvoice; + ALWaveTable *table; + void *clientPrivate; + s16 state; + s16 priority; + s16 fxBus; + s16 unityPitch; +} ALVoice; + +typedef struct ALVoiceConfig_s { + s16 priority; /* voice priority */ + s16 fxBus; /* bus assignment */ + u8 unityPitch; /* unity pitch flag */ +} ALVoiceConfig; + +typedef struct { + ALPlayer *head; /* client list head */ + ALLink pFreeList; /* list of free physical voices */ + ALLink pAllocList; /* list of allocated physical voices */ + ALLink pLameList; /* list of voices ready to be freed */ + s32 paramSamples; + s32 curSamples; /* samples from start of game */ + ALDMANew dma; + ALHeap *heap; + + struct ALParam_s *paramList; + + struct ALMainBus_s *mainBus; + struct ALAuxBus_s *auxBus; /* ptr to array of aux bus structs */ + struct ALFilter_s *outputFilter; /* last filter in the filter chain */ + + s32 numPVoices; + s32 maxAuxBusses; + s32 outputRate; /* output sample rate */ + s32 maxOutSamples; /* Maximum samples rsp can generate + at one time at output rate */ +} ALSynth; + +void alSynNew(ALSynth *s, ALSynConfig *config); +void alSynDelete(ALSynth *s); + +void alSynAddPlayer(ALSynth *s, ALPlayer *client); +void alSynRemovePlayer(ALSynth *s, ALPlayer *client); + +s32 alSynAllocVoice(ALSynth *s, ALVoice *v, ALVoiceConfig *vc); +void alSynFreeVoice(ALSynth *s, ALVoice *voice); + +void alSynStartVoice(ALSynth *s, ALVoice *voice, ALWaveTable *w); +void alSynStartVoiceParams(ALSynth *s, ALVoice *voice, ALWaveTable *w, + f32 pitch, s16 vol, ALPan pan, u8 fxmix, + ALMicroTime t); +void alSynStopVoice(ALSynth *s, ALVoice *voice); + +void alSynSetVol(ALSynth *s, ALVoice *v, s16 vol, ALMicroTime delta); +void alSynSetPitch(ALSynth *s, ALVoice *voice, f32 ratio); +void alSynSetPan(ALSynth *s, ALVoice *voice, ALPan pan); +void alSynSetFXMix(ALSynth *s, ALVoice *voice, u8 fxmix); +void alSynSetPriority(ALSynth *s, ALVoice *voice, s16 priority); +s16 alSynGetPriority(ALSynth *s, ALVoice *voice); + +ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp); +ALFxRef alSynGetFXRef(ALSynth *s, s16 bus, s16 index); +void alSynFreeFX(ALSynth *s, ALFxRef *fx); +void alSynSetFXParam(ALSynth *s, ALFxRef fx, s16 paramID, void *param); + +/*********************************************************************** + * Audio Library (AL) stuff + ***********************************************************************/ +typedef struct { + ALSynth drvr; +} ALGlobals; + +extern ALGlobals *alGlobals; + +void alInit(ALGlobals *glob, ALSynConfig *c); +void alClose(ALGlobals *glob); + +Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen); + +/*********************************************************************** + * Sequence Player stuff + ***********************************************************************/ + +/* + * Play states + */ +#define AL_STOPPED 0 +#define AL_PLAYING 1 +#define AL_STOPPING 2 + +#define AL_DEFAULT_PRIORITY 5 +#define AL_DEFAULT_VOICE 0 +#define AL_MAX_CHANNELS 16 + +/* + * Audio Library event type definitions + */ +enum ALMsg { + AL_SEQ_REF_EVT, /* Reference to a pending event in the sequence. */ + AL_SEQ_MIDI_EVT, + AL_SEQP_MIDI_EVT, + AL_TEMPO_EVT, + AL_SEQ_END_EVT, + AL_NOTE_END_EVT, + AL_SEQP_ENV_EVT, + AL_SEQP_META_EVT, + AL_SEQP_PROG_EVT, + AL_SEQP_API_EVT, + AL_SEQP_VOL_EVT, + AL_SEQP_LOOP_EVT, + AL_SEQP_PRIORITY_EVT, + AL_SEQP_SEQ_EVT, + AL_SEQP_BANK_EVT, + AL_SEQP_PLAY_EVT, + AL_SEQP_STOP_EVT, + AL_SEQP_STOPPING_EVT, + AL_TRACK_END, + AL_CSP_LOOPSTART, + AL_CSP_LOOPEND, + AL_CSP_NOTEOFF_EVT, + AL_TREM_OSC_EVT, + AL_VIB_OSC_EVT +}; + +/* + * Midi event definitions + */ +#define AL_EVTQ_END 0x7fffffff + +enum AL_MIDIstatus { + /* For distinguishing channel number from status */ + AL_MIDI_ChannelMask = 0x0F, + AL_MIDI_StatusMask = 0xF0, + + /* Channel voice messages */ + AL_MIDI_ChannelVoice = 0x80, + AL_MIDI_NoteOff = 0x80, + AL_MIDI_NoteOn = 0x90, + AL_MIDI_PolyKeyPressure = 0xA0, + AL_MIDI_ControlChange = 0xB0, + AL_MIDI_ChannelModeSelect = 0xB0, + AL_MIDI_ProgramChange = 0xC0, + AL_MIDI_ChannelPressure = 0xD0, + AL_MIDI_PitchBendChange = 0xE0, + + /* System messages */ + AL_MIDI_SysEx = 0xF0, /* System Exclusive */ + + /* System common */ + AL_MIDI_SystemCommon = 0xF1, + AL_MIDI_TimeCodeQuarterFrame = 0xF1, + AL_MIDI_SongPositionPointer = 0xF2, + AL_MIDI_SongSelect = 0xF3, + AL_MIDI_Undefined1 = 0xF4, + AL_MIDI_Undefined2 = 0xF5, + AL_MIDI_TuneRequest = 0xF6, + AL_MIDI_EOX = 0xF7, /* End of System Exclusive */ + + /* System real time */ + AL_MIDI_SystemRealTime = 0xF8, + AL_MIDI_TimingClock = 0xF8, + AL_MIDI_Undefined3 = 0xF9, + AL_MIDI_Start = 0xFA, + AL_MIDI_Continue = 0xFB, + AL_MIDI_Stop = 0xFC, + AL_MIDI_Undefined4 = 0xFD, + AL_MIDI_ActiveSensing = 0xFE, + AL_MIDI_SystemReset = 0xFF, + AL_MIDI_Meta = 0xFF /* MIDI Files only */ +}; + +enum AL_MIDIctrl { + AL_MIDI_VOLUME_CTRL = 0x07, + AL_MIDI_PAN_CTRL = 0x0A, + AL_MIDI_PRIORITY_CTRL = 0x10, /* use general purpose controller for priority */ + AL_MIDI_FX_CTRL_0 = 0x14, + AL_MIDI_FX_CTRL_1 = 0x15, + AL_MIDI_FX_CTRL_2 = 0x16, + AL_MIDI_FX_CTRL_3 = 0x17, + AL_MIDI_FX_CTRL_4 = 0x18, + AL_MIDI_FX_CTRL_5 = 0x19, + AL_MIDI_FX_CTRL_6 = 0x1A, + AL_MIDI_FX_CTRL_7 = 0x1B, + AL_MIDI_FX_CTRL_8 = 0x1C, + AL_MIDI_FX_CTRL_9 = 0x1D, + AL_MIDI_SUSTAIN_CTRL = 0x40, + AL_MIDI_FX1_CTRL = 0x5B, + AL_MIDI_FX3_CTRL = 0x5D +}; + +enum AL_MIDImeta { + AL_MIDI_META_TEMPO = 0x51, + AL_MIDI_META_EOT = 0x2f +}; + + +#define AL_CMIDI_BLOCK_CODE 0xFE +#define AL_CMIDI_LOOPSTART_CODE 0x2E +#define AL_CMIDI_LOOPEND_CODE 0x2D +#define AL_CMIDI_CNTRL_LOOPSTART 102 +#define AL_CMIDI_CNTRL_LOOPEND 103 +#define AL_CMIDI_CNTRL_LOOPCOUNT_SM 104 +#define AL_CMIDI_CNTRL_LOOPCOUNT_BIG 105 + +typedef struct { + u8 *curPtr; /* ptr to the next event */ + s32 lastTicks; /* sequence clock ticks (used by alSeqSetLoc) */ + s32 curTicks; /* sequence clock ticks of next event (used by loop end test) */ + s16 lastStatus; /* the last status msg */ +} ALSeqMarker; + +typedef struct { + s32 ticks; /* MIDI, Tempo and End events must start with ticks */ + u8 status; + u8 byte1; + u8 byte2; + u32 duration; +} ALMIDIEvent; + +typedef struct { + s32 ticks; + u8 status; + u8 type; + u8 len; + u8 byte1; + u8 byte2; + u8 byte3; +} ALTempoEvent; + +typedef struct { + s32 ticks; + u8 status; + u8 type; + u8 len; +} ALEndEvent; + +typedef struct { + struct ALVoice_s *voice; +} ALNoteEvent; + +typedef struct { + struct ALVoice_s *voice; + ALMicroTime delta; + u8 vol; +} ALVolumeEvent; + +typedef struct { + s16 vol; +} ALSeqpVolEvent; + +typedef struct { + ALSeqMarker *start; + ALSeqMarker *end; + s32 count; +} ALSeqpLoopEvent; + +typedef struct { + u8 chan; + u8 priority; +} ALSeqpPriorityEvent; + +typedef struct { + void *seq; /* pointer to a seq (could be an ALSeq or an ALCSeq). */ +} ALSeqpSeqEvent; + +typedef struct { + ALBank *bank; +} ALSeqpBankEvent; + +typedef struct { + struct ALVoiceState_s *vs; + void *oscState; + u8 chan; +} ALOscEvent; + +typedef struct { + s16 type; + union { + ALMIDIEvent midi; + ALTempoEvent tempo; + ALEndEvent end; + ALNoteEvent note; + ALVolumeEvent vol; + ALSeqpLoopEvent loop; + ALSeqpVolEvent spvol; + ALSeqpPriorityEvent sppriority; + ALSeqpSeqEvent spseq; + ALSeqpBankEvent spbank; + ALOscEvent osc; + } msg; +} ALEvent; + +typedef struct { + ALLink node; + ALMicroTime delta; + ALEvent evt; +} ALEventListItem; + +typedef struct { + ALLink freeList; + ALLink allocList; + s32 eventCount; +} ALEventQueue; + +void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, + s32 itemCount); +ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt); +void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, + ALMicroTime delta); +void alEvtqFlush(ALEventQueue *evtq); +void alEvtqFlushType(ALEventQueue *evtq, s16 type); + + +#define AL_PHASE_ATTACK 0 +#define AL_PHASE_NOTEON 0 +#define AL_PHASE_DECAY 1 +#define AL_PHASE_SUSTAIN 2 +#define AL_PHASE_RELEASE 3 +#define AL_PHASE_SUSTREL 4 + +typedef struct ALVoiceState_s { + struct ALVoiceState_s *next;/* MUST be first */ + ALVoice voice; + ALSound *sound; + ALMicroTime envEndTime; /* time of envelope segment end */ + f32 pitch; /* currect pitch ratio */ + f32 vibrato; /* current value of the vibrato */ + u8 envGain; /* current envelope gain */ + u8 channel; /* channel assignment */ + u8 key; /* note on key number */ + u8 velocity; /* note on velocity */ + u8 envPhase; /* what envelope phase */ + u8 phase; + u8 tremelo; /* current value of the tremelo */ + u8 flags; /* bit 0 tremelo flag + bit 1 vibrato flag */ +} ALVoiceState; + +typedef struct { + ALInstrument *instrument; /* instrument assigned to this chan */ + s16 bendRange; /* pitch bend range in cents */ + ALFxId fxId; /* type of fx assigned to this chan */ + ALPan pan; /* overall pan for this chan */ + u8 priority; /* priority for this chan */ + u8 vol; /* current volume for this chan */ + u8 fxmix; /* current fx mix for this chan */ + u8 sustain; /* current sustain pedal state */ + f32 pitchBend; /* current pitch bend val in cents */ +} ALChanState; + +typedef struct ALSeq_s { + u8 *base; /* ptr to start of sequence file */ + u8 *trackStart; /* ptr to first MIDI event */ + u8 *curPtr; /* ptr to next event to read */ + s32 lastTicks; /* MIDI ticks for last event */ + s32 len; /* length of sequence in bytes */ + f32 qnpt; /* qrter notes / tick (1/division) */ + s16 division; /* ticks per quarter note */ + s16 lastStatus; /* for running status */ +} ALSeq; + +typedef struct { + u32 trackOffset[16]; + u32 division; +} ALCMidiHdr; + +typedef struct ALCSeq_s { + ALCMidiHdr *base; /* ptr to start of sequence file */ + u32 validTracks; /* set of flags, showing valid tracks */ + f32 qnpt; /* qrter notes / tick (1/division) */ + u32 lastTicks; /* keep track of ticks incase app wants */ + u32 lastDeltaTicks; /* number of delta ticks of last event */ + u32 deltaFlag; /* flag: set if delta's not subtracted */ + u8 *curLoc[16]; /* ptr to current track location, */ + /* may point to next event, or may point */ + /* to a backup code */ + u8 *curBUPtr[16]; /* ptr to next event if in backup mode */ + u8 curBULen[16]; /* if > 0, then in backup mode */ + u8 lastStatus[16]; /* for running status */ + u32 evtDeltaTicks[16]; /* delta time to next event */ +} ALCSeq; + +typedef struct { + u32 validTracks; + s32 lastTicks; + u32 lastDeltaTicks; + u8 *curLoc[16]; + u8 *curBUPtr[16]; + u8 curBULen[16]; + u8 lastStatus[16]; + u32 evtDeltaTicks[16]; +} ALCSeqMarker; + +#define NO_SOUND_ERR_MASK 0x01 +#define NOTE_OFF_ERR_MASK 0x02 +#define NO_VOICE_ERR_MASK 0x04 + +typedef struct { + s32 maxVoices; /* max number of voices to alloc */ + s32 maxEvents; /* max internal events to support */ + u8 maxChannels; /* max MIDI channels to support (16)*/ + u8 debugFlags; /* control which error get reported */ + ALHeap *heap; /* ptr to initialized heap */ + void *initOsc; + void *updateOsc; + void *stopOsc; +} ALSeqpConfig; + +typedef ALMicroTime (*ALOscInit)(void **oscState,f32 *initVal, u8 oscType, + u8 oscRate, u8 oscDepth, u8 oscDelay); +typedef ALMicroTime (*ALOscUpdate)(void *oscState, f32 *updateVal); +typedef void (*ALOscStop)(void *oscState); + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALSynth *drvr; /* reference to the client driver */ + ALSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + ALVoiceState *vAllocHead; /* list head for allocated voices */ + ALVoiceState *vAllocTail; /* list tail for allocated voices */ + ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; + ALSeqMarker *loopStart; + ALSeqMarker *loopEnd; + s32 loopCount; /* -1 = loop forever, 0 = no loop */ +} ALSeqPlayer; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALSynth *drvr; /* reference to the client driver */ + ALCSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + ALVoiceState *vAllocHead; /* list head for allocated voices */ + ALVoiceState *vAllocTail; /* list tail for allocated voices */ + ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; +} ALCSPlayer; + +/* + * Sequence data representation routines + */ +void alSeqNew(ALSeq *seq, u8 *ptr, s32 len); +void alSeqNextEvent(ALSeq *seq, ALEvent *event); +s32 alSeqGetTicks(ALSeq *seq); +f32 alSeqTicksToSec(ALSeq *seq, s32 ticks, u32 tempo); +u32 alSeqSecToTicks(ALSeq *seq, f32 sec, u32 tempo); +void alSeqNewMarker(ALSeq *seq, ALSeqMarker *m, u32 ticks); +void alSeqSetLoc(ALSeq *seq, ALSeqMarker *marker); +void alSeqGetLoc(ALSeq *seq, ALSeqMarker *marker); +/* + * Compact Sequence data representation routines + */ +void alCSeqNew(ALCSeq *seq, u8 *ptr); +void alCSeqNextEvent(ALCSeq *seq,ALEvent *evt); +s32 alCSeqGetTicks(ALCSeq *seq); +f32 alCSeqTicksToSec(ALCSeq *seq, s32 ticks, u32 tempo); +u32 alCSeqSecToTicks(ALCSeq *seq, f32 sec, u32 tempo); +void alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks); +void alCSeqSetLoc(ALCSeq *seq, ALCSeqMarker *marker); +void alCSeqGetLoc(ALCSeq *seq, ALCSeqMarker *marker); + +/* + * Sequence Player routines + */ +f32 alCents2Ratio(s32 cents); + +void alSeqpNew(ALSeqPlayer *seqp, ALSeqpConfig *config); +void alSeqpDelete(ALSeqPlayer *seqp); +void alSeqpSetSeq(ALSeqPlayer *seqp, ALSeq *seq); +ALSeq *alSeqpGetSeq(ALSeqPlayer *seqp); +void alSeqpPlay(ALSeqPlayer *seqp); +void alSeqpStop(ALSeqPlayer *seqp); +s32 alSeqpGetState(ALSeqPlayer *seqp); +void alSeqpSetBank(ALSeqPlayer *seqp, ALBank *b); +void alSeqpSetTempo(ALSeqPlayer *seqp, s32 tempo); +s32 alSeqpGetTempo(ALSeqPlayer *seqp); +s16 alSeqpGetVol(ALSeqPlayer *seqp); /* Master volume control */ +void alSeqpSetVol(ALSeqPlayer *seqp, s16 vol); +void alSeqpLoop(ALSeqPlayer *seqp, ALSeqMarker *start, ALSeqMarker *end, s32 count); + +void alSeqpSetChlProgram(ALSeqPlayer *seqp, u8 chan, u8 prog); +s32 alSeqpGetChlProgram(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlFXMix(ALSeqPlayer *seqp, u8 chan, u8 fxmix); +u8 alSeqpGetChlFXMix(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlVol(ALSeqPlayer *seqp, u8 chan, u8 vol); +u8 alSeqpGetChlVol(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlPan(ALSeqPlayer *seqp, u8 chan, ALPan pan); +ALPan alSeqpGetChlPan(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlPriority(ALSeqPlayer *seqp, u8 chan, u8 priority); +u8 alSeqpGetChlPriority(ALSeqPlayer *seqp, u8 chan); +void alSeqpSendMidi(ALSeqPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); + + +/* Maintain backwards compatibility with old routine names. */ +#define alSeqpSetProgram alSeqpSetChlProgram +#define alSeqpGetProgram alSeqpGetChlProgram +#define alSeqpSetFXMix alSeqpSetChlFXMix +#define alSeqpGetFXMix alSeqpGetChlFXMix +#define alSeqpSetPan alSeqpSetChlPan +#define alSeqpGetPan alSeqpGetChlPan +#define alSeqpSetChannelPriority alSeqpSetChlPriority +#define alSeqpGetChannelPriority alSeqpGetChlPriority + + + +/* + * Compressed Sequence Player routines + */ +void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *config); +void alCSPDelete(ALCSPlayer *seqp); +void alCSPSetSeq(ALCSPlayer *seqp, ALCSeq *seq); +ALCSeq *alCSPGetSeq(ALCSPlayer *seqp); +void alCSPPlay(ALCSPlayer *seqp); +void alCSPStop(ALCSPlayer *seqp); +s32 alCSPGetState(ALCSPlayer *seqp); +void alCSPSetBank(ALCSPlayer *seqp, ALBank *b); +void alCSPSetTempo(ALCSPlayer *seqp, s32 tempo); +s32 alCSPGetTempo(ALCSPlayer *seqp); +s16 alCSPGetVol(ALCSPlayer *seqp); +void alCSPSetVol(ALCSPlayer *seqp, s16 vol); + +void alCSPSetChlProgram(ALCSPlayer *seqp, u8 chan, u8 prog); +s32 alCSPGetChlProgram(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlFXMix(ALCSPlayer *seqp, u8 chan, u8 fxmix); +u8 alCSPGetChlFXMix(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlPan(ALCSPlayer *seqp, u8 chan, ALPan pan); +ALPan alCSPGetChlPan(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlVol(ALCSPlayer *seqp, u8 chan, u8 vol); +u8 alCSPGetChlVol(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlPriority(ALCSPlayer *seqp, u8 chan, u8 priority); +u8 alCSPGetChlPriority(ALCSPlayer *seqp, u8 chan); +void alCSPSendMidi(ALCSPlayer *seqp, s32 ticks, u8 status, + u8 byte1, u8 byte2); + + +/* Maintain backwards compatibility with old routine names. */ +#define alCSPSetProgram alCSPSetChlProgram +#define alCSPGetProgram alCSPGetChlProgram +#define alCSPSetFXMix alCSPSetChlFXMix +#define alCSPGetFXMix alCSPGetChlFXMix +#define alCSPSetPan alCSPSetChlPan +#define alCSPGetPan alCSPGetChlPan +#define alCSPSetChannelPriority alCSPSetChlPriority +#define alCSPGetChannelPriority alCSPGetChlPriority + + + +/*********************************************************************** + * Sound Player stuff + ***********************************************************************/ + +typedef struct { + s32 maxSounds; + s32 maxEvents; + ALHeap *heap; +} ALSndpConfig; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALEventQueue evtq; + ALEvent nextEvent; + ALSynth *drvr; /* reference to the client driver */ + s32 target; + void *sndState; + s32 maxSounds; + ALMicroTime frameTime; + ALMicroTime nextDelta; /* microseconds to next callback */ + ALMicroTime curTime; +} ALSndPlayer; + +typedef s16 ALSndId; + +void alSndpNew(ALSndPlayer *sndp, ALSndpConfig *c); +void alSndpDelete(ALSndPlayer *sndp); + +ALSndId alSndpAllocate(ALSndPlayer *sndp, ALSound *sound); +void alSndpDeallocate(ALSndPlayer *sndp, ALSndId id); + +void alSndpSetSound(ALSndPlayer *sndp, ALSndId id); +ALSndId alSndpGetSound(ALSndPlayer *sndp); + +void alSndpPlay(ALSndPlayer *sndp); +void alSndpPlayAt(ALSndPlayer *sndp, ALMicroTime delta); +void alSndpStop(ALSndPlayer *sndp); + +void alSndpSetVol(ALSndPlayer *sndp, s16 vol); +void alSndpSetPitch(ALSndPlayer *sndp, f32 pitch); +void alSndpSetPan(ALSndPlayer *sndp, ALPan pan); +void alSndpSetPriority(ALSndPlayer *sndp, ALSndId id, u8 priority); + +void alSndpSetFXMix(ALSndPlayer *sndp, u8 mix); +s32 alSndpGetState(ALSndPlayer *sndp); + +#ifndef _FINALROM +void alParseAbiCL(Acmd *cmdList, u32 nbytes); #endif +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !__LIB_AUDIO__ */ diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index f63e2adc0..cf96d54b0 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -367,24 +367,13 @@ extern u32 var80090b10; extern u32 var80090b14; extern u32 var800914d8; extern u32 var80091558; -extern u32 var80091568; -extern u32 var80091580; -extern u32 var80091588; -extern u32 var80091590; -extern Acmd *var800915c8[2]; -extern u32 var800915d0; -extern u32 var800915d4; -extern OSThread g_AudioThread; -extern u32 var80091810; -extern u32 var80091828; -extern OSMesgQueue var80091848; -extern u32 var80091860; -extern u32 var80091880; -extern u32 var800918d0; -extern u32 var800918dc; -extern u32 var800918e0; -extern s32 var800918e8; -extern u32 var800918ec; +extern u64 var80091568; +extern u64 var80091570; +extern u64 var80091578; +extern u64 var80091580; +extern u64 var80091588; +extern u64 var80091590; +extern AMAudioMgr g_AudioManager; extern void *g_AudioSp; extern OSScTask *g_AmgrCurrentCmdList; extern u32 var80091900; diff --git a/src/include/lib/lib_2fba0.h b/src/include/lib/lib_2fba0.h index a11fb5d24..c9810936f 100644 --- a/src/include/lib/lib_2fba0.h +++ b/src/include/lib/lib_2fba0.h @@ -4,6 +4,5 @@ #include "types.h" u32 func0002fba0(void); -u32 func0002fc0c(void); #endif diff --git a/src/include/lib/lib_30ce0.h b/src/include/lib/lib_30ce0.h index 568b4e706..e414a3781 100644 --- a/src/include/lib/lib_30ce0.h +++ b/src/include/lib/lib_30ce0.h @@ -4,7 +4,6 @@ #include "types.h" u32 func00030ce0(void); -Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen); u32 func00031504(void); u32 func00031564(void); u32 func00031590(void); @@ -12,7 +11,5 @@ u32 func000315f4(void); u32 func00031634(void); u32 func00031698(void); u32 func000316d0(void); -u32 alLink(void); -u32 alUnlink(void); #endif diff --git a/src/include/lib/lib_3c4d0.h b/src/include/lib/lib_3c4d0.h index bd6192ab4..81f076cc6 100644 --- a/src/include/lib/lib_3c4d0.h +++ b/src/include/lib/lib_3c4d0.h @@ -5,7 +5,6 @@ u32 func0003c4d0(void); u32 func0003c56c(void); -u32 alEvtqPostEvent(void); u32 func0003c7c0(void); u32 func0003c900(void); u32 func0003c970(void); diff --git a/src/include/lib/lib_490b0.h b/src/include/lib/lib_490b0.h index a170f3608..816df9228 100644 --- a/src/include/lib/lib_490b0.h +++ b/src/include/lib/lib_490b0.h @@ -4,6 +4,6 @@ #include "types.h" void func000490b0(void *framebuffer); -u32 func00049120(void); +u64 func00049120(void); #endif diff --git a/src/include/types.h b/src/include/types.h index 27503a90d..6bae48d1a 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -6904,4 +6904,48 @@ struct font { struct font2a4 unk2a4[94]; }; +typedef union { + struct { + short type; + } gen; + + struct { + short type; + struct AudioInfo_s *info; + } done; + + OSScMsg app; +} AudioMsg; + +typedef struct AudioInfo_s { + short *data; /* Output data pointer */ + short frameSamples; /* # of samples synthesized in this frame */ + OSScTask task; /* scheduler structure */ + AudioMsg msg; /* completion message */ +} AudioInfo; + +typedef struct { + Acmd *ACMDList[2]; + AudioInfo *audioInfo[3]; + OSThread thread; + OSMesgQueue audioFrameMsgQ; + OSMesg audioFrameMsgBuf[8]; + OSMesgQueue audioReplyMsgQ; + OSMesg audioReplyMsgBuf[8]; + ALGlobals g; +} AMAudioMgr; + +typedef struct { + ALLink node; + u32 startAddr; + u32 lastFrame; + char *ptr; +} AMDMABuffer; + +typedef struct { + u8 initialized; + AMDMABuffer *firstUsed; + AMDMABuffer *firstFree; +} AMDMAState; + #endif diff --git a/src/lib/lib_08a20.c b/src/lib/lib_08a20.c index 898414c3b..5955d6aaf 100644 --- a/src/lib/lib_08a20.c +++ b/src/lib/lib_08a20.c @@ -378,13 +378,7 @@ u32 var8005d50c = 0x00000000; s8 g_AudioIsThreadRunning = false; u32 var8005d514 = 0x00000001; -struct audioinfo { - s16 *data; - s16 framesamples; - OSScTask task; -}; - -void amgrHandleDoneMsg(struct audioinfo *info); +void amgrHandleDoneMsg(AudioInfo *info); void amgrAllocateStack(void) { @@ -469,16 +463,16 @@ glabel amgrCreate /* 8b5c: 3c018006 */ lui $at,%hi(var8005cf94) /* 8b60: 0c002598 */ jal func00009660 /* 8b64: a020cf94 */ sb $zero,%lo(var8005cf94)($at) -/* 8b68: 3c048009 */ lui $a0,%hi(var80091848) +/* 8b68: 3c048009 */ lui $a0,%hi(g_AudioManager+0x280) /* 8b6c: 3c058009 */ lui $a1,%hi(var80091860) /* 8b70: 24a51860 */ addiu $a1,$a1,%lo(var80091860) -/* 8b74: 24841848 */ addiu $a0,$a0,%lo(var80091848) +/* 8b74: 24841848 */ addiu $a0,$a0,%lo(g_AudioManager+0x280) /* 8b78: 0c0120d0 */ jal osCreateMesgQueue /* 8b7c: 24060008 */ addiu $a2,$zero,0x8 -/* 8b80: 3c048009 */ lui $a0,%hi(var80091810) -/* 8b84: 3c058009 */ lui $a1,%hi(var80091828) -/* 8b88: 24a51828 */ addiu $a1,$a1,%lo(var80091828) -/* 8b8c: 24841810 */ addiu $a0,$a0,%lo(var80091810) +/* 8b80: 3c048009 */ lui $a0,%hi(g_AudioManager+0x248) +/* 8b84: 3c058009 */ lui $a1,%hi(g_AudioManager+0x260) +/* 8b88: 24a51828 */ addiu $a1,$a1,%lo(g_AudioManager+0x260) +/* 8b8c: 24841810 */ addiu $a0,$a0,%lo(g_AudioManager+0x248) /* 8b90: 0c0120d0 */ jal osCreateMesgQueue /* 8b94: 24060008 */ addiu $a2,$zero,0x8 /* 8b98: 92af0000 */ lbu $t7,0x0($s5) @@ -490,12 +484,12 @@ glabel amgrCreate /* 8bb0: 000ec843 */ sra $t9,$t6,0x1 /* 8bb4: ae590000 */ sw $t9,0x0($s2) .L00008bb8: -/* 8bb8: 3c108009 */ lui $s0,%hi(var800915c8) -/* 8bbc: 3c138009 */ lui $s3,%hi(var800915d0) +/* 8bb8: 3c108009 */ lui $s0,%hi(g_AudioManager) +/* 8bbc: 3c138009 */ lui $s3,%hi(g_AudioManager+0x8) /* 8bc0: 3c118009 */ lui $s1,%hi(var800951f0) /* 8bc4: 263151f0 */ addiu $s1,$s1,%lo(var800951f0) -/* 8bc8: 267315d0 */ addiu $s3,$s3,%lo(var800915d0) -/* 8bcc: 261015c8 */ addiu $s0,$s0,%lo(var800915c8) +/* 8bc8: 267315d0 */ addiu $s3,$s3,%lo(g_AudioManager+0x8) +/* 8bcc: 261015c8 */ addiu $s0,$s0,%lo(g_AudioManager) .L00008bd0: /* 8bd0: 8e480000 */ lw $t0,0x0($s2) /* 8bd4: 00002025 */ or $a0,$zero,$zero @@ -509,10 +503,10 @@ glabel amgrCreate /* 8bf4: 0213082b */ sltu $at,$s0,$s3 /* 8bf8: 1420fff5 */ bnez $at,.L00008bd0 /* 8bfc: ae02fffc */ sw $v0,-0x4($s0) -/* 8c00: 3c108009 */ lui $s0,%hi(var800915c8) -/* 8c04: 3c128009 */ lui $s2,%hi(var800915d4) -/* 8c08: 265215d4 */ addiu $s2,$s2,%lo(var800915d4) -/* 8c0c: 261015c8 */ addiu $s0,$s0,%lo(var800915c8) +/* 8c00: 3c108009 */ lui $s0,%hi(g_AudioManager) +/* 8c04: 3c128009 */ lui $s2,%hi(g_AudioManager+0x0c) +/* 8c08: 265215d4 */ addiu $s2,$s2,%lo(g_AudioManager+0x0c) +/* 8c0c: 261015c8 */ addiu $s0,$s0,%lo(g_AudioManager) .L00008c10: /* 8c10: 240a0060 */ addiu $t2,$zero,0x60 /* 8c14: afaa0010 */ sw $t2,0x10($sp) @@ -817,8 +811,8 @@ glabel amgrCreate /* 9074: 5420fff6 */ bnezl $at,.L00009050 /* 9078: 92b80000 */ lbu $t8,0x0($s5) .L0000907c: -/* 907c: 3c048009 */ lui $a0,%hi(var80091880) -/* 9080: 24841880 */ addiu $a0,$a0,%lo(var80091880) +/* 907c: 3c048009 */ lui $a0,%hi(g_AudioManager+0x2b8) +/* 9080: 24841880 */ addiu $a0,$a0,%lo(g_AudioManager+0x2b8) /* 9084: 0c00bee8 */ jal func0002fba0 /* 9088: 00e02825 */ or $a1,$a3,$zero /* 908c: 00002025 */ or $a0,$zero,$zero @@ -826,12 +820,12 @@ glabel amgrCreate /* 9094: 2405003c */ addiu $a1,$zero,0x3c /* 9098: 3c088009 */ lui $t0,%hi(g_AudioSp) /* 909c: 8d0818f0 */ lw $t0,%lo(g_AudioSp)($t0) -/* 90a0: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* 90a0: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* 90a4: 3c067001 */ lui $a2,%hi(amgrMain) /* 90a8: 24090014 */ addiu $t1,$zero,0x14 /* 90ac: afa90014 */ sw $t1,0x14($sp) /* 90b0: 24c69154 */ addiu $a2,$a2,%lo(amgrMain) -/* 90b4: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* 90b4: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* 90b8: 24050004 */ addiu $a1,$zero,0x4 /* 90bc: 00003825 */ or $a3,$zero,$zero /* 90c0: 0c000fb8 */ jal osCreateThread @@ -849,15 +843,15 @@ glabel amgrCreate void amgrStartThread(void) { - osStartThread(&g_AudioThread); + osStartThread(&g_AudioManager.thread); g_AudioIsThreadRunning = true; } GLOBAL_ASM( glabel amgr0009118 -/* 9118: 3c028009 */ lui $v0,%hi(var80091810) +/* 9118: 3c028009 */ lui $v0,%hi(g_AudioManager+0x248) /* 911c: 03e00008 */ jr $ra -/* 9120: 24421810 */ addiu $v0,$v0,%lo(var80091810) +/* 9120: 24421810 */ addiu $v0,$v0,%lo(g_AudioManager+0x248) ); /** @@ -868,7 +862,7 @@ glabel amgr0009118 void amgrStopThread(void) { if (g_AudioIsThreadRunning) { - osStopThread(&g_AudioThread); + osStopThread(&g_AudioManager.thread); } } @@ -885,7 +879,7 @@ glabel amgrMain /* 9174: 2dce0001 */ sltiu $t6,$t6,0x1 /* 9178: 3c048009 */ lui $a0,%hi(g_SchedThread) /* 917c: 3c058009 */ lui $a1,%hi(var800918d0) -/* 9180: 3c068009 */ lui $a2,%hi(var80091810) +/* 9180: 3c068009 */ lui $a2,%hi(g_AudioManager+0x248) /* 9184: afbe0038 */ sw $s8,0x38($sp) /* 9188: afb70034 */ sw $s7,0x34($sp) /* 918c: afb60030 */ sw $s6,0x30($sp) @@ -897,7 +891,7 @@ glabel amgrMain /* 91a4: 00009825 */ or $s3,$zero,$zero /* 91a8: afa00064 */ sw $zero,0x64($sp) /* 91ac: afa00060 */ sw $zero,0x60($sp) -/* 91b0: 24c61810 */ addiu $a2,$a2,%lo(var80091810) +/* 91b0: 24c61810 */ addiu $a2,$a2,%lo(g_AudioManager+0x248) /* 91b4: 24a518d0 */ addiu $a1,$a1,%lo(var800918d0) /* 91b8: 2484dbd0 */ addiu $a0,$a0,%lo(g_SchedThread) /* 91bc: 0c00078c */ jal osScAddClient @@ -914,8 +908,8 @@ glabel amgrMain /* 91e8: 24170004 */ addiu $s7,$zero,0x4 /* 91ec: 27b60064 */ addiu $s6,$sp,0x64 .L000091f0: -/* 91f0: 3c048009 */ lui $a0,%hi(var80091810) -/* 91f4: 24841810 */ addiu $a0,$a0,%lo(var80091810) +/* 91f0: 3c048009 */ lui $a0,%hi(g_AudioManager+0x248) +/* 91f4: 24841810 */ addiu $a0,$a0,%lo(g_AudioManager+0x248) /* 91f8: 02c02825 */ or $a1,$s6,$zero /* 91fc: 0c0121bc */ jal osRecvMesg /* 9200: 24060001 */ addiu $a2,$zero,0x1 @@ -939,12 +933,12 @@ glabel amgrMain /* 9244: 3c188009 */ lui $t8,%hi(var80092828) /* 9248: 8f182828 */ lw $t8,%lo(var80092828)($t8) /* 924c: 24010003 */ addiu $at,$zero,0x3 -/* 9250: 3c048009 */ lui $a0,%hi(var800915d0) +/* 9250: 3c048009 */ lui $a0,%hi(g_AudioManager+0x8) /* 9254: 0301001b */ divu $zero,$t8,$at /* 9258: 0000c810 */ mfhi $t9 /* 925c: 00194080 */ sll $t0,$t9,0x2 /* 9260: 00882021 */ addu $a0,$a0,$t0 -/* 9264: 8c8415d0 */ lw $a0,%lo(var800915d0)($a0) +/* 9264: 8c8415d0 */ lw $a0,%lo(g_AudioManager+0x8)($a0) /* 9268: 0c002512 */ jal amgrHandleFrameMsg /* 926c: 8fa50060 */ lw $a1,0x60($sp) /* 9270: 0c002682 */ jal func00009a08 @@ -961,9 +955,9 @@ glabel amgrMain /* 929c: 006d082b */ sltu $at,$v1,$t5 /* 92a0: 01014023 */ subu $t0,$t0,$at /* 92a4: aea30004 */ sw $v1,0x4($s5) -/* 92a8: 3c018009 */ lui $at,%hi(var80091574) +/* 92a8: 3c018009 */ lui $at,%hi(var80091570+0x4) /* 92ac: 006d4823 */ subu $t1,$v1,$t5 -/* 92b0: ac291574 */ sw $t1,%lo(var80091574)($at) +/* 92b0: ac291574 */ sw $t1,%lo(var80091570+0x4)($at) /* 92b4: ac281570 */ sw $t0,0x1570($at) /* 92b8: 240100f0 */ addiu $at,$zero,0xf0 /* 92bc: 0241001a */ div $zero,$s2,$at @@ -1037,8 +1031,8 @@ glabel amgrMain /* 93c0: ae2f0004 */ sw $t7,0x4($s1) .L000093c4: /* 93c4: 8f18d514 */ lw $t8,%lo(var8005d514)($t8) -/* 93c8: 3c048009 */ lui $a0,%hi(var80091848) -/* 93cc: 24841848 */ addiu $a0,$a0,%lo(var80091848) +/* 93c8: 3c048009 */ lui $a0,%hi(g_AudioManager+0x280) +/* 93cc: 24841848 */ addiu $a0,$a0,%lo(g_AudioManager+0x280) /* 93d0: 17000003 */ bnez $t8,.L000093e0 /* 93d4: 27a50060 */ addiu $a1,$sp,0x60 /* 93d8: 0c0121bc */ jal osRecvMesg @@ -1057,9 +1051,9 @@ glabel amgrMain .L00009404: /* 9404: 1260ff7a */ beqz $s3,.L000091f0 /* 9408: 00000000 */ nop -/* 940c: 3c048009 */ lui $a0,%hi(var80091880) -/* 9410: 0c00bf03 */ jal func0002fc0c -/* 9414: 24841880 */ addiu $a0,$a0,%lo(var80091880) +/* 940c: 3c048009 */ lui $a0,%hi(g_AudioManager+0x2b8) +/* 9410: 0c00bf03 */ jal alClose +/* 9414: 24841880 */ addiu $a0,$a0,%lo(g_AudioManager+0x2b8) /* 9418: 8fbf003c */ lw $ra,0x3c($sp) /* 941c: 8fb00018 */ lw $s0,0x18($sp) /* 9420: 8fb1001c */ lw $s1,0x1c($sp) @@ -1074,6 +1068,69 @@ glabel amgrMain /* 9444: 27bd0070 */ addiu $sp,$sp,0x70 ); +// Mismatch: needs bss relocation +//void amgrMain(void *arg) +//{ +// s32 count = 0; // s2 +// bool done = false; // s3 +// s16 *msg = NULL; // 64 +// AudioInfo *info = NULL; // 60 +// +// static u32 var8005d514; +// static u64 var80091570; +// static u64 var80091578; +// +// osScAddClient(&g_SchedThread, &var800918d0, &g_AudioManager.audioFrameMsgQ, (void *)!IS4MB()); +// +// while (!done) { +// osRecvMesg(&g_AudioManager.audioFrameMsgQ, (OSMesg *) &msg, OS_MESG_BLOCK); +// +// switch (*msg) { +// case 4: +// var80091588 = func00049120(); +// func00009aa0(0x30000); +// amgrHandleFrameMsg(var800915d0[var80092828 % 3], info); +// func00009a08(); +// +// count++; +// func00009aa0(0x60000); +// +// var80091590 = func00049120(); +// var80091570 = var80091590 - var80091588; +// +// // 2d8 +// if (count % 240 == 0) { +// var80091578 = var80091580 / 240; +// var80091568 = 0; +// var80091580 = 0; +// } else { +// // 34c +// var80091580 = (var80091580 + var80091590) - var80091588; +// } +// +// if (var80091568 < var80091590 - var80091588) { +// var80091568 = var80091590 - var80091588; +// } +// +// if (var8005d514 == 0) { +// osRecvMesg(&g_AudioManager.audioReplyMsgQ, (OSMesg *) &info, OS_MESG_BLOCK); +// } +// +// var8005d514 = 0; +// amgrHandleDoneMsg(info); +// break; +// case 5: +// done = true; +// break; +// case 10: +// done = true; +// break; +// } +// } +// +// alClose(&g_AudioManager.g); +//} + GLOBAL_ASM( glabel amgrHandleFrameMsg /* 9448: 3c068009 */ lui $a2,%hi(g_AmgrCurrentCmdList) @@ -1096,11 +1153,11 @@ glabel amgrHandleFrameMsg /* 9488: 3c198006 */ lui $t9,%hi(var8005cf90) /* 948c: 8f39cf90 */ lw $t9,%lo(var8005cf90)($t9) /* 9490: 3c0ea450 */ lui $t6,0xa450 -/* 9494: 3c098009 */ lui $t1,%hi(var800915c8) +/* 9494: 3c098009 */ lui $t1,%hi(g_AudioManager) /* 9498: 00194080 */ sll $t0,$t9,0x2 /* 949c: 8dcf0004 */ lw $t7,0x4($t6) /* 94a0: 01284821 */ addu $t1,$t1,$t0 -/* 94a4: 8d2915c8 */ lw $t1,%lo(var800915c8)($t1) +/* 94a4: 8d2915c8 */ lw $t1,%lo(g_AudioManager)($t1) /* 94a8: 000fc082 */ srl $t8,$t7,0x2 /* 94ac: afb8002c */ sw $t8,0x2c($sp) /* 94b0: afa90024 */ sw $t1,0x24($sp) @@ -1153,11 +1210,11 @@ glabel amgrHandleFrameMsg /* 9560: 3c088006 */ lui $t0,%hi(var8005a0b0) /* 9564: 24639fe0 */ addiu $v1,$v1,%lo(var80059fe0) /* 9568: 24040002 */ addiu $a0,$zero,0x2 -/* 956c: 3c198009 */ lui $t9,%hi(var80091848) +/* 956c: 3c198009 */ lui $t9,%hi(g_AudioManager+0x280) /* 9570: 2508a0b0 */ addiu $t0,$t0,%lo(var8005a0b0) /* 9574: 3c0a8006 */ lui $t2,%hi(var8005b4d0) /* 9578: 3c0b8009 */ lui $t3,%hi(var8008a2d0) -/* 957c: 27391848 */ addiu $t9,$t9,%lo(var80091848) +/* 957c: 27391848 */ addiu $t9,$t9,%lo(g_AudioManager+0x280) /* 9580: 01034823 */ subu $t1,$t0,$v1 /* 9584: 254ab4d0 */ addiu $t2,$t2,%lo(var8005b4d0) /* 9588: 256ba2d0 */ addiu $t3,$t3,%lo(var8008a2d0) @@ -1223,7 +1280,7 @@ glabel amgrHandleFrameMsg // amgrClearDmaBuffers(); // // somevalue = vara4500004 / 4; -// datastart = var800915c8[var8005cf90]; +// datastart = g_AudioManager.ACMDList[var8005cf90]; // outbuffer = (s16 *) osVirtualToPhysical(info->data); // // if (previnfo) { @@ -1267,7 +1324,7 @@ glabel amgrHandleFrameMsg // g_AmgrCurrentCmdList = task; //} -void amgrHandleDoneMsg(struct audioinfo *info) +void amgrHandleDoneMsg(AudioInfo *info) { static bool firsttime = true; diff --git a/src/lib/lib_0e9d0.c b/src/lib/lib_0e9d0.c index ff5ece507..d390df6ee 100644 --- a/src/lib/lib_0e9d0.c +++ b/src/lib/lib_0e9d0.c @@ -2171,10 +2171,10 @@ glabel func0000fe88 /* fe94: afb00028 */ sw $s0,0x28($sp) /* fe98: 0c012230 */ jal osGetThreadPri /* fe9c: 00002025 */ or $a0,$zero,$zero -/* fea0: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* fea0: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* fea4: 00408025 */ or $s0,$v0,$zero /* fea8: 0c012230 */ jal osGetThreadPri -/* feac: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* feac: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* feb0: 00002025 */ or $a0,$zero,$zero /* feb4: 0c01210c */ jal osSetThreadPri /* feb8: 24450001 */ addiu $a1,$v0,0x1 @@ -2832,9 +2832,9 @@ glabel func00010718 /* 10730: 0c012230 */ jal osGetThreadPri /* 10734: 00002025 */ or $a0,$zero,$zero /* 10738: 2408ffff */ addiu $t0,$zero,-1 -/* 1073c: 3c048009 */ lui $a0,%hi(g_AudioThread) +/* 1073c: 3c048009 */ lui $a0,%hi(g_AudioManager+0x18) /* 10740: afa2003c */ sw $v0,0x3c($sp) -/* 10744: 248415e0 */ addiu $a0,$a0,%lo(g_AudioThread) +/* 10744: 248415e0 */ addiu $a0,$a0,%lo(g_AudioManager+0x18) /* 10748: 0c012230 */ jal osGetThreadPri /* 1074c: afa80038 */ sw $t0,0x38($sp) /* 10750: 00002025 */ or $a0,$zero,$zero diff --git a/src/lib/lib_2fba0.c b/src/lib/lib_2fba0.c index 61b716063..4b95105ad 100644 --- a/src/lib/lib_2fba0.c +++ b/src/lib/lib_2fba0.c @@ -46,7 +46,7 @@ glabel func0002fba0 ); GLOBAL_ASM( -glabel func0002fc0c +glabel alClose /* 2fc0c: 27bdffe8 */ addiu $sp,$sp,-24 /* 2fc10: afbf0014 */ sw $ra,0x14($sp) /* 2fc14: afa40018 */ sw $a0,0x18($sp)