-
Notifications
You must be signed in to change notification settings - Fork 2
/
WSFModV1.h
234 lines (177 loc) · 6.23 KB
/
WSFModV1.h
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
/*
Whelchel Sound Format
Based on MODs
Josh Whelchel 2003
www.syntesis.ath.cx
*/
/***************************************************************************
* Copyright (C) 2005 by Josh Whelchel *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
///
/// \file WSFMod.h Main MOD classes and defs.
#ifndef __WSFMOD1H__
#define __WSFMOD1H__
#include <string.h>
#include "WSFGlob.h"
#include "WSFPackV1.h"
#include "WSFMod.h"
#ifndef NULL
#define NULL 0
#endif
#define WSFM1HEAD "WSF1" ///< File Header for WSF format
#define WSFM1VERHI 1 ///< Version of WSF currently supported vX.00
#define WSFM1VERLO 19 ///< Version of WSF currently supported v1.XX
class CWSFMod;
/// Searches through a data buffer for a string
wsfb *SearchForString( wsfb *lpBuf, wsul nSize, char *cStr, int nTagLen );
/// MOD loading formats.
/// These match the g_cModExt array of file extensions.
typedef enum modvers1_e
{
WSFM1_IT, ///< IT File Format
WSFM1_XM, ///< XM File Format
WSFM1_S3M, ///< S3M File Format
WSFM1_MOD, ///< MOD File Format
WSFM1_WSF, ///< WSF File Format (internal use only)
WSFM1_WTF, ///< WTF File Format (internal use only)
// Insert Formats Here
WSFM1_COUNT,
WSFM1_NONE
} WSFModVers1;
/// Get Mod Type
int GetModType( char *cFile );
/// Mod Format Extensions.
/// These match WSFModVers enum
extern char *g_cModExt[];
/// Mod Format Descriptions.
/// These match WSFModVers enum and g_cModExt
extern char *g_cModDesc[];
/// Mod Format Enablers.
/// These are flags to show whether or not the format is supported or not
extern wsfb g_bModFlag[];
wsfb *ReplaceData( wsfb *bIn, unsigned int nIn, unsigned int *nOut, unsigned int nRepOff, unsigned int nRepLength, wsfb *bFill, unsigned int nFillLen );
/// Preserves ModFusion v1 WSF format!
/// Handles Loading + Saving WSF modules.
/// Handles all the WSF module functions
/// for loading and saving
class CWSFLoaderV1 : public CBaseLoader
{
public:
CWSFLoaderV1();
/// Base Function for Loading
int Load( wsfb *bData, wsul nSize, wsf_loaddata *wLD );
/// Base Saving Function
int Save( wsf_modout *wOut, wsf_loaddata *wLD );
// Additional Saving Unit
int Save( wsf_modout *wOut, wsf_loaddata *wLD, int *nSCounts );
/// Function to get pointers to ACTUAL samples
// int GetSamplePointers( wsfb *bData, wsul nSize, wsf_gspdata *gspData );
/// Sets Pack Name (for saving)
int SetPack( char *cName, CWSFPackV1 *wPack )
{
if (cName)
strcpy(m_cCurPack,cName);
if (wPack)
m_wPack = wPack;
return 0;
};
/// Gets Pack
CWSFPackV1 *GetPack( void )
{
return m_wPack;
};
void SetPack( wsf_file *wPack );
/// Sets the need to frees Pack. If false then it'll load all samples at once
void SetFreePack( int nFree )
{
m_nFreePack = nFree;
};
private:
char m_cCurPack[200]; ///< Current Pack Name for WSF
CWSFPackV1 *m_wPack; ///< Sample Pack
wsfb m_nModType; ///< Internal MOD Type (yea) WSFModVers enum
int m_nFreePack;
wsf_file *m_fPack; ///< Pack File Handle if set (:
};
/// Handles Main MOD and WSF functions in the ModFusion 1 Compatible Format.
/// Handles MOD writing and saving, along with
/// WSF commands. Also handles tags in the
/// ascii section.
///
class CWSFModV1
{
public:
/// Loads Mod into buffer
int LoadMod( char *cFileName, int nFreePack = 1, wsul *nOSamps = NULL );
/// Loads Mod into buffer
int LoadMod( wsfb *bData, wsul nSize, int nFreePack, wsul *nOSamps, int nType );
/// Loads Mod into buffer
int LoadMod( wsf_file *wf, int nFreePack, wsul *nOSamps, int nType );
/// Frees Mod
int FreeMod( void );
/// Write Mod
int WriteMod( wsf_modout *wOut, int nWSF, int *nSCounts = NULL );
/// Save Pack
int SavePack( int nComp );
/// Free Pack
int FreePack( void );
/// Set Pack Name (for Saving WSF)
int SetPackName( char *cName );
/// Load Previously Begun Pack
int LoadPack( char *cName );
int ReplaceSamplesForSave( wsf_modout *wOut, CBaseLoader *xBL, wsf_loaddata *wLD );
/// Gets Mod Type
wsfb GetModType2( void )
{
return m_nModType;
};
/// Returns the ascii handler class
CWSFAscii *GetAscii( void )
{
return &m_mAsc;
};
CWSFPackV1 *GetPack( void )
{
return m_wPack;
};
/// Sets pack with this, NULL to stop using wsf_file.
void SetPack( wsf_file *wPack )
{
m_fPack = wPack;
};
CWSFModV1();
~CWSFModV1();
/// Sets password sum before needing to convert to WSF or back
void SetPassSum( int nPassSum );
char m_cModTitle[30]; ///< Mod Title
char m_cCurPack[200]; ///< Current Pack Name for WSF
wsf_loaddata m_wLD; ///< Load Data Structure
private:
int m_nLoaded; ///< MOD Loaded?
wsfb m_nModType; ///< Mod Type from WSFModVers enum
CWSFPackV1 *m_wPack; ///< Pack
CWSFAscii m_mAsc; ///< Ascii Handler
wsf_file *m_fPack; ///< If not NULL, will call SetPack with this.
};
CBaseLoader *GetBaseLoader( wsfb nModType );
void FreeGSPData( wsf_gspdata *gspData );
void InitGSPData( wsf_gspdata *gspData );
/// Pushes values into gspData (ONLY IF YOU START WITH 0 SAMPLES AND MUST LOAD THROUGH)
void PushIntoGSP( wsf_gspdata *gspData, wsul nSize, wsul nOffset, wsul nSamps, wsfb nCh, wsfb nBit, char *cName );
#endif