NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_BankFile.h
1
#ifndef NW4R_SND_BANK_FILE_H
2
#define NW4R_SND_BANK_FILE_H
3
4
/*******************************************************************************
5
* headers
6
*/
7
8
#include <types.h>
9
10
#include "nw4r/snd/snd_WaveFile.h"
11
12
#include "nw4r/snd/snd_Util.h"
13
14
#include "nw4r/ut/ut_binaryFileFormat.h"
15
16
/*******************************************************************************
17
* types
18
*/
19
20
namespace
nw4r {
namespace
snd {
namespace
detail
21
{
22
struct
BankFile
23
{
24
/* Header */
25
26
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2afe21
27
struct
Header
28
{
29
ut::BinaryFileHeader
fileHeader;
// size 0x10, offset 0x00
30
ulong dataBlockOffset;
// size 0x04, offset 0x10
31
ulong dataBlockSize;
// size 0x04, offset 0x14
32
ulong waveBlockOffset;
// size 0x04, offset 0x18
33
ulong waveBlockSize;
// size 0x04, offset 0x1c
34
};
// size 0x20
35
36
/* DataBlock */
37
38
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b0666
39
struct
InstParam
40
{
41
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b04df
42
union
43
{
44
s32 waveIndex;
// size 0x04
45
WaveInfo
const
*waveInfoAddress;
// size 0x04
46
WaveDataLocationCallback
*waveDataLocationCallback;
// size 0x04
47
};
// size 0x04, offset 0x00
48
u8 attack;
// size 0x01, offset 0x04
49
u8 decay;
// size 0x01, offset 0x05
50
u8 sustain;
// size 0x01, offset 0x06
51
u8 release;
// size 0x01, offset 0x07
52
u8 hold;
// size 0x01, offset 0x08
53
u8 waveDataLocationType;
// size 0x01, offset 0x09
54
u8 noteOffType;
// size 0x01, offset 0x0a
55
u8 alternateAssign;
// size 0x01, offset 0x0b
56
u8 originalKey;
// size 0x01, offset 0x0c
57
u8 volume;
// size 0x01, offset 0x0d
58
u8 pan;
// size 0x01, offset 0x0e
59
u8 padding2;
// 2?
60
f32 tune;
// size 0x04, offset 0x10
61
// TODO: template parameters
62
Util::DataRef<void>
lfoTableRef;
// size 0x08, offset 0x14
63
Util::DataRef<void>
graphEnvTablevRef;
// size 0x08, offset 0x1c
64
Util::DataRef<void>
randomizerTableRef;
// size 0x08, offset 0x24
65
ulong reserved;
66
};
// size 0x30
67
68
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b2114
69
struct
RangeTable
70
{
71
u8 tableSize;
// size 0x01, offset 0x00
72
u8 key[];
// flexible, offset 0x01 (unit size 0x01)
73
};
// size 0x01
74
75
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b203e
76
struct
IndexTable
77
{
78
u8 min;
// size 0x01, offset 0x00
79
u8 max;
// size 0x01, offset 0x01
80
u16 reserved;
81
byte_t ref[];
// flexible, offset 0x04 (unit size 0x01)
82
};
// size 0x04
83
84
typedef
Util::DataRef<void, InstParam, RangeTable, IndexTable>
85
DataRegion;
86
87
static
ulong
const
SIGNATURE_DATA_BLOCK =
88
NW4R_FOUR_BYTE(
'D'
,
'A'
,
'T'
,
'A'
);
89
90
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b006b
91
struct
DataBlock
92
{
93
ut::BinaryBlockHeader
blockHeader;
// size 0x08, offset 0x00
94
Util::Table<DataRegion>
instTable;
// size 0x0c, offset 0x08
95
};
// size 0x14
96
97
/* WaveBlock */
98
99
static
ulong
const
SIGNATURE_WAVE_BLOCK =
100
NW4R_FOUR_BYTE(
'W'
,
'A'
,
'V'
,
'E'
);
101
typedef
Util::DataRef<WaveFile::WaveInfo>
WaveRegion;
102
103
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b022c
104
struct
WaveBlock
105
{
106
ut::BinaryBlockHeader
blockHeader;
// size 0x08, offset 0x00
107
Util::Table<WaveRegion>
waveInfoTable;
// size 0x0c, offset 0x08
108
};
// size 0x14
109
110
/* BankFile */
111
112
static
ulong
const
SIGNATURE_FILE =
113
NW4R_FOUR_BYTE(
'R'
,
'B'
,
'N'
,
'K'
);
114
static
int
const
FILE_VERSION = NW4R_FILE_VERSION(1, 2);
115
};
// "namespace" BankFile
116
117
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b0cdd
118
struct
InstInfo
119
{
120
// enums
121
public
:
122
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b0c84
123
enum
NoteOffType
124
{
125
NOTE_OFF_TYPE_RELEASE,
126
NOTE_OFF_TYPE_IGNORE,
127
};
128
129
// nested types
130
public
:
131
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b03e4
132
struct
WaveDataLocation
133
{
134
// enums
135
public
:
136
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b02aa
137
enum
WaveDataLocationType
138
{
139
WAVE_DATA_LOCATION_INDEX,
140
WAVE_DATA_LOCATION_ADDRESS,
141
WAVE_DATA_LOCATION_CALLBACK,
142
};
143
144
// members
145
public
:
146
WaveDataLocationType type;
// size 0x04, offset 0x00
147
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b0335
148
union
149
{
150
s32 index;
// size 0x04
151
WaveInfo
const
*address;
// size 0x04
152
WaveDataLocationCallback
*callback;
// size 0x04
153
};
// size 0x04, offset 0x04
154
};
// size 0x08
155
156
// members
157
public
:
158
WaveDataLocation
waveDataLocation;
// size 0x08, offset 0x00
159
u8 attack;
// size 0x01, offset 0x08
160
u8 hold;
// size 0x01, offset 0x09
161
u8 decay;
// size 0x01, offset 0x0a
162
u8 sustain;
// size 0x01, offset 0x0b
163
u8 release;
// size 0x01, offset 0x0c
164
/* 3 bytes padding */
165
NoteOffType noteOffType;
// size 0x04, offset 0x10
166
u8 alternateAssign;
// size 0x01, offset 0x14
167
u8 originalKey;
// size 0x01, offset 0x15
168
u8 pan;
// size 0x01, offset 0x16
169
u8 volume;
// size 0x01, offset 0x17
170
f32 tune;
// size 0x04, offset 0x18
171
};
// size 0x1c
172
}}}
// namespace nw4r::snd::detail
173
174
/*******************************************************************************
175
* classes and functions
176
*/
177
178
namespace
nw4r {
namespace
snd {
namespace
detail
179
{
180
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b0a17
181
class
BankFileReader
182
{
183
// methods
184
public
:
185
// cdtors
186
BankFileReader(
void
const
*bankData);
187
188
// methods
189
bool
ReadInstInfo(
InstInfo
*instInfo,
int
prgNo,
int
key,
190
int
velocity)
const
;
191
bool
ReadWaveInfo(
WaveInfo
*waveParam,
192
InstInfo::WaveDataLocation
const
&waveDataLocation,
193
void
const
*waveDataAddress,
194
WaveInfo
const
**waveInfoAddress)
const
;
195
196
private
:
197
BankFile::InstParam
const
*GetInstParam(
int
prgNo,
int
key,
198
int
velocity)
const
;
199
BankFile::DataRegion
const
*GetReferenceToSubRegion(
200
BankFile::DataRegion
const
*ref,
int
splitKey)
const
;
201
202
static
bool
IsValidFileHeader(
void
const
*bankData);
203
204
// static members
205
public
:
206
static
int
const
SUPPORTED_FILE_VERSION = NW4R_FILE_VERSION(1, 2);
207
208
// members
209
private
:
210
BankFile::Header
const
*mHeader;
// size 0x04, offset 0x00
211
BankFile::DataBlock
const
*mDataBlock;
// size 0x04, offset 0x04
212
BankFile::WaveBlock
const
*mWaveBlock;
// size 0x04, offset 0x08
213
};
// size 0x0c
214
}}}
// namespace nw4r::snd::detail
215
216
#endif
// NW4R_SND_BANK_FILE_H
nw4r::snd::detail::WaveDataLocationCallback
Definition
snd_WaveFile.h:184
nw4r::snd::detail::BankFile::DataBlock
Definition
snd_BankFile.h:92
nw4r::snd::detail::BankFile::Header
Definition
snd_BankFile.h:28
nw4r::snd::detail::BankFile::IndexTable
Definition
snd_BankFile.h:77
nw4r::snd::detail::BankFile::InstParam
Definition
snd_BankFile.h:40
nw4r::snd::detail::BankFile::RangeTable
Definition
snd_BankFile.h:70
nw4r::snd::detail::BankFile::WaveBlock
Definition
snd_BankFile.h:105
nw4r::snd::detail::BankFile
Definition
snd_BankFile.h:23
nw4r::snd::detail::InstInfo::WaveDataLocation
Definition
snd_BankFile.h:133
nw4r::snd::detail::InstInfo
Definition
snd_BankFile.h:119
nw4r::snd::detail::Util::DataRef
Definition
snd_Util.h:40
nw4r::snd::detail::Util::Table
Definition
snd_Util.h:50
nw4r::snd::detail::WaveInfo
Definition
snd_WaveFile.h:105
nw4r::ut::BinaryBlockHeader
Definition
ut_binaryFileFormat.h:8
nw4r::ut::BinaryFileHeader
Definition
ut_binaryFileFormat.h:13
include
lib
nw4r
snd
snd_BankFile.h
Made with ❤️ by
CLF78
and
RootCubed
. Logos by
Chasical
and
B1
. Website generated by
Doxygen
1.13.2