Skip to content

Commit ddb6ef1

Browse files
bodyprog: sound system recognition
1 parent 87ef956 commit ddb6ef1

7 files changed

Lines changed: 304 additions & 291 deletions

File tree

configs/USA/sym.bodyprog.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,15 @@ Sd_PlaySfx = 0x80046048; // type:func
463463
Sd_LastVoiceKeyOff = 0x800468EC; // type:func
464464
Sd_AllVoicesKeyOff = 0x800469AC; // type:func
465465
Sd_AllVoicesKeyOffVWithRROff = 0x800469E8; // type:func
466+
Sd_XaAudioPlay = 0x80046D3C;
467+
Sd_XaAudioLengthGet = 0x80046DCC;
466468
Sd_SetVolume = 0x80047798; // type:func
467469
Sd_SetVolBgm = 0x80047808; // type:func
468470
Sd_SetVolXa = 0x80047860; // type:func
469471
Sd_GetVolSe = 0x800478B8; // type:func
470472
Sd_SetReverbDepth = 0x80047AD0; // type:func
471473
Sd_SetReverbEnable = 0x80047AFC; // type:func
474+
func_80047D1C = 0x80047D1C;
472475

473476
//-----------------------------------------------------------------------------
474477
//--- PA: 0x0231F0 VA: 0x80047D50 subsegment: c, libsd/bodyprog_CD_80047D50
@@ -2106,7 +2109,8 @@ Y_ARRAY.295 = 0x800A9FB4;
21062109
//------------------------------------------------------------------------------
21072110
//--- PA: 0x085A80 VA: 0x800AA5E0 subsegment: .data, libsd/bodyprog_80045A7C
21082111
//------------------------------------------------------------------------------
2109-
REVERB_DEPTHS = 0x800AA5E0;
2112+
g_Sd_ReverbDepthsList = 0x800AA5E0;
2113+
g_XaItemData = 0x800AA894;
21102114

21112115
//-------------------------------------------------------------------
21122116
//--- PA: 0x088920 VA: 0x800AD480 subsegment: .data, view/vw_calc
@@ -2523,7 +2527,8 @@ vcRefPosSt = 0x800BCDF8; // type:VECTOR3 size:0
25232527
g_WorldGfx = 0x800BCE18; // type:u8 size:0x2DBC
25242528
g_Map = 0x800C1020; // type:u8 size:0x58C - size from bzero call
25252529
g_Sound_ActiveSfxIdx = 0x800C15BE; // type:s16
2526-
g_Sound_ReverbDepth = 0x800C1687;
2530+
g_Sd_AudioLoadState = 0x800C1670;
2531+
g_Sd_ReverbDepth = 0x800C1687;
25272532
g_Game_VSyncTimeSinceBoot = 0x800C1690;
25282533
D_800C16A8 = 0x800C16A8; // type:u8 size:0x20
25292534
vwViewPointInfo = 0x800C37E0; // type:VW_VIEW_WORK size:0x84

include/bodyprog/bodyprog.h

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -970,19 +970,6 @@ typedef struct
970970
} s_800A992C;
971971
STATIC_ASSERT_SIZEOF(s_800A992C, 24);
972972

973-
typedef struct
974-
{
975-
u8 field_0;
976-
u8 unk_1; // } Padding?
977-
u8 unk_2; // }
978-
u8 unk_3; // }
979-
u32 field_4 : 24;
980-
u8 field_4_24 : 8;
981-
u32 field_8 : 24;
982-
u8 field_8_24 : 8;
983-
} s_800AA894;
984-
STATIC_ASSERT_SIZEOF(s_800AA894, 12);
985-
986973
/** Related to weapon attacks. */
987974
typedef struct
988975
{
@@ -1187,36 +1174,6 @@ typedef struct
11871174
u8 field_1;
11881175
} s_800C15F0;
11891176

