Audio header

This commit is contained in:
Ethan Roseman 2020-12-10 07:53:35 +09:00
parent bec22c22e4
commit 8243e81b2e
8 changed files with 1469 additions and 1120 deletions

View File

@ -260,7 +260,7 @@ glabel D_80078168
glabel D_80078170
.word 0x00000000
glabel D_80078174
glabel nuAuPreNMIFunc
.word 0x00000000
glabel D_80078178

View File

@ -158,8 +158,8 @@ glabel func_8004AB00
/* 26154 8004AD54 248491A0 */ addiu $a0, $a0, %lo(D_800B91A0)
/* 26158 8004AD58 3C028005 */ lui $v0, %hi(D_8004B328)
/* 2615C 8004AD5C 2442B328 */ addiu $v0, $v0, %lo(D_8004B328)
/* 26160 8004AD60 3C018008 */ lui $at, %hi(D_80078174)
/* 26164 8004AD64 AC228174 */ sw $v0, %lo(D_80078174)($at)
/* 26160 8004AD60 3C018008 */ lui $at, %hi(nuAuPreNMIFunc)
/* 26164 8004AD64 AC228174 */ sw $v0, %lo(nuAuPreNMIFunc)($at)
/* 26168 8004AD68 0C015894 */ jal func_80056250
/* 2616C 8004AD6C 27A50018 */ addiu $a1, $sp, 0x18
/* 26170 8004AD70 8FA40020 */ lw $a0, 0x20($sp)

View File

@ -145,8 +145,8 @@ glabel func_8004AE08
/* 26408 8004B008 0040302D */ daddu $a2, $v0, $zero
/* 2640C 8004B00C 0C015970 */ jal alAudioFrame
/* 26410 8004B010 02A0382D */ daddu $a3, $s5, $zero
/* 26414 8004B014 3C038008 */ lui $v1, %hi(D_80078174)
/* 26418 8004B018 8C638174 */ lw $v1, %lo(D_80078174)($v1)
/* 26414 8004B014 3C038008 */ lui $v1, %hi(nuAuPreNMIFunc)
/* 26418 8004B018 8C638174 */ lw $v1, %lo(nuAuPreNMIFunc)($v1)
/* 2641C 8004B01C 1060FFA0 */ beqz $v1, .L8004AEA0
/* 26420 8004B020 AFA2007C */ sw $v0, 0x7c($sp)
/* 26424 8004B024 92E20000 */ lbu $v0, ($s7)
@ -158,8 +158,8 @@ glabel func_8004AE08
/* 2643C 8004B03C 08012C19 */ j .L8004B064
/* 26440 8004B040 00000000 */ nop
.L8004B044:
/* 26444 8004B044 3C028008 */ lui $v0, %hi(D_80078174)
/* 26448 8004B048 8C428174 */ lw $v0, %lo(D_80078174)($v0)
/* 26444 8004B044 3C028008 */ lui $v0, %hi(nuAuPreNMIFunc)
/* 26448 8004B048 8C428174 */ lw $v0, %lo(nuAuPreNMIFunc)($v0)
/* 2644C 8004B04C 10400005 */ beqz $v0, .L8004B064
/* 26450 8004B050 00000000 */ nop
/* 26454 8004B054 3C058008 */ lui $a1, %hi(D_80078170)

346
include/nu/nualsgi.h Normal file
View File

