1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
#ifndef NW4R_SND_SOUND_STARTABLE_H
#define NW4R_SND_SOUND_STARTABLE_H
/*******************************************************************************
* headers
*/
#include "common.h" // u32
#include "nw4r/snd/snd_BasicSound.h"
#include "nw4r/snd/snd_ExternalSoundPlayer.h"
/*******************************************************************************
* types
*/
// forward declarations
namespace nw4r { namespace snd { class SoundHandle; }}
/*******************************************************************************
* classes and functions
*/
namespace nw4r { namespace snd
{
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x289cb
class SoundStartable
{
// enums
public:
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x267f0
enum StartResult
{
START_SUCCESS,
START_ERR_LOW_PRIORITY,
START_ERR_INVALID_LABEL_STRING,
START_ERR_INVALID_SOUNDID,
START_ERR_NOT_DATA_LOADED,
START_ERR_NOT_ENOUGH_PLAYER_HEAP,
START_ERR_CANNOT_OPEN_FILE,
START_ERR_NOT_AVAILABLE,
START_ERR_CANNOT_ALLOCATE_TRACK,
START_ERR_NOT_ENOUGH_INSTANCE,
START_ERR_INVALID_PARAMETER,
START_ERR_INVALID_SEQ_START_LOCATION_LABEL,
START_ERR_USER = 128,
START_ERR_UNKNOWN = 255,
};
// nested types
public:
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27291
struct StartInfo
{
StartInfo() : enableFlag(0) {}
// enums
public:
enum EnableFlag
{
ENABLE_START_OFFSET = 1 << 0,
ENABLE_PLAYER_ID = 1 << 1,
ENABLE_PLAYER_PRIORITY = 1 << 2,
ENABLE_ACTOR_PLAYER_ID = 1 << 3,
ENABLE_SEQ_SOUND_INFO = 1 << 4,
};
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27187
enum StartOffsetType
{
START_OFFSET_TYPE_MILLISEC,
START_OFFSET_TYPE_TICK,
START_OFFSET_TYPE_SAMPLE,
};
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x27208
struct SeqSoundInfo
{
SeqSoundInfo() : seqDataAddress(NULL), startLocationLabel(NULL) {}
void *seqDataAddress; // size 0x04, offset 0x00
char const *startLocationLabel; // size 0x04, offset 0x04
}; // size 0x08
// members
public:
u32 enableFlag; // size 0x04, offset 0x00
StartOffsetType startOffsetType; // size 0x04, offset 0x04
int startOffset; // size 0x04, offset 0x08
u32 playerId; // size 0x04, offset 0x0c
int playerPriority; // size 0x04, offset 0x10
int actorPlayerId; // size 0x04, offset 0x14
SeqSoundInfo seqSoundInfo; // size 0x08, offset 0x18
}; // size 0x20
// methods
public:
// cdtors
virtual ~SoundStartable() {}
// virtual function ordering
// vtable SoundStartable
virtual StartResult detail_SetupSound(SoundHandle *handle, u32 soundId,
bool holdFlag,
StartInfo const *startInfo) = 0;
virtual u32 detail_ConvertLabelStringToSoundId(char const *label) = 0;
// methods
StartResult detail_StartSound(
SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo
);
StartResult detail_StartSound(
SoundHandle *pHandle, const char *label, const StartInfo *pStartInfo
);
StartResult detail_HoldSound(
SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo
);
StartResult detail_HoldSound(
SoundHandle *pHandle, const char *label, const StartInfo *pStartInfo
);
StartResult detail_PrepareSound(
SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo
);
StartResult detail_PrepareSound(
SoundHandle *pHandle, const char *label,
const StartInfo *pStartInfo
);
bool StartSound(SoundHandle *pHandle, u32 id) {
return detail_StartSound(pHandle, id, NULL) == START_SUCCESS;
}
bool StartSound(SoundHandle *pHandle, const char *label) {
return detail_StartSound(pHandle, label, NULL) == START_SUCCESS;
}
bool StartSound(SoundHandle *pHandle, unsigned int id) {
return detail_StartSound(pHandle, id, NULL) == START_SUCCESS;
}
bool StartSound(SoundHandle *pHandle, int id) {
return detail_StartSound(pHandle, id, NULL) == START_SUCCESS;
}
bool HoldSound(SoundHandle *pHandle, u32 id) {
return detail_HoldSound(pHandle, id, NULL) == START_SUCCESS;
}
bool HoldSound(SoundHandle *pHandle, const char *label) {
return detail_HoldSound(pHandle, label, NULL) == START_SUCCESS;
}
bool HoldSound(SoundHandle *pHandle, unsigned int id) {
return detail_HoldSound(pHandle, id, NULL) == START_SUCCESS;
}
bool HoldSound(SoundHandle *pHandle, int id) {
return detail_HoldSound(pHandle, id, NULL) == START_SUCCESS;
}
bool PrepareSound(SoundHandle *pHandle, u32 id) {
return detail_PrepareSound(pHandle, id, NULL) == START_SUCCESS;
}
bool PrepareSound(SoundHandle *pHandle, unsigned int id) {
return detail_PrepareSound(pHandle, id, NULL) == START_SUCCESS;
}
bool PrepareSound(SoundHandle *pHandle, int id) {
return detail_PrepareSound(pHandle, id, NULL) == START_SUCCESS;
}
// The detail_ functions above are probably not meant to be called directly from game code,
// so these inlines probably exist, but I haven't found them in Ketteiban or BBA. An inline
// fixes a regswap in d/snd so that's more evidence. Names are obviously made up.
// TODO: Do these exist in other variants for different ID types too???
StartResult StartSoundReturnStatus(SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo) {
return detail_StartSound(pHandle, id, pStartInfo);
}
StartResult HoldSoundReturnStatus(SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo) {
return detail_HoldSound(pHandle, id, pStartInfo);
}
StartResult PrepareSoundReturnStatus(SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo) {
return detail_PrepareSound(pHandle, id, pStartInfo);
}
// members
private:
/* vtable */ // size 0x04, offset 0x00
}; // size 0x04
}} // namespace nw4r::snd
#endif // NW4R_SND_SOUND_STARTABLE_H
|