1190-
typedef struct
1191-
{
1192-
s32 field_0;
1193-
s32 field_4;
1194-
s32 field_8;
1195-
} s_800C1688;
1196-
1197-
/** Sound struct for currently used SFX? */
1198-
typedef struct
1199-
{
1200-
u8 field_0;
1201-
u8 field_1;
1202-
s16 field_2;
1203-
s16 field_4;
1204-
s16 field_6;
1205-
s16 field_8;
1206-
s16 field_A; // Pitch?
1207-
s16 volumeLeft_C;
1208-
s16 volumeRight_E;
1209-
} s_800C1698;
1210-
1211-
typedef struct
1212-
{
1213-
s8 field_0;
1214-
s8 unk_1;
1215-
u16 field_2;
1216-
u32 field_4;
1217-
s32 field_8;
1218-
} s_800C37D4;
1219-
12201177
// Used in string parsing.
12211178
typedef struct
12221179
{
@@ -2085,8 +2042,6 @@ extern u16 D_800A9774[];
20852042

20862043
extern u16 g_UnknownEngineCmdTable1[];
20872044

2088-
extern s_800C37D4 D_800A986C[];
2089-
20902045
extern s32 D_800A9A20;
20912046

20922047
/** X. */
@@ -2288,12 +2243,8 @@ extern u32 D_800A9FB0;
22882243

22892244
extern s32 D_800A9FB4[];
22902245

2291-
extern u8 REVERB_DEPTHS[];
2292-
22932246
extern u8 D_800AA604[][16];
22942247

2295-
extern s_800AA894 D_800AA894[];
2296-
22972248
extern u8 D_800AE185;
22982249

22992250
extern u8 D_800AE186;
@@ -2520,10 +2471,6 @@ extern u16 D_800C15F8[];
25202471
/** Voices? */
25212472
extern s16 D_800C1628[];
25222473

2523-
extern s_800C1688 D_800C1688;
2524-
2525-
extern s_800C1698 D_800C1698;
2526-
25272474
extern s16 D_800C16A4;
25282475

25292476
extern s32 D_800C16C8; // Type assumed.
@@ -2553,25 +2500,15 @@ extern s32 D_800C3994;
25532500

25542501
extern u8 D_800C37D0;
25552502

2556-
extern s_800C37D4* D_800C37D8;
2557-
25582503
extern s_800C38B0 D_800C38B0;
25592504

25602505
extern s_800C38B4 D_800C38B4;
25612506

25622507
/** Times? */
25632508
extern q19_12 D_800C4710[];
25642509

2565-
extern u8 D_800C37C8;
2566-
2567-
extern u32 D_800C37CC;
2568-
2569-
extern s_800C37D4* D_800C37D4;
2570-
25712510
extern u8 D_800C37DC;
25722511

2573-
extern u8 D_800C37DD;
2574-
25752512
/** String position. */
25762513
extern DVECTOR g_StringPosition; // 0x800C38A8
25772514

@@ -3179,11 +3116,6 @@ u8 func_80046BB4(u8 arg0);
31793116

31803117
void func_80046C54(u8 arg0, u8 vol);
31813118

3182-
/** Sound command func. Unknown category. */
3183-
void func_80046D3C(u16 cmd);
3184-
3185-
s32 func_80046DCC(s32 idx);
3186-
31873119
void func_80046E00(void);
31883120

31893121
void func_8004729C(u16 sfxId);
@@ -3194,35 +3126,6 @@ void func_80047308(void);
31943126

31953127
void func_8004760C(void);
31963128

3197-
/** Sound func. */
3198-
void func_800478DC(u8 cmd);
3199-
3200-
void func_80047A70(void);
3201-
3202-
void Sd_SetVolBgm(s16 volLeft, s16 volRight);
3203-
3204-
void Sd_SetVolXa(s16 volLeft, s16 volRight);
3205-
3206-
s16 Sd_GetVolSe(s16 arg0);
3207-
3208-
void Sd_SetReverbDepth(u8 depth);
3209-
3210-
void Sd_SetReverbEnable(s32 mode);
3211-
3212-
void func_80047B24(s32 arg0);
3213-
3214-
void func_80047B80(void);
3215-
3216-
void func_80047D1C(void);
3217-
3218-
void func_80047D50(void);
3219-
3220-
void func_80047DB0(void);
3221-
3222-
void func_80047E3C(void);
3223-
3224-
void func_80047F18(void);
3225-
32263129
void func_80048000(void);
32273130

32283131
void func_8004807C(void);
@@ -3254,8 +3157,6 @@ void func_800485B8(s32 arg0, u8 arg1, u32 arg2);
32543157

32553158
void func_800485C0(s32 idx);
32563159

3257-
void func_800485D8(void);
3258-
32593160
/** @brief Executes a new primitive command and checks the status against the previous.
32603161
* If the previous primitive commands haven't completed, it starts
32613162
* adding to `D_800C1658.timer_0` each time the process fails. When it

include/bodyprog/sound_system.h

Lines changed: 119 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,24 @@
2222
// STRUCTS
2323
// ========
2424

25+
typedef struct
26+
{
27+
u8 xaFileIdx_0;
28+
u8 unk_1; // } Padding?
29+
u8 unk_2; // }
30+
u8 unk_3; // }
31+
u32 sector_4 : 24;
32+
u8 field_4_24 : 8; // Index. This indicate the element of the group idx defined at `field_8_24`.
33+
u32 audioLength_8 : 24;
34+
u8 field_8_24 : 8; // Index. This indicate some sort of group.
35+
} s_XaItemData;
36+
STATIC_ASSERT_SIZEOF(s_XaItemData, 12);
37+
2538
typedef struct
2639
{
2740
u16 timer_0; // A timer related to audio command processes.
28-
u16 field_2;
29-
u16 field_4;
41+
u16 xaAudioIdxCheck_2; // XA Audio index. Used for check if the file exist.
42+
u16 xaAudioIdx_4; // XA Audio index. Used for playing the audio.
3043
u16 field_6;
3144
u16 field_8[1]; // Unknown size.
3245
s16 field_A;
@@ -36,19 +49,20 @@ typedef struct
3649
u8 isStereoEnabled_12; // `bool`
3750
s8 field_13;
3851
u8 bgmFadeSpeed_14; /** Value to get rested in order to speed the music fade. Range: [0, 2], default: 0. */
39-
u8 field_15;
40-
u8 field_16; // `bool` | XA streaming related. If a voiceline audio is playing, this is set to `false`, otherwise `true`.
41-
u8 muteGame_17; // `bool` | Mutes the game. If the value is `true`, the whole game audio will progressively lower
42-
// in volume until mute. The sounds will keep playing, but muted.
52+
u8 isVabLoading_15; /** `bool` | Loading: `true`, Nothing loading: `false`, default: Nothing loading. */
53+
u8 field_16; /** `bool` | XA streaming related. If a voiceline audio is playing, this is set to `false`, otherwise `true`. */
54+
u8 muteGame_17; /** `bool` | Mutes the game. If the value is `true`, the whole game audio will progressively lower
55+
* in volume until mute. The sounds will keep playing, but muted.
56+
*/
4357
} s_800C1658;
4458

