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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
/*
* The provenance of this file is really confusing.
* OPeNBooK9003 didn't write it, it came from some form of tutorial or
* example, and I've found some copies, but none that make sense here.
*
* - "Sam's Teach Yourself DirectX 7 Programming in 24 Hours"
* A book from 1999 - a year too new, and a DirectX version too new.
* - "DirectSound Wrapper Classes"
* https://www.codeproject.com/articles/12076/directsound-wrapper-classes
* Published in 2006 - 7 years too new.
* - "Chicken Tournament"
* https://github.com/shlusiak/Chicken-Tournament/blob/master/src/Resources/MMIO.h
* A game from 2003.
*/
//-----------------------------------------------------------------
// MMIO Objects
// C++ Header - MMIO.h
//-----------------------------------------------------------------
#ifndef __MMIO_H__
#define __MMIO_H__
//-----------------------------------------------------------------
// Inclusions
//-----------------------------------------------------------------
#include "../common.h"
#include <MMSystem.h>
//-----------------------------------------------------------------
// CMMChunk Class - Multimedia RIFF Chunk Object
//-----------------------------------------------------------------
class AFX_CLASS_EXPORT CMMChunk : public MMCKINFO
{
// Protected Constructor(s)/Destructor
protected:
CMMChunk() { };
};
//-----------------------------------------------------------------
// CMMIdChunk Class - Multimedia RIFF Id Chunk Object
//-----------------------------------------------------------------
class AFX_CLASS_EXPORT CMMIdChunk : public CMMChunk
{
// Public Constructor(s)/Destructor
public:
CMMIdChunk(char c0, char c1, char c2, char c3);
CMMIdChunk(LPCSTR psz, UINT uiFlags = 0u);
};
//-----------------------------------------------------------------
// CMMTypeChunk Class - Multimedia RIFF Type Chunk Object
//-----------------------------------------------------------------
class AFX_CLASS_EXPORT CMMTypeChunk : public CMMChunk
{
// Public Constructor(s)/Destructor
public:
CMMTypeChunk(char c0, char c1, char c2, char c3);
CMMTypeChunk(LPCSTR psz, UINT uiFlags = 0u);
};
//-----------------------------------------------------------------
// CMMIOInfo Class - Multimedia RIFF I/O Info Object
//-----------------------------------------------------------------
class AFX_CLASS_EXPORT CMMIOInfo : public MMIOINFO
{
// Public Constructor(s)/Destructor
public:
CMMIOInfo();
};
//-----------------------------------------------------------------
// CMMMemoryIOInfo Class - Multimedia RIFF Memory I/O Info Object
//-----------------------------------------------------------------
class AFX_CLASS_EXPORT CMMMemoryIOInfo : public CMMIOInfo
{
// Public Constructor(s)/Destructor
public:
CMMMemoryIOInfo(LONG lBuffer, DWORD dwMinExpansion = 0);
CMMMemoryIOInfo(HPSTR pBuffer, LONG lBuffer, DWORD
dwMinExpansion = 0);
};
//-----------------------------------------------------------------
// CMMIO Class - Multimedia RIFF I/O Object
//-----------------------------------------------------------------
class AFX_CLASS_EXPORT CMMIO : public CObject
{
// Public Constructor(s)/Destructor
public:
CMMIO();
CMMIO(HMMIO hmmio);
CMMIO(const char* pszFileName, DWORD dwOpenFlag =
MMIO_READ);
CMMIO(CMMMemoryIOInfo& mmioinfo);
// Public Methods
public:
void Open(const char* pszFileName,
DWORD dwOpenFlags = MMIO_READ);
void Open(CMMMemoryIOInfo &mmioinfo);
MMRESULT Close(UINT uiFlags = 0u);
MMRESULT Ascend(CMMChunk &mmckInfo, UINT uiFlags = 0u);
MMRESULT Descend(CMMChunk &mmckInfo, UINT uiFlags = 0u);
MMRESULT Descend(CMMChunk &mmckInfo, CMMChunk &mmckParent,
UINT uiFlags = 0u);
LONG Read(HPSTR pData, LONG lLen);
LONG Write(const char* pData, LONG lLen);
LONG Seek(LONG lOffset, int iOrigin);
LRESULT SendMessage(UINT uiMsg, LPARAM lParam1,
LPARAM lParam2);
MMRESULT SetBuffer(LPSTR pBuffer, LONG lBuffer,
UINT uiFlags = 0u);
MMRESULT GetInfo(CMMIOInfo &, UINT uiFlags = 0);
MMRESULT SetInfo(CMMIOInfo &, UINT uiFlags = 0);
MMRESULT Advance(CMMIOInfo &, UINT uiFlags);
// Public Data
public:
HMMIO m_hmmio;
};
//-----------------------------------------------------------------
// CMMIdChunk Inline Public Constructor(s)/Destructor
//-----------------------------------------------------------------
inline CMMIdChunk::CMMIdChunk(char c0, char c1, char c2, char c3)
{
ckid = mmioFOURCC(c0, c1, c2, c3);
}
inline CMMIdChunk::CMMIdChunk(LPCSTR psz, UINT uiFlags)
{
ckid = ::mmioStringToFOURCC(psz, uiFlags);
}
//-----------------------------------------------------------------
// CMMTypeChunk Inline Public Constructor(s)/Destructor
//-----------------------------------------------------------------
inline CMMTypeChunk::CMMTypeChunk(char c0, char c1, char c2, char c3)
{
fccType = mmioFOURCC(c0, c1, c2, c3);
}
inline CMMTypeChunk::CMMTypeChunk(LPCSTR psz, UINT uiFlags)
{
fccType = ::mmioStringToFOURCC(psz, uiFlags);
}
//-----------------------------------------------------------------
// CMMIOInfo Inline Public Constructor(s)/Destructor
//-----------------------------------------------------------------
inline CMMIOInfo::CMMIOInfo()
{
::ZeroMemory(this, sizeof(MMIOINFO));
}
//-----------------------------------------------------------------
// CMMMemoryIOInfo Inline Public Constructor(s)/Destructor
//-----------------------------------------------------------------
inline CMMMemoryIOInfo::CMMMemoryIOInfo(LONG lBuffer,
DWORD dwMinExpansion)
{
pIOProc = NULL;
fccIOProc = FOURCC_MEM;
pchBuffer = NULL;
cchBuffer = lBuffer;
adwInfo[0] = dwMinExpansion;
}
inline CMMMemoryIOInfo::CMMMemoryIOInfo(HPSTR pBuffer, LONG cchBuf,
DWORD dwMinExpansion)
{
pIOProc = NULL;
fccIOProc = FOURCC_MEM;
pchBuffer = pBuffer;
cchBuffer = cchBuf;
adwInfo[0] = dwMinExpansion;
}
//-----------------------------------------------------------------
// CMMIO Inline Public Constructor(s)/Destructor
//-----------------------------------------------------------------
inline CMMIO::CMMIO() : m_hmmio(NULL)
{
}
inline
CMMIO::CMMIO(HMMIO hmmio) : m_hmmio(hmmio)
{
}
inline CMMIO::CMMIO(const char* pszFileName, DWORD dwOpenFlag)
{
Open(pszFileName, dwOpenFlag);
}
inline CMMIO::CMMIO(CMMMemoryIOInfo &mmioinfo)
{
Open(mmioinfo);
}
//-----------------------------------------------------------------
// CMMIO Inline Public Methods
//-----------------------------------------------------------------
inline MMRESULT CMMIO::Close(UINT uiFlags)
{
ASSERT(m_hmmio);
MMRESULT mmr = ::mmioClose(m_hmmio, uiFlags);
m_hmmio = NULL;
return mmr;
}
inline LONG CMMIO::Read(HPSTR pData, LONG lLen)
{
ASSERT(m_hmmio);
return ::mmioRead(m_hmmio, pData, lLen);
}
inline MMRESULT CMMIO::Ascend(CMMChunk &mmckInfo, UINT uiFlags)
{
ASSERT(m_hmmio);
return ::mmioAscend(m_hmmio, &mmckInfo, uiFlags);
}
inline MMRESULT CMMIO::Descend(CMMChunk &mmckInfo, UINT uiFlags)
{
ASSERT(m_hmmio);
return ::mmioDescend(m_hmmio, &mmckInfo, 0, uiFlags);
}
inline MMRESULT CMMIO::Descend(CMMChunk &mmckInfo,
CMMChunk &mmckParent, UINT uiFlags)
{
ASSERT(m_hmmio);
return ::mmioDescend(m_hmmio, &mmckInfo, &mmckParent, uiFlags);
}
inline LONG CMMIO::Seek(LONG lOffset, int iOrigin)
{
ASSERT(m_hmmio);
return ::mmioSeek(m_hmmio, lOffset, iOrigin);
}
inline LRESULT CMMIO::SendMessage(UINT uiMsg, LPARAM lParam1,
LPARAM lParam2)
{
ASSERT(m_hmmio);
return ::mmioSendMessage(m_hmmio, uiMsg, lParam1, lParam2);
}
inline MMRESULT CMMIO::SetBuffer(LPSTR pBuffer, LONG lBuffer,
UINT uiFlags)
{
ASSERT(m_hmmio);
return ::mmioSetBuffer(m_hmmio, pBuffer, lBuffer, uiFlags);
}
inline LONG CMMIO::Write(const char* pData, LONG lLen)
{
ASSERT(m_hmmio);
return ::mmioWrite(m_hmmio, pData, lLen);
}
inline MMRESULT CMMIO::GetInfo(CMMIOInfo &Info, UINT uiFlags)
{
ASSERT(m_hmmio);
return ::mmioGetInfo(m_hmmio, &Info, uiFlags);
}
inline MMRESULT CMMIO::SetInfo(CMMIOInfo &Info, UINT uiFlags)
{
ASSERT(m_hmmio);
return ::mmioSetInfo(m_hmmio, &Info, uiFlags);
}
inline MMRESULT CMMIO::Advance(CMMIOInfo &Info, UINT uiFlags)
{
ASSERT(m_hmmio);
return ::mmioAdvance(m_hmmio, &Info, uiFlags);
}
#endif
|