-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.pas
7286 lines (6041 loc) · 197 KB
/
main.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
This is part of Vortex Tracker II project
(c)2000-2009 S.V.Bulba
Author: Sergey Bulba, [email protected]
Support page: http://bulba.untergrund.net/
(c)2017-2021 Version 2.0 and later
Ivan Pirog (Flexx/Enhancers), [email protected]
}
{.$DEFINE NOREDRAW}
{.$DEFINE DEBUG}
{.$DEFINE LOGGER}
unit Main;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus,
StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, StdActns,
ActnList, ToolWin, ImgList, AY, WaveOutAPI, trfuncs, grids, ChildWin,
MidiType, MidiIn, ColorThemes, ShellAPI, inifiles, RegExpr{$IFDEF LOGGER}, Logger {$ENDIF};
const
UM_REDRAWTRACKS = WM_USER + 1;
UM_PLAYINGOFF = WM_USER + 2;
UM_FINALIZEWO = WM_USER + 3;
StdAutoEnvMax = 7;
StdAutoEnv: array[0..StdAutoEnvMax, 0..1] of integer =
((1, 1), (3, 4), (1, 2), (1, 4), (3, 1), (5, 2), (2, 1), (3, 2));
AppName = 'Vortex Tracker';
VersionString = '2.6';
IsBeta = ' dev';
BetaNumber = ' 22';
VersionFullString = VersionString + IsBeta + BetaNumber;
FullVersString = AppName + ' ' + VersionFullString;
HalfVersString = 'Version ' + VersionFullString;
VortexDirName = AppName + ' ' + VersionString + IsBeta;
SamplesDefaultDir = '\Instruments\Samples';
OrnamentsDefaultDir = '\Instruments\Ornaments';
DemosongsDefaultDir = '\Demosongs';
FontsDir = '\Fonts';
InternalFonts: array[0..26] of array[0..1] of string = (
('SegoeVT', 'Segoe VT'),
('ArrowsFont', 'Arrows'),
('ConsolasFont', 'Consolas'),
('ConsolasBFont', 'Consolas'),
('CQMono', 'CQ Mono'),
('DroidSansFont', 'Droid Sans Mono'),
('ConsolaMono', 'Consola Mono'),
('ConsolaMonoBold', 'Consola Mono'),
('EtelkaMono', 'Etelka Monospace Pro'),
('EtelkaMonoBold', 'Etelka Monospace Pro'),
('RobotoMono', 'Roboto Mono'),
('RobotoMonoBold', 'Roboto Mono'),
('HackFont', 'Hack'),
('HackBFont', 'Hack'),
('LiberationFont', 'Liberation Mono'),
('LiberationBFont', 'Liberation Mono'),
('ShareTechFont', 'Share Tech Mono'),
('ZXSpectrumFont', 'ZX Spectrum'),
('Kongtext', 'Kongtext'),
('Gohufont', 'gohufont-14'),
('GohufontBold', 'gohufont-14b'),
('ProFontWindows', 'ProFontWindows'),
('JackInput', 'JackInput'),
('CourierNew', 'Courier New'),
('CourierNewB', 'Courier New'),
('CourierNewI', 'Courier New'),
('wstgerm', 'WST_Germ')
);
ModuleExtensions: array[0..14] of string = (
'.vt2', '.pt1', '.pt2', '.pt3', '.stc', '.stp',
'.sqt', '.asc', '.psc', '.fls', '.gtr', '.ftc',
'.psm', '.fxm', '.ay'
);
type
TSize = record
Width: Integer;
Height: Integer;
Left: Integer;
Top: Integer;
end;
TChansArrayBool = array[0..2] of boolean;
ERegistryError = class(Exception);
TMainForm = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
FileNewItem: TMenuItem;
FileOpenItem: TMenuItem;
FileCloseItem: TMenuItem;
Window1: TMenuItem;
Help1: TMenuItem;
N1: TMenuItem;
FileExitItem: TMenuItem;
HelpAboutItem: TMenuItem;
OpenDialog: TOpenDialog;
FileSaveItem: TMenuItem;
FileSaveAsItem: TMenuItem;
Edit1: TMenuItem;
CutItem: TMenuItem;
CopyItem: TMenuItem;
PasteItem: TMenuItem;
StatusBar: TStatusBar;
ActionList1: TActionList;
FileNew1: TAction;
FileSave1: TAction;
FileExit1: TAction;
FileOpen1: TAction;
FileSaveAs1: TAction;
HelpAbout1: TAction;
FileClose1: TWindowClose;
ToolBar2: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton9: TToolButton;
ImageList1: TImageList;
N2: TMenuItem;
Options1: TMenuItem;
SaveDialog1: TSaveDialog;
ToolButton13: TToolButton;
Play1: TAction;
Play2: TMenuItem;
Play4: TMenuItem;
Stop2: TMenuItem;
PopupMenu1: TPopupMenu;
Setloopposition1: TMenuItem;
Deleteposition1: TMenuItem;
Insertposition1: TMenuItem;
SetLoopPos: TAction;
InsertPosition: TAction;
DeletePosition: TAction;
ToolButton15: TToolButton;
ToggleLooping: TAction;
Togglelooping1: TMenuItem;
N3: TMenuItem;
RFile1: TMenuItem;
RFile2: TMenuItem;
RFile3: TMenuItem;
RFile4: TMenuItem;
RFile5: TMenuItem;
RFile6: TMenuItem;
ToggleChip: TAction;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ToggleChanAlloc: TAction;
ToolButton17: TToolButton;
ToggleLoopingAll: TAction;
Play3: TMenuItem;
Toggleloopingall1: TMenuItem;
N4: TMenuItem;
Tracksmanager1: TMenuItem;
Globaltransposition1: TMenuItem;
TrackBar1: TTrackBar;
PlayPat: TAction;
PlayPatFromLine: TAction;
ToolButton20: TToolButton;
ToolButton21: TToolButton;
Playpatternfromstart1: TMenuItem;
Playpatternfromcurrentline1: TMenuItem;
Exports1: TMenuItem;
SaveSNDHMenu: TMenuItem;
SaveDialogSNDH: TSaveDialog;
SaveforZXMenu: TMenuItem;
SaveDialogZXAY: TSaveDialog;
EditCopy1: TAction;
EditCut1: TAction;
EditPaste1: TAction;
Undo: TAction;
Redo: TAction;
Undo1: TMenuItem;
Redo1: TMenuItem;
TransposeUp1: TAction;
TransposeDown1: TAction;
TransposeUp12: TAction;
TransposeDown12: TAction;
PopupMenu2: TPopupMenu;
TransposeUp1a: TMenuItem;
TransposeDown1a: TMenuItem;
TransposeUp12a: TMenuItem;
TransposeDown12a: TMenuItem;
N5: TMenuItem;
Undo2: TMenuItem;
Redo2: TMenuItem;
N6: TMenuItem;
Copy1: TMenuItem;
Cut1: TMenuItem;
Paste1: TMenuItem;
N7: TMenuItem;
ToolButton26: TToolButton;
ToolButton27: TToolButton;
PopupMenu3: TPopupMenu;
File2: TMenuItem;
Play5: TMenuItem;
rack1: TMenuItem;
N8: TMenuItem;
Togglesamples1: TMenuItem;
ToolButton25: TToolButton;
N9: TMenuItem;
ExpandTwice1: TMenuItem;
Compresspattern1: TMenuItem;
Merge1: TMenuItem;
midiin1: TMidiInput;
RenumberPatterns: TMenuItem;
DuplicateLastNoteParams: TAction;
MoveBetwnPatrns: TAction;
AutoNumeratePatterns: TMenuItem;
ToolButton29: TToolButton;
BackupTimer: TTimer;
Color1: TMenuItem;
PositionColorRed: TMenuItem;
PositionColorBlue: TMenuItem;
PositionColorGreen: TMenuItem;
PositionColorMaroon: TMenuItem;
PositionColorPurple: TMenuItem;
PositionColorGray: TMenuItem;
PositionColorTeal: TMenuItem;
PositionColorDefault: TMenuItem;
SyncCheckTimer: TTimer;
SyncFinishTimer: TTimer;
ResetColors: TMenuItem;
sep1: TMenuItem;
sep2: TMenuItem;
sep3: TMenuItem;
DuplicatePosition1: TMenuItem;
ClonePosition1: TMenuItem;
Changepatternslength1: TMenuItem;
sep4: TMenuItem;
Splitpattern1: TMenuItem;
SyncCopyBuffers: TTimer;
PlayStopBtn: TToolButton;
PlayStop: TAction;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
AutoStep0: TAction;
AutoStep1: TAction;
AutoStep2: TAction;
AutoStep3: TAction;
AutoStep4: TAction;
AutoStep5: TAction;
AutoStep6: TAction;
AutoStep7: TAction;
AutoStep8: TAction;
AutoStep9: TAction;
ExportWAV: TMenuItem;
N11: TMenuItem;
ExportToWAV: TAction;
NewTurbosound: TAction;
Newturbosoudtrack1: TMenuItem;
SaveAsTwoModules: TAction;
Saveas2modules1: TMenuItem;
Stop: TAction;
Maximize: TMenuItem;
Maximize1: TAction;
Normal: TAction;
Normal1: TMenuItem;
PlayFromLine: TAction;
PlayFromLine1: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
SwapChannelsLeft: TMenuItem;
SwapChannelsRight: TMenuItem;
SwapChannelsLeft1: TAction;
SwapChannelsRight1: TAction;
JoinTracks: TAction;
JoinTracks1: TMenuItem;
SaveAsTemplate: TAction;
SaveAsTemplate1: TMenuItem;
OpenDemo: TMenuItem;
JmpPatStartAct: TAction;
JmpPatEndAct: TAction;
JmpLineStartAct: TAction;
JmpLineEndAct: TAction;
ExportPSG: TMenuItem;
MIDITimer: TTimer;
PositionColorL1: TMenuItem;
PositionColorL2: TMenuItem;
PositionColorL3: TMenuItem;
PositionColorL4: TMenuItem;
PositionColorL5: TMenuItem;
TransposeUp3: TAction;
TransposeUp5: TAction;
TransposeDown3: TAction;
TransposeDown5: TAction;
TransposeUp3a: TMenuItem;
TransposeDown3a: TMenuItem;
TransposeUp5a: TMenuItem;
TransposeDown5a: TMenuItem;
CopyToModPlug: TMenuItem;
CopyToRenoise: TMenuItem;
CopyToModplugAct: TAction;
CopyToRenoiseAct: TAction;
CopyToFamiAct: TAction;
CopyToFami: TMenuItem;
CopyTo: TMenuItem;
CopyOpenMPT: TMenuItem;
CopyRenoise: TMenuItem;
CopyFami: TMenuItem;
N20: TMenuItem;
N21: TMenuItem;
PackPatternAct: TAction;
PackPattern1: TMenuItem;
ExportPSGAct: TAction;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
JoinTracksBtn: TAction;
ToggleSamplesAct: TAction;
TracksManagerAct: TAction;
GlobalTranspositionAct: TAction;
function IsFileWritable(FilePath: String): Boolean;
function VScrollVisible(NewHeight: Integer): Boolean;
function HScrollVisible(NewLeft: Integer): Boolean;
function VScrollSize(NewHeight: Integer): Integer;
function HScrollSize(NewLeft: Integer): Integer;
function BorderSize: Integer;
function DoubleBorderSize: Integer;
function AbsTop: Integer;
function OuterHeight: Integer;
function MonitorWorkAreaWidth: Integer;
function MonitorWorkAreaHeight: Integer;
function WorkAreaHeight(NewHeight: Integer): Integer;
function OneTrack: Boolean;
function ResizeChildsHeight: Boolean;
function ChildsWidth: Integer;
function ChildsRight: Integer;
function ChildsBottom: Integer;
function ChildsMaxHeight: Integer;
procedure SetWidth(Value: Integer; Fixed: Boolean);
procedure FixWidth;
procedure ResetConstraints(CalculateMinWidth: Boolean);
function IsShortCut(var Message: TWMKey): Boolean; override;
function NoPatterns: Boolean;
function GetSizeForChilds(MainWindowState: TWindowState; MoveChild: Boolean): TSize;
procedure SetWindowSize(NewSize: TSize);
procedure AddWindowListItem(Child: TMDIChild);
procedure DeleteWindowListItem(Child: TMDIChild);
procedure AutoMetrixForChilds(MainWindowState: TWindowState);
procedure SetChildsTab(Tab: Integer);
procedure UnpackSamples;
procedure UnpackOrnaments;
procedure OpenDemosong(Sender: TObject);
procedure UnpackDemosongs;
procedure AppException(Sender: TObject; E: Exception);
procedure SetChildsPosition(MainWindowState: TWindowState);
procedure CreateChildWrapper(const Name: string);
procedure FileNew1Execute(Sender: TObject);
procedure FileOpen1Execute(Sender: TObject);
procedure HelpAbout1Execute(Sender: TObject);
procedure FileExit1Execute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RedrawAllSamOrnBrowsers;
procedure RedrawChilds;
procedure umredrawtracks(var Msg: TMessage); message UM_REDRAWTRACKS;
procedure umplayingoff(var Msg: TMessage); message UM_PLAYINGOFF;
procedure umfinalizewo(var Msg: TMessage); message UM_FINALIZEWO;
procedure Options1Click(Sender: TObject);
procedure FileSave1Execute(Sender: TObject);
procedure FileSave1Update(Sender: TObject);
procedure FileSaveAs1Execute(Sender: TObject);
procedure FileSaveAs1Update(Sender: TObject);
procedure Play1Update(Sender: TObject);
procedure Play1Execute(Sender: TObject);
procedure RestoreTracksFocus;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SetLoopPosExecute(Sender: TObject);
procedure SetLoopPosUpdate(Sender: TObject);
procedure InsertPositionExecute(Sender: TObject);
procedure DeletePositionExecute(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ToggleLoopingExecute(Sender: TObject);
procedure AddFileName(FN: string);
procedure OpenRecent(n: integer);
procedure RFile1Click(Sender: TObject);
procedure RFile2Click(Sender: TObject);
procedure RFile3Click(Sender: TObject);
procedure RFile4Click(Sender: TObject);
procedure RFile5Click(Sender: TObject);
procedure RFile6Click(Sender: TObject);
procedure RestoreControls;
procedure ScrollToPlayingWindow;
procedure ToggleChipExecute(Sender: TObject);
procedure ToggleChanAllocExecute(Sender: TObject);
procedure SetChannelsAllocation(CA: integer);
procedure ToggleLoopingAllExecute(Sender: TObject);
procedure DisableControls(DisableTracks: Boolean);
//procedure CheckSecondWindow(DisableTracks: Boolean);
{
// Commented code block, because users really
// don't need templates for samples
procedure SetSampleTemplate(Tmp: integer);
procedure AddToSampTemplate(const SamTik: TSampleTick);
procedure ResetSampTemplate;
}
procedure SetEmulatingChip(ChType: ChTypes);
procedure TracksManagerUpdate(Sender: TObject);
procedure TracksManagerClick(Sender: TObject);
procedure GlobalTranspositionUpdate(Sender: TObject);
procedure GlobalTranspositionClick(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure ResetOptions;
function IsFontValid(FontName: string): Boolean;
procedure GetFileAssocFromText(FileAssocText: string);
function FileAssocToText: string;
procedure SaveOptions;
procedure LoadOptions;
function IsFileAssociationExists(FileExt: string): boolean;
function IsVortexFileAssociation(FileExt, AssocName: string): boolean;
procedure CheckFileAssociations;
procedure SetFileAssociations;
procedure PlayPatFromLineUpdate(Sender: TObject);
procedure PlayPatUpdate(Sender: TObject);
procedure PlayPatExecute(Sender: TObject);
procedure PlayPatFromLineExecute(Sender: TObject);
procedure SaveSNDHMenuClick(Sender: TObject);
procedure SaveforZXMenuClick(Sender: TObject);
procedure SaveDialogZXAYTypeChange(Sender: TObject);
procedure SetDialogZXAYExt;
procedure SaveDialog1TypeChange(Sender: TObject);
procedure SetPriority(Pr: longword);
procedure EditCopy1Update(Sender: TObject);
procedure EditCut1Update(Sender: TObject);
procedure EditCut1Execute(Sender: TObject);
procedure EditCopy1Execute(Sender: TObject);
procedure EditPaste1Update(Sender: TObject);
procedure EditPaste1Execute(Sender: TObject);
procedure UndoUpdate(Sender: TObject);
procedure UndoExecute(Sender: TObject);
procedure RedoUpdate(Sender: TObject);
procedure RedoExecute(Sender: TObject);
procedure CheckCommandLine;
procedure SavePT3(CW: TMDIChild; FileName: string; AsText: boolean);
procedure SavePT3Backup(CW: TMDIChild; FileName: string; AsText: boolean);
function AllowSave(fn: string): boolean;
procedure RedrawPlWindow(PW: TMDIChild; ps, pat, line: integer);
procedure TransposeChannel(WorkWin: TMDIChild; Pat, Chn, i, Semitones: integer);
procedure TransposeColumns(WorkWin: TMDIChild; Pat: integer; Env: boolean; Chans: TChansArrayBool; LFrom, LTo, Semitones: integer; MakeUndo: boolean);
procedure TransposeSelection(Semitones: integer);
procedure TransposeUp1Update(Sender: TObject);
procedure TransposeDown1Update(Sender: TObject);
procedure TransposeUp12Update(Sender: TObject);
procedure TransposeDown12Update(Sender: TObject);
procedure TransposeUp1Execute(Sender: TObject);
procedure TransposeDown1Execute(Sender: TObject);
procedure TransposeUp12Execute(Sender: TObject);
procedure TransposeDown12Execute(Sender: TObject);
procedure PopupMenu3Click(Sender: TObject);
procedure SetBar(BarNum: integer; Value: boolean);
procedure ToggleSamplesUpdate(Sender: TObject);
procedure ToggleSamplesClick(Sender: TObject);
procedure ExpandTwice1Click(Sender: TObject);
procedure Compresspattern1Click(Sender: TObject);
procedure Merge1Click(Sender: TObject);
procedure midiin1MidiInput(Sender: TObject);
procedure RenumberPatternsClick(Sender: TObject);
procedure UpdateEnvelopeAsNote;
procedure ChangeDupNoteParams;
procedure DuplicateLastNoteParamsExecute(Sender: TObject);
procedure ChangeBetweenPatterns;
procedure MoveBetwnPatrnsExecute(Sender: TObject);
procedure AutoNumeratePatternsClick(Sender: TObject);
procedure AutoCutChilds(NewSize: TSize);
procedure AutoToolBarPosition(NewSize: TSize);
procedure SaveBackups(Sender: TObject);
procedure ChangeBackupTimer;
procedure SetPositionColor(NumColor: byte);
procedure PositionColorRedClick(Sender: TObject);
procedure PositionColorGreenClick(Sender: TObject);
procedure PositionColorBlueClick(Sender: TObject);
procedure PositionColorMaroonClick(Sender: TObject);
procedure PositionColorPurpleClick(Sender: TObject);
procedure PositionColorGrayClick(Sender: TObject);
procedure PositionColorTealClick(Sender: TObject);
procedure PositionColorDefaultClick(Sender: TObject);
procedure PositionColorRedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorGreenDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorBlueDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorMaroonDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorPurpleDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorGrayDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorTealDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorDefaultDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorL1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorL1Click(Sender: TObject);
procedure PositionColorL2DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorL2Click(Sender: TObject);
procedure PositionColorL3DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorL3Click(Sender: TObject);
procedure PositionColorL4DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorL4Click(Sender: TObject);
procedure PositionColorL5DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure PositionColorL5Click(Sender: TObject);
procedure Setloopposition1MeasureItem(Sender: TObject; ACanvas: TCanvas; var Width, Height: Integer);
procedure PopupMenu1Popup(Sender: TObject);
procedure DrawSubmenuColor(Color: TColor; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
procedure SendSyncMessage;
procedure SyncCheckTimerTimer(Sender: TObject);
procedure SyncFinishTimerTimer(Sender: TObject);
procedure PrepareColors;
procedure ResetColorsClick(Sender: TObject);
procedure DuplicatePosition1Click(Sender: TObject);
procedure ClonePosition1Click(Sender: TObject);
procedure Changepatternslength1Click(Sender: TObject);
procedure Splitpattern1Click(Sender: TObject);
procedure PositionColorBlackClick(Sender: TObject);
procedure RedrawOff;
procedure RedrawOn;
procedure InsertPositionUpdate(Sender: TObject);
procedure DeletePositionUpdate(Sender: TObject);
procedure SyncCopyBuffersTimer(Sender: TObject);
procedure PlayStopExecute(Sender: TObject);
procedure PlayStopUpdate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure AutoStep0Execute(Sender: TObject);
procedure AutoStep1Execute(Sender: TObject);
procedure AutoStep2Execute(Sender: TObject);
procedure AutoStep3Execute(Sender: TObject);
procedure AutoStep4Execute(Sender: TObject);
procedure AutoStep5Execute(Sender: TObject);
procedure AutoStep6Execute(Sender: TObject);
procedure AutoStep7Execute(Sender: TObject);
procedure AutoStep8Execute(Sender: TObject);
procedure AutoStep9Execute(Sender: TObject);
procedure ExportToWAVExecute(Sender: TObject);
procedure ExportToWAVUpdate(Sender: TObject);
procedure NewTurbosoundExecute(Sender: TObject);
procedure SaveAsTwoModulesUpdate(Sender: TObject);
procedure FormDblClick(Sender: TObject);
procedure StopExecute(Sender: TObject);
procedure Maximize1Execute(Sender: TObject);
procedure NormalExecute(Sender: TObject);
procedure PlayFromLineExecute(Sender: TObject);
procedure SaveAsTwoModulesExecute(Sender: TObject);
procedure PlayFromLineUpdate(Sender: TObject);
procedure ToggleLoopingAllUpdate(Sender: TObject);
procedure ToggleLoopingUpdate(Sender: TObject);
procedure StopUpdate(Sender: TObject);
procedure FileNew1Update(Sender: TObject);
procedure FileOpen1Update(Sender: TObject);
procedure FileClose1Update(Sender: TObject);
procedure NewTurbosoundUpdate(Sender: TObject);
procedure SwapChannelsLeft1Execute(Sender: TObject);
procedure SwapChannelsRight1Execute(Sender: TObject);
procedure SwapChannelsLeft1Update(Sender: TObject);
procedure SwapChannelsRight1Update(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure JoinTracksUpdate(Sender: TObject);
procedure JoinTracksExecute(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SaveAsTemplateUpdate(Sender: TObject);
procedure SaveAsTemplateExecute(Sender: TObject);
procedure UpdateDecHexValues;
procedure DisableControlsForExport;
procedure EnableControlsForExport;
procedure MIDITimerTimer(Sender: TObject);
procedure TransposeUp3Execute(Sender: TObject);
procedure TransposeDown3Execute(Sender: TObject);
procedure TransposeUp5Execute(Sender: TObject);
procedure TransposeDown5Execute(Sender: TObject);
procedure TransposeUp3Update(Sender: TObject);
procedure TransposeDown3Update(Sender: TObject);
procedure TransposeUp5Update(Sender: TObject);
procedure TransposeDown5Update(Sender: TObject);
procedure CopyToModplugActUpdate(Sender: TObject);
procedure CopyToRenoiseActUpdate(Sender: TObject);
procedure CopyToModplugActExecute(Sender: TObject);
procedure CopyToRenoiseActExecute(Sender: TObject);
procedure CopyToFamiActUpdate(Sender: TObject);
procedure CopyToFamiActExecute(Sender: TObject);
procedure PackPatternActExecute(Sender: TObject);
procedure ExportPSGActExecute(Sender: TObject);
procedure ExportPSGActUpdate(Sender: TObject);
procedure StatusBarDblClick(Sender: TObject);
private
{ Private declarations }
procedure CloseTemplateModule;
procedure CreateMDIChild(const Name: string; Turbosound: Boolean);
procedure WMSysCommand(var Msg: TWMSysCommand);message WM_SYSCOMMAND;
//procedure WMSize(var Msg: TWMSize); message WM_SIZE;
//procedure WMSizing(var Msg: TWMSize); message WM_SIZING;
procedure WMPosChanging(var Msg: TWMWINDOWPOSCHANGING); message WM_WINDOWPOSCHANGING;
//procedure WMWindowPosChanged(var Msg: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED;
procedure WMDropFiles(var Msg: TWMDropFiles);message WM_DROPFILES;
procedure WMDisplayChange(var Message: TWMDisplayChange);message WM_DISPLAYCHANGE;
procedure WMUser(var Message:TMessage); message WM_USER;
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
{ Public declarations }
PrevTop: Integer;
WidthFix, HeightFix: Integer;
SizeFixed: Boolean;
SnapedToRight: Boolean;
Snaped: Boolean;
MaximizeChilds: Boolean;
Tone_Table_On_Load: integer;
EditorFont: TFont;
TestLineFont: TFont;
RecentFiles: array[0..5] of string;
LoopAllAllowed: boolean;
{
// Sample templates is disabled now
SampleLineTemplates: array of TSampleTick;
CurrentSampleLineTemplate: integer;
}
GlobalVolume, GlobalVolumeMax: integer;
DefaultTable: Smallint;
StartupAction: Byte;
StartupOpenModule: Boolean;
StartupOpenTheme: Boolean;
TemplateSongPath: string;
WinThemeIndex: Integer;
// samples and ornaments for global buffer, for copy/paste
BuffSample: TSample;
BuffOrnament: TOrnament;
NumberOfLinesChanged: boolean;
ResizeActionBlocked: boolean;
SampleBrowserVisible, OrnamentsBrowserVisible: boolean;
VTExit: boolean;
LastChildWidth, LastChildHeight: Integer;
SamplesDir, OrnamentsDir: String;
RedrawEnabled: Boolean;
ChildsTable: array of TMDIChild;
DontAddToRecent: Boolean;
end;
function IntelWord(a: word): word;
type
TLastClipboard = (LCNone, LCTracks, LCSamples, LCOrnaments);
TTracksCopy = record
SrcWindow: TMDIChild;
Pattern: PPattern;
PatNum: Integer;
Channel: Byte;
FromLine: Byte;
ToLine: Byte;
Ornament: Boolean;
Command: Boolean;
end;
TSampleCopy = record
SrcWindow: TMDIChild;
Sample: PSample;
FromColumn: Byte;
ToColumn: Byte;
FromLine: Byte;
ToLine: Byte;
StartColumn: Byte;
StartLine: Byte;
Ready: Boolean;
end;
var
MainForm: TMainForm;
Priority: dword = NORMAL_PRIORITY_CLASS;
TracksCursorXLeft: Integer;
OrnXShift: Integer;
OrnNCol: Integer = 4;
OrnNChars: Integer = 9;
DisableUpdateChilds: Boolean;
SyncMessageFile: string;
SyncVTInstanses: boolean;
SyncSampleBufferFile, SyncOrnamentBufferFile, SyncSamplePartFile: string;
SyncSampleBufferFileAge, SyncOrnamentBufferFileAge, SyncSamplePartFileAge: Integer;
SyncBufferBlocked: Boolean;
ChildsEventsBlocked: Boolean;
EditorFontChanged: Boolean;
DisplayChanged: Boolean;
ColorTheme: TColorTheme;
ColorThemeName: String;
CBackground, CSelLineBackground, CHighlBackground, COutBackground,
COutHlBackground, CText, CSelLineText, CHighlText, COutText,
CLineNum, CSelLineNum, CHighlLineNum, CEnvelope, CSelEnvelope, CNoise, CSelNoise,
CNote, CSelNote, CNoteParams, CSelNoteParams, CNoteCommands,
CSelNoteCommands, CSeparators, COutSeparators,
CSamOrnBackground, CSamOrnSelBackground, CSamOrnText, CSamOrnSelText,
CSamOrnLineNum, CSamOrnSelLineNum, CSamNoise, CSamSelNoise,
CSamOrnSeparators, CSamOrnTone, CSamOrnSelTone,
CFullScreenBackground: TColor;
NoteKeys: array[0..255] of shortint;
Panoram: array[0..2] of Byte;
VortexDir, VortexDocumentsDir, ConfigFilePath: String;
EnvelopeAsNote: Boolean;
DupNoteParams: Boolean;
MoveBetweenPatrns: Boolean;
SamToneShiftAsNote: Boolean;
OrnToneShiftAsNote: Boolean;
PositionSize: Integer;
DecBaseLinesOn: Boolean;
DecBaseNoiseOn: Boolean;
HighlightSpeedOn: Boolean;
DisableSeparators: Boolean;
AutoBackupsOn: Boolean;
AutoBackupsMins: byte;
DisableHints: Boolean;
DisableCtrlClick: Boolean;
DisableInfoWin: Boolean;
VortexFirstStart: Boolean;
ManualChipFreq: Integer;
DefaultChipFreq: Integer;
DefaultIntFreq: Integer;
ExportSampleRate, ExportBitRate, ExportChannels, ExportChip, ExportRepeats: Integer;
ExportPath: String;
ChanAlloc: TChansArray;
ChanAllocIndex: integer;
SysCmd: Integer;
WindowSnap, WindowUnsnap: Boolean;
VScrollbarSize, HScrollbarSize: Integer;
DrawOffAfterClose: Boolean;
MoveShift: Integer;
WinCount: Integer;
FileAssocChanged: Boolean;
SetChildAsTemplate: Boolean;
LastClipboard: TLastClipboard;
TracksCopy: TTracksCopy;
SampleCopy: TSampleCopy;
OrnamentCopySrcWindow: TMDIChild;
SamplesQuickDir, OrnamentsQuickDir: String;
{$IFDEF LOGGER}Logger: TLogger;{$ENDIF}
FileAssociations: array[0..13, 0..3] of string =
(
('1', '.vt2', 'VortexTracker2', 'VortexTracker 2 module'),
('1', '.vtt', 'VortexTracker2Theme', 'VortexTracker Color Theme'),
('0', '.pt1', 'ProTracker1', 'ProTracker 1 module'),
('0', '.pt2', 'ProTracker2', 'ProTracker 2 module'),
('0', '.pt3', 'ProTracker3', 'ProTracker 3 module'),
('0', '.ftc', 'FastTracker', 'Fast Tracker module'),
('0', '.stc', 'SoundTracker1', 'SoundTracker 1.X module'),
('0', '.stp', 'SoundTrackerPro', 'SoundTracker Pro module'),
('0', '.asc', 'ASCSoundMaster', 'ASC Sound Master module'),
('0', '.fls', 'FlashTracker', 'Flash Tracker module'),
('0', '.gtr', 'GlobalTracker', 'Global Tracker module'),
('0', '.psc', 'ProSoundCreator', 'Pro Sound Creator module'),
('0', '.psm', 'ProSoundMaker', 'Pro Sound Maker module'),
('0', '.sqt', 'SQTracker', 'SQ-Tracker module')
);
implementation
{$R *.DFM}
{$J+} { Assignable Typed Constant }
uses About, options, TrkMng, GlbTrn, ExportZX, selectts, TglSams, HotKeys,
Math, Types, InstrumentsPack, Registry, ShlObj, StrUtils, ClipBrd;
type
TStr4 = array[0..3] of char;
const
TSData: packed record
Type1: TStr4; Size1: word;
Type2: TStr4; Size2: word;
TSID: TStr4;
end = (Type1: 'PT3!'; Type2: 'PT3!'; TSID: '02TS');
var
LibHandle: THandle;
AddFontMemResource: function (p1: Pointer; p2: Cardinal; p3: PDesignVector; p4: PDWORD): Cardinal; stdcall;
function UnderWine: Boolean;
const
IsWine: Boolean = False;
Detected: Boolean = False;
var
H: Cardinal;
begin
if Detected then begin
Result := IsWine;
Exit;
end;
Result := False;
H := LoadLibrary('ntdll.dll');
if H > HINSTANCE_ERROR then
begin
Result := Assigned(GetProcAddress(H, 'wine_get_version'));
FreeLibrary(H);
end;
IsWine := Result;
Detected := True;
end;
function GetUserDocumentsDir: string;
var
FilePath: array [0..MAX_PATH] of char;
begin
ShGetSpecialFolderPath(0, FilePath, CSIDL_PERSONAL, False);
Result := FilePath;
end;
function TMainForm.IsFileWritable(FilePath: String): Boolean;
var attrs: Integer;
begin
{$WARN SYMBOL_PLATFORM OFF}
Result := True;
// File doesn't exists
if not FileExists(FilePath) then Exit;
// Get current file attributes
attrs := FileGetAttr(FilePath);
if attrs and faReadOnly > 0 then begin
// Try to unset read only attribute
FileSetAttr(FilePath, attrs and not faReadOnly);
// And check for read only again
if FileGetAttr(FilePath) and faReadOnly > 0 then begin
Application.MessageBox(PChar('File "'+ ExtractFilename(FilePath) +'" is read only.'), 'Vortex Tracker',
MB_OK + MB_ICONSTOP + MB_TOPMOST);
Result := False;
end;
end;
{$WARN SYMBOL_PLATFORM ON}
end;
function TMainForm.VScrollVisible(NewHeight: Integer): Boolean;
var i: Integer;
begin
for i := 0 to MDIChildCount-1 do with TMDIChild(MDIChildren[i]) do
if Top < 0 then begin
Result := True;
Exit;
end;
Result := Top + ChildsBottom + OuterHeight + ToolBar2.Height + StatusBar.Height - 6 > Monitor.WorkareaRect.Bottom;
end;
function TMainForm.HScrollVisible(NewLeft: Integer): Boolean;
var i: Integer;
begin
if MDIChildCount < 2 then begin
Result := False;
Exit;
end;
for i := 0 to MDIChildCount-1 do with TMDIChild(MDIChildren[i]) do
if Left < 0 then begin
Result := True;
Exit;
end;
Result := NewLeft + ChildsRight {+ BorderSize} > Monitor.WorkareaRect.Right;
end;
function TMainForm.VScrollSize(NewHeight: Integer): Integer;
begin
if VScrollVisible(NewHeight) then
Result := VScrollbarSize
else
Result := 0;
end;
function TMainForm.HScrollSize(NewLeft: Integer): Integer;
begin
if HScrollVisible(NewLeft) then
Result := HScrollbarSize
else
Result := 0;
end;
function TMainForm.BorderSize: Integer;
const Value: Integer = 0;
begin
if Value = 0 then Value := ((Width - ClientWidth) div 2);
Result := Value;
end;
function TMainForm.DoubleBorderSize: Integer;
const Value: Integer = 0;
begin
if Value = 0 then Value := Width - ClientWidth;
Result := Value;
end;
function TMainForm.AbsTop: Integer;
begin
Result := Top - Monitor.WorkareaRect.Top;
end;
function TMainForm.OuterHeight: Integer;
const Value: Integer = 0;
begin
if Value = 0 then Value := Height - ClientHeight;
Result := Value;
end;
function TMainForm.MonitorWorkAreaWidth: Integer;
const
MonitorNum: Integer = -1;
Value: Integer = 0;
begin
if (MonitorNum = Monitor.MonitorNum) and not DisplayChanged then begin
Result := Value;
Exit;
end;
MonitorNum := Monitor.MonitorNum;
Value := Monitor.WorkareaRect.Right - Monitor.WorkareaRect.Left;
Result := Value;
end;
function TMainForm.MonitorWorkAreaHeight: Integer;
const
MonitorNum: Integer = -1;
Value: Integer = 0;
begin
if (MonitorNum = Monitor.MonitorNum) and not DisplayChanged then begin
Result := Value;
Exit;
end;
MonitorNum := Monitor.MonitorNum;
Value := Monitor.WorkareaRect.Bottom - Monitor.WorkareaRect.Top;
Result := Value;
end;
function TMainForm.WorkAreaHeight(NewHeight: Integer): Integer;
begin
Result := NewHeight - ToolBar2.Height - StatusBar.Height - 5;
end;
function TMainForm.OneTrack: Boolean;
begin
Result := (MDIChildCount = 1) or ((MDIChildCount = 2) and (TMDIChild(ActiveMDIChild).TSWindow <> nil));
end;
function TMainForm.ResizeChildsHeight: Boolean;
var i: Integer;
begin