Commit 82bf854

Nick Faro committed on
New file format version
commit 82bf854bd98e29b80f95cf3823860ba97c0e8a3b parent 507f081
11 changed files +353−463
Modifiedcodegen.pas +2−2
@@ -105,7 +105,7 @@ procedure RenderSongToGBDKC(Song: TSong; DescriptorName: String; Filename: strin
105 SL.Add(IntToStr(HighMask)); 105 SL.Add(IntToStr(HighMask));
106 106
107 for J := Low(TNoiseMacro) to High(TNoiseMacro) do 107 for J := Low(TNoiseMacro) to High(TNoiseMacro) do
108 SL.Add(IntToStr(Byte(Instrument.NoiseMacro[J]))); 108 SL.Add(IntToStr(Byte(0)));
109 end 109 end
110 else 110 else
111 for J := Low(AsmInstrument) to High(AsmInstrument) do 111 for J := Low(AsmInstrument) to High(AsmInstrument) do
@@ -271,7 +271,7 @@ begin
271 SL.Add(IntToStr(HighMask)); 271 SL.Add(IntToStr(HighMask));
272 272
273 for J := Low(TNoiseMacro) to High(TNoiseMacro) do 273 for J := Low(TNoiseMacro) to High(TNoiseMacro) do
274 SL.Add(IntToStr(Instruments[I].NoiseMacro[J])); 274 SL.Add(IntToStr(0));
275 end 275 end
276 else begin 276 else begin
277 for J := Low(AsmInstrument) to High(AsmInstrument) do 277 for J := Low(AsmInstrument) to High(AsmInstrument) do
Modifiedconstants.pas +1−0
@@ -127,6 +127,7 @@ const
127 As8 = 70; 127 As8 = 70;
128 B_8 = 71; 128 B_8 = 71;
129 HIGHEST_NOTE = 71; 129 HIGHEST_NOTE = 71;
130 MIDDLE_NOTE = ((HIGHEST_NOTE - LOWEST_NOTE) div 2)+1;
130 LAST_NOTE = 72; 131 LAST_NOTE = 72;
131 NO_NOTE = 90; 132 NO_NOTE = 90;
132 133
ModifiedhUGETracker.lpi +26−31
@@ -231,7 +231,7 @@
231 <PackageName Value="LCL"/> 231 <PackageName Value="LCL"/>
232 </Item5> 232 </Item5>
233 </RequiredPackages> 233 </RequiredPackages>
234 <Units Count="25"> 234 <Units Count="24">
235 <Unit0> 235 <Unit0>
236 <Filename Value="hUGETracker.lpr"/> 236 <Filename Value="hUGETracker.lpr"/>
237 <IsPartOfProject Value="True"/> 237 <IsPartOfProject Value="True"/>
@@ -285,84 +285,79 @@
285 <UnitName Value="Constants"/> 285 <UnitName Value="Constants"/>
286 </Unit10> 286 </Unit10>
287 <Unit11> 287 <Unit11>
288 <Filename Value="waves.pas"/>
289 <IsPartOfProject Value="True"/>
290 <UnitName Value="Waves"/>
291 </Unit11>
292 <Unit12>
293 <Filename Value="about_hugetracker.pas"/> 288 <Filename Value="about_hugetracker.pas"/>
294 <IsPartOfProject Value="True"/> 289 <IsPartOfProject Value="True"/>
295 <ComponentName Value="frmAboutHugetracker"/> 290 <ComponentName Value="frmAboutHugetracker"/>
296 <HasResources Value="True"/> 291 <HasResources Value="True"/>
297 <ResourceBaseClass Value="Form"/> 292 <ResourceBaseClass Value="Form"/>
298 </Unit12> 293 </Unit11>
299 <Unit13> 294 <Unit12>
300 <Filename Value="trackergrid.pas"/> 295 <Filename Value="trackergrid.pas"/>
301 <IsPartOfProject Value="True"/> 296 <IsPartOfProject Value="True"/>
302 <UnitName Value="TrackerGrid"/> 297 <UnitName Value="TrackerGrid"/>
303 </Unit13> 298 </Unit12>
304 <Unit14> 299 <Unit13>
305 <Filename Value="clipboardutils.pas"/> 300 <Filename Value="clipboardutils.pas"/>
306 <IsPartOfProject Value="True"/> 301 <IsPartOfProject Value="True"/>
307 <UnitName Value="ClipboardUtils"/> 302 <UnitName Value="ClipboardUtils"/>
308 </Unit14> 303 </Unit13>
309 <Unit15> 304 <Unit14>
310 <Filename Value="hugedatatypes.pas"/> 305 <Filename Value="hugedatatypes.pas"/>
311 <IsPartOfProject Value="True"/> 306 <IsPartOfProject Value="True"/>
312 <UnitName Value="HugeDatatypes"/> 307 <UnitName Value="HugeDatatypes"/>
313 </Unit15> 308 </Unit14>
314 <Unit16> 309 <Unit15>
315 <Filename Value="codegen.pas"/> 310 <Filename Value="codegen.pas"/>
316 <IsPartOfProject Value="True"/> 311 <IsPartOfProject Value="True"/>
317 <UnitName Value="Codegen"/> 312 <UnitName Value="Codegen"/>
318 </Unit16> 313 </Unit15>
319 <Unit17> 314 <Unit16>
320 <Filename Value="symparser.pas"/> 315 <Filename Value="symparser.pas"/>
321 <IsPartOfProject Value="True"/> 316 <IsPartOfProject Value="True"/>
322 <UnitName Value="SymParser"/> 317 <UnitName Value="SymParser"/>
323 </Unit17> 318 </Unit16>
324 <Unit18> 319 <Unit17>
325 <Filename Value="effecteditor.pas"/> 320 <Filename Value="effecteditor.pas"/>
326 <IsPartOfProject Value="True"/> 321 <IsPartOfProject Value="True"/>
327 <ComponentName Value="frmEffectEditor"/> 322 <ComponentName Value="frmEffectEditor"/>
328 <HasResources Value="True"/> 323 <HasResources Value="True"/>
329 <ResourceBaseClass Value="Form"/> 324 <ResourceBaseClass Value="Form"/>
330 </Unit18> 325 </Unit17>
331 <Unit19> 326 <Unit18>
332 <Filename Value="options.pas"/> 327 <Filename Value="options.pas"/>
333 <IsPartOfProject Value="True"/> 328 <IsPartOfProject Value="True"/>
334 <ComponentName Value="frmOptions"/> 329 <ComponentName Value="frmOptions"/>
335 <HasResources Value="True"/> 330 <HasResources Value="True"/>
336 <ResourceBaseClass Value="Form"/> 331 <ResourceBaseClass Value="Form"/>
337 </Unit19> 332 </Unit18>
338 <Unit20> 333 <Unit19>
339 <Filename Value="rendertowave.pas"/> 334 <Filename Value="rendertowave.pas"/>
340 <IsPartOfProject Value="True"/> 335 <IsPartOfProject Value="True"/>
341 <ComponentName Value="frmRenderToWave"/> 336 <ComponentName Value="frmRenderToWave"/>
342 <HasResources Value="True"/> 337 <HasResources Value="True"/>
343 <ResourceBaseClass Value="Form"/> 338 <ResourceBaseClass Value="Form"/>
344 <UnitName Value="RenderToWave"/> 339 <UnitName Value="RenderToWave"/>
345 </Unit20> 340 </Unit19>
346 <Unit21> 341 <Unit20>
347 <Filename Value="modimport.pas"/> 342 <Filename Value="modimport.pas"/>
348 <IsPartOfProject Value="True"/> 343 <IsPartOfProject Value="True"/>
349 <UnitName Value="MODImport"/> 344 <UnitName Value="MODImport"/>
350 </Unit21> 345 </Unit20>
351 <Unit22> 346 <Unit21>
352 <Filename Value="keymap.pas"/> 347 <Filename Value="keymap.pas"/>
353 <IsPartOfProject Value="True"/> 348 <IsPartOfProject Value="True"/>
354 <UnitName Value="Keymap"/> 349 <UnitName Value="Keymap"/>
355 </Unit22> 350 </Unit21>
356 <Unit23> 351 <Unit22>
357 <Filename Value="hugesettings.pas"/> 352 <Filename Value="hugesettings.pas"/>
358 <IsPartOfProject Value="True"/> 353 <IsPartOfProject Value="True"/>
359 <UnitName Value="hUGESettings"/> 354 <UnitName Value="hUGESettings"/>
360 </Unit23> 355 </Unit22>
361 <Unit24> 356 <Unit23>
362 <Filename Value="dmfimport.pas"/> 357 <Filename Value="dmfimport.pas"/>
363 <IsPartOfProject Value="True"/> 358 <IsPartOfProject Value="True"/>
364 <UnitName Value="DMFImport"/> 359 <UnitName Value="DMFImport"/>
365 </Unit24> 360 </Unit23>
366 </Units> 361 </Units>
367 </ProjectOptions> 362 </ProjectOptions>
368 <CompilerOptions> 363 <CompilerOptions>
Modifiedhugedatatypes.pas +268−23
@@ -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;
Modifiedinstruments.pas +4−190
@@ -5,193 +5,7 @@ unit instruments;
5 interface 5 interface
6 6
7 uses 7 uses
8 Classes, SysUtils; 8 Classes, SysUtils, HugeDatatypes;
9
10 type
11 TInstrumentType = (itSquare = 0, itWave = 1, itNoise = 2);
12 TDutyType = 0..3;
13 TSweepType = (stUp, stDown);
14 TStepWidth = (swFifteen, swSeven);
15 TEnvelopeVolume = 0..15;
16 TEnvelopeSweepAmount = 0..7;
17 TNoiseMacro = array[0..5] of -31..32;
18
19 TInstrumentV1 = packed record
20 Type_: TInstrumentType;
21
22 Name: ShortString;
23 Length: Integer;
24 // Highmask
25 LengthEnabled: Boolean;
26
27 InitialVolume: TEnvelopeVolume;
28 VolSweepDirection: TSweepType;
29 VolSweepAmount: TEnvelopeSweepAmount;
30
31 // itSquare
32 // NR10
33 SweepTime: Integer;
34 SweepIncDec: TSweepType;
35 SweepShift: Integer;
36
37 // NR11
38 Duty: TDutyType;
39
40 // itWave
41
42 // NR32
43 OutputLevel: Integer;
44 // itWave
45 Waveform: Integer;
46
47 // itNoise
48 // NR42
49 ShiftClockFreq: Integer; // Unused
50 CounterStep: TStepWidth;
51 DividingRatio: Integer;
52 end;
53
54 TInstrumentV2 = packed record
55 Type_: TInstrumentType;
56
57 Name: ShortString;
58 Length: Integer;
59 // Highmask
60 LengthEnabled: Boolean;
61
62 InitialVolume: TEnvelopeVolume;
63 VolSweepDirection: TSweepType;
64 VolSweepAmount: TEnvelopeSweepAmount;
65
66 // itSquare
67 // NR10
68 SweepTime: Integer;
69 SweepIncDec: TSweepType;
70 SweepShift: Integer;
71
72 // NR11
73 Duty: TDutyType;
74
75 // itWave
76
77 // NR32
78 OutputLevel: Integer;
79 // itWave
80 Waveform: Integer;
81
82 // itNoise
83 // NR42
84 ShiftClockFreq: Integer; // Unused
85 CounterStep: TStepWidth;
86 DividingRatio: Integer;
87 NoiseMacro: TNoiseMacro;
88 end;
89
90 TInstrument = TInstrumentV2;
91
92 TAsmInstrument = array[0..3] of Byte;
93
94 TRegisters = record
95 case Type_: TInstrumentType of
96 itSquare: (NR10, NR11, NR12, NR13, NR14: Byte);
97 itWave: (NR30, NR31, NR32, NR33, NR34: Byte);
98 itNoise: (NR41, NR42, NR43, NR44: Byte);
99 end;
100
101 Bit = Boolean;
102 TwoBits = 0..%11;
103 ThreeBits = 0..%111;
104 FourBits = 0..%1111;
105 FiveBits = 0..%11111;
106 SixBits = 0..%111111;
107 SevenBits = 0..%1111111;
108 EightBits = Byte;
109
110 TSweepRegister = bitpacked record
111 case Boolean of
112 True: (
113 Shift: ThreeBits;
114 IncDec: Bit;
115 SweepTime: ThreeBits;
116 _: Bit;
117 );
118 False: (ByteValue: Byte);
119 end;
120
121 TSquareLengthRegister = bitpacked record
122 case Boolean of
123 True: (
124 Length: SixBits;
125 Duty: TwoBits;
126 );
127 False: (ByteValue: Byte);
128 end;
129
130 TEnvelopeRegister = bitpacked record
131 case Boolean of
132 True: (
133 SweepNumber: ThreeBits;
134 Direction: Bit;
135 InitialVolume: FourBits;
136 );
137 False: (ByteValue: Byte);
138 end;
139
140 TLowByteRegister = Byte;
141
142 THighByteRegister = bitpacked record
143 case Boolean of
144 True: (
145 FrequencyBits: ThreeBits;
146 _Padding: ThreeBits;
147 UseLength: Bit;
148 Initial: Bit;
149 );
150 False: (ByteValue: Byte);
151 end;
152
153 TCh3SoundOnOffRegister = bitpacked record
154 case Boolean of
155 True: (
156 _Padding: SevenBits;
157 Playback: Bit;
158 );
159 False: (ByteValue: Byte);
160 end;
161
162 TCh3SoundLengthRegister = Byte;
163
164 TCh3OutputLevelRegister = bitpacked record
165 case Boolean of
166 True: (
167 _Padding: FiveBits;
168 OutputLevel: TwoBits;
169 _Padding2: Bit;
170 );
171 False: (ByteValue: Byte);
172 end;
173
174 TCh4SoundLengthRegister = 0..63;
175
176 TPolynomialCounterRegister = bitpacked record
177 case Boolean of
178 True: (
179 DividingRatio: ThreeBits;
180 SevenBitCounter: Bit;
181 ShiftClockFrequency: FourBits;
182 );
183 False: (ByteValue: Byte);
184 end;
185
186 TCh4HighByteRegister = bitpacked record
187 case Boolean of
188 True: (
189 _Padding: SixBits;
190 UseLength: Bit;
191 Initial: Bit;
192 );
193 False: (ByteValue: Byte);
194 end;
195 9
196 function NoiseInstrumentToRegisters( 10 function NoiseInstrumentToRegisters(
197 Frequency: Word; 11 Frequency: Word;
@@ -246,8 +60,8 @@ begin
246 60
247 // Because *InstrumentToRegisters is meant for previewing, it puts in 61 // Because *InstrumentToRegisters is meant for previewing, it puts in
248 // a value for shift clock freq, so we have to remove it and put in the mask 62 // a value for shift clock freq, so we have to remove it and put in the mask
249 // instead. 63 // instead. The mask is a leftover from old versions, so it's always zero.
250 Poly.ShiftClockFrequency := Instrument.ShiftClockFreq; 64 Poly.ShiftClockFrequency := 0;
251 Result[3] := Regs.NR44; 65 Result[3] := Regs.NR44;
252 end; 66 end;
253 67
@@ -320,7 +134,7 @@ begin
320 134
321 NR43.ShiftClockFrequency := $F - (Frequency shr 7); // Quantize CH4 note 135 NR43.ShiftClockFrequency := $F - (Frequency shr 7); // Quantize CH4 note
322 136
323 NR43.DividingRatio:= Instr.DividingRatio; 137 NR43.DividingRatio:= 0; //Instr.DividingRatio;
324 NR43.SevenBitCounter:=Instr.CounterStep = swSeven; 138 NR43.SevenBitCounter:=Instr.CounterStep = swSeven;
325 139
326 NR44.Initial:= Initial; 140 NR44.Initial:= Initial;
Modifiedsong.pas +32−14
@@ -7,7 +7,7 @@ unit Song;
7 7
8 interface 8 interface
9 9
10 uses Classes, HugeDatatypes, instruments, Constants, waves, math, sysutils; 10 uses Classes, HugeDatatypes, instruments, Constants, math, sysutils;
11 11
12 type 12 type
13 ESongVersionException = class(Exception); 13 ESongVersionException = class(Exception);
@@ -71,7 +71,7 @@ type
71 Artist: ShortString; 71 Artist: ShortString;
72 Comment: ShortString; 72 Comment: ShortString;
73 73
74 Instruments: TInstrumentCollection; 74 Instruments: TInstrumentCollectionV2;
75 Waves: TWaveBank; 75 Waves: TWaveBank;
76 76
77 TicksPerRow: Integer; 77 TicksPerRow: Integer;
@@ -123,6 +123,8 @@ function PatternIsUsed(Idx: Integer; const Song: TSong): Boolean;
123 123
124 implementation 124 implementation
125 125
126 uses Utils;
127
126 // Thanks to WP on the FreePascal forums for this code! 128 // Thanks to WP on the FreePascal forums for this code!
127 // https://forum.lazarus.freepascal.org/index.php/topic,47892.msg344152.html#msg344152 129 // https://forum.lazarus.freepascal.org/index.php/topic,47892.msg344152.html#msg344152
128 130
@@ -454,8 +456,10 @@ begin
454 Comment := ''; 456 Comment := '';
455 end; 457 end;
456 458
457 for I := Low(S.Instruments.All) to High(S.Instruments.All) do 459 for I := Low(S.Instruments.All) to High(S.Instruments.All) do begin
458 S.Instruments.All[I] := Default(TInstrument); 460 S.Instruments.All[I] := Default(TInstrument);
461 BlankPattern(@S.Instruments.All[I].Subpattern);
462 end;
459 463
460 for I := Low(S.Instruments.Duty) to High(S.Instruments.Duty) do begin 464 for I := Low(S.Instruments.Duty) to High(S.Instruments.Duty) do begin
461 with S.Instruments.Duty[I] do begin 465 with S.Instruments.Duty[I] do begin
@@ -493,9 +497,6 @@ begin
493 InitialVolume := High(TEnvelopeVolume); 497 InitialVolume := High(TEnvelopeVolume);
494 VolSweepDirection := stDown; 498 VolSweepDirection := stDown;
495 VolSweepAmount := 0; 499 VolSweepAmount := 0;
496 NoiseMacro := Default(TNoiseMacro);
497 ShiftClockFreq := 0;
498 DividingRatio := 0;
499 CounterStep := swFifteen; 500 CounterStep := swFifteen;
500 end; 501 end;
501 502
@@ -678,7 +679,7 @@ var
678 Result := False; 679 Result := False;
679 end; 680 end;
680 681
681 procedure ConvertPattern(var Pat: TPatternV1); 682 procedure ConvertPattern(var Pat: TPatternV2);
682 var 683 var
683 I: Integer; 684 I: Integer;
684 Regs: TRegisters; 685 Regs: TRegisters;
@@ -689,7 +690,7 @@ var
689 for I := Low(Pat) to High(Pat) do begin 690 for I := Low(Pat) to High(Pat) do begin
690 if (Pat[I].Instrument = 0) or (Pat[I].Note = NO_NOTE) then Continue; 691 if (Pat[I].Instrument = 0) or (Pat[I].Note = NO_NOTE) then Continue;
691 692
692 Regs := NoiseInstrumentToRegisters(NotesToFreqs.KeyData[Pat[I].Note], False, SV4.Instruments.Noise[Pat[I].Instrument]); 693 Regs := NoiseInstrumentToRegisters(NotesToFreqs.KeyData[Pat[I].Note], False, Result.Instruments.Noise[Pat[I].Instrument]);
693 if PolyCounter.DividingRatio = 0 then 694 if PolyCounter.DividingRatio = 0 then
694 RealR := 0.5 695 RealR := 0.5
695 else 696 else
@@ -717,13 +718,13 @@ begin
717 SV4.Instruments.All[I].NoiseMacro := Default(TNoiseMacro); 718 SV4.Instruments.All[I].NoiseMacro := Default(TNoiseMacro);
718 end; 719 end;
719 720
721 Result := UpgradeSong(SV4);
722
720 // Rewrite noise patterns to accomodate the new noise instruments... 723 // Rewrite noise patterns to accomodate the new noise instruments...
721 for I := 0 to SV4.Patterns.Count-1 do 724 for I := 0 to Result.Patterns.Count-1 do
722 if UsedInCH4(SV4.Patterns.Keys[I]) then begin 725 if UsedInCH4(Result.Patterns.Keys[I]) then begin
723 ConvertPattern(SV4.Patterns.Data[I]^); 726 ConvertPattern(Result.Patterns.Data[I]^);
724 end; 727 end;
725
726 Result := UpgradeSong(SV4);
727 end; 728 end;
728 729
729 function UpgradeSong(S: TSongV4): TSong; 730 function UpgradeSong(S: TSongV4): TSong;
@@ -751,7 +752,24 @@ begin
751 SV6.Artist:=S.Artist; 752 SV6.Artist:=S.Artist;
752 SV6.Comment:=S.Comment; 753 SV6.Comment:=S.Comment;
753 754
754 SV6.Instruments:=S.Instruments; 755 for I := Low(S.Instruments.All) to High(S.Instruments.All) do begin
756 SV6.Instruments.All[I].Type_ := S.Instruments.All[I].Type_;
757 SV6.Instruments.All[I].Name := S.Instruments.All[I].Name;
758 SV6.Instruments.All[I].Length := S.Instruments.All[I].Length;
759 SV6.Instruments.All[I].LengthEnabled := S.Instruments.All[I].LengthEnabled;
760 SV6.Instruments.All[I].InitialVolume := S.Instruments.All[I].InitialVolume;
761 SV6.Instruments.All[I].VolSweepDirection := S.Instruments.All[I].VolSweepDirection;
762 SV6.Instruments.All[I].VolSweepAmount := S.Instruments.All[I].VolSweepAmount;
763 SV6.Instruments.All[I].SweepTime := S.Instruments.All[I].SweepTime;
764 SV6.Instruments.All[I].SweepIncDec := S.Instruments.All[I].SweepIncDec;
765 SV6.Instruments.All[I].SweepShift := S.Instruments.All[I].SweepShift;
766 SV6.Instruments.All[I].Duty := S.Instruments.All[I].Duty;
767 SV6.Instruments.All[I].OutputLevel := S.Instruments.All[I].OutputLevel;
768 SV6.Instruments.All[I].Waveform := S.Instruments.All[I].Waveform;
769 SV6.Instruments.All[I].CounterStep := S.Instruments.All[I].CounterStep;
770 BlankPattern(@SV6.Instruments.All[I].Subpattern);
771 end;
772
755 SV6.Waves := S.Waves; 773 SV6.Waves := S.Waves;
756 774
757 SV6.TicksPerRow:=S.TicksPerRow; 775 SV6.TicksPerRow:=S.TicksPerRow;
Modifiedtracker.lfm +8−31
@@ -1,7 +1,7 @@
1 object frmTracker: TfrmTracker 1 object frmTracker: TfrmTracker
2 Left = 1181 2 Left = 674
3 Height = 902 3 Height = 902
4 Top = 246 4 Top = 72
5 Width = 1458 5 Width = 1458
6 AllowDropFiles = True 6 AllowDropFiles = True
7 Caption = 'hUGETracker' 7 Caption = 'hUGETracker'
@@ -902,18 +902,18 @@ object frmTracker: TfrmTracker
902 end 902 end
903 end 903 end
904 object NoiseGroupBox: TGroupBox 904 object NoiseGroupBox: TGroupBox
905 Left = 7 905 Left = 651
906 Height = 223 906 Height = 59
907 Top = 477 907 Top = 294
908 Width = 397 908 Width = 237
909 Anchors = [] 909 Anchors = []
910 BorderSpacing.Left = 7 910 BorderSpacing.Left = 7
911 BorderSpacing.Top = 7 911 BorderSpacing.Top = 7
912 BorderSpacing.Right = 7 912 BorderSpacing.Right = 7
913 BorderSpacing.Bottom = 7 913 BorderSpacing.Bottom = 7
914 Caption = 'Noise' 914 Caption = 'Noise'
915 ClientHeight = 203 915 ClientHeight = 39
916 ClientWidth = 393 916 ClientWidth = 233
917 ParentFont = False 917 ParentFont = False
918 TabOrder = 4 918 TabOrder = 4
919 object SevenBitCounterCheckbox: TCheckBox 919 object SevenBitCounterCheckbox: TCheckBox
@@ -928,29 +928,6 @@ object frmTracker: TfrmTracker
928 ParentFont = False 928 ParentFont = False
929 TabOrder = 0 929 TabOrder = 0
930 end 930 end
931 object Panel6: TPanel
932 Left = 8
933 Height = 152
934 Top = 40
935 Width = 376
936 BevelOuter = bvLowered
937 ClientHeight = 152
938 ClientWidth = 376
939 ParentFont = False
940 TabOrder = 1
941 object NoiseMacroPaintbox: TPaintBox
942 Left = 1
943 Height = 150
944 Top = 1
945 Width = 374
946 Align = alClient
947 ParentFont = False
948 OnMouseDown = NoiseMacroPaintboxMouseDown
949 OnMouseMove = NoiseMacroPaintboxMouseMove
950 OnMouseUp = NoiseMacroPaintboxMouseUp
951 OnPaint = NoiseMacroPaintboxPaint
952 end
953 end
954 end 931 end
955 end 932 end
956 object GroupBox1: TGroupBox 933 object GroupBox1: TGroupBox
Modifiedtracker.pas +2−57
@@ -6,7 +6,7 @@ interface
6 uses 6 uses
7 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, 7 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
8 Menus, Spin, StdCtrls, ActnList, StdActns, SynEdit, SynHighlighterAny, 8 Menus, Spin, StdCtrls, ActnList, StdActns, SynEdit, SynHighlighterAny,
9 FileUtil, math, Instruments, Waves, Song, Utils, Constants, 9 FileUtil, math, Instruments, Song, Utils, Constants,
10 sound, vars, machine, about_hugetracker, TrackerGrid, lclintf, lmessages, 10 sound, vars, machine, about_hugetracker, TrackerGrid, lclintf, lmessages,
11 Buttons, Grids, DBCtrls, HugeDatatypes, LCLType, Clipbrd, RackCtls, Codegen, 11 Buttons, Grids, DBCtrls, HugeDatatypes, LCLType, Clipbrd, RackCtls, Codegen,
12 SymParser, options, bgrabitmap, effecteditor, RenderToWave, 12 SymParser, options, bgrabitmap, effecteditor, RenderToWave,
@@ -53,8 +53,6 @@ type
53 MenuItem43: TMenuItem; 53 MenuItem43: TMenuItem;
54 MenuItem44: TMenuItem; 54 MenuItem44: TMenuItem;
55 MenuItem54: TMenuItem; 55 MenuItem54: TMenuItem;
56 NoiseMacroPaintbox: TPaintBox;
57 Panel6: TPanel;
58 GBDKCSaveDialog: TSaveDialog; 56 GBDKCSaveDialog: TSaveDialog;
59 RGBDSAsmSaveDialog: TSaveDialog; 57 RGBDSAsmSaveDialog: TSaveDialog;
60 StopAction: TAction; 58 StopAction: TAction;
@@ -301,11 +299,8 @@ type
301 procedure MenuItem41Click(Sender: TObject); 299 procedure MenuItem41Click(Sender: TObject);
302 procedure NoiseMacroPaintboxMouseDown(Sender: TObject; 300 procedure NoiseMacroPaintboxMouseDown(Sender: TObject;
303 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 301 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
304 procedure NoiseMacroPaintboxMouseMove(Sender: TObject; Shift: TShiftState;
305 X, Y: Integer);
306 procedure NoiseMacroPaintboxMouseUp(Sender: TObject; Button: TMouseButton; 302 procedure NoiseMacroPaintboxMouseUp(Sender: TObject; Button: TMouseButton;
307 Shift: TShiftState; X, Y: Integer); 303 Shift: TShiftState; X, Y: Integer);
308 procedure NoiseMacroPaintboxPaint(Sender: TObject);
309 procedure OrderEditStringGridCellProcess(Sender: TObject; aCol, 304 procedure OrderEditStringGridCellProcess(Sender: TObject; aCol,
310 aRow: Integer; processType: TCellProcessType; var aValue: string); 305 aRow: Integer; processType: TCellProcessType; var aValue: string);
311 procedure OrderEditStringGridValidateEntry(sender: TObject; aCol, 306 procedure OrderEditStringGridValidateEntry(sender: TObject; aCol,
@@ -815,7 +810,7 @@ begin
815 Spokeb(Addr+1, Regs.NR41); 810 Spokeb(Addr+1, Regs.NR41);
816 811
817 for I := 0 to 5 do begin 812 for I := 0 to 5 do begin
818 Spokeb(Addr+2+I, Byte(Instr.NoiseMacro[I])); 813 Spokeb(Addr+2+I, Byte(0));
819 end; 814 end;
820 815
821 PokeSymbol(SYM_HALT_MACRO_INDEX, 1); 816 PokeSymbol(SYM_HALT_MACRO_INDEX, 1);
@@ -1233,7 +1228,6 @@ begin
1233 1228
1234 WavePaintbox.Invalidate; 1229 WavePaintbox.Invalidate;
1235 EnvelopePaintBox.Invalidate; 1230 EnvelopePaintBox.Invalidate;
1236 NoiseMacroPaintbox.Invalidate;
1237 end; 1231 end;
1238 1232
1239 procedure TfrmTracker.ChangeToSquare; 1233 procedure TfrmTracker.ChangeToSquare;
@@ -1860,61 +1854,12 @@ begin
1860 DrawingMacro := True; 1854 DrawingMacro := True;
1861 end; 1855 end;
1862 1856
1863 procedure TfrmTracker.NoiseMacroPaintboxMouseMove(Sender: TObject;
1864 Shift: TShiftState; X, Y: Integer);
1865 var
1866 MacroIdx, Val: Integer;
1867 begin
1868 if DrawingMacro then begin
1869 MacroIdx := EnsureRange(Trunc((X/NoiseMacroPaintbox.Width) * 6), 0, 5);
1870 Val := 32-EnsureRange(Trunc((Y/NoiseMacroPaintbox.Height) * 63), 0, 63);
1871
1872 CurrentInstrument^.NoiseMacro[MacroIdx] := Val;
1873 NoiseMacroPaintbox.Invalidate;
1874 end;
1875 end;
1876
1877 procedure TfrmTracker.NoiseMacroPaintboxMouseUp(Sender: TObject; 1857 procedure TfrmTracker.NoiseMacroPaintboxMouseUp(Sender: TObject;
1878 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 1858 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
1879 begin 1859 begin
1880 DrawingMacro := False; 1860 DrawingMacro := False;
1881 end; 1861 end;
1882 1862
1883 procedure TfrmTracker.NoiseMacroPaintboxPaint(Sender: TObject);
1884 var
1885 BarWidth, BarStep: Double;
1886 I: Integer;
1887 Rect: TRect;
1888
1889 function FormatMacroNumber(Val: Integer): string;
1890 begin
1891 if Val = 0 then Exit('')
1892 else if Val > 0 then Exit('+'+IntToStr(Val))
1893 else Exit(IntToStr(Val));
1894 end;
1895
1896 begin
1897 BarWidth := (NoiseMacroPaintbox.Width / 6); // TODO: change this constant?
1898 BarStep := (NoiseMacroPaintbox.Height / 63);
1899 with NoiseMacroPaintbox.Canvas do begin
1900 Brush.Color := clGameboyBlack;
1901 Clear;
1902
1903 Brush.Color := clGameboyMidGreen;
1904 Pen.Color := clGameboyBlack;
1905 for I := Low(TNoiseMacro) to High(TNoiseMacro) do begin
1906 Rect := TRect.Create(
1907 Trunc(I*BarWidth),
1908 NoiseMacroPaintbox.Height div 2,
1909 Trunc((I+1)*BarWidth),
1910 Ceil((NoiseMacroPaintbox.Height / 2) - (CurrentInstrument^.NoiseMacro[I] * BarStep))
1911 );
1912 FillRect(Rect);
1913 TextOut(Rect.Left + Trunc(Rect.Width/2.5), Rect.Top + (Rect.Height div 2), FormatMacroNumber(CurrentInstrument^.NoiseMacro[I]));
1914 end;
1915 end;
1916 end;
1917
1918 procedure TfrmTracker.OrderEditStringGridCellProcess(Sender: TObject; aCol, 1863 procedure TfrmTracker.OrderEditStringGridCellProcess(Sender: TObject; aCol,
1919 aRow: Integer; processType: TCellProcessType; var aValue: string); 1864 aRow: Integer; processType: TCellProcessType; var aValue: string);
1920 begin 1865 begin
Modifiedtrackergrid.pas +9−10
@@ -197,17 +197,16 @@ var
197 NoteString: ShortString; 197 NoteString: ShortString;
198 begin 198 begin
199 with Canvas do begin 199 with Canvas do begin
200 if NoteMap.TryGetData(Cell.Note, NoteString) then begin 200 Font.Color := clNote;
201 Font.Color := clNote; 201
202 TextOut(PenPos.X, PenPos.Y, NoteString); 202 if (Cell.Note = NO_NOTE) or (Cell.Note = MIDDLE_NOTE) then begin
203 end
204 else begin
205 Font.Color := clDots; 203 Font.Color := clDots;
206 if Cell.Note = NO_NOTE then 204 TextOut(PenPos.X, PenPos.Y, '...')
207 TextOut(PenPos.X, PenPos.Y, '...') 205 end
208 else 206 else if Cell.Note > 36 then
209 TextOut(PenPos.X, PenPos.Y, '???'); 207 TextOut(PenPos.X, PenPos.Y, '+'+FormatFloat('00', Cell.Note - MIDDLE_NOTE))
210 end; 208 else if Cell.Note < 36 then
209 TextOut(PenPos.X, PenPos.Y, '-'+FormatFloat('00', MIDDLE_NOTE - Cell.Note));
211 210
212 TextOut(PenPos.X, PenPos.Y, ' '); 211 TextOut(PenPos.X, PenPos.Y, ' ');
213 212
Modifiedutils.pas +1−72
@@ -5,7 +5,7 @@ unit Utils;
5 interface 5 interface
6 6
7 uses 7 uses
8 Classes, SysUtils, Song, Waves, HugeDatatypes, Constants, gHashSet, fgl, instruments, math; 8 Classes, SysUtils, Song, HugeDatatypes, Constants, gHashSet, fgl, instruments, math;
9 9
10 function Lerp(v0, v1, t: Double): Double; 10 function Lerp(v0, v1, t: Double): Double;
11 function Snap(Value, Every: Integer): Integer; 11 function Snap(Value, Every: Integer): Integer;
@@ -16,7 +16,6 @@ procedure BlankPattern(Pat: PPattern);
16 procedure BlankCell(var Cell: TCell); 16 procedure BlankCell(var Cell: TCell);
17 function EffectCodeToStr(Code: Integer; Params: TEffectParams): String; 17 function EffectCodeToStr(Code: Integer; Params: TEffectParams): String;
18 function EffectToExplanation(Code: Integer; Params: TEffectParams): String; 18 function EffectToExplanation(Code: Integer; Params: TEffectParams): String;
19 //function UniqueOrdersDuringPlayback(Song: TSong; FromPos, ToPos: Integer): Integer;
20 19
21 function ModInst(Inst: Integer): Integer; 20 function ModInst(Inst: Integer): Integer;
22 function UnmodInst(Bank: TInstrumentType; Inst: Integer): Integer; 21 function UnmodInst(Bank: TInstrumentType; Inst: Integer): Integer;
@@ -104,76 +103,6 @@ begin
104 end; 103 end;
105 end; 104 end;
106 105
107 {function UniqueOrdersDuringPlayback(Song: TSong; FromPos, ToPos: Integer
108 ): Integer;
109 var
110 Seen: array of Integer;
111 CurOrder, CurRow: Integer;
112 OrderChanged: Boolean;
113 NextOrder, NextRow: Integer;
114 OrderCount, TotalSeenOrders: Integer;
115 Cell: TCell;
116 I: Integer;
117 Pat: TPattern;
118 begin
119 CurOrder := FromPos;
120 CurRow := 0;
121 OrderChanged := True;
122 TotalSeenOrders := 0;
123
124 with Song do
125 OrderCount := MaxIntValue([High(OrderMatrix[0]), High(OrderMatrix[1]),
126 High(OrderMatrix[2]), High(OrderMatrix[3])]);
127
128 SetLength(Seen, OrderCount);
129
130 NextOrder := -1;
131 NextRow := -1;
132 repeat
133 if OrderChanged then begin
134 OrderChanged := False;
135 Inc(Seen[CurOrder]);
136 Inc(TotalSeenOrders);
137 end;
138
139 for I := 0 to 3 do begin
140 Pat := Song.Patterns[Song.OrderMatrix[I, CurOrder]]^;
141 Cell := Pat[CurRow];
142 case Cell.EffectCode of
143 $B: NextOrder := Max(Cell.EffectParams.Value-1, OrderCount-1);
144 $D: NextRow := Cell.EffectParams.Value;
145 end;
146 end;
147
148 if NextOrder = -1 then
149 NextOrder := CurOrder;
150
151 if NextRow = -1 then
152 NextRow := CurRow + 1;
153
154 if NextRow > High(TPattern) then begin
155 NextRow := 0;
156 NextOrder := CurOrder + 1;
157 end;
158
159 if NextOrder > OrderCount-1 then begin
160 OrderChanged := True;
161 NextOrder := 0;
162 end;
163
164 if CurOrder <> NextOrder then
165 OrderChanged := True;
166
167 CurOrder := NextOrder;
168 CurRow := NextRow;
169 NextOrder := -1;
170 NextRow := -1;
171 writeln(CurOrder, ' ', curRow);
172 until (Seen[CurOrder] > 1) or (CurOrder = ToPos);
173
174 Result := TotalSeenOrders;
175 end;}
176
177 function ModInst(Inst: Integer): Integer; 106 function ModInst(Inst: Integer): Integer;
178 begin 107 begin
179 Result := ((Inst-1) mod 15)+1; 108 Result := ((Inst-1) mod 15)+1;
Deletedwaves.pas +0−33
@@ -1,33 +0,0 @@
1 unit Waves;
2
3 {$mode delphi}
4
5 interface
6
7 uses
8 Classes, SysUtils;
9
10 type
11 TWaveV1 = packed array[0..32] of Byte;
12 TWaveV2 = packed array[0..31] of Byte;
13 TWave = TWaveV2;
14 T4bitWave = packed array[0..15] of Byte;
15
16 const
17 DefaultWaves: array[0..10] of TWave =
18 (($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),
19 ($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),
20 ($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),
21 ($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),
22 ($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),
23 ($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),
24 ($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),
25 ($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),
26 ($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),
27 ($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),
28 ($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));
29
30 implementation
31
32 end.
33