NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
snd_MemorySoundArchive.h
1#ifndef NW4R_SND_MEMORY_SOUND_ARCHIVE_H
2#define NW4R_SND_MEMORY_SOUND_ARCHIVE_H
3
4/*******************************************************************************
5 * headers
6 */
7
8#include <types.h>
9
10// WARNING: DO NOT REORDER these #include directives, data pooling depends on it
11
12// clang-format off
13#include "nw4r/ut/ut_FileStream.h" // This needs to be
14#include "nw4r/snd/snd_SoundArchive.h" // before this
15// clang-format on
16
17#include "nw4r/snd/snd_SoundArchiveFile.h"
18
19/*******************************************************************************
20 * classes and functions
21 */
22
23namespace nw4r { namespace snd
24{
25 // TODO: get a specific source (name, game id)
26 /* dwarfv1_megadump.txt:284789-284793
27 * This is the struct info for nw4hbm::snd::MemorySoundArchive from an
28 * older version of the HBM library that actually uses it, but it seems
29 * similar enough to the current version, so it is used as a reference here.
30 */
31 class MemorySoundArchive : public SoundArchive
32 {
33 // nested types
34 private:
35 class MemoryFileStream;
36
37 // methods
38 public:
39 // cdtors
40 MemorySoundArchive();
41 virtual ~MemorySoundArchive();
42
43 // virtual function ordering
44 // vtable SoundArchive
45 virtual void const *detail_GetFileAddress(ulong fileId) const;
46 virtual void const *detail_GetWaveDataFileAddress(ulong fileId) const;
47 virtual int detail_GetRequiredStreamBufferSize() const;
48 virtual ut::FileStream *OpenStream(void *buffer, int size, ulong begin,
49 ulong length) const;
50 virtual ut::FileStream *OpenExtStream(void *buffer, int size,
51 char const *extFilePath,
52 ulong begin, ulong length) const;
53
54 // methods
55 bool Setup(void const *soundArchiveData);
56 void Shutdown();
57
58 // members
59 private:
60 /* base SoundArchive */ // size 0x108, offset 0x000
61 void const *mData; // size 0x004, offset 0x108
62 detail::SoundArchiveFileReader mFileReader; // size 0x044, offset 0x10c
63 }; // size 0x150
64
65 // NOTE: Must be completed after MemorySoundArchive for data ordering
66 // TODO: get a specific source (name, game id)
67 /* dwarfv1_megadump.txt:293462-293467
68 * This is the struct info for
69 * nw4hbm::snd::MemorySoundArchive::MemoryFileStream from an older version
70 * of the HBM library that actually uses it, but it seems similar enough to
71 * the current version, so it is used as a reference here.
72 */
74 {
75 // methods
76 public:
77 // cdtors
78 MemoryFileStream(void const *buffer, ulong size);
79 virtual ~MemoryFileStream() {}
80
81 // virtual function ordering
82 // vtable ut::IOStream
83 virtual void Close();
84 virtual s32 Read(void *buf, ulong length);
85
86 // vtable ut::FileStream
87 virtual void Seek(s32 offset, ulong origin);
88
89 // For instantiation ordering (WARNING: Do not rearrange)
90 virtual bool CanSeek() const { return true; }
91 virtual bool CanCancel() const { return true; }
92 virtual bool CanAsync() const { return false; }
93 virtual bool CanRead() const { return true; }
94 virtual bool CanWrite() const { return false; }
95 virtual ulong Tell() const { return mPosition; }
96 virtual ulong GetSize() const { return mSize; }
97
98 // members
99 private:
100 /* base ut::FileStream */ // size 0x14, offset 0x00
101 void const *mBuffer; // size 0x04, offset 0x14
102 ulong mSize; // size 0x04, offset 0x18
103 ulong mPosition; // size 0x04, offset 0x1c
104 }; // size 0x20
105}} // namespace nw4r::snd
106
107#endif // NW4R_SND_MEMORY_SOUND_ARCHIVE_H