NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_AnimSoundReader.h
1#include "nw4r/snd/snd_Util.h"
2#include "nw4r/ut/ut_binaryFileFormat.h"
3
4namespace nw4r {
5namespace snd {
6namespace detail {
7
8// Type and name revealed by BBA
10 int field_0x00; // at 0x00
11 int field_0x04; // at 0x04
12 u8 flags; // at 0x08
13 s8 field_0x09; // at 0x09
14 u8 field_0x0A; // at 0x0A
15};
16
17struct AnimEvent {
18 ulong flags; // at 0x00
19 ulong soundId; // at 0x04
20 detail::Util::DataRef<const char> soundLabelRef; // at 0x08
21 u8 volume; // at 0x10
22 u8 field_0x11; // at 0x11
23 u8 varNo; // at 0x12
24 f32 pitch; // at 0x14
25 UNKWORD field_0x18; // at 0x18
26 UNKWORD field_0x1C; // at 0x1C
27
28 bool ShouldPreventStart() const {
29 return flags & 1;
30 }
31
32 const char *GetSoundLabel() const {
33 return Util::GetDataRefAddress0(soundLabelRef, this);
34 }
35
36 bool GetVarNo(ulong *var) const {
37 if (flags & 2) {
38 *var = varNo;
39 return true;
40 }
41 return false;
42 }
43
44 bool MatchesDirection(int playDirection) const {
45 bool ret = 0;
46 ulong config = field_0x11;
47 if ((config == 0 || (playDirection == 0 && config == 1) || (playDirection == 1 && config == 2))) {
48 ret = true;
49 }
50 return ret;
51 }
52};
53
54// Name from Inazuma, BBA
56 AnimEventFrameInfo mInfo; // at 0x00
57 Util::DataRef<AnimEvent> event; // at 0x0C
58};
59
60// Names unknown
62 static ulong const SIGNATURE_FILE = NW4R_FOUR_BYTE('R', 'A', 'S', 'D');
63 static int const FILE_VERSION = NW4R_FILE_VERSION(1, 0);
64
65 struct Header {
66 ut::BinaryFileHeader fileHeader; // size 0x10, offset 0x00
67 ulong blockOffset; // at 0x10
68 };
69
70 struct EventTable {
71 Util::Table<AnimEventRef> eventRef; // at 0x00
72 };
73
74 struct Block {
75 ut::BinaryBlockHeader blockHeader; // at 0x00
76 ulong duration; // at 0x08
77 Util::DataRef<EventTable> eventTable; // at 0x0C
78 };
79};
80
81// Name from Inazuma
82class AnimSoundFileReader {
83public:
84 AnimSoundFileReader();
85 bool Setup(const void *buf);
86 void Shutdown();
87 ulong GetEventCount() const;
88
89 const AnimSoundFile::EventTable *GetEventTable() const;
90 const AnimEventRef *GetEventRef(ulong id) const;
91 const AnimEvent *GetEvent(const AnimEventRef *ref) const;
92
93 bool IsValid() const {
94 return mpHeader != NULL;
95 }
96
97 ulong GetAnimDuration() const {
98 if (!IsValid()) {
99 return 0;
100 }
101 return mpBlock->duration;
102 }
103
104private:
105 const AnimSoundFile::Header *mpHeader; // at 0x00
106 const AnimSoundFile::Block *mpBlock; // at 0x04
107};
108
109} // namespace detail
110} // namespace snd
111} // namespace nw4r