sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

heap.h (4117B)


      1 #ifndef AUDIO_HEAP_H
      2 #define AUDIO_HEAP_H
      3 
      4 #include <PR/ultratypes.h>
      5 
      6 #include "internal.h"
      7 
      8 #define SOUND_LOAD_STATUS_NOT_LOADED     0
      9 #define SOUND_LOAD_STATUS_IN_PROGRESS    1
     10 #define SOUND_LOAD_STATUS_COMPLETE       2
     11 #define SOUND_LOAD_STATUS_DISCARDABLE    3
     12 #define SOUND_LOAD_STATUS_4              4
     13 #define SOUND_LOAD_STATUS_5              5
     14 
     15 #define IS_BANK_LOAD_COMPLETE(bankId) (gBankLoadStatus[bankId] >= SOUND_LOAD_STATUS_COMPLETE)
     16 #define IS_SEQ_LOAD_COMPLETE(seqId) (gSeqLoadStatus[seqId] >= SOUND_LOAD_STATUS_COMPLETE)
     17 
     18 struct SoundAllocPool {
     19     u8 *start;
     20     u8 *cur;
     21     u32 size;
     22     s32 numAllocatedEntries;
     23 }; // size = 0x10
     24 
     25 struct SeqOrBankEntry {
     26     u8 *ptr;
     27     u32 size;
     28 #if defined(VERSION_SH) || defined(VERSION_CN)
     29     s16 poolIndex;
     30     s16 id;
     31 #else
     32     s32 id; // seqId or bankId
     33 #endif
     34 }; // size = 0xC
     35 
     36 struct PersistentPool {
     37     /*0x00*/ u32 numEntries;
     38     /*0x04*/ struct SoundAllocPool pool;
     39     /*0x14*/ struct SeqOrBankEntry entries[32];
     40 }; // size = 0x194
     41 
     42 struct TemporaryPool {
     43     /*EU,   SH*/
     44     /*0x00, 0x00*/ u32 nextSide;
     45     /*0x04,     */ struct SoundAllocPool pool;
     46     /*0x04,        pool.start     */
     47     /*0x08,        pool.cur       */
     48     /*0x0C, 0x0C   pool.size      */
     49     /*0x10, 0x10   pool.numAllocatedEntries */
     50     /*0x14,     */ struct SeqOrBankEntry entries[2];
     51     /*0x14, 0x14   entries[0].ptr */
     52     /*0x18,        entries[0].size*/
     53     /*0x1C, 0x1E   entries[0].id  */
     54     /*0x20, 0x20   entries[1].ptr */
     55     /*0x24,        entries[1].size*/
     56     /*0x28, 0x2A   entries[1].id  */
     57 }; // size = 0x2C
     58 
     59 struct SoundMultiPool {
     60     /*0x000*/ struct PersistentPool persistent;
     61     /*0x194*/ struct TemporaryPool temporary;
     62     /*     */ u32 pad2[4];
     63 }; // size = 0x1D0
     64 
     65 struct Unk1Pool {
     66     struct SoundAllocPool pool;
     67     struct SeqOrBankEntry entries[32];
     68 };
     69 
     70 struct UnkEntry {
     71     s8 used;
     72     s8 medium;
     73     s8 bankId;
     74     u32 pad;
     75     u8 *srcAddr;
     76     u8 *dstAddr;
     77     u32 size;
     78 };
     79 
     80 struct UnkPool {
     81     /*0x00*/  struct SoundAllocPool pool;
     82     /*0x10*/  struct UnkEntry entries[64];
     83     /*0x510*/ s32 numEntries;
     84     /*0x514*/ u32 unk514;
     85 };
     86 
     87 extern u8 gAudioHeap[];
     88 extern s16 gVolume;
     89 extern s8 gReverbDownsampleRate;
     90 extern struct SoundAllocPool gAudioInitPool;
     91 extern struct SoundAllocPool gNotesAndBuffersPool;
     92 extern struct SoundAllocPool gPersistentCommonPool;
     93 extern struct SoundAllocPool gTemporaryCommonPool;
     94 extern struct SoundMultiPool gSeqLoadedPool;
     95 extern struct SoundMultiPool gBankLoadedPool;
     96 #if defined(VERSION_SH) || defined(VERSION_CN)
     97 extern struct Unk1Pool gUnkPool1;
     98 extern struct UnkPool gUnkPool2;
     99 extern struct UnkPool gUnkPool3;
    100 #endif
    101 extern u8 gBankLoadStatus[64];
    102 extern u8 gSeqLoadStatus[256];
    103 extern volatile u8 gAudioResetStatus;
    104 extern u8 gAudioResetPresetIdToLoad;
    105 
    106 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
    107 extern volatile u8 gAudioResetStatus;
    108 #endif
    109 
    110 void *soundAlloc(struct SoundAllocPool *pool, u32 size);
    111 void *sound_alloc_uninitialized(struct SoundAllocPool *pool, u32 size);
    112 void sound_init_main_pools(s32 sizeForAudioInitPool);
    113 void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size);
    114 #if defined(VERSION_SH) || defined(VERSION_CN)
    115 void *alloc_bank_or_seq(s32 poolIdx, s32 size, s32 arg3, s32 id);
    116 void *get_bank_or_seq(s32 poolIdx, s32 arg1, s32 id);
    117 #else
    118 void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id);
    119 void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id);
    120 #endif
    121 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
    122 s32 audio_shut_down_and_reset_step(void);
    123 void audio_reset_session(void);
    124 #else
    125 void audio_reset_session(struct AudioSessionSettings *preset);
    126 #endif
    127 void discard_bank(s32 bankId);
    128 
    129 #if defined(VERSION_SH) || defined(VERSION_CN)
    130 void fill_filter(s16 filter[8], s32 arg1, s32 arg2);
    131 u8 *func_sh_802f1d40(u32 size, s32 bank, u8 *arg2, s8 medium);
    132 u8 *func_sh_802f1d90(u32 size, s32 bank, u8 *arg2, s8 medium);
    133 void *unk_pool1_lookup(s32 poolIdx, s32 id);
    134 void *unk_pool1_alloc(s32 poolIndex, s32 arg1, u32 size);
    135 #endif
    136 
    137 #endif // AUDIO_HEAP_H