-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinstedit.inc
3762 lines (3314 loc) · 148 KB
/
instedit.inc
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/>.
{
procedure reset_instrument_preview;
procedure INSTRUMENT_test(instr,instr2: Byte; chan: Byte; fkey: Word; process_macros: Boolean);
function _1st_marked: Byte;
function _2nd_marked: Byte;
function marked_instruments: Byte;
procedure reset_marked_instruments;
function get_4op_to_test: Word;
function check_4op_to_test: Word;
function check_4op_instrument(ins: Byte): Word;
function check_4op_flag(ins: Byte): Boolean;
procedure reset_4op_flag(ins: Byte);
procedure set_4op_flag(ins: Byte);
procedure update_4op_flag_marks;
procedure INSTRUMENT_CONTROL_page_refresh(page: Byte);
procedure _show_adsr(var dest; xstart,ystart: Byte;
attack,decay,sustain,release,attenuation: Byte;
eg_type: Byte;
attr,attr_hi: Byte;
reset: Boolean);
procedure INSTRUMENT_CONTROL_page_refresh_alt(page: Byte);
function _4op_conn_to_idx(str: String): Byte;
procedure _show_conn_scheme(xstart,ystart,conn: Byte; hi_op: tSET_OF_CHARS);
function _get_feedback_val: Byte;
procedure _inc_feedback_val;
procedure _dec_feedback_val;
function _get_finetune_val: Shortint;
procedure _inc_finetune_val;
procedure _dec_finetune_val;
procedure _page_build;
procedure _page_refresh;
procedure _sync_radio_buttons;
procedure INSTRUMENT_CONTROL_edit;
procedure copy_object;
procedure paste_object(mode: Byte);
procedure instr_control_ai;
procedure instr_control_proc;
function INSTRUMENT_CONTROL: Byte;
procedure instr_control_proc_alt;
function INSTRUMENT_CONTROL_alt(instr: Byte; title: String): Byte;
}
const
_ADSR_preview_flag: Boolean = TRUE;
const
_operator_enabled: array[1..4] of Boolean = (TRUE,TRUE,TRUE,TRUE);
_carrier_flag: array[BOOLEAN] of Byte = (2,1);
_ins_mark_chr = #16;
_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_connection_str: array[0..3] of String[5] = (
'FM/FM','FM/AM','AM/FM','AM/AM');
procedure reset_instrument_preview;
var
temp: Word;
begin
If (play_status <> isPlaying) then reset_player;
temp := check_4op_to_test;
If NOT (temp <> 0) then
update_instr_data(instrum_page)
else begin
update_instr_data(LO(temp));
update_instr_data(HI(temp));
end;
end;
procedure INSTRUMENT_test(instr,instr2: Byte; chan: Byte; fkey: Word; process_macros: Boolean);
var
temp,temp2,temp3,temp5: Byte;
valid_key,temp4: Boolean;
chan_handle: array[1..20] of Byte;
channels: Byte;
_1op_preview,_4op_mode: Boolean;
function _1op_preview_active: Boolean;
var
temp,nm_slots: Byte;
begin
nm_slots := 0;
For temp := 1 to 4 do
If _operator_enabled[temp] then
Inc(nm_slots);
_1op_preview_active := (nm_slots = 1);
end;
function output_note(chan,board_pos: Byte): Boolean;
var
note: Byte;
freq: Word;
ins: tADTRACK2_INS;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'INSTEDIT.INC:INSTRUMENT_test:output_note';
{$ENDIF}
note := board_pos+12*(current_octave-1);
If NOT (note in [0..12*8+1]) then
begin
output_note := FALSE;
EXIT;
end;
chan_handle[chan] := board_scancodes[board_pos];
If _4op_mode then
chan := _4op_main_chan[chan];
If _1op_preview then
begin
If _operator_enabled[1] or _operator_enabled[2] then
ins := songdata.instr_data[instr]
else ins := songdata.instr_data[instr2];
pBYTE(@ins)[10] := pBYTE(@ins)[10] OR 1;
load_instrument(ins,chan);
If _operator_enabled[1] or _operator_enabled[2] then
set_ins_volume($3f-ORD(_operator_enabled[1])*($3f-LO(volume_table[chan])),
$3f-ORD(_operator_enabled[2])*($3f-HI(volume_table[chan])),
chan)
else set_ins_volume($3f-ORD(_operator_enabled[3])*($3f-LO(volume_table[chan])),
$3f-ORD(_operator_enabled[4])*($3f-HI(volume_table[chan])),
chan);
end
else
begin
load_instrument(songdata.instr_data[instr],chan);
set_ins_volume($3f-ORD(_operator_enabled[1])*($3f-LO(volume_table[chan])),
$3f-ORD(_operator_enabled[2])*($3f-HI(volume_table[chan])),
chan);
If percussion_mode and
(songdata.instr_data[instr].perc_voice in [4,5]) then
load_instrument(songdata.instr_data[instr],_perc_sim_chan[chan]);
If _4op_mode then
begin
load_instrument(songdata.instr_data[instr2],PRED(chan));
set_ins_volume($3f-ORD(_operator_enabled[3])*($3f-LO(volume_table[PRED(chan)])),
$3f-ORD(_operator_enabled[4])*($3f-HI(volume_table[PRED(chan)])),
PRED(chan));
end;
end;
macro_speedup := songdata.macro_speedup;
If (play_status = isStopped) then update_timer(songdata.tempo);
freq := nFreq(note-1)+$2000+
SHORTINT(pBYTE(@Addr(songdata.instr_data[instr])^)[12]);
event_table[chan].note := note;
freq_table[chan] := freq;
freqtable2[chan] := freq;
key_on(chan);
change_freq(chan,freq);
If process_macros then
If NOT (_1op_preview and (_operator_enabled[3] or _operator_enabled[4])) then
init_macro_table(chan,note,instr,freq)
else init_macro_table(chan,note,instr2,freq)
else begin
macro_table[chan].fmreg_table := 0;
macro_table[chan].arpg_table := 0;
macro_table[chan].vib_table := 0;
end;
If _4op_mode and NOT _1op_preview then
begin
If process_macros then init_macro_table(PRED(chan),note,instr2,freq)
else begin
macro_table[PRED(chan)].fmreg_table := 0;
macro_table[PRED(chan)].arpg_table := 0;
macro_table[PRED(chan)].vib_table := 0;
end;
end;
end;
begin { INSTRUMENT_test }
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'INSTEDIT.INC:INSTRUMENT_test';
{$ENDIF}
If ctrl_pressed or alt_pressed or shift_pressed then EXIT;
_1op_preview := _1op_preview_active;
_4op_mode := NOT _1op_preview_active and (songdata.flag_4op <> 0) and (instr2 <> 0);
valid_key := FALSE;
For temp := 1 to 29 do
If NOT shift_pressed then
If (board_scancodes[temp] = HI(fkey)) then
begin valid_key := TRUE; BREAK; end;
If NOT valid_key or
NOT (temp+12*(current_octave-1)-1 in [0..12*8+1]) then EXIT;
If (Empty(songdata.instr_data[instr],SizeOf(songdata.instr_data[instr])) and
Empty(songdata.instr_macros[instr],SizeOf(songdata.instr_macros[instr]))) or
(_4op_mode and Empty(songdata.instr_data[instr2],SizeOf(songdata.instr_data[instr2])) and
Empty(songdata.instr_macros[instr2],SizeOf(songdata.instr_macros[instr2]))) then
EXIT;
temp2 := temp;
ins_trailing_flag := TRUE;
status_backup.replay_forbidden := replay_forbidden;
status_backup.play_status := play_status;
replay_forbidden := TRUE;
If (play_status <> isStopped) then play_status := isPaused;
nul_volume_bars;
really_no_status_refresh := TRUE;
Move(channel_flag,channel_flag_backup,SizeOf(channel_flag_backup));
Move(event_table,event_table_backup,SizeOf(event_table_backup));
common_flag_backup := songdata.common_flag;
volume_scaling_backup := volume_scaling;
songdata.common_flag := songdata.common_flag AND NOT $80;
volume_scaling := FALSE;
FillChar(channel_flag,SizeOf(channel_flag),BYTE(TRUE));
Move(pan_lock,pan_lock_backup,SizeOf(pan_lock));
Move(volume_lock,volume_lock_backup,SizeOf(volume_lock));
Move(peak_lock,peak_lock_backup,SizeOf(volume_lock));
Move(panning_table,panning_table_backup,SizeOf(panning_table));
FillChar(pan_lock,SizeOf(pan_lock),0);
FillChar(volume_lock,SizeOf(volume_lock),0);
FillChar(peak_lock,SizeOf(volume_lock),0);
flag_4op_backup := songdata.flag_4op;
If NOT percussion_mode and
NOT (songdata.flag_4op <> 0) then channels := 18
else If NOT (songdata.flag_4op <> 0) then channels := 15
else begin
If _4op_mode then
begin
songdata.flag_4op := $3f;
channels := 6;
end
else begin
songdata.flag_4op := 0;
If NOT percussion_mode then channels := 18
else channels := 15;
end;
end;
reset_player;
FillChar(chan_handle,SizeOf(chan_handle),0);
Move(fmpar_table,fmpar_table_backup,SizeOf(fmpar_table_backup));
Move(volume_table,volume_table_backup,SizeOf(volume_table_backup));
Move(freq_table,freq_table_backup,SizeOf(freq_table));
Move(freqtable2,freqtable2_backup,SizeOf(freqtable2));
Move(keyoff_loop,keyoff_loop_backup,SizeOf(keyoff_loop));
FillChar(keyoff_loop,SizeOf(keyoff_loop),FALSE);
misc_register := current_tremolo_depth SHL 7+
current_vibrato_depth SHL 6+
BYTE(percussion_mode) SHL 5;
key_off(17);
key_off(18);
opl2out(_instr[11],misc_register);
If percussion_mode and
(songdata.instr_data[instr].perc_voice in [1..5]) then
begin
output_note(songdata.instr_data[instr].perc_voice+15,temp2);
While scankey(board_scancodes[temp2]) do
begin
{$IFDEF GO32V2}
realtime_gfx_poll_proc;
{$ELSE}
_draw_screen_without_delay := TRUE;
keyboard_poll_input;
{$ENDIF}
keyboard_reset_buffer;
draw_screen;
end;
end
else Repeat
{$IFNDEF GO32V2}
keyboard_poll_input;
{$ENDIF}
valid_key := FALSE;
For temp := 1 to 29 do
begin
temp2 := board_scancodes[temp];
temp4 := scankey(temp2);
If NOT _4op_mode then
begin
temp3 := get_chanpos(chan_handle,channels,temp2);
temp5 := get_chanpos(chan_handle,channels,0);
end
else begin
temp3 := get_chanpos2(chan_handle,channels,temp2);
temp5 := get_chanpos2(chan_handle,channels,0);
end;
If temp4 then valid_key := TRUE;
If temp4 and (temp3 = 0) and (temp5 <> 0) then
output_note(temp5,temp);
If NOT temp4 and (temp3 <> 0) then
begin
chan_handle[temp3] := 0;
key_off(temp3);
If alt_pressed then keyoff_loop[temp3] := TRUE;
end;
end;
{$IFDEF GO32V2}
realtime_gfx_poll_proc;
{$ELSE}
_draw_screen_without_delay := TRUE;
keyboard_poll_input;
{$ENDIF}
keyboard_reset_buffer;
draw_screen;
until NOT valid_key;
While ctrl_pressed do
begin
{$IFDEF GO32V2}
realtime_gfx_poll_proc;
{$ELSE}
_draw_screen_without_delay := TRUE;
keyboard_poll_input;
{$ENDIF}
keyboard_reset_buffer;
draw_screen;
end;
For temp := 1 to 20 do key_off(temp);
songdata.flag_4op := flag_4op_backup;
Move(fmpar_table_backup,fmpar_table,SizeOf(fmpar_table));
Move(volume_table_backup,volume_table,SizeOf(volume_table));
Move(panning_table_backup,panning_table,SizeOf(panning_table));
songdata.common_flag := common_flag_backup;
volume_scaling := volume_scaling_backup;
If (status_backup.play_status = isPlaying) then reset_player;
Move(channel_flag_backup,channel_flag,SizeOf(channel_flag));
Move(event_table_backup,event_table,SizeOf(event_table));
Move(pan_lock_backup,pan_lock,SizeOf(pan_lock));
Move(volume_lock_backup,volume_lock,SizeOf(volume_lock));
Move(peak_lock_backup,peak_lock,SizeOf(volume_lock));
really_no_status_refresh := FALSE;
Move(freq_table_backup,freq_table,SizeOf(freq_table));
Move(freqtable2_backup,freqtable2,SizeOf(freqtable2));
Move(keyoff_loop_backup,keyoff_loop,SizeOf(keyoff_loop));
FillChar(macro_table,SizeOf(macro_table),0);
replay_forbidden := status_backup.replay_forbidden;
play_status := status_backup.play_status;
ins_trailing_flag := FALSE;
keyboard_reset_buffer;
end;
var
color_table: array[1..3] of Byte;
function _1st_marked: Byte;
var
temp,result: Byte;
begin
result := 0;
For temp := 1 to 255 do
If (songdata.instr_names[temp][1] = _ins_mark_chr) then
begin
result := temp;
BREAK;
end;
_1st_marked := result;
end;
function _2nd_marked: Byte;
var
temp,result: Byte;
begin
result := 0;
If (_1st_marked <> 0) then
For temp := SUCC(_1st_marked) to 255 do
If (songdata.instr_names[temp][1] = _ins_mark_chr) then
begin
result := temp;
BREAK;
end;
_2nd_marked := result;
end;
function marked_instruments: Byte;
var
temp,result: Byte;
begin
result := 0;
For temp := 1 to 255 do
If (songdata.instr_names[temp][1] = _ins_mark_chr) then
Inc(result);
marked_instruments := result;
end;
procedure reset_marked_instruments;
begin
If (marked_instruments < 2) then
If (songdata.instr_names[instrum_page][1] = _ins_mark_chr) then
songdata.instr_names[instrum_page][1] := ' '
else
else begin
songdata.instr_names[_2nd_marked][1] := ' ';
songdata.instr_names[_1st_marked][1] := ' ';
end;
update_4op_flag_marks;
end;
function get_4op_to_test: Word;
var
result: Word;
begin
result := 0;
If (songdata.flag_4op <> 0) then
If check_4op_flag(current_inst) then
result := SUCC(current_inst)+current_inst SHL 8
else If (current_inst > 1) and check_4op_flag(PRED(current_inst)) then
result := current_inst+PRED(current_inst) SHL 8;
get_4op_to_test := result;
end;
function check_4op_to_test: Word;
var
result: Word;
begin
result := 0;
If check_4op_flag(current_inst) then
result := SUCC(current_inst)+current_inst SHL 8
else If (current_inst > 1) and check_4op_flag(PRED(current_inst)) then
result := current_inst+PRED(current_inst) SHL 8;
check_4op_to_test := result;
end;
function check_4op_instrument(ins: Byte): Word;
var
result: Word;
begin
result := 0;
If check_4op_flag(ins) then
result := SUCC(ins)+ins SHL 8
else If (ins > 1) and check_4op_flag(PRED(ins)) then
result := ins+PRED(ins) SHL 8;
check_4op_instrument := result;
end;
function check_4op_flag(ins: Byte): Boolean;
var
result: Boolean;
idx: Byte;
begin
result := FALSE;
For idx := 1 to songdata.ins_4op_flags.num_4op do
If (songdata.ins_4op_flags.idx_4op[idx] = ins) then
begin
result := TRUE;
BREAK;
end;
check_4op_flag := result;
end;
procedure reset_4op_flag(ins: Byte);
var
temp_ins_4op_flags: tINS_4OP_FLAGS;
idx: Byte;
begin
If NOT check_4op_flag(ins) then EXIT;
temp_ins_4op_flags.num_4op := 0;
idx := 1;
While (idx <= songdata.ins_4op_flags.num_4op) and
(songdata.ins_4op_flags.idx_4op[idx] < ins) do
begin
Inc(temp_ins_4op_flags.num_4op);
temp_ins_4op_flags.idx_4op[temp_ins_4op_flags.num_4op] :=
songdata.ins_4op_flags.idx_4op[idx];
Inc(idx);
end;
Inc(idx);
While (idx <= songdata.ins_4op_flags.num_4op) do
begin
Inc(temp_ins_4op_flags.num_4op);
temp_ins_4op_flags.idx_4op[temp_ins_4op_flags.num_4op] :=
songdata.ins_4op_flags.idx_4op[idx];
Inc(idx);
end;
songdata.ins_4op_flags := temp_ins_4op_flags;
end;
procedure set_4op_flag(ins: Byte);
var
temp_ins_4op_flags: tINS_4OP_FLAGS;
idx: Byte;
begin
If (ins = 255) then EXIT;
If check_4op_flag(ins) then
reset_4op_flag(ins);
If (ins > 1) and check_4op_flag(PRED(ins)) then
reset_4op_flag(PRED(ins));
If (ins < 255) and check_4op_flag(SUCC(ins)) then
reset_4op_flag(SUCC(ins));
temp_ins_4op_flags.num_4op := 0;
idx := 1;
While (idx <= songdata.ins_4op_flags.num_4op) and
(songdata.ins_4op_flags.idx_4op[idx] < ins) do
begin
Inc(temp_ins_4op_flags.num_4op);
temp_ins_4op_flags.idx_4op[temp_ins_4op_flags.num_4op] :=
songdata.ins_4op_flags.idx_4op[idx];
Inc(idx);
end;
Inc(temp_ins_4op_flags.num_4op);
temp_ins_4op_flags.idx_4op[temp_ins_4op_flags.num_4op] := ins;
While (idx <= songdata.ins_4op_flags.num_4op) do
begin
Inc(temp_ins_4op_flags.num_4op);
temp_ins_4op_flags.idx_4op[temp_ins_4op_flags.num_4op] :=
songdata.ins_4op_flags.idx_4op[idx];
Inc(idx);
end;
songdata.ins_4op_flags := temp_ins_4op_flags;
end;
procedure update_4op_flag_marks;
var
temp: Byte;
begin
For temp := 1 to PRED(255) do
If NOT check_4op_flag(temp) then
begin
If (songdata.instr_names[temp][1] in _4op_flag_chars) then
songdata.instr_names[temp][1] := ' ';
If (songdata.instr_names[SUCC(temp)][1] in _4op_flag_chars) then
songdata.instr_names[SUCC(temp)][1] := ' ';
end;
For temp := 1 to PRED(255) do
If check_4op_flag(temp) then
begin
If (songdata.instr_names[temp][1] = ' ') then
songdata.instr_names[temp][1] := _4op_flag_chr_beg;
If (songdata.instr_names[SUCC(temp)][1] = ' ') then
songdata.instr_names[SUCC(temp)][1] := _4op_flag_chr_end;
end;
end;
procedure INSTRUMENT_CONTROL_page_refresh(page: Byte);
var
temp: Byte;
temp_str: String;
_status_shift_pos: Byte;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'INSTEDIT.INC:INSTRUMENT_CONTROL_page_refresh';
{$ENDIF}
update_4op_flag_marks;
If (ins_parameter(page,10) AND 1 <> 1) then
For temp := 1 to 18 do
ShowCStr(mn_environment.v_dest,
INSCTRL_xshift+10,INSCTRL_yshift+06+temp,
inst_itm1[temp].str,
dialog_background+dialog_contxt_dis2,
color_table[inst_itm1[temp].colr])
else
For temp := 1 to 18 do
ShowCStr(mn_environment.v_dest,
INSCTRL_xshift+10,INSCTRL_yshift+06+temp,
inst_itm2[temp].str,
dialog_background+dialog_contxt_dis2,
color_table[inst_itm2[temp].colr]);
ShowStr(mn_environment.v_dest,
INSCTRL_xshift+56,INSCTRL_yshift+05,
byte2hex(page),
dialog_background+dialog_title);
For temp := 1 to 10 do
ShowStr(mn_environment.v_dest,
INSCTRL_xshift+32,INSCTRL_yshift+08+pos2[temp],
byte2hex(pBYTE(@Addr(songdata.instr_data[page])^)[_instr_data_ofs[temp]]),
dialog_background+dialog_item);
ShowCStr(mn_environment.v_dest,
INSCTRL_xshift+30,INSCTRL_yshift+08+pos2[11],
connection_str[pBYTE(@Addr(songdata.instr_data[page])^)[_instr_data_ofs[11]] AND 1]+'~/~'+
CHR(ORD('0')+(pBYTE(@Addr(songdata.instr_data[page])^)[_instr_data_ofs[11]] SHR 1 AND 7)),
dialog_background+dialog_item,
color_table[inst_itm1[temp].colr]);
Case songdata.instr_data[page].panning of
0: ShowStr(mn_environment.v_dest,
INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[12],
'CENTER',
dialog_background+dialog_item);
1: ShowStr(mn_environment.v_dest,
INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[12],
'LEFT ',
dialog_background+dialog_item);
2: ShowStr(mn_environment.v_dest,
INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[12],
'RiGHT ',
dialog_background+dialog_item);
end;
If (songdata.instr_data[page].fine_tune < 0) then
ShowStr(mn_environment.v_dest,
INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[13],
'-'+ExpStrR(Num2str(Abs(songdata.instr_data[page].fine_tune),16),2,' '),
dialog_background+dialog_item)
else
ShowStr(mn_environment.v_dest,
INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[13],
'+'+ExpStrR(Num2str(Abs(songdata.instr_data[page].fine_tune),16),2,' '),
dialog_background+dialog_item);
_status_shift_pos := 0;
If (check_4op_flag(page) or ((page > 1) and check_4op_flag(PRED(page)))) then
begin
_status_shift_pos := 5;
ShowCStr(mn_environment.v_dest,
INSCTRL_xshift+09,INSCTRL_yshift+26,
' [~'#4#3'~] '#205#205#205,
dialog_background+dialog_border,
dialog_background+dialog_context)
end
else
ShowCStr(mn_environment.v_dest,
INSCTRL_xshift+09,INSCTRL_yshift+26,
' [~'+perc_voice_str[songdata.instr_data[page].perc_voice]+'~] ',
dialog_background+dialog_border,
dialog_background+dialog_context);
If (songdata.instr_macros[page].length <> 0) then temp_str := ' [~MACRO:FM'
else temp_str := ' ';
With songdata.macro_table[
songdata.instr_macros[page].arpeggio_table].arpeggio do
If (songdata.instr_macros[page].arpeggio_table <> 0) then
If (temp_str <> ' ') then temp_str := temp_str+'+ARP'
else temp_str := temp_str+'[~MACRO:ARP';
With songdata.macro_table[
songdata.instr_macros[page].vibrato_table].vibrato do
If (songdata.instr_macros[page].vibrato_table <> 0) then
If (temp_str <> ' ') then temp_str := temp_str+'+ViB'
else temp_str := temp_str+'[~MACRO:ViB';
If (temp_str <> ' ') then temp_str := temp_str+'~] ';
ShowCStr(mn_environment.v_dest,INSCTRL_xshift+19-_status_shift_pos,INSCTRL_yshift+26,
ExpStrR(temp_str,27,#205),
dialog_background+dialog_border,
dialog_background+dialog_context);
STATUS_LINE_refresh;
end;
var
adsr_bckg: Byte;
procedure _show_adsr(dest: tSCREEN_MEM_PTR; xstart,ystart: Byte;
attack,decay,sustain,release,attenuation: Byte;
eg_type: Byte;
attr,attr_hi: Byte;
reset: Boolean);
function _gfx_bar_str(value: Byte): String;
var
result: String;
begin
result := '';
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);
_gfx_bar_str := flipstr(result);
end;
var
index,pos: Integer;
temp,temp2: Real;
function _conv(value,variant: Byte): Byte;
begin
If (value <> 0) then _conv := variant
else _conv := 1;
end;
begin { _show_adsr }
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'INSTEDIT.INC:_show_adsr';
{$ENDIF}
fr_setting.update_area := FALSE;
fr_setting.shadow_enabled := FALSE;
If NOT is_default_screen_mode then
Frame(dest,xstart,ystart+1,xstart+61,ystart+11,
instrument_bckg,'',0,frame_solid_type1)
else If reset then
Frame(dest,xstart,ystart,xstart+63,ystart+12,
instrument_bckg,'',0,frame_solid_type1)
else Frame(dest,xstart,ystart,xstart+63,ystart+12,
instrument_adsr+instrument_text,' ADSR PREViEW ',
instrument_adsr+instrument_text,
frame_double);
fr_setting.update_area := TRUE;
fr_setting.shadow_enabled := TRUE;
If (attack <> 0) then
attack := min(ROUND(15/ln(15)*ln(attack)),1);
If (decay <> 0) then
decay := min(ROUND(15/ln(15)*ln(decay)),1)
else sustain := 0;
If (sustain <> 0) then
sustain := min(ROUND(15/ln(15)*ln(sustain)),1);
If (release <> 0) then
release := min(ROUND(15/ln(15)*ln(release)),1);
If reset then EXIT;
pos := 1;
temp := 0;
For index := 0 to (15-attack) do
begin
temp := temp+8*16/(16-attack);
If (attack <> 0) then
begin
ShowVStr(dest,xstart+1+pos,ystart+1,
ExpStrL(_gfx_bar_str(ROUND(temp/63*(63-attenuation))),9,' '),
attr_hi);
Inc(pos);
end;
end;
If (attack = 0) then
begin
Inc(pos);
temp := 8*16;
end;
If (decay = 0) and ((release <> 0) or
((sustain <> 0) and (eg_type = 1))) then
decay := 15;
If (decay <> 0) then
For index := 0 to (15-decay) do
begin
temp := temp-8*16/16*sustain/(16-decay);
ShowVStr(dest,xstart+1+pos,ystart+1,
ExpStrL(_gfx_bar_str(ROUND(temp/63*(63-attenuation))),9,' '),
attr_hi);
Inc(pos);
end;
If (decay = 0) then
Inc(pos);
If (eg_type <> 1) and (release <> 0) then
sustain := 0;
If (sustain = 0) and (release <> 0) then
sustain := 1;
For index := 1 to sustain do
If (sustain <> 0) then
begin
ShowVStr(dest,xstart+1+pos,ystart+1,
ExpStrL(_gfx_bar_str(ROUND(temp/63*(63-attenuation))),9,' '),
attr_hi);
Inc(pos);
end;
If (sustain = 0) then
Inc(pos);
temp2 := temp;
For index := 1 to (15-release) do
begin
temp := temp-temp2/(16-release);
If (release <> 0) and (temp > 0) then
begin
If (eg_type <> 1) then
ShowVStr(dest,xstart+1+pos,ystart+1,
ExpStrL(_gfx_bar_str(ROUND(temp/63*(63-attenuation))),9,' '),
attr_hi)
else
ShowVStr(dest,xstart+1+pos,ystart+1,
ExpStrL(_gfx_bar_str(ROUND(temp/63*(63-attenuation))),9,' '),
attr);
Inc(pos);
end;
end;
If (release > 0) then
ShowStr(dest,xstart+2,ystart+10,
Copy(Copy(ExpStrR(#246,_conv(attack,16-attack),' ')+
ExpStrR(#246,_conv(decay,16-decay),' ')+
ExpStrR(#246,_conv(sustain,sustain),' ')+
ExpStrR(#246,_conv(release,15-release),' '),1,60-1)+
#246+ExpStrL('',60,' '),1,60),
attr_hi)
else
ShowStr(dest,xstart+2,ystart+10,
ExpStrR(#246,_conv(attack,16-attack),' ')+
ExpStrR(#246,_conv(decay,16-decay),' ')+
ExpStrR(#246,_conv(sustain,sustain),' ')+
ExpStrR(#246,_conv(release,15-release)+
15-_conv(release,15-release)+
15-_conv(sustain,sustain)+
15-_conv(decay,16-decay)+
15-_conv(attack,16-attack),' '),
attr_hi);
If (release > 0) then
ShowStr(dest,xstart+2,ystart+11,
Copy(Copy(ExpStrR('A',_conv(attack,16-attack),#250)+
ExpStrR('D',_conv(decay,16-decay),#250)+
ExpStrR('S',_conv(sustain,sustain),#250)+
ExpStrR('R',_conv(release,15-release),#250),1,60-1)+
#175+ExpStrL('',60,#250),1,60),
attr_hi)
else
ShowStr(dest,xstart+2,ystart+11,
ExpStrR('A',_conv(attack,16-attack),#250)+
ExpStrR('D',_conv(decay,16-decay),#250)+
ExpStrR('S',_conv(sustain,sustain),#250)+
ExpStrR('R',_conv(release,15-release)+
15-_conv(release,15-release)+
15-_conv(sustain,sustain)+
15-_conv(decay,16-decay)+
15-_conv(attack,16-attack),#250),
attr_hi);
end;
procedure INSTRUMENT_CONTROL_page_refresh_alt(page: Byte);
var
temp: Byte;
temp_str: String;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'INSTEDIT.INC:INSTRUMENT_CONTROL_page_refresh_alt';
{$ENDIF}
update_4op_flag_marks;
If (ins_parameter(page,10) AND 1 <> 1) then
For temp := 1 to 18 do
ShowCStr(mn_environment.v_dest,INSCTRL_xshift+10,INSCTRL_yshift+06+temp,inst_itm1[temp].str,
dialog_background+dialog_contxt_dis2,
color_table[inst_itm1[temp].colr])
else
For temp := 1 to 18 do
ShowCStr(mn_environment.v_dest,INSCTRL_xshift+10,INSCTRL_yshift+06+temp,inst_itm2[temp].str,
dialog_background+dialog_contxt_dis2,
color_table[inst_itm2[temp].colr]);
For temp := 1 to 10 do
ShowStr(mn_environment.v_dest,INSCTRL_xshift+32,INSCTRL_yshift+08+pos2[temp],
byte2hex(pBYTE(@Addr(songdata.instr_data[page])^)[_instr_data_ofs[temp]]),
instrument_bckg+instrument_hi_text);
ShowCStr(mn_environment.v_dest,
INSCTRL_xshift+30,INSCTRL_yshift+08+pos2[11],
connection_str[pBYTE(@Addr(songdata.instr_data[page])^)[_instr_data_ofs[11]] AND 1]+'~/~'+
CHR(ORD('0')+(pBYTE(@Addr(songdata.instr_data[page])^)[_instr_data_ofs[11]] SHR 1 AND 7)),
dialog_background+dialog_item,
color_table[inst_itm1[temp].colr]);
Case songdata.instr_data[page].panning of
0: ShowStr(mn_environment.v_dest,INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[12],
'CENTER',
instrument_bckg+instrument_hi_text);
1: ShowStr(mn_environment.v_dest,INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[12],
'LEFT ',
instrument_bckg+instrument_hi_text);
2: ShowStr(mn_environment.v_dest,INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[12],
'RiGHT ',
instrument_bckg+instrument_hi_text);
end;
If (songdata.instr_data[page].fine_tune < 0) then
ShowStr(mn_environment.v_dest,INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[13],
'-'+ExpStrR(Num2str(Abs(songdata.instr_data[page].fine_tune),16),2,' '),
instrument_bckg+instrument_hi_text)
else
ShowStr(mn_environment.v_dest,INSCTRL_xshift+24,INSCTRL_yshift+08+pos2[13],
'+'+ExpStrR(Num2str(Abs(songdata.instr_data[page].fine_tune),16),2,' '),
instrument_bckg+instrument_hi_text);
ShowCStr(mn_environment.v_dest,
INSCTRL_xshift+09,INSCTRL_yshift+26,
' [~'+perc_voice_str[songdata.instr_data[page].perc_voice]+'~] ',
dialog_background+dialog_border,
dialog_background+dialog_context);
If (songdata.instr_macros[page].length <> 0) then temp_str := ' [~MACRO:FM'
else temp_str := ' ';
With songdata.macro_table[
songdata.instr_macros[page].arpeggio_table].arpeggio do
If (songdata.instr_macros[page].arpeggio_table <> 0) then
If (temp_str <> ' ') then temp_str := temp_str+'+ARP'
else temp_str := temp_str+'[~MACRO:ARP';
With songdata.macro_table[
songdata.instr_macros[page].vibrato_table].vibrato do
If (songdata.instr_macros[page].vibrato_table <> 0) then
If (temp_str <> ' ') then temp_str := temp_str+'+ViB'
else temp_str := temp_str+'[~MACRO:ViB';
If (temp_str <> ' ') then temp_str := temp_str+'~] ';
ShowCStr(mn_environment.v_dest,INSCTRL_xshift+19,INSCTRL_yshift+26,
ExpStrR(temp_str,21+1,#205),
dialog_background+dialog_border,
dialog_background+dialog_context);
end;
var
temp: Byte;
xstart,ystart: Byte;
nope: Boolean;
hpos,vpos: Byte;
carrier: Boolean;
inst: ^tADTRACK2_INS;
type
tSET_OF_CHARS = Set of Char;
tBYTE_PTR = ^Byte;
function _4op_conn_to_idx(str: String): Byte;
var
idx,result: Byte;
temps: String;
begin
temps := FilterStr1(str,'~');
result := 2;
For idx := 0 to 3 do
If (temps = _4op_connection_str[idx]) then
begin
Inc(result,idx);
BREAK;
end;
_4op_conn_to_idx := result;
end;