@ -0,0 +1,346 @@
/*======================================================================*/
/* NuSYS Audio Library for SGI Library & naudio */
/* nualsgi.h */
/* */
/* Copyright (C) 1997, NINTENDO Co,Ltd. */
/* */
/* $Id: nualsgi.h,v 1.10 1999/01/14 05:45:36 ohki Exp ohki $ */
/*======================================================================*/
#ifndef _NUALSGI_H_
#define _NUALSGI_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* DEFINE */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* AUDIO MANAGER DEFINE */
/*----------------------------------------------------------------------*/
/* AUDIO HEAP calculation */
/* */
/* (1) alInit heap size */
/* AUDIO HEAP calls the function alHeapAlloc to allocate heap memory when synthesizer, */
/* sequence, or sound drivers are initialized. */
/* The size of the alHeap area required is determined as follows. */
/* */
/* */
/* 144 + maxPVoices * 432 + 32 * maxUPdates + FxType */
/* */
/* FxType varies with the type of effect and takes the following values. */
/* AL_FX_NONE 0 */
/* AL_FX_SMALLROOM 8192 */
/* AL_FX_BIGROOM 8224 */
/* AL_FX_ECHO 1640 */
/* AL_FX_CHORUS 304 */
/* AL_FX_FLANGE 304 */
/* */
/* (2) Heap size for alSeqpNew and alCSPNew */
/* */
/* maxChannels * 16 + maxVoices * 64 + maxEvents * 32 */
/* */
/* (3)Heap size for alSndpNew */
/* */
/* maxSounds * 48 + maxEvents * 32 */
/* */
/*----------------------------------------------------------------------*/
/*--------------------------------------*/
/* SYNTHE DEFINE */
/*--------------------------------------*/
#define NU_AU_SYN_VVOICE_MAX 64 /* Maximum number of virtual voices (Not actually used).*/
#define NU_AU_SYN_PVOICE_MAX 32 /* Maximum number of physical voices. */
#define NU_AU_SYN_UPDATE_MAX 128 /* Maximum number of synthesizer parameter updates*/
#define NU_AU_SYN_HEAP_SIZE (144+NU_AU_SYN_PVOICE_MAX*432+32*NU_AU_SYN_UPDATE_MAX+0x2000)
/*--------------------------------------*/
/* SEQUENCE DEFINE */
/*--------------------------------------*/
#define NU_AU_SEQ_VOICE_MAX 24 /* Maximum number of voices*/
#define NU_AU_SEQ_EVENT_MAX 48 /* Number of events */
#define NU_AU_SEQ_CHANNEL_MAX 16 /* Number of MIDI channels (typically 16) */
#define NU_AU_SEQ_HEAP_SIZE (16*NU_AU_CHANNEL_MAX+32*NU_AU_EVENT_MAX)
#define NU_AU_SEQ_PLAYER0 0
#define NU_AU_SEQ_PLAYER1 1
#define NU_AU_SEQ_MODE_FADEOUT 0x0001
#define NU_AU_SEQ_MODE_PLAYPENDING 0x0002
/*--------------------------------------*/
/* SOUND DEFINE */
/*--------------------------------------*/
#define NU_AU_SND_SOUND_MAX 8 /* Maximum number of sounds*/
#define NU_AU_SND_EVENT_MAX (NU_AU_SND_SOUND_MAX*2) /* Maximum number of events */
#define NU_AU_SND_HEAP_SIZE (NU_AU_SND_SOUND_MAX*48+NU_AU_SND_EVENT*64)
/*--------------------------------------*/
/* AUDIO DMA DEFINE */
/*--------------------------------------*/
#define NU_AU_DMA_BUFFER_NUM 64 /* Number of DMA transfer buffers */
#define NU_AU_DMA_BUFFER_SIZE 1024 /* Size of the DMA buffer */
#define NU_AU_BUFFER_USE_FRAME 1 /* Frame interval for the cleared DMA buffer */
/*--------------------------------------*/
/* SOUND DEFINE */
/*--------------------------------------*/
#define NU_AU_MGR_THREAD_PRI 70
#define NU_AU_MGR_THREAD_ID 6
#define NU_AU_STACK_SIZE 0x2000
#define NU_AU_CLIST_LEN 0x800
#define NU_AU_CLIST_SIZE (NU_AU_CLIST_LEN*sizeof(Acmd)) /* Buffer size for the command list */
#define NU_AU_BUFFER_MAX 0x1000 /* Size of the buffer for the synthesizer */
#define NU_AU_OUTPUT_RATE 32000 /* Set the frequency. */
#define NU_AU_MESG_MAX 8
#define NU_AU_HEAP_MIN_SIZE (NU_AU_SND_HEAP_SIZE+NU_AU_SEQ_HEAP_SIZE+NU_AU_SYN_HEAP_SIZE+NU_AU_DMA_BUFFER_NUM*NU_AU_DMA_BUFFER_SIZE+NU_AU_CLIST_SIZE*2)
#define NU_AU_HEAP_SIZE 0x50000 /* Default HEAP size */
#define NU_AU_HEAP_ADDR (NU_GFX_FRAMEBUFFER_ADDR - NU_AU_HEAP_SIZE)
#ifdef N_AUDIO
#define NU_AU_AUDIO_SAMPLES 184 /* Sample number is a multiple of 16. */
#else
#define NU_AU_AUDIO_SAMPLES 16 /* Sample number is a multiple of 16. */
#endif /* N_AUDIO */
#define NU_AU_AUDIO_EXTRASMP 0 /* Number of extra samples */
#define NU_AU_TASK_STOP 0 /* Stop audio task execution. */
#define NU_AU_TASK_RUN 1 /* Allow audio task execution. */
#define NU_AU_AI_FIFO_MSG 0x100 /* AI event message */
#define NU_AU_AI_DEBUG_MSG 0x1000 /* For AI debugging */
#define NU_AU_FRAMERATE_NTSC 60 /* NTSC/MPAL */
#define NU_AU_FRAMERATE_PAL 50 /* PAL */
/*--------------------------------------*/
/* DEBUG & PERFORMANCE */
/*--------------------------------------*/
#define NU_AU_DEBUG_NORMAL 0x00000001 /* warning & error */
#define NU_AU_DEBUG_DISABLEDMA 0x00010000 /* disable dma callback */
#define NU_AU_DEBUG_DISABLEAI 0x00020000 /* disable set AI */
#define NU_AU_DEBUG_DISABLETASK 0x00040000 /* disable task */
#define NU_AU_DEBUG_FIFOOFF 0x00080000 /* FIFO EVENT OFF */
#define NU_AU_DEBUG_RETRACEOFF 0x00100000 /* RETRACE EVENT OFF */
#define NU_AU_DEBUG_NODMABUF 0x00000001 /* No DMA Buffer */
#define NU_AU_DEBUG_ACMDBUFOVER 0x00000002 /* Acmd buffer is small */
#define NU_AU_DEBUG_DMABUFSIZE 0x00000004 /* dma buffer size is small */
#define NU_AU_DEBUG_DMANOTCOMPLETE 0x00000008 /* dma not completed */
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
#include <ultra64.h>
#ifdef N_AUDIO
#include <PR/n_libaudio.h>
#include <PR/n_libaudio_s_to_n.h>
#else /* N_AUDIO */
#include <PR/libaudio.h>
#endif /* N_AUDIO */
/*--------------------------------------*/
/* audio typedef */
/*--------------------------------------*/
/*--------------------------------------*/
/* DMA BUFFER STRUCT */
/*--------------------------------------*/
typedef struct {
ALLink node; /* Pointer to the linked list*/
s32 startAddr; /* Address in data ROM */
s32 frameCnt; /* Buffer frame counter */
char* ptr; /* Value of the pointer to buffer */
} NUDMABuffer;
/*--------------------------------------*/
/* DMA callback for the Sequence Player */
/* DMA status used by the routines */
/* Structure that stores the use status of the DMABuffer*/
/*--------------------------------------*/
typedef struct {
u8 initialized; /* Flag indicating whether the structure has been initialized */
NUDMABuffer* firstUsed; /* Start of the DMA Buffer linked list being used */
NUDMABuffer* firstFree; /* Start of the free DMA Buffer linked list */
} NUDMAState;
/* Sequence Display structure*/
typedef struct st_Seqence{
ALCSPlayer player; /* Sequence Display structure */
ALCSeq sequence;
u8* data_ptr; /* Sequence data */
s32 seqno; /* Sequence No. */
u32 mode; /* Control extension */
u16 counter;
u16 speed;
} NUAuSeqPlayer;
typedef struct st_SndState {
ALSndId* Id;
u8 flag;
} NUAuSndId;
/*--------------------------------------*/
/* CALL BACK Function typedef */
/*--------------------------------------*/
typedef void (*NUAuPreNMIFunc)(NUScMsg,u32); /* PRENMI callback function */
typedef void (*NUAuMgrFunc)(void); /* Acmd callback function */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* extern variables */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*--------------------------------------*/
/* audio variables */
/*--------------------------------------*/
extern u64* nuAuMgrStack;
extern NUScTask nuAuTask; /* Audio task buffer*/
extern s16* nuAuBuffer_ptr[]; /* Audio buffer */
extern NUScClient nuAuClient;
extern OSThread nuAuMgrThread;
extern u32 nuAuFrameCounter; /* Frame counter */
extern ALHeap nuAuHeap; /* Heap structure */
extern NUAuSeqPlayer nuAuSeqPlayer[];
extern u8* nuAuSeqData;
extern ALBankFile* nuAuSeqBank_ptr;
extern ALSeqFile* nuAuSeqFile_ptr;
extern ALSndPlayer nuAuSndPlayer;
extern ALBankFile* nuAuSndBank_ptr;
extern ALSndId* nuAuSndId;
extern ALSynConfig nuAuSynConfig;
extern ALSeqpConfig nuAuSeqpConfig;
extern ALSndpConfig nuAnSndpConfig;
extern u8 nuAuTaskStop;
extern u8 nuAuPreNMI;
extern NUAuPreNMIFunc nuAuPreNMIFunc;
extern NUAuMgrFunc nuAuMgrFunc;
extern OSMesgQueue nuAuMesgQ; /* Audio Manager queue */
extern ALGlobals nuAuGlobal;
extern s16 nuAuDmaBufNum;
extern s16 nuAuDmaBufSize;
extern NUDMAState nuAuDmaState;
extern NUDMABuffer* nuAuDmaBuf;
extern Acmd* nuAuCmdListBuf; /* pointer of command list */
extern u32 nuAuAcmdLen;
extern u8 nuAuRetraceCount;
extern u32 nuAuDebFlag;
extern u32 nuAuDebStatus; /* Status flag */
extern u32 nuAuDebDmaCount; /* Total number of PI-DMAs */
extern u32 nuAuDebDmaFrame; /* DMA counter */
extern u32 nuAuDebDmaMax; /* Maximum number of PI-DMAs */
extern u32 nuAuDebDmaBufMaxUse;/* Maximum number of DMA buffers used */
extern u32 nuAuDebDmaCallbackCount;/* Total number of DMA callbacks */
extern u32 nuAuDebDmaCallbackFrame;/* Number of DMA callbacks */
extern u32 nuAuDebDmaCallbackMax; /* Maximum number of DMA callbacks*/
extern u32 nuAuDebAcmdLenMax; /* Maximum length of the audio command list */
extern s16 nuAuFrameSampleSize; /* Number of samples created at one time */
extern s16 nuAuExtraSampleSize; /* Number of extra samples */
extern ALSynConfig nuAuSynConfig;
extern ALSeqpConfig nuAuSeqpConfig;
extern ALSndpConfig nuAuSndpConfig;
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* Global Function */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*--------------------------------------*/
/* audio Manager function */
/*--------------------------------------*/
extern s32 nuAuInit(void);
extern s32 nuAuInitEx(void);
extern s32 nuAuMgrInit(void* heap_ptr, u32 size, ALSynConfig* synconfig);
extern s32 nuAuMgrInitEx(void* heap_ptr, u32 size, ALSynConfig* synConfig);
extern void nuAuSeqPlayerInit(ALSeqpConfig* seqpconfig, u32 size, u32 player_no);
extern void nuAuSeqPlayerBankSet(u8* bank_addr, u32 bank_size, u8* table_addr);
extern void nuAuSeqPlayerPlay(u32 player_no);
extern void nuAuSeqPlayerSeqSet(u8* seq_addr);
extern void nuAuSeqPlayerSetNo(u32 player_no ,u32 seq_no);
extern void nuAuSeqPlayerFadeOut(u32 player_no ,u32 speed);
extern void nuAuSeqPlayerControl(void);
extern void nuAuSndPlayerInit(ALSndpConfig* sndconfig);
extern void nuAuSndPlayerBankSet(u8* bank_addr, u32 bank_size, u8* table_addr);
extern ALSndId nuAuSndPlayerPlay(u32 sndNo);
extern void nuAuPreNMIFuncSet(NUAuPreNMIFunc func);
extern void nuAuPreNMIProc(NUScMsg mesg_type, u32 frameCounter);
extern void nuAuMgrFuncSet(NUAuMgrFunc func);
extern ALDMAproc nuAuDmaNew(NUDMAState **state);
extern void nuAuCleanDMABuffers(void);
extern void nuAuHeapInit(ALHeap* hp, u8* base, s32 len);
extern void* nuAuHeapAlloc(s32 length);
extern s32 nuAuHeapGetFree(void);
extern s32 nuAuHeapGetUsed(void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* MACRO */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* Delete the callback function */
#define nuAuPreNMIFuncRemove() nuAuPreNMIFuncSet(NULL)
#define nuAuMgrFuncRemove() nuAuMgrFuncSet(NULL)
#define nuAuSeqPlayerGetChlVol(player_no, chan) \
alCSPGetChlVol(&nuAuSeqPlayer[player_no].player, chan)
#define nuAuSeqPlayerGetChlFXMix(player_no, chan) \
alCSPGetChlFXMix(&nuAuSeqPlayer[player_no].player, chan)
#define nuAuSeqPlayerGetChlPan(player_no, chan) \
alCSPGetChlPan(&nuAuSeqPlayer[player_no].player, chan)
#define nuAuSeqPlayerGetChlPriority(player_no, chan) \
alCSPGetChlPriority(&nuAuSeqPlayer[player_no].player, chan)
#define nuAuSeqPlayerGetChlProgram(player_no, chan) \
alCSPGetChlProgram(&nuAuSeqPlayer[player_no].player, chan)
#define nuAuSeqPlayerGetSeq(player_no) \
alCSPGetSeq(&nuAuSeqPlayer[player_no].player)
#define nuAuSeqPlayerGetSeqno(player_no) \
nuAuSeqPlayer[player_no].seqno
#define nuAuSeqPlayerGetState(player_no) \
alCSPGetState(&nuAuSeqPlayer[player_no].player)
#define nuAuSeqPlayerGetTempo(player_no) \
alCSPGetTempo(&nuAuSeqPlayer[player_no].player)
#define nuAuSeqPlayerGetVol(player_no) \
alCSPGetVol(&nuAuSeqPlayer[player_no].player)
#define nuAuSeqPlayerStop(player_no) \
alCSPStop(&nuAuSeqPlayer[player_no].player)
#define nuAuSeqPlayerSetVol(player_no, vol) \
alCSPSetVol(&nuAuSeqPlayer[player_no].player, vol)
#define nuAuSeqPlayerSetTempo(player_no, tempo) \
alCSPSetTempo(&nuAuSeqPlayer[player_no].player, tempo)
#define nuAuSeqPlayerSetChlProgram(player_no, chan, prog) \
alCSPSetChlProgram(&nuAuSeqPlayer[player_no].player, chan, prog)
#define nuAuSeqPlayerSetChlPriority(player_no, chan, priority) \
alCSPSetChlPriority(&nuAuSeqPlayer[player_no].player, chan, priority)
#define nuAuSeqPlayerSetChlPan(player_no, chan, pan) \
alCSPSetChlPan(&nuAuSeqPlayer[player_no].player, chan, pan)
#define nuAuSeqPlayerSetChlFXMix(player_no, chan, fxmix) \
alCSPSetChlFXMix(&nuAuSeqPlayer[player_no].player, chan, fxmix)
#define nuAuSeqPlayerSetChlVol(player_no, chan, vol) \
alCSPSetChlVol(&nuAuSeqPlayer[player_no].player, chan, vol)
#define nuAuSeqPlayerSendMidi(player_no, ticks, status, byte1, byte2) \
alCSPSetPlayerSendMidi(&nuAuSeqPlayer[player_no].player, ticks, status, byte1, byte2)
#define nuAuSndPlayerGetState() alSndpGetState(&nuAuSndPlayer)
#define nuAuSndPlayerPlayAt(delta) alSndpPlayAt(&nuAuSndPlayer,delta)
#define nuAuSndPlayerSetFXMix(mix) alSndpSetFXMix(&nuAuSndPlayer,mix)
#define nuAuSndPlayerSetPan(pan) alSndpSetPan(&nuAuSndPlayer,pan)
#define nuAuSndPlayerSetPitch(pitch) alSndpSetPitch(&nuAuSndPlayer,pitch)
#define nuAuSndPlayerSetPriority(id,priority) alSndpSetPriority(&nuAuSndPlayer,id,priority)
#define nuAuSndPlayerSetVol(vol) alSndpSetVol(&nuAuSndPlayer,vol)
#define nuAuSndPlayerStop() alSndpStop(&nuAuSndPlayer)
#define nuAuSndPlayerSetSound(SndId) alSndpSetSound(&nuAuSndPlayer,SndId)
/*----------------------------------------------------------------------*/
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* _NUALSGI_H_ */

View File

@ -1,21 +1,23 @@
#include "common.h"
#include "nu/nusys.h"
#include "nu/nualsgi.h"
INCLUDE_ASM(s32, "code_25f00_len_940", func_8004AB00);
void func_8004ADD0(s32 arg0) {
OSIntMask osIntMask = osSetIntMask(OS_IM_NONE);
void nuAuPreNMIFuncSet(NUAuPreNMIFunc func) {
OSIntMask mask = osSetIntMask(OS_IM_NONE);
D_80078174 = arg0;
osSetIntMask(osIntMask);
nuAuPreNMIFunc = func;
osSetIntMask(mask);
}
INCLUDE_ASM(s32, "code_25f00_len_940", func_8004AE08);
INCLUDE_ASM(s32, "code_25f00_len_940", nuAuDmaCallBack);
INCLUDE_ASM(s32, "code_25f00_len_940", nuAuDmaNew);
INCLUDE_ASM(ALDMAproc, "code_25f00_len_940", nuAuDmaNew, NUDMAState **state);
INCLUDE_ASM(s32, "code_25f00_len_940", nuAuCleanDMABuffers);
INCLUDE_ASM(void, "code_25f00_len_940", nuAuCleanDMABuffers);
INCLUDE_ASM(s32, "code_25f00_len_940", func_8004B328);

View File

@ -222,6 +222,7 @@ spawn_drops = 0x80048280;
get_coin_drop_amount = 0x80048D50;
is_point_within_region = 0x80048FD4;
DoBasicAI = 0x8004A47C;
nuAuPreNMIFuncSet = 0x8004ADD0;
nuAuDmaCallBack = 0x8004B074; // !
nuAuDmaNew = 0x8004B224;
nuAuCleanDMABuffers = 0x8004B268;
@ -561,6 +562,7 @@ setup_demo_player = 0x80072D2C;
load_demo_battle = 0x80072E14;
EnemyNpcHit = 0x80077F70;
EnemyNpcDefeat = 0x8007809C;
nuAuPreNMIFunc = 0x80078174;
D_80078DB0 = 0x80078DB0;
D_80078DB4 = 0x80078DB4;
gEffectTable = 0x8007F214;

View File

@ -118,7 +118,6 @@ D_80078160 = 0x80078160;
D_80078164 = 0x80078164;
D_80078168 = 0x80078168;
D_80078170 = 0x80078170;
D_80078174 = 0x80078174;
D_80078178 = 0x80078178;
D_8007817C = 0x8007817C;
D_80078180 = 0x80078180;