Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/audio/heap.h
7858 views
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
{
20
u8 *start;
21
u8 *cur;
22
u32 size;
23
s32 numAllocatedEntries;
24
}; // size = 0x10
25
26
struct SeqOrBankEntry {
27
u8 *ptr;
28
u32 size;
29
#ifdef VERSION_SH
30
s16 poolIndex;
31
s16 id;
32
#else
33
s32 id; // seqId or bankId
34
#endif
35
}; // size = 0xC
36
37
struct PersistentPool
38
{
39
/*0x00*/ u32 numEntries;
40
/*0x04*/ struct SoundAllocPool pool;
41
/*0x14*/ struct SeqOrBankEntry entries[32];
42
}; // size = 0x194
43
44
struct TemporaryPool
45
{
46
/*EU, SH*/
47
/*0x00, 0x00*/ u32 nextSide;
48
/*0x04, */ struct SoundAllocPool pool;
49
/*0x04, pool.start */
50
/*0x08, pool.cur */
51
/*0x0C, 0x0C pool.size */
52
/*0x10, 0x10 pool.numAllocatedEntries */
53
/*0x14, */ struct SeqOrBankEntry entries[2];
54
/*0x14, 0x14 entries[0].ptr */
55
/*0x18, entries[0].size*/
56
/*0x1C, 0x1E entries[0].id */
57
/*0x20, 0x20 entries[1].ptr */
58
/*0x24, entries[1].size*/
59
/*0x28, 0x2A entries[1].id */
60
}; // size = 0x2C
61
62
struct SoundMultiPool
63
{
64
/*0x000*/ struct PersistentPool persistent;
65
/*0x194*/ struct TemporaryPool temporary;
66
/* */ u32 pad2[4];
67
}; // size = 0x1D0
68
69
struct Unk1Pool
70
{
71
struct SoundAllocPool pool;
72
struct SeqOrBankEntry entries[32];
73
};
74
75
struct UnkEntry
76
{
77
s8 used;
78
s8 medium;
79
s8 bankId;
80
u32 pad;
81
u8 *srcAddr;
82
u8 *dstAddr;
83
u32 size;
84
};
85
86
struct UnkPool
87
{
88
/*0x00*/ struct SoundAllocPool pool;
89
/*0x10*/ struct UnkEntry entries[64];
90
/*0x510*/ s32 numEntries;
91
/*0x514*/ u32 unk514;
92
};
93
94
extern u8 gAudioHeap[];
95
extern s16 gVolume;
96
extern s8 gReverbDownsampleRate;
97
extern struct SoundAllocPool gAudioInitPool;
98
extern struct SoundAllocPool gNotesAndBuffersPool;
99
extern struct SoundAllocPool gPersistentCommonPool;
100
extern struct SoundAllocPool gTemporaryCommonPool;
101
extern struct SoundMultiPool gSeqLoadedPool;
102
extern struct SoundMultiPool gBankLoadedPool;
103
#ifdef VERSION_SH
104
extern struct Unk1Pool gUnkPool1;
105
extern struct UnkPool gUnkPool2;
106
extern struct UnkPool gUnkPool3;
107
#endif
108
extern u8 gBankLoadStatus[64];
109
extern u8 gSeqLoadStatus[256];
110
extern volatile u8 gAudioResetStatus;
111
extern u8 gAudioResetPresetIdToLoad;
112
113
#if defined(VERSION_EU) || defined(VERSION_SH)
114
extern volatile u8 gAudioResetStatus;
115
#endif
116
117
void *soundAlloc(struct SoundAllocPool *pool, u32 size);
118
void *sound_alloc_uninitialized(struct SoundAllocPool *pool, u32 size);
119
void sound_init_main_pools(s32 sizeForAudioInitPool);
120
void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size);
121
#ifdef VERSION_SH
122
void *alloc_bank_or_seq(s32 poolIdx, s32 size, s32 arg3, s32 id);
123
void *get_bank_or_seq(s32 poolIdx, s32 arg1, s32 id);
124
#else
125
void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id);
126
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id);
127
#endif
128
#if defined(VERSION_EU) || defined(VERSION_SH)
129
s32 audio_shut_down_and_reset_step(void);
130
void audio_reset_session(void);
131
#else
132
void audio_reset_session(struct AudioSessionSettings *preset);
133
#endif
134
void discard_bank(s32 bankId);
135
136
#ifdef VERSION_SH
137
void fill_filter(s16 filter[8], s32 arg1, s32 arg2);
138
u8 *func_sh_802f1d40(u32 size, s32 bank, u8 *arg2, s8 medium);
139
u8 *func_sh_802f1d90(u32 size, s32 bank, u8 *arg2, s8 medium);
140
void *unk_pool1_lookup(s32 poolIdx, s32 id);
141
void *unk_pool1_alloc(s32 poolIndex, s32 arg1, u32 size);
142
#endif
143
144
#endif // AUDIO_HEAP_H
145
146