4559
typedef struct
4660
{
47-
u8 field_0;
48-
u8 field_1;
49-
u8 field_2;
61+
u8 vabLoadState_0; // States related to audio streaming. VAB Audio.
62+
u8 field_1; // States related to audio streaming.
63+
u8 field_2; // States related to audio streaming.
5064
u8 field_3;
51-
} s_800C1670;
65+
} s_Sd_AudioLoadStates;
5266

5367
// Game current volume configuration struct?
5468
typedef struct
@@ -68,10 +82,46 @@ typedef struct
6882
u8 globalVolumeXa_E; // Global Voice volume channel (not configurable).
6983
} s_800C1678;
7084

85+
typedef struct
86+
{
87+
s32 field_0;
88+
s32 field_4;
89+
s32 field_8;
90+
} s_800C1688;
91+
92+
/** Sound struct for currently used SFX? */
93+
typedef struct
94+
{
95+
u8 field_0;
96+
u8 field_1;
97+
s16 field_2;
98+
s16 field_4;
99+
s16 field_6;
100+
s16 field_8;
101+
s16 field_A; // Pitch?
102+
s16 volumeLeft_C;
103+
s16 volumeRight_E;
104+
} s_800C1698;
105+
106+
typedef struct
107+
{
108+
s8 field_0;
109+
s8 unk_1;
110+
u16 field_2;
111+
u32 field_4; // VA Sound Sector count?
112+
s32 field_8;
113+
} s_800C37D4;
114+
71115
// ========
72116
// GLOBALS
73117
// ========
74118

119+
extern u8 g_Sd_ReverbDepthsList[]; // 0x800AA5E0
120+
121+
extern s_800C37D4 D_800A986C[];
122+
123+
extern s_XaItemData g_XaItemData[]; // 0x800AA894
124+
75125
// Only used in `sd_work_init` as iterator variable.
76126
extern s32 D_800C15B8;
77127

@@ -84,18 +134,34 @@ extern s32 D_800C15DC;
84134
// Only used in `func_80047A70` as iterator variable.
85135
extern s32 D_800C15E0;
86136

87-
// Very likely to be related to music.
88137
extern s_800C1658 D_800C1658;
89138

90-
extern s_800C1670 D_800C1670;
139+
extern s_Sd_AudioLoadStates g_Sd_AudioLoadState; // 0x800C1670
91140

92141
extern s_800C1678 D_800C1678;
93142

94-
extern u8 g_Sound_ReverbDepth;
143+
extern u8 g_Sd_ReverbDepth; // 0x800C1687;
95144

96-
// Command pool related to audio and streaming.
145+
extern s_800C1688 D_800C1688;
146+
147+
extern s_800C1698 D_800C1698;
148+
149+
extern u8 D_800C37C8;
150+
151+
extern u32 D_800C37CC;
152+
153+
/** Command pool related to audio and streaming.
154+
* Seems like `func_800485D8` is the main function on charge of executing commands,
155+
* as this function is part of the mainloop function.
156+
*/
97157
extern u8 D_800C16A8[32];
98158

159+
extern s_800C37D4* D_800C37D4;
160+
161+
extern s_800C37D4* D_800C37D8;
162+
163+
extern u8 D_800C37DD;
164+
99165
// ==========
100166
// FUNCTIONS
101167
// ==========
@@ -119,7 +185,46 @@ void Sd_AllVoicesKeyOff(void);
119185
/** @brief Executes `SdUtKeyOffVWithRROff` and runs through all elements of `smf_port`. */
120186
void Sd_AllVoicesKeyOffVWithRROff(void);
121187

188+
/** @brief Plays XA audios defined at `g_XaItemData`. */
189+
void Sd_XaAudioPlay(u16 sfx); // 0x80046D3C
190+
191+
/** @unused Gets the length of XA audios defined at `g_XaItemData`. */
192+
s32 Sd_XaAudioLengthGet(s32 idx); // 0x80046DCC
193+
122194
/** @brief Sets the volume for the global channels of the music, sound effects, and voices. */
123195
void Sd_SetVolume(u8 xaVol, s16 bgmVol, u8 seVol);
124196

197+
void Sd_SetVolBgm(s16 volLeft, s16 volRight); // 0x80047808
198+
199+
void Sd_SetVolXa(s16 volLeft, s16 volRight); // 0x80047860
200+
201+
s16 Sd_GetVolSe(s16 arg0); // 0x800478B8
202+
203+
/** Updates and add commands to a command pool. */
204+
void func_800478DC(u8 cmd); // 0x800478DC
205+
206+
/** Updates a command pool by shifting a field. */
207+
void func_80047A70(void); // 0x80047A70
208+
209+
void func_80047B80(void); // 0x80047B80
210+
211+
void Sd_SetReverbDepth(u8 depth); // 0x80047AD0
212+
213+
void Sd_SetReverbEnable(s32 mode); // 0x80047AFC
214+
215+
void func_80047B24(s32 arg0); // 0x80047B24
216+
217+
void func_80047D1C(void); // 0x80047D1C
218+
219+
void func_80047D50(void); // 0x80047D50
220+
221+
void func_80047DB0(void); // 0x80047DB0
222+
223+
void func_80047E3C(void); // 0x80047E3C
224+
225+
void func_80047F18(void); // 0x80047F18
226+
227+
void func_800485D8(void); // 0x800485D8
228+
229+
125230
#endif

0 commit comments

Comments
 (0)