-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathadt2ext5.pas
4699 lines (4169 loc) · 167 KB
/
adt2ext5.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 file is part of Adlib Tracker II (AT2).
//
// AT2 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// AT2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with AT2. If not, see <http://www.gnu.org/licenses/>.
unit AdT2ext5;
{$S-,Q-,R-,V-,B-,X+}
{$PACKRECORDS 1}
interface
const
arp_tab_selected: Boolean = FALSE;
vib_tab_selected: Boolean = FALSE;
var
ptr_arpeggio_table: Byte;
ptr_vibrato_table: Byte;
procedure bnk_file_loader;
procedure fib_file_loader;
procedure ibk_file_loader;
procedure bnk_file_loader_alt(instr: Word);
procedure fib_file_loader_alt(instr: Word);
procedure ibk_file_loader_alt(instr: Word);
procedure a2b_file_loader(bankSelector: Boolean; loadBankPossible: Boolean);
procedure a2w_file_loader(loadFromFile: Boolean; loadMacros: Boolean; bankSelector: Boolean;
loadBankPossible: Boolean; updateCurInstr: Boolean);
implementation
uses
{$IFNDEF UNIX}
CRT,
{$ENDIF}
{$IFDEF GO32V2}
GO32,
{$ELSE}
SDL_Timer,
{$ENDIF}
DOS,
AdT2opl3,AdT2sys,AdT2keyb,AdT2unit,AdT2extn,AdT2ext2,AdT2ext3,AdT2ext4,AdT2text,AdT2pack,
StringIO,DialogIO,ParserIO,TxtScrIO,DepackIO;
procedure a2b_lister_external_proc; forward;
procedure a2w_lister_external_proc_callback; forward;
procedure a2w_macro_lister_external_proc_callback; forward;
procedure bnk_lister_external_proc; forward;
procedure fib_lister_external_proc; forward;
procedure ibk_lister_external_proc; forward;
var
xstart,ystart: Byte;
window_xsize,window_ysize: Byte;
context_str,context_str2,context_str3: String;
var
temp_marks: array[1..255] of Char;
a2b_queue: array[1..255+3] of String[74];
a2b_queue_more: array[1..255+3] of String[104];
a2w_queue: array[1..255+3] of String[72];
a2w_queue_more: array[1..255+3] of String[102];
a2w_queue_more2: array[1..255+3] of String[121];
a2w_queue_m: array[1..255+5] of String[72];
a2w_institle_pos: Byte;
update_current_inst: Boolean;
var
xstart_arp,ystart_arp,xstart_vib,ystart_vib: Byte;
scrollbar_xstart,scrollbar_ystart,scrollbar_size: Byte;
macro_table_size: Byte;
arpeggio_table_idx,vibrato_table_idx: Byte;
arpeggio_table_pos,vibrato_table_pos: Byte;
procedure import_old_instruments(old_songdata: pOLD_FIXED_SONGDATA;
new_songdata: pFIXED_SONGDATA;
instr,count: Byte);
var
temp: Byte;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT5.PAS:import_old_instruments';
{$ENDIF}
For temp := instr to instr+PRED(count) do
begin
new_songdata^.instr_names[temp] := Copy(new_songdata^.instr_names[temp],1,9)+
Copy(old_songdata^.instr_names[temp],10,22);
new_songdata^.instr_data[temp].fm_data := old_songdata^.instr_data[temp].fm_data;
new_songdata^.instr_data[temp].panning := old_songdata^.instr_data[temp].panning;
new_songdata^.instr_data[temp].fine_tune := old_songdata^.instr_data[temp].fine_tune;
new_songdata^.instr_data[temp].perc_voice := 0;
end;
end;
function count_instruments: Byte;
var
result: Byte;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT5.PAS:count_instruments';
{$ENDIF}
result := 255;
While (result > 0) and
Empty(temp_songdata.instr_data[result],INSTRUMENT_SIZE) and
(CutStr(Copy(temp_songdata.instr_names[result],10,32)) = '') do
Dec(result);
count_instruments := result;
end;
function count_macros: Byte;
var
result: Byte;
begin
result := 255;
While (result > 0) and Empty(temp_songdata.macro_table[result].arpeggio,
SizeOf(tARPEGGIO_TABLE))
and Empty(temp_songdata.macro_table[result].vibrato,
SizeOf(tVIBRATO_TABLE)) do
Dec(result);
count_macros := result;
end;
function get_free_arpeggio_table_idx(data: tARPEGGIO_TABLE): Byte;
var
result: Byte;
free_flag: Boolean;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT5.PAS:get_free_arpeggio_table_idx';
{$ENDIF}
result := 0;
free_flag := FALSE;
// first try to find empty space or same macro for overwriting
Repeat
Inc(result);
If Empty(songdata.macro_table[result].arpeggio,
SizeOf(tARPEGGIO_TABLE)) or
Compare(songdata.macro_table[result].arpeggio,data,
SizeOf(tARPEGGIO_TABLE)) then
free_flag := TRUE;
until free_flag or (result = 255);
// next to find dummy macro (length=0) for overwriting
If NOT free_flag then
Repeat
If (temp_songdata.macro_table[result].arpeggio.length = 0) then
free_flag := TRUE
else Dec(result);
until free_flag or (result = 0);
get_free_arpeggio_table_idx := result;
end;
function get_free_vibrato_table_idx(data: tVIBRATO_TABLE): Byte;
var
result: Byte;
free_flag: Boolean;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT5.PAS:get_free_vibrato_table_idx';
{$ENDIF}
result := 0;
free_flag := FALSE;
// first try to find empty space or same macro for overwriting
Repeat
Inc(result);
If Empty(songdata.macro_table[result].vibrato,
SizeOf(tViBRATO_TABLE)) or
Compare(songdata.macro_table[result].vibrato,data,
SizeOf(tVIBRATO_TABLE)) then
free_flag := TRUE;
until free_flag or (result = 255);
// next to find dummy macro (length=0) for overwriting
If NOT free_flag then
Repeat
If (temp_songdata.macro_table[result].vibrato.length = 0) then
free_flag := TRUE
else Dec(result);
until free_flag or (result = 0);
get_free_vibrato_table_idx := result;
end;
function _gfx_bar_str(value: Byte; neg: Boolean): String;
var
result: String;
begin
result := '';
If NOT neg then
Repeat
If (value > 15) then
begin
result := result+#219;
Dec(value,15);
end;
If (value <= 15) and (value <> 0) then
result := result+CHR(127+value)
until (value <= 15)
else Repeat
If (value > 15) then
begin
result := #219+result;
Dec(value,15);
end;
If (value <= 15) and (value <> 0) then
result := CHR(158-value)+result;
until (value <= 15);
_gfx_bar_str := flipstr(result);
end;
const
_4op_flag_chr_beg = #172;
_4op_flag_chr_end = #173;
_4op_flag_chars: Set of Char = [_4op_flag_chr_beg,_4op_flag_chr_end];
_4op_flag_column: array[1..255] of Char = '';
_a2b_lister_count: Byte = 0;
_a2w_lister_count: Byte = 0;
var
_4op_idx11,_4op_idx12,
_4op_idx21,_4op_idx22: Byte;
_4op_ins_flag: Boolean;
function check_4op_flag_temp(ins: Byte): Boolean;
var
result: Boolean;
idx: Byte;
begin
result := FALSE;
For idx := 1 to temp_songdata.ins_4op_flags.num_4op do
If (temp_songdata.ins_4op_flags.idx_4op[idx] = ins) then
begin
result := TRUE;
BREAK;
end;
check_4op_flag_temp := result;
end;
function get_4op_to_test_temp: Word;
var
result: Word;
curr_inst: Byte;
begin
result := 0;
curr_inst := mn_environment.curr_pos;
If (curr_inst in [1..255]) and (songdata.flag_4op <> 0) then
If (_4op_flag_column[curr_inst] = _4op_flag_chr_beg) then
result := SUCC(curr_inst)+curr_inst SHL 8
else If (curr_inst > 1) and (_4op_flag_column[curr_inst] = _4op_flag_chr_end) then
result := curr_inst+PRED(curr_inst) SHL 8;
get_4op_to_test_temp := result;
end;
procedure a2b_lister_external_proc_callback; forward;
procedure a2b_lister_external_proc;
var
temp: Byte;
attr: Byte;
begin
For temp := 1 to _a2b_lister_count do
begin
If (mn_environment.curr_pos = mn_environment.curr_page+temp-1) then
attr := mn_setting.text2_attr
else attr := mn_setting.text_attr;
ShowStr(mn_environment.v_dest,mn_environment.xpos+1,mn_environment.ypos+3+temp,
_4op_flag_column[mn_environment.curr_page+temp-1],
attr);
end;
a2b_lister_external_proc_callback;
end;
procedure a2b_file_loader(bankSelector: Boolean; loadBankPossible: Boolean);
type
tOLD_HEADER = Record
ident: array[1..11] of Char;
crc32: Longint;
ffver: Byte;
b0len: Word;
end;
type
tHEADER = Record
ident: array[1..11] of Char;
crc32: Longint;
ffver: Byte;
b0len: Longint;
end;
const
id = '_A2insbank_';
var
f: File;
header: tOLD_HEADER;
header2: tHEADER;
crc,temp: Longint;
old_external_proc: procedure;
old_topic_len: Byte;
old_cycle_moves: Boolean;
idx,index,nm_valid: Byte;
temp_str: String;
ysize: Byte;
const
new_keys: array[1..3] of Word = (kESC,kENTER,kCtENTR);
var
old_keys: array[1..3] of Word;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT5.PAS:a2b_file_loader';
{$ENDIF}
progress_num_steps := 0;
progress_step := 0;
{$i-}
Assign(f,instdata_source);
ResetF(f);
{$i+}
If (IOresult <> 0) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - DiSK ERROR?$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
temp_songdata := songdata;
BlockReadF(f,header,SizeOf(header),temp);
If NOT ((temp = SizeOf(header)) and (header.ident = id)) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
If NOT (header.ffver in [1..FFVER_A2B]) then
begin
CloseF(f);
Dialog('UNKNOWN FiLE FORMAT VERSiON$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
init_old_songdata;
If (header.ffver in [1..4]) then
begin
FillChar(buf1,SizeOf(buf1),0);
BlockReadF(f,buf1,header.b0len,temp);
If NOT (temp = header.b0len) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
crc := DWORD_NULL;
crc := Update32(header.b0len,2,crc);
crc := Update32(buf1,header.b0len,crc);
If (crc <> header.crc32) then
begin
CloseF(f);
Dialog('CRC FAiLED - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
Case header.ffver of
4: Move(buf1,old_songdata.instr_names,header.b0len);
3: LZSS_decompress(buf1,old_songdata.instr_names,header.b0len);
2: LZW_decompress(buf1,old_songdata.instr_names);
1: SIXPACK_decompress(buf1,old_songdata.instr_names,header.b0len);
end;
For temp := 1 to 250 do
old_songdata.instr_data[temp].panning := 0;
import_old_instruments(Addr(old_songdata),Addr(temp_songdata),1,250);
end;
If (header.ffver in [5..8]) then
begin
FillChar(buf1,SizeOf(buf1),0);
BlockReadF(f,buf1,header.b0len,temp);
If NOT (temp = header.b0len) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
crc := DWORD_NULL;
crc := Update32(header.b0len,2,crc);
crc := Update32(buf1,header.b0len,crc);
If (crc <> header.crc32) then
begin
CloseF(f);
Dialog('CRC FAiLED - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
Case header.ffver of
8: Move(buf1,old_songdata.instr_names,header.b0len);
7: LZSS_decompress(buf1,old_songdata.instr_names,header.b0len);
6: LZW_decompress(buf1,old_songdata.instr_names);
5: SIXPACK_decompress(buf1,old_songdata.instr_names,header.b0len);
end;
import_old_instruments(Addr(old_songdata),Addr(temp_songdata),1,250);
end;
If (header.ffver = 9) then
begin
ResetF(f);
BlockReadF(f,header2,SizeOf(header2),temp);
If NOT ((temp = SizeOf(header2)) and (header2.ident = id)) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
FillChar(buf1,SizeOf(buf1),0);
BlockReadF(f,buf1,header2.b0len,temp);
If NOT (temp = header2.b0len) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
crc := DWORD_NULL;
crc := Update32(header2.b0len,2,crc);
crc := Update32(buf1,header2.b0len,crc);
If (crc <> header2.crc32) then
begin
CloseF(f);
Dialog('CRC FAiLED - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
For temp := 1 to 255 do
temp_marks[temp] := temp_songdata.instr_names[temp][1];
APACK_decompress(buf1,temp_songdata.instr_names);
For temp := 1 to 255 do
Insert(temp_marks[temp]+
'iNS_'+byte2hex(temp)+#247' ',
temp_songdata.instr_names[temp],1);
end;
If (header.ffver = FFVER_A2B) then
begin
ResetF(f);
BlockReadF(f,header2,SizeOf(header2),temp);
If NOT ((temp = SizeOf(header2)) and (header2.ident = id)) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
FillChar(buf1,SizeOf(buf1),0);
BlockReadF(f,buf1,header2.b0len,temp);
If NOT (temp = header2.b0len) then
begin
CloseF(f);
Dialog('ERROR READiNG DATA - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
crc := DWORD_NULL;
crc := Update32(header2.b0len,2,crc);
crc := Update32(buf1,header2.b0len,crc);
If (crc <> header2.crc32) then
begin
CloseF(f);
Dialog('CRC FAiLED - FiLE CORRUPTED$'+
'LOADiNG STOPPED$',
'~O~KAY$',' A2B LOADER ',1);
EXIT;
end;
For temp := 1 to 255 do
temp_marks[temp] := temp_songdata.instr_names[temp][1];
progress_num_steps := 0;
LZH_decompress(buf1,buf2,header2.b0len);
Move(buf2,temp_songdata.instr_names,SizeOf(songdata.instr_names)+
SizeOf(songdata.instr_data));
Move(buf2[SizeOf(songdata.instr_names)+
SizeOf(songdata.instr_data)],temp_songdata.ins_4op_flags,
SizeOf(songdata.ins_4op_flags));
For temp := 1 to 255 do
Insert(temp_marks[temp]+
'iNS_'+byte2hex(temp)+#247' ',
temp_songdata.instr_names[temp],1);
end;
FillChar(temp_songdata.dis_fmreg_col,SizeOf(temp_songdata.dis_fmreg_col),FALSE);
CloseF(f);
If NOT bankSelector then
begin
songdata.instr_names := temp_songdata.instr_names;
songdata.instr_data := temp_songdata.instr_data;
load_flag := 1;
EXIT;
end;
// init 4OP flags
FillChar(_4op_flag_column,SizeOf(_4op_flag_column),0);
For temp := 1 to PRED(255) do
If check_4op_flag_temp(temp) then
begin
If NOT (_4op_flag_column[temp] in _4op_flag_chars) then
_4op_flag_column[temp] := _4op_flag_chr_beg;
If NOT (_4op_flag_column[SUCC(temp)] in _4op_flag_chars) then
_4op_flag_column[SUCC(temp)] := _4op_flag_chr_end;
end;
a2b_queue[1] := a2b_header_str[1];
a2b_queue[2] := a2b_header_str[2];
a2b_queue[3] := a2b_header_str[3];
a2b_queue_more[1] := a2b_header_hires_str[1];
a2b_queue_more[2] := a2b_header_hires_str[2];
a2b_queue_more[3] := a2b_header_hires_str[3];
nm_valid := count_instruments;
If (nm_valid = 0) then nm_valid := 1;
For idx := 1 to nm_valid do
begin
a2b_queue[3+idx] := '~'+ExpStrR(Copy(temp_songdata.instr_names[idx],1,9)+'~'+
Copy(temp_songdata.instr_names[idx],10,32),45,' ');
a2b_queue_more[3+idx] := a2b_queue[3+idx];
With temp_songdata.instr_data[idx].fm_data do
begin
a2b_queue_more[3+idx] := a2b_queue_more[3+idx]+
byte2hex(AM_VIB_EG_carrier)+
byte2hex(AM_VIB_EG_modulator)+' '+
byte2hex(KSL_VOLUM_carrier)+
byte2hex(KSL_VOLUM_modulator)+' '+
byte2hex(ATTCK_DEC_carrier)+
byte2hex(ATTCK_DEC_modulator)+' '+
byte2hex(SUSTN_REL_carrier)+
byte2hex(SUSTN_REL_modulator)+' '+
byte2hex(WAVEFORM_carrier)+
byte2hex(WAVEFORM_modulator)+' '+
byte2hex(FEEDBACK_FM)+' ';
end;
Case temp_songdata.instr_data[idx].panning of
0..2: temp_str := ins_pan_str2[temp_songdata.instr_data[idx].panning];
else temp_str := ExpStrL('',7,#250);
end;
a2b_queue[3+idx] := a2b_queue[3+idx]+temp_str+' ';
a2b_queue_more[3+idx] := a2b_queue_more[3+idx]+temp_str+' ';
If (temp_songdata.instr_data[idx].fine_tune > 0) then
temp_str := '+'+ExpStrR(Num2str(temp_songdata.instr_data[idx].fine_tune,16),5,' ')
else If (temp_songdata.instr_data[idx].fine_tune < 0) then
temp_str := '-'+ExpStrR(Num2str(0-temp_songdata.instr_data[idx].fine_tune,16),5,' ')
else temp_str := ExpStrR('',6,' ');
a2b_queue[3+idx] := a2b_queue[3+idx]+temp_str+' ';
a2b_queue_more[3+idx] := a2b_queue_more[3+idx]+temp_str+' ';
Case temp_songdata.instr_data[idx].perc_voice of
0..5: temp_str := perc_voice_str[temp_songdata.instr_data[idx].perc_voice];
else temp_str := ExpStrL('',7,' ');
end;
a2b_queue[3+idx] := a2b_queue[3+idx]+temp_str;
a2b_queue_more[3+idx] := a2b_queue_more[3+idx]+temp_str;
end;
Move(mn_setting.terminate_keys,old_keys,SizeOf(old_keys));
old_external_proc := mn_environment.ext_proc;
old_topic_len := mn_setting.topic_len;
old_cycle_moves := mn_setting.cycle_moves;
Move(new_keys,mn_setting.terminate_keys,SizeOf(new_keys));
mn_environment.ext_proc := a2b_lister_external_proc;
mn_setting.topic_len := 3;
mn_setting.cycle_moves := FALSE;
If loadBankPossible then
mn_environment.context := ' ~[~'+Num2str(nm_valid,10)+'~/255]~ ^ENTER '#196#16' LOAD COMPLETE BANK '
else mn_environment.context := '~[~'+Num2str(nm_valid,10)+'~/255]~';
keyboard_reset_buffer;
If is_default_screen_mode then ysize := 20
else ysize := 30;
_a2b_lister_count := ysize-3;
If NOT _force_program_quit then
If (program_screen_mode in [0,3,4,5]) then
index := Menu(a2b_queue,01,01,min(1,get_bank_position(instdata_source,nm_valid)),
74,ysize,nm_valid+3,' '+iCASE(NameOnly(instdata_source))+' ')
else index := Menu(a2b_queue_more,01,01,min(1,get_bank_position(instdata_source,nm_valid)),
104,30,nm_valid+3,' '+iCASE(NameOnly(instdata_source))+' ');
add_bank_position(instdata_source,nm_valid,index+3);
Move(old_keys,mn_setting.terminate_keys,SizeOf(old_keys));
mn_environment.ext_proc := old_external_proc;
mn_setting.topic_len := old_topic_len;
mn_setting.cycle_moves := old_cycle_moves;
If (mn_environment.keystroke = kENTER) or
(loadBankPossible and (mn_environment.keystroke = kCtENTR)) then
begin
If (mn_environment.keystroke = kENTER) then
begin
If shift_pressed then
begin
// put 4op instrument (alternate)
_4op_ins_flag := FALSE;
If (_4op_flag_column[index] = _4op_flag_chr_beg) then
If check_4op_flag(current_inst) then
begin
_4op_ins_flag := TRUE;
_4op_idx11 := current_inst;
_4op_idx12 := SUCC(current_inst);
_4op_idx21 := index;
_4op_idx22 := SUCC(index);
end
else If check_4op_flag(PRED(current_inst)) then
begin
_4op_ins_flag := TRUE;
_4op_idx11 := PRED(min(current_inst,2));
_4op_idx12 := min(current_inst,2);
_4op_idx21 := index;
_4op_idx22 := SUCC(index);
end
else
else If (_4op_flag_column[index] = _4op_flag_chr_end) then
If check_4op_flag(current_inst) then
begin
_4op_ins_flag := TRUE;
_4op_idx11 := current_inst;
_4op_idx12 := SUCC(current_inst);
_4op_idx21 := PRED(index);
_4op_idx22 := index;
end
else If check_4op_flag(PRED(current_inst)) then
begin
_4op_ins_flag := TRUE;
_4op_idx11 := PRED(min(current_inst,2));
_4op_idx12 := min(current_inst,2);
_4op_idx21 := PRED(index);
_4op_idx22 := index;
end;
If _4op_ins_flag then
begin
songdata.instr_data[_4op_idx11] := temp_songdata.instr_data[_4op_idx21];
songdata.instr_names[_4op_idx11] := Copy(songdata.instr_names[_4op_idx11],1,9)+
Copy(temp_songdata.instr_names[_4op_idx21],10,32);
songdata.instr_data[_4op_idx12] := temp_songdata.instr_data[_4op_idx22];
songdata.instr_names[_4op_idx12] := Copy(songdata.instr_names[_4op_idx12],1,9)+
Copy(temp_songdata.instr_names[_4op_idx22],10,32);
end;
end
else begin
// put 4op instrument (force)
_4op_ins_flag := FALSE;
If (_4op_flag_column[index] = _4op_flag_chr_beg) then
begin
_4op_ins_flag := TRUE;
_4op_idx11 := current_inst;
_4op_idx12 := SUCC(current_inst);
_4op_idx21 := index;
_4op_idx22 := SUCC(index);
end
else If (_4op_flag_column[index] = _4op_flag_chr_end) then
begin
_4op_ins_flag := TRUE;
_4op_idx11 := PRED(min(current_inst,2));
_4op_idx12 := min(current_inst,2);
_4op_idx21 := PRED(index);
_4op_idx22 := index;
end;
If _4op_ins_flag then
begin
songdata.instr_data[_4op_idx11] := temp_songdata.instr_data[_4op_idx21];
songdata.instr_names[_4op_idx11] := Copy(songdata.instr_names[_4op_idx11],1,9)+
Copy(temp_songdata.instr_names[_4op_idx21],10,32);
songdata.instr_data[_4op_idx12] := temp_songdata.instr_data[_4op_idx22];
songdata.instr_names[_4op_idx12] := Copy(songdata.instr_names[_4op_idx12],1,9)+
Copy(temp_songdata.instr_names[_4op_idx22],10,32);
set_4op_flag(_4op_idx11);
end;
end;
// put 2op instrument
If NOT _4op_ins_flag then
begin
songdata.instr_data[current_inst] := temp_songdata.instr_data[index];
songdata.instr_names[current_inst] := Copy(songdata.instr_names[current_inst],1,9)+
Copy(temp_songdata.instr_names[index],10,32);
end;
end
else
begin
songdata.instr_data := temp_songdata.instr_data;
songdata.ins_4op_flags := temp_songdata.ins_4op_flags;
For idx := 1 to 255 do
songdata.instr_names[idx] := Copy(songdata.instr_names[idx],1,9)+
Copy(temp_songdata.instr_names[idx],10,32);
end;
load_flag := 1;
load_flag_alt := BYTE_NULL;
end;
keyboard_reset_buffer;
end;
procedure _macro_preview_refresh;
var
temp,max_value: Integer;
d_factor: Real;
function arpeggio_def_attr(page: Byte): Word;
var
attr,
attr2: Byte;
begin
If (page <= temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.length) then
If (page >= temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.loop_begin) and
(page <= temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.loop_begin+
PRED(temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.loop_length)) and
(temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.loop_begin > 0) and
(temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.loop_length > 0) then
begin
attr := macro_background+macro_text_loop;
attr2 := macro_current_bckg+macro_current_loop;
end
else If (page >= temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.keyoff_pos) and
(temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.keyoff_pos > 0) then
begin
attr := macro_background+macro_text_keyoff;
attr2 := macro_current_bckg+macro_current_koff;
end
else begin
attr := macro_background+macro_text;
attr2 := macro_current_bckg+macro_current;
end
else begin
attr := macro_background+macro_text_dis;
attr2 := macro_current_bckg+macro_current_dis;
end;
arpeggio_def_attr := attr+attr2 SHL 8;
end;
function vibrato_def_attr(page: Byte): Word;
var
attr,
attr2: Byte;
begin
If (page <= temp_songdata.macro_table[vibrato_table_idx].
vibrato.length) then
If (page >= temp_songdata.macro_table[vibrato_table_idx].
vibrato.loop_begin) and
(page <= temp_songdata.macro_table[vibrato_table_idx].
vibrato.loop_begin+
PRED(temp_songdata.macro_table[vibrato_table_idx].
vibrato.loop_length)) and
(temp_songdata.macro_table[vibrato_table_idx].
vibrato.loop_begin > 0) and
(temp_songdata.macro_table[vibrato_table_idx].
vibrato.loop_length > 0) then
begin
attr := macro_background+macro_text_loop;
attr2 := macro_current_bckg+macro_current_loop;
end
else If (page >= temp_songdata.macro_table[vibrato_table_idx].
vibrato.keyoff_pos) and
(temp_songdata.macro_table[vibrato_table_idx].
vibrato.keyoff_pos > 0) then
begin
attr := macro_background+macro_text_keyoff;
attr2 := macro_current_bckg+macro_current_koff;
end
else begin
attr := macro_background+macro_text;
attr2 := macro_current_bckg+macro_current;
end
else begin
attr := macro_background+macro_text_dis;
attr2 := macro_current_bckg+macro_current_dis;
end;
vibrato_def_attr := attr+attr2 SHL 8;
end;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT5.PAS:_macro_preview_refresh';
{$ENDIF}
// arpeggio preview
ShowStr(centered_frame_vdest,xstart_arp+15,ystart_arp,
#253,
macro_background+macro_topic2);
ShowStr(centered_frame_vdest,xstart_arp+15,ystart_arp+7,
#252,
macro_background+macro_topic2);
ShowVStr(centered_frame_vdest,xstart_arp,ystart_arp+1,
#179#179#179#179#179#158,
macro_background+macro_text);
ShowVStr(centered_frame_vdest,xstart_arp+30,ystart_arp+1,
#179#179#179#179#179#158,
macro_background+macro_text);
max_value := 0;
For temp := 1 to 255 do
If (temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.data[temp] > max_value) then
If (temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.data[temp] < $80) then
max_value := Abs(temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.data[temp]);
ShowStr(centered_frame_vdest,xstart_arp+31,ystart_arp+1,
ExpStrR(Num2Str(max_value,10),3,' '),
macro_background+macro_topic);
ShowStr(centered_frame_vdest,xstart_arp+31,ystart_arp+2,
'+',
macro_background+macro_topic);
d_factor := 90/min(max_value,1);
For temp := -14 to 14 do
If (arpeggio_table_pos+temp >= 1) and (arpeggio_table_pos+temp <= 255) then
If (temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.data[arpeggio_table_pos+temp] < $80) then
ShowVStr(centered_frame_vdest,xstart_arp+15+temp,ystart_arp+1,
ExpStrL(_gfx_bar_str(Round(temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.data[arpeggio_table_pos+temp]*d_factor),FALSE),6,' '),
LO(arpeggio_def_attr(arpeggio_table_pos+temp)))
else ShowVStr(centered_frame_vdest,xstart_arp+15+temp,ystart_arp+1,
ExpStrL(FilterStr(note_layout[temp_songdata.macro_table[arpeggio_table_idx].
arpeggio.data[arpeggio_table_pos+temp]-$80],'-',#241),6,' '),
LO(arpeggio_def_attr(arpeggio_table_pos+temp)))
else ShowVStr(centered_frame_vdest,xstart_arp+15+temp,ystart_arp+1,
ExpStrL('',6,' '),
macro_background+macro_text);
// vibrato preview
ShowStr(centered_frame_vdest,xstart_vib+15,ystart_vib,
#253,
macro_background+macro_topic2);
ShowStr(centered_frame_vdest,xstart_vib+15,ystart_vib+7,
#252,
macro_background+macro_topic2);
ShowVStr(centered_frame_vdest,xstart_vib,ystart_vib+1,
#179#179#158#179#179#179,
macro_background+macro_text);
ShowVStr(centered_frame_vdest,xstart_vib+30,ystart_vib+1,
#179#179#158#179#179#179,
macro_background+macro_text);
max_value := 0;
For temp := 1 to 255 do
If (Abs(temp_songdata.macro_table[vibrato_table_idx].
vibrato.data[temp]) > max_value) then
max_value := Abs(temp_songdata.macro_table[vibrato_table_idx].
vibrato.data[temp]);
ShowStr(centered_frame_vdest,xstart_vib+31,ystart_vib+1,
ExpStrR(Num2Str(max_value,10),3,' '),
macro_background+macro_topic);
ShowStr(centered_frame_vdest,xstart_vib+31,ystart_vib+2,
'+',
macro_background+macro_topic);
ShowStr(centered_frame_vdest,xstart_vib+31,ystart_vib+5,
'-',
macro_background+macro_topic);
ShowStr(centered_frame_vdest,xstart_vib+31,ystart_vib+6,
ExpStrR(Num2Str(max_value,10),3,' '),
macro_background+macro_topic);
d_factor := 45/min(max_value,1);
For temp := -14 to 14 do
If (vibrato_table_pos+temp >= 1) and (vibrato_table_pos+temp <= 255) then
If (Round(temp_songdata.macro_table[vibrato_table_idx].
vibrato.data[vibrato_table_pos+temp]*d_factor) >= 0) then
ShowVStr(centered_frame_vdest,xstart_vib+15+temp,ystart_vib+1,
ExpStrR(ExpStrL(_gfx_bar_str(Round(temp_songdata.macro_table[vibrato_table_idx].
vibrato.data[vibrato_table_pos+temp]*d_factor),FALSE),3,' '),6,' '),
LO(vibrato_def_attr(vibrato_table_pos+temp)))
else ShowVStr(centered_frame_vdest,xstart_vib+15+temp,ystart_vib+1,
ExpStrL(ExpStrR(_gfx_bar_str(Round(Abs(temp_songdata.macro_table[vibrato_table_idx].
vibrato.data[vibrato_table_pos+temp])*d_factor),TRUE),3,' '),6,' '),
LO(vibrato_def_attr(vibrato_table_pos+temp)))
else ShowVStr(centered_frame_vdest,xstart_vib+15+temp,ystart_vib+1,
ExpStrR('',6,' '),
macro_background+macro_text);
end;
procedure a2w_macro_lister_external_proc;
const
_check_chr: array[BOOLEAN] of Char = (#251,' ');
var
temp,idx: Byte;
attr,attr2,attr3: Byte;
temps: String;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT5.PAS:a2w_macro_lister_external_proc';
{$ENDIF}
temps := Copy(mn_environment.curr_item,2,2);
idx := Str2num(temps,16);
If (idx = 0) then idx := 1;
VScrollBar(centered_frame_vdest,scrollbar_xstart,scrollbar_ystart,
scrollbar_size,macro_table_size,idx,WORD_NULL,
macro_background+macro_border,
macro_background+macro_border);
arpeggio_table_idx := idx;
vibrato_table_idx := idx;
Case mn_environment.keystroke of
kSPACE: begin
If shift_pressed then
begin
arp_tab_selected := NOT arp_tab_selected;