-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuntDispatcher.pas
277 lines (247 loc) · 9.67 KB
/
untDispatcher.pas
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
{
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Boban Spasic
Unit description:
Decide the conversion to be done depending on the input files
}
unit untDispatcher;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, TypInfo, untdxutils, untConverter;
procedure DispatchCheck(ABank: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string); //TX7 and DX7II
procedure DispatchCheck(ABankA, ABankB: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string); overload; //DX7II big dump
procedure DispatchCheck(ABankA, ABankB, APerf: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string); overload; //DX7II with Performance
procedure DispatchCheck(ABankA1, ABankB1, ABankA2, ABankB2, APerf: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string); overload; //DX1 and DX5
implementation
procedure DispatchCheck(ABank: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string);
var
msBank: TMemoryStream;
ms: MemSet;
begin
msBank := TMemoryStream.Create;
msBank.LoadFromFile(ABank);
ms := ContainsDX_SixOP_MemSet(msBank);
if (VMEM in ms) and (AMEM in ms) and not ((PMEM in ms) or (LMPMEM in ms) or (D_VMEM in ms) or (D_AMEM in ms)) then
begin
if msBank.Size >= 5232 then
begin
WriteLn('It is a DX7II bank with supplement');
if AVerbose then WriteLn('Using ConvertDX7IItoMDX with one stream');
ConvertDX7IItoMDX(msBank, ABank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
if (VMEM in ms) and (AMEM in ms) and (D_VMEM in ms) and (D_AMEM in ms) and not ((PMEM in ms) or (LMPMEM in ms)) then
begin
if msBank.Size >= 5232 then
begin
WriteLn('It is a multiple DX7II bank with supplement');
if AVerbose then WriteLn('Using ConvertMultiDX7IItoMDX with one stream');
ConvertMultiDX7IItoMDX(msBank, ABank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
if (VMEM in ms) and (PMEM in ms) and not ((AMEM in ms) or (LMPMEM in ms)) then
begin
if msBank.Size >= 8192 then
begin
WriteLn('It is a TX7 bank with function');
if AVerbose then WriteLn('Using ConvertTX7toMDX with one stream');
ConvertTX7toMDX(msBank, AOutput, ANumber, AVerbose);
end;
end;
if (VMEM in ms) and (LMPMEM in ms) and (AMEM in ms) then
begin
if msBank.Size >= 12114 then
begin
WriteLn('It is a DX7II All dump');
if AVerbose then WriteLn('Using ConvertBigDX7IItoMDX with one stream');
ConvertBigDX7IItoMDX(msBank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
if (VMEM in ms) and (LMPMEM in ms) and not (AMEM in ms) then
begin
if (msBank.Size >= 9858) and (msBank.Size <= 18108) then
begin
WriteLn('It is a INCOMPLETE DX7II All dump');
WriteLn('Do not expect wonders from this conversion');
if AVerbose then WriteLn('Using ConvertBigDX7IItoMDX with one stream');
ConvertBigDX7IItoMDX(msBank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
if (VMEM in ms) and (PMEM802 in ms) and (AMEM in ms) then
begin
if msBank.Size >= 16821 then
begin
WriteLn('It is a TX802 All dump');
if AVerbose then WriteLn('Using ConvertTX802ToMDX with one stream');
ConvertTX802ToMDX(msBank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
if (PMEM802 in ms) and not ((AMEM in ms) or (VMEM in ms)) then
begin
if msBank.Size >= 11589 then
begin
WriteLn('It is a TX802 performance');
if AVerbose then WriteLn('Using ConvertTX802ToMDX with one stream');
ConvertTX802ToMDX(msBank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
msBank.Free;
end;
procedure DispatchCheck(ABankA, ABankB: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string); overload;
var
msBankA: TMemoryStream;
msBankB: TMemoryStream;
msAll: TMemoryStream;
msA: MemSet;
msB: MemSet;
begin
msBankA := TMemoryStream.Create;
msBankA.LoadFromFile(ABankA);
msBankB := TMemoryStream.Create;
msBankB.LoadFromFile(ABankB);
msAll := TMemoryStream.Create;
msAll.CopyFrom(msBankA, msBankA.Size);
msAll.CopyFrom(msBankB, msBankB.Size);
msA := ContainsDX_SixOP_MemSet(msBankA);
msB := ContainsDX_SixOP_MemSet(msBankB);
if (VMEM in msA) and (LMPMEM in msA) and (AMEM in msA) and (VMEM in msB) and (LMPMEM in msB) and (AMEM in msB) then
begin
WriteLn('It is a DX7II set');
WriteLn('Be sure to use Internal as Bank A1 and Cartridge as Bank B1 files');
if AVerbose then WriteLn('Using Convert2BigDX7IItoMDX with two streams');
Convert2BigDX7IItoMDX(msBankA, msBankB, AOutput, ANumber, AVerbose, ASettings);
end;
if (VMEM in msA) and (AMEM in msA) and (LMPMEM in msB) and not ((VMEM in msB) or (AMEM in msB) or (LMPMEM in msA)) then
begin
//VMEM+AMEM in one file, PMEM in other file
WriteLn('It is a DX7II set');
if AVerbose then WriteLn('Using ConvertBigDX7IItoMDX with one stream');
ConvertBigDX7IItoMDX(msAll, AOutput, ANumber, AVerbose, ASettings);
end;
if (VMEM in msA) and (AMEM in msA) and (PMEM802 in msB) then
begin
//VMEM+AMEM in one file, PMEM in other file
WriteLn('It is a TX802 set');
if AVerbose then WriteLn('Using ConvertTX802ToMDX with one stream');
ConvertTX802ToMDX(msAll, ABankB, ANumber, AVerbose, ASettings);
end;
msBankA.Free;
msBankB.Free;
msAll.Free;
end;
procedure DispatchCheck(ABankA, ABankB, APerf: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string);
var
msBankA: TMemoryStream;
msBankB: TMemoryStream;
msPerf: TMemoryStream;
msAll: TMemoryStream;
msA: MemSet;
msB: MemSet;
msP: MemSet;
begin
msBankA := TMemoryStream.Create;
msBankA.LoadFromFile(ABankA);
msBankB := TMemoryStream.Create;
msBankB.LoadFromFile(ABankB);
msPerf := TMemoryStream.Create;
msPerf.LoadFromFile(APerf);
msAll := TMemoryStream.Create;
msAll.CopyFrom(msBankA, msBankA.Size);
msAll.CopyFrom(msBankB, msBankB.Size);
msAll.CopyFrom(msPerf, msPerf.Size);
msA := ContainsDX_SixOP_MemSet(msBankA);
msB := ContainsDX_SixOP_MemSet(msBankB);
msP := ContainsDX_SixOP_MemSet(msPerf);
if (VMEM in msA) and (VMEM in msB) and (AMEM in msA) and (AMEM in msB) and
(LMPMEM in msP) then
begin
WriteLn('It is a DX7II performance set');
if AVerbose then WriteLn('Using ConvertBigDX7IItoMDX with one stream');
ConvertBigDX7IItoMDX(msAll, AOutput, ANumber, AVerbose, ASettings);
end;
if (VMEM in msA) and (VMEM in msB) and (LMPMEM in msP) and not ((AMEM in msA) or (AMEM in msB)) then
begin
WriteLn('It is a INCOMPLETE DX7II performance set without AMEM data');
WriteLn('Do not expect wonders from this conversion');
if AVerbose then WriteLn('Using ConvertBigDX7IItoMDX with one stream');
ConvertBigDX7IItoMDX(msAll, AOutput, ANumber, AVerbose, ASettings);
end;
if (VMEM in msA) and (VMEM in msB) and (AMEM in msA) and (AMEM in msB) and
(PMEM802 in msP) then
begin
WriteLn('It is a TX802 performance set');
if AVerbose then WriteLn('Using ConvertTX802ToMDX with one stream');
ConvertTX802ToMDX(msAll, AOutput, ANumber, AVerbose, ASettings);
end;
msBankA.Free;
msBankB.Free;
msPerf.Free;
msAll.Free;
end;
procedure DispatchCheck(ABankA1, ABankB1, ABankA2, ABankB2, APerf: string; ANumber: integer; AVerbose: boolean; AOutput, ASettings: string);
var
msBankA1: TMemoryStream;
msBankB1: TMemoryStream;
msBankA2: TMemoryStream;
msBankB2: TMemoryStream;
msPerf: TMemoryStream;
msAll: TMemoryStream;
msA1: MemSet;
msB1: MemSet;
msA2: MemSet;
msB2: MemSet;
msP: MemSet;
begin
msBankA1 := TMemoryStream.Create;
msBankA1.LoadFromFile(ABankA1);
msBankB1 := TMemoryStream.Create;
msBankB1.LoadFromFile(ABankB1);
msBankA2 := TMemoryStream.Create;
msBankA2.LoadFromFile(ABankA2);
msBankB2 := TMemoryStream.Create;
msBankB2.LoadFromFile(ABankB2);
msPerf := TMemoryStream.Create;
msPerf.LoadFromFile(APerf);
msAll := TMemoryStream.Create;
msAll.CopyFrom(msBankA1, msBankA1.Size);
msAll.CopyFrom(msBankB1, msBankB1.Size);
msAll.CopyFrom(msBankA2, msBankA2.Size);
msAll.CopyFrom(msBankB2, msBankB2.Size);
msAll.CopyFrom(msPerf, msPerf.Size);
msA1 := ContainsDX_SixOP_MemSet(msBankA1);
msB1 := ContainsDX_SixOP_MemSet(msBankB1);
msA2 := ContainsDX_SixOP_MemSet(msBankA1);
msB2 := ContainsDX_SixOP_MemSet(msBankB1);
msP := ContainsDX_SixOP_MemSet(msPerf);
if (VMEM in msA1) and (VMEM in msB1) and (VMEM in msA2) and
(VMEM in msB2) and (PMEM in msP) then
begin
WriteLn('It is a DX5 performance set');
if AVerbose then WriteLn('Using ConvertDX5toMDX with one stream');
ConvertDX5toMDX(msAll, AOutput, ANumber, AVerbose);
end;
if (VMEM in msA1) and (VMEM in msB1) and (VMEM in msA2) and (VMEM in msA2) and (AMEM in msA1) and (AMEM in msB1) and (AMEM in msA2) and (AMEM in msA2) and (PMEM802 in msP) then
begin
WriteLn('It is a TX802 performance set');
if AVerbose then WriteLn('Using ConvertTX802ToMDX with one stream');
ConvertTX802ToMDX(msAll, AOutput, ANumber, AVerbose, ASettings);
end;
if (VMEM in msA1) and (VMEM in msB1) and (VMEM in msA2) and (VMEM in msA2) and not ((AMEM in msA1) and (AMEM in msB1) and (AMEM in msA2) and (AMEM in msA2)) and (PMEM802 in msP) then
begin
WriteLn('It is a INCOMPLETE TX802 performance set without AMEM data');
WriteLn('Do not expect wonders from this conversion');
if AVerbose then WriteLn('Using ConvertTX802ToMDX with one stream');
ConvertTX802ToMDX(msAll, AOutput, ANumber, AVerbose, ASettings);
end;
msBankA1.Free;
msBankB1.Free;
msBankA2.Free;
msBankB2.Free;
msPerf.Free;
msAll.Free;
end;
end.