@@ -5,35 +5,13 @@ unit HugeDatatypes; |
| 5 |
interface |
5 |
interface |
| 6 |
|
6 |
|
| 7 |
uses |
7 |
uses |
| 8 |
Classes, SysUtils, fgl, instruments, waves; |
8 |
Classes, SysUtils, fgl; |
| 9 |
|
9 |
|
| 10 |
type |
10 |
type |
| 11 |
Nibble = $0..$F; |
11 |
Nibble = $0..$F; |
| 12 |
|
12 |
|
| 13 |
TRoutine = string; |
13 |
TRoutine = string; |
| 14 |
|
14 |
|
| 15 |
TInstrumentBankV1 = packed array[1..15] of TInstrumentV1; |
|
|
| 16 |
TInstrumentCollectionV1 = packed record |
|
|
| 17 |
case Boolean of |
|
|
| 18 |
False: (Duty, Wave, Noise: TInstrumentBankV1); |
|
|
| 19 |
True: (All: packed array[1..45] of TInstrumentV1); |
|
|
| 20 |
end; |
|
|
| 21 |
|
|
|
| 22 |
TInstrumentBankV2 = packed array[1..15] of TInstrumentV2; |
|
|
| 23 |
TInstrumentCollectionV2 = packed record |
|
|
| 24 |
case Boolean of |
|
|
| 25 |
False: (Duty, Wave, Noise: TInstrumentBankV2); |
|
|
| 26 |
True: (All: packed array[1..45] of TInstrumentV2); |
|
|
| 27 |
end; |
|
|
| 28 |
|
|
|
| 29 |
TInstrumentBank = TInstrumentBankV2; |
|
|
| 30 |
TInstrumentCollection = TInstrumentCollectionV2; |
|
|
| 31 |
|
|
|
| 32 |
TWaveBankV1 = packed array[0..15] of TWaveV1; |
|
|
| 33 |
TWaveBankV2 = packed array[0..15] of TWaveV2; |
|
|
| 34 |
TWaveBank = TWaveBankV2; |
|
|
| 35 |
TRoutineBank = packed array[0..15] of TRoutine; |
|
|
| 36 |
|
|
|
| 37 |
TEffectParams = bitpacked record |
15 |
TEffectParams = bitpacked record |
| 38 |
case Boolean of |
16 |
case Boolean of |
| 39 |
True: (Param2, Param1: Nibble); |
17 |
True: (Param2, Param1: Nibble); |
@@ -75,6 +53,259 @@ type |
| 75 |
destructor Destroy; override; |
53 |
destructor Destroy; override; |
| 76 |
end; |
54 |
end; |
| 77 |
|
55 |
|
|
|
56 |
TWaveV1 = packed array[0..32] of Byte; |
|
|
57 |
TWaveV2 = packed array[0..31] of Byte; |
|
|
58 |
TWave = TWaveV2; |
|
|
59 |
T4bitWave = packed array[0..15] of Byte; |
|
|
60 |
|
|
|
61 |
TInstrumentType = (itSquare = 0, itWave = 1, itNoise = 2); |
|
|
62 |
TDutyType = 0..3; |
|
|
63 |
TSweepType = (stUp, stDown); |
|
|
64 |
TStepWidth = (swFifteen, swSeven); |
|
|
65 |
TEnvelopeVolume = 0..15; |
|
|
66 |
TEnvelopeSweepAmount = 0..7; |
|
|
67 |
TNoiseMacro = array[0..5] of -31..32; |
|
|
68 |
|
|
|
69 |
TInstrumentV1 = packed record |
|
|
70 |
Type_: TInstrumentType; |
|
|
71 |
|
|
|
72 |
Name: ShortString; |
|
|
73 |
Length: Integer; |
|
|
74 |
// Highmask |
|
|
75 |
LengthEnabled: Boolean; |
|
|
76 |
|
|
|
77 |
InitialVolume: TEnvelopeVolume; |
|
|
78 |
VolSweepDirection: TSweepType; |
|
|
79 |
VolSweepAmount: TEnvelopeSweepAmount; |
|
|
80 |
|
|
|
81 |
// itSquare |
|
|
82 |
// NR10 |
|
|
83 |
SweepTime: Integer; |
|
|
84 |
SweepIncDec: TSweepType; |
|
|
85 |
SweepShift: Integer; |
|
|
86 |
|
|
|
87 |
// NR11 |
|
|
88 |
Duty: TDutyType; |
|
|
89 |
|
|
|
90 |
// itWave |
|
|
91 |
|
|
|
92 |
// NR32 |
|
|
93 |
OutputLevel: Integer; |
|
|
94 |
// itWave |
|
|
95 |
Waveform: Integer; |
|
|
96 |
|
|
|
97 |
// itNoise |
|
|
98 |
// NR42 |
|
|
99 |
ShiftClockFreq: Integer; // Unused |
|
|
100 |
CounterStep: TStepWidth; |
|
|
101 |
DividingRatio: Integer; |
|
|
102 |
end; |
|
|
103 |
|
|
|
104 |
TInstrumentV2 = packed record |
|
|
105 |
Type_: TInstrumentType; |
|
|
106 |
|
|
|
107 |
Name: ShortString; |
|
|
108 |
Length: Integer; |
|
|
109 |
// Highmask |
|
|
110 |
LengthEnabled: Boolean; |
|
|
111 |
|
|
|
112 |
InitialVolume: TEnvelopeVolume; |
|
|
113 |
VolSweepDirection: TSweepType; |
|
|
114 |
VolSweepAmount: TEnvelopeSweepAmount; |
|
|
115 |
|
|
|
116 |
// itSquare |
|
|
117 |
// NR10 |
|
|
118 |
SweepTime: Integer; |
|
|
119 |
SweepIncDec: TSweepType; |
|
|
120 |
SweepShift: Integer; |
|
|
121 |
|
|
|
122 |
// NR11 |
|
|
123 |
Duty: TDutyType; |
|
|
124 |
|
|
|
125 |
// itWave |
|
|
126 |
|
|
|
127 |
// NR32 |
|
|
128 |
OutputLevel: Integer; |
|
|
129 |
// itWave |
|
|
130 |
Waveform: Integer; |
|
|
131 |
|
|
|
132 |
// itNoise |
|
|
133 |
// NR42 |
|
|
134 |
ShiftClockFreq: Integer; // Unused |
|
|
135 |
CounterStep: TStepWidth; |
|
|
136 |
DividingRatio: Integer; |
|
|
137 |
NoiseMacro: TNoiseMacro; |
|
|
138 |
end; |
|
|
139 |
|
|
|
140 |
TInstrumentV3 = packed record |
|
|
141 |
Type_: TInstrumentType; |
|
|
142 |
|
|
|
143 |
Name: ShortString; |
|
|
144 |
Length: Integer; |
|
|
145 |
// Highmask |
|
|
146 |
LengthEnabled: Boolean; |
|
|
147 |
|
|
|
148 |
InitialVolume: TEnvelopeVolume; |
|
|
149 |
VolSweepDirection: TSweepType; |
|
|
150 |
VolSweepAmount: TEnvelopeSweepAmount; |
|
|
151 |
|
|
|
152 |
// itSquare |
|
|
153 |
// NR10 |
|
|
154 |
SweepTime: Integer; |
|
|
155 |
SweepIncDec: TSweepType; |
|
|
156 |
SweepShift: Integer; |
|
|
157 |
|
|
|
158 |
// NR11 |
|
|
159 |
Duty: TDutyType; |
|
|
160 |
|
|
|
161 |
// itWave |
|
|
162 |
|
|
|
163 |
// NR32 |
|
|
164 |
OutputLevel: Integer; |
|
|
165 |
// itWave |
|
|
166 |
Waveform: Integer; |
|
|
167 |
|
|
|
168 |
// itNoise |
|
|
169 |
// NR42 |
|
|
170 |
CounterStep: TStepWidth; |
|
|
171 |
Subpattern: TPattern; |
|
|
172 |
end; |
|
|
173 |
|
|
|
174 |
TInstrument = TInstrumentV3; |
|
|
175 |
|
|
|
176 |
TAsmInstrument = array[0..3] of Byte; |
|
|
177 |
|
|
|
178 |
TRegisters = record |
|
|
179 |
case Type_: TInstrumentType of |
|
|
180 |
itSquare: (NR10, NR11, NR12, NR13, NR14: Byte); |
|
|
181 |
itWave: (NR30, NR31, NR32, NR33, NR34: Byte); |
|
|
182 |
itNoise: (NR41, NR42, NR43, NR44: Byte); |
|
|
183 |
end; |
|
|
184 |
|
|
|
185 |
Bit = Boolean; |
|
|
186 |
TwoBits = 0..%11; |
|
|
187 |
ThreeBits = 0..%111; |
|
|
188 |
FourBits = 0..%1111; |
|
|
189 |
FiveBits = 0..%11111; |
|
|
190 |
SixBits = 0..%111111; |
|
|
191 |
SevenBits = 0..%1111111; |
|
|
192 |
EightBits = Byte; |
|
|
193 |
|
|
|
194 |
TSweepRegister = bitpacked record |
|
|
195 |
case Boolean of |
|
|
196 |
True: ( |
|
|
197 |
Shift: ThreeBits; |
|
|
198 |
IncDec: Bit; |
|
|
199 |
SweepTime: ThreeBits; |
|
|
200 |
_: Bit; |
|
|
201 |
); |
|
|
202 |
False: (ByteValue: Byte); |
|
|
203 |
end; |
|
|
204 |
|
|
|
205 |
TSquareLengthRegister = bitpacked record |
|
|
206 |
case Boolean of |
|
|
207 |
True: ( |
|
|
208 |
Length: SixBits; |
|
|
209 |
Duty: TwoBits; |
|
|
210 |
); |
|
|
211 |
False: (ByteValue: Byte); |
|
|
212 |
end; |
|
|
213 |
|
|
|
214 |
TEnvelopeRegister = bitpacked record |
|
|
215 |
case Boolean of |
|
|
216 |
True: ( |
|
|
217 |
SweepNumber: ThreeBits; |
|
|
218 |
Direction: Bit; |
|
|
219 |
InitialVolume: FourBits; |
|
|
220 |
); |
|
|
221 |
False: (ByteValue: Byte); |
|
|
222 |
end; |
|
|
223 |
|
|
|
224 |
TLowByteRegister = Byte; |
|
|
225 |
|
|
|
226 |
THighByteRegister = bitpacked record |
|
|
227 |
case Boolean of |
|
|
228 |
True: ( |
|
|
229 |
FrequencyBits: ThreeBits; |
|
|
230 |
_Padding: ThreeBits; |
|
|
231 |
UseLength: Bit; |
|
|
232 |
Initial: Bit; |
|
|
233 |
); |
|
|
234 |
False: (ByteValue: Byte); |
|
|
235 |
end; |
|
|
236 |
|
|
|
237 |
TCh3SoundOnOffRegister = bitpacked record |
|
|
238 |
case Boolean of |
|
|
239 |
True: ( |
|
|
240 |
_Padding: SevenBits; |
|
|
241 |
Playback: Bit; |
|
|
242 |
); |
|
|
243 |
False: (ByteValue: Byte); |
|
|
244 |
end; |
|
|
245 |
|
|
|
246 |
TCh3SoundLengthRegister = Byte; |
|
|
247 |
|
|
|
248 |
TCh3OutputLevelRegister = bitpacked record |
|
|
249 |
case Boolean of |
|
|
250 |
True: ( |
|
|
251 |
_Padding: FiveBits; |
|
|
252 |
OutputLevel: TwoBits; |
|
|
253 |
_Padding2: Bit; |
|
|
254 |
); |
|
|
255 |
False: (ByteValue: Byte); |
|
|
256 |
end; |
|
|
257 |
|
|
|
258 |
TCh4SoundLengthRegister = 0..63; |
|
|
259 |
|
|
|
260 |
TPolynomialCounterRegister = bitpacked record |
|
|
261 |
case Boolean of |
|
|
262 |
True: ( |
|
|
263 |
DividingRatio: ThreeBits; |
|
|
264 |
SevenBitCounter: Bit; |
|
|
265 |
ShiftClockFrequency: FourBits; |
|
|
266 |
); |
|
|
267 |
False: (ByteValue: Byte); |
|
|
268 |
end; |
|
|
269 |
|
|
|
270 |
TCh4HighByteRegister = bitpacked record |
|
|
271 |
case Boolean of |
|
|
272 |
True: ( |
|
|
273 |
_Padding: SixBits; |
|
|
274 |
UseLength: Bit; |
|
|
275 |
Initial: Bit; |
|
|
276 |
); |
|
|
277 |
False: (ByteValue: Byte); |
|
|
278 |
end; |
|
|
279 |
|
|
|
280 |
TInstrumentBankV1 = packed array[1..15] of TInstrumentV1; |
|
|
281 |
TInstrumentCollectionV1 = packed record |
|
|
282 |
case Boolean of |
|
|
283 |
False: (Duty, Wave, Noise: TInstrumentBankV1); |
|
|
284 |
True: (All: packed array[1..45] of TInstrumentV1); |
|
|
285 |
end; |
|
|
286 |
|
|
|
287 |
TInstrumentBankV2 = packed array[1..15] of TInstrumentV2; |
|
|
288 |
TInstrumentCollectionV2 = packed record |
|
|
289 |
case Boolean of |
|
|
290 |
False: (Duty, Wave, Noise: TInstrumentBankV2); |
|
|
291 |
True: (All: packed array[1..45] of TInstrumentV2); |
|
|
292 |
end; |
|
|
293 |
|
|
|
294 |
TInstrumentBankV3 = packed array[1..15] of TInstrumentV3; |
|
|
295 |
TInstrumentCollectionV3 = packed record |
|
|
296 |
case Boolean of |
|
|
297 |
False: (Duty, Wave, Noise: TInstrumentBankV3); |
|
|
298 |
True: (All: packed array[1..45] of TInstrumentV3); |
|
|
299 |
end; |
|
|
300 |
|
|
|
301 |
TInstrumentBank = TInstrumentBankV3; |
|
|
302 |
TInstrumentCollection = TInstrumentCollectionV3; |
|
|
303 |
|
|
|
304 |
TWaveBankV1 = packed array[0..15] of TWaveV1; |
|
|
305 |
TWaveBankV2 = packed array[0..15] of TWaveV2; |
|
|
306 |
TWaveBank = TWaveBankV2; |
|
|
307 |
TRoutineBank = packed array[0..15] of TRoutine; |
|
|
308 |
|
| 78 |
TOrderMatrix = packed array[0..3] of array of Integer; |
309 |
TOrderMatrix = packed array[0..3] of array of Integer; |
| 79 |
|
310 |
|
| 80 |
TCellPart = ( |
311 |
TCellPart = ( |
@@ -107,6 +338,20 @@ operator = (L, R: TSelectionPos): Boolean; |
| 107 |
procedure IncSelectionPos(var SP: TSelectionPos); |
338 |
procedure IncSelectionPos(var SP: TSelectionPos); |
| 108 |
procedure DecSelectionPos(var SP: TSelectionPos); |
339 |
procedure DecSelectionPos(var SP: TSelectionPos); |
| 109 |
|
340 |
|
|
|
341 |
const |
|
|
342 |
DefaultWaves: array[0..10] of TWave = |
|
|
343 |
(($0,$0,$0,$0,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f), |
|
|
344 |
($0,$0,$0,$0,$0,$0,$0,$0,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f), |
|
|
345 |
($0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f,$f), |
|
|
346 |
($0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$f,$f,$f,$f,$f,$f,$f,$f), |
|
|
347 |
($0,$0,$0,$1,$1,$2,$2,$3,$3,$4,$4,$5,$5,$6,$6,$7,$7,$8,$8,$9,$9,$a,$a,$b,$b,$c,$c,$d,$d,$e,$e,$f), |
|
|
348 |
($f,$e,$d,$c,$b,$a,$9,$8,$7,$6,$5,$4,$3,$2,$1,$0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$a,$b,$c,$d,$e,$f,$f), |
|
|
349 |
($7,$a,$c,$d,$d,$b,$7,$5,$2,$1,$1,$3,$6,$8,$b,$d,$d,$c,$9,$7,$4,$1,$0,$1,$4,$7,$9,$c,$d,$d,$b,$8), |
|
|
350 |
($0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f,$0,$f), |
|
|
351 |
($f,$e,$f,$c,$f,$a,$f,$8,$f,$6,$f,$4,$f,$2,$f,$0,$f,$2,$f,$4,$f,$6,$f,$8,$f,$a,$f,$c,$f,$e,$f,$f), |
|
|
352 |
($f,$e,$d,$d,$c,$c,$b,$b,$a,$a,$9,$9,$8,$8,$7,$7,$8,$a,$b,$d,$f,$1,$2,$4,$5,$7,$8,$a,$b,$d,$e,$e), |
|
|
353 |
($8,$4,$1,$1,$6,$1,$e,$d,$5,$7,$4,$7,$5,$a,$a,$d,$c,$e,$a,$3,$1,$7,$7,$9,$d,$d,$2,$0,$0,$3,$4,$7)); |
|
|
354 |
|
| 110 |
implementation |
355 |
implementation |
| 111 |
|
356 |
|
| 112 |
uses Utils; |
357 |
uses Utils; |