-
Notifications
You must be signed in to change notification settings - Fork 11
/
adt2ext2.pas
1725 lines (1321 loc) · 49.9 KB
/
adt2ext2.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 AdT2ext2;
{$S-,Q-,R-,V-,B-,X+}
{$PACKRECORDS 1}
interface
const
quick_mark_type: Byte = 0;
discard_block: Boolean = FALSE;
old_chan_pos: Byte = 1;
old_hpos: Byte = 1;
old_page: Byte = 0;
old_block_chan_pos: Byte = 1;
old_block_patt_hpos: Byte = 1;
old_block_patt_page: Byte = 0;
procedure process_global_keys;
procedure PROGRAM_SCREEN_init;
function INSTRUMENT_CONTROL_alt(instr: Byte; title: String): Byte;
procedure INSTRUMENT_test(instr,instr2,chan: Byte; fkey: Word;
process_macros: Boolean);
procedure INSTRUMENT_CONTROL_page_refresh(page: Byte);
procedure INSTRUMENT_CONTROL_edit;
procedure PATTERN_ORDER_page_refresh(page: Byte);
procedure PATTERN_ORDER_edit(var page,hpos,vpos: Byte);
procedure PATTERN_tabs_refresh;
procedure PATTERN_page_refresh(page: Byte);
procedure STATUS_LINE_refresh;
procedure PATTERN_position_preview(pattern,line,channel,mode: Byte);
function PATTERN_trace: Word;
procedure PATTERN_edit(var pattern,page,hpos: Byte);
procedure process_config_file;
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;
implementation
uses
{$IFNDEF UNIX}
CRT,
{$ENDIF}
{$IFDEF GO32V2}
GO32,
{$ELSE}
SDL_Timer,
{$ENDIF}
StrUtils,
AdT2opl3,AdT2unit,AdT2sys,AdT2extn,AdT2ext4,AdT2ext5,AdT2text,AdT2pack,AdT2keyb,
TxtScrIO,StringIO,DialogIO,ParserIO;
var
old_pattern_patt,old_pattern_page,
old_pattern_hpos,
old_block_xstart,old_block_ystart: Byte;
old_marking: Boolean;
{$i instedit.inc}
{$i ipattord.inc}
{$i ipattern.inc}
procedure FADE_OUT_RECORDING;
{$IFNDEF GO32V2}
const
frame_start: Longint = 0;
frame_end: Longint = 0;
actual_frame_end: Longint = 0;
var
xstart,ystart: Byte;
temp,temp2: Byte;
label _jmp1,_end;
begin
If (play_status = isStopped) or (sdl_opl3_emulator = 0) then
begin
sdl_opl3_emulator := 0;
opl3_channel_recording_mode := FALSE;
EXIT;
end;
ScreenMemCopy(screen_ptr,ptr_screen_backup);
centered_frame_vdest := screen_ptr;
HideCursor;
dl_environment.context := ' ESC '#196#16' STOP ';
centered_frame(xstart,ystart,43,3,' WAV RECORDER ',
dialog_background+dialog_border,
dialog_background+dialog_title,
frame_double);
ShowStr(screen_ptr,xstart+43-Length(dl_environment.context),ystart+3,
dl_environment.context,
dialog_background+dialog_border);
dl_environment.context := '';
show_progress(40);
ShowStr(screen_ptr,xstart+2,ystart+1,
'FADiNG OUT WAV RECORDiNG...',
dialog_background+dialog_text);
progress_xstart := xstart+2;
progress_ystart := ystart+2;
progress_num_steps := 1;
progress_step := 1;
progress_value:= 63;
progress_old_value := BYTE_NULL;
For temp := 63 downto 0 do
begin
If scankey(1) then GOTO _jmp1;
fade_out_volume := temp;
set_global_volume;
show_progress(temp);
For temp2 := 1 to 10 do
begin
If scankey(1) then GOTO _jmp1;
keyboard_reset_buffer;
actual_frame_end := SDL_GetTicks;
frame_end := frame_start+fade_delay_tab[temp];
If (actual_frame_end+fade_delay_tab[temp] > frame_end) then
begin
frame_end := actual_frame_end;
_draw_screen_without_delay := TRUE;
draw_screen;
end;
SDL_Delay(frame_end-actual_frame_end);
frame_start := SDL_GetTicks;
end;
_draw_screen_without_delay := TRUE;
draw_screen;
end;
_jmp1:
show_progress(0);
ShowStr(screen_ptr,xstart+2,ystart+1,
'FADiNG iN SONG PLAYBACK... ',
dialog_background+dialog_text);
flush_WAV_data;
sdl_opl3_emulator := 0;
opl3_channel_recording_mode := FALSE;
For temp := 0 to 63 do
begin
If scankey(1) then GOTO _end;
fade_out_volume := temp;
set_global_volume;
show_progress(temp);
If scankey(1) then GOTO _end;
_draw_screen_without_delay := TRUE;
draw_screen;
keyboard_reset_buffer;
actual_frame_end := SDL_GetTicks;
frame_end := frame_start+5;
If (actual_frame_end > frame_end) then frame_end := actual_frame_end;
SDL_Delay(frame_end-actual_frame_end);
frame_start := SDL_GetTicks;
end;
_end:
flush_WAV_data;
sdl_opl3_emulator := 0;
opl3_channel_recording_mode := FALSE;
fade_out_volume := 63;
set_global_volume;
move_to_screen_data := ptr_screen_backup;
move_to_screen_area[1] := xstart;
move_to_screen_area[2] := ystart;
move_to_screen_area[3] := xstart+43+2+1;
move_to_screen_area[4] := ystart+3+1;
move2screen;
{$ELSE}
begin
{$ENDIF}
end;
procedure FADE_IN_RECORDING;
{$IFNDEF GO32V2}
const
frame_start: Longint = 0;
frame_end: Longint = 0;
actual_frame_end: Longint = 0;
var
xstart,ystart: Byte;
temp,temp2: Byte;
smooth_fadeOut: Boolean;
label _end;
begin
If (sdl_opl3_emulator = 1) or (calc_following_order(0) = -1) then EXIT;
If (play_status = isStopped) then smooth_fadeOut := FALSE
else smooth_fadeOut := TRUE;
ScreenMemCopy(screen_ptr,ptr_screen_backup);
centered_frame_vdest := screen_ptr;
HideCursor;
dl_environment.context := ' ESC '#196#16' STOP ';
centered_frame(xstart,ystart,43,3,' WAV RECORDER ',
dialog_background+dialog_border,
dialog_background+dialog_title,
frame_double);
ShowStr(screen_ptr,xstart+43-Length(dl_environment.context),ystart+3,
dl_environment.context,
dialog_background+dialog_border);
dl_environment.context := '';
progress_xstart := xstart+2;
progress_ystart := ystart+2;
progress_num_steps := 1;
progress_step := 1;
progress_value:= 63;
progress_old_value := BYTE_NULL;
If smooth_fadeOut then
begin
show_progress(40);
ShowStr(screen_ptr,xstart+2,ystart+1,
'FADiNG OUT SONG PLAYBACK...',
dialog_background+dialog_text);
For temp := 63 downto 0 do
begin
If scankey(1) then GOTO _end;
fade_out_volume := temp;
set_global_volume;
show_progress(temp);
_draw_screen_without_delay := TRUE;
draw_screen;
keyboard_reset_buffer;
actual_frame_end := SDL_GetTicks;
frame_end := frame_start+5;
If (actual_frame_end > frame_end) then frame_end := actual_frame_end;
SDL_Delay(frame_end-actual_frame_end);
frame_start := SDL_GetTicks;
If scankey(1) then GOTO _end;
end;
end
else
SDL_Delay(100);
show_progress(0);
ShowStr(screen_ptr,xstart+2,ystart+1,
'FADiNG iN WAV RECORDiNG... ',
dialog_background+dialog_text);
Case play_status of
isStopped: begin
If trace_by_default then tracing := TRUE;
start_playing;
end;
isPaused: begin
replay_forbidden := FALSE;
play_status := isPlaying;
end;
end;
fade_out_playback(FALSE);
sdl_opl3_emulator := 1;
For temp := 0 to 63 do
begin
If scankey(1) then GOTO _end;
fade_out_volume := temp;
set_global_volume;
show_progress(temp);
_draw_screen_without_delay := TRUE;
draw_screen;
For temp2 := 1 to 10 do
begin
If scankey(1) then GOTO _end;
keyboard_reset_buffer;
actual_frame_end := SDL_GetTicks;
frame_end := frame_start+fade_delay_tab[temp];
If (actual_frame_end+fade_delay_tab[temp] > frame_end) then
begin
frame_end := actual_frame_end;
_draw_screen_without_delay := TRUE;
draw_screen;
end;
SDL_Delay(frame_end-actual_frame_end);
frame_start := SDL_GetTicks;
end;
_draw_screen_without_delay := TRUE;
draw_screen;
end;
_end:
sdl_opl3_emulator := 1;
fade_out_volume := 63;
set_global_volume;
move_to_screen_data := ptr_screen_backup;
move_to_screen_area[1] := xstart;
move_to_screen_area[2] := ystart;
move_to_screen_area[3] := xstart+43+2+1;
move_to_screen_area[4] := ystart+3+1;
move2screen;
{$ELSE}
begin
{$ENDIF}
end;
procedure process_global_keys;
var
temp,temp2: Byte;
start_row,end_row: Byte;
chunk: tCHUNK;
begin
If NOT ins_trailing_flag and ctrl_pressed then
If scankey(SC_1) then current_octave := 1
else If scankey(SC_2) then current_octave := 2
else If scankey(SC_3) then current_octave := 3
else If scankey(SC_4) then current_octave := 4
else If scankey(SC_5) then current_octave := 5
else If scankey(SC_6) then current_octave := 6
else If scankey(SC_7) then current_octave := 7
else If scankey(SC_8) then current_octave := 8;
If alt_pressed and NOT ctrl_pressed then
If scankey(SC_PLUS) or (shift_pressed and scankey(SC_UP)) then
begin
If (overall_volume < 63) then
begin
Inc(overall_volume);
set_global_volume;
end;
end
else If scankey(SC_MINUS2) or (shift_pressed and scankey(SC_DOWN)) then
begin
If (overall_volume > 0) then
begin
Dec(overall_volume);
set_global_volume;
end;
end;
If ctrl_pressed and NOT alt_pressed and NOT scankey(SC_TAB) and
(scankey(SC_UP) or scankey(SC_DOWN)) then
begin
If scankey(SC_UP) and scankey(SC_DOWN) then
begin
_IRQ_freq_shift_reset_flag := TRUE;
If NOT shift_pressed then
IRQ_freq_shift := songdata.bpm_data.tempo_finetune
else IRQ_freq_shift := 0
end
else If scankey(SC_UP) and NOT scankey(SC_DOWN) and
(SUCC(IRQ_freq+IRQ_freq_shift+playback_speed_shift) <= MAX_IRQ_FREQ) then
If (NOT shift_pressed or (shift_pressed and NOT (_IRQFREQ_blink_flag and (_IRQFREQ_blink_ticks < 5)))) and
NOT (_IRQ_freq_shift_reset_flag and _IRQFREQ_blink_flag and (_IRQFREQ_blink_ticks < 5)) then
begin
Inc(IRQ_freq_shift);
_IRQ_freq_shift_reset_flag := FALSE;
end
else
else If NOT scankey(SC_UP) and scankey(SC_DOWN) and
(PRED(IRQ_freq+IRQ_freq_shift+playback_speed_shift) >= MIN_IRQ_FREQ) then
If (NOT shift_pressed or (shift_pressed and NOT (_IRQFREQ_blink_flag and (_IRQFREQ_blink_ticks < 5)))) and
NOT (_IRQ_freq_shift_reset_flag and _IRQFREQ_blink_flag and (_IRQFREQ_blink_ticks < 5)) then
begin
Dec(IRQ_freq_shift);
_IRQ_freq_shift_reset_flag := FALSE;
end;
If (songdata.bpm_data.tempo_finetune <> IRQ_freq_shift) then
module_archived := FALSE;
_IRQFREQ_update_event := TRUE;
_IRQFREQ_blink_flag := TRUE;
_IRQFREQ_blink_ticks := 0;
TimerSetup(IRQ_freq+IRQ_freq_shift+playback_speed_shift);
keyboard_reset_buffer;
end;
{$IFNDEF GO32V2}
If scankey(SC_F11) and
((alt_pressed and NOT ctrl_pressed) or
(ctrl_pressed and NOT alt_pressed)) then
begin
If ctrl_pressed and NOT opl3_flushmode and
((sdl_opl3_emulator = 0) or (play_status = isStopped)) then
begin
opl3_channel_recording_mode := TRUE;
track_notes := FALSE;
If shift_pressed then sdl_opl3_emulator := 0;
end;
If NOT shift_pressed then sdl_opl3_emulator := 1
else FADE_IN_RECORDING;
keyboard_reset_buffer;
end;
If scankey(SC_F12) and
((alt_pressed and NOT ctrl_pressed) or
(ctrl_pressed and NOT alt_pressed)) then
begin
If NOT shift_pressed then
begin
flush_WAV_data;
sdl_opl3_emulator := 0;
opl3_channel_recording_mode := FALSE;
end
else FADE_OUT_RECORDING;
keyboard_reset_buffer;
end;
{$ENDIF}
If track_notes and scankey(SC_BACKSPACE) then
begin
If NOT ctrl_pressed then
begin
start_row := pattern_page;
end_row := pattern_page;
end
else begin
start_row := 0;
end_row := songdata.patt_len;
end;
For temp2 := start_row to end_row do
For temp := 1 to nm_track_chan do
If channel_flag[track_chan_start+temp-1] then
begin
chunk := pattdata^[pattern_patt DIV 8][pattern_patt MOD 8]
[track_chan_start+temp-1][temp2];
chunk.note := 0;
chunk.instr_def := 0;
pattdata^[pattern_patt DIV 8][pattern_patt MOD 8]
[track_chan_start+temp-1][temp2] := chunk;
end;
end;
end;
procedure PROGRAM_SCREEN_init;
var
temp: Byte;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT2.PAS:PROGRAM_SCREEN_init';
{$ENDIF}
fr_setting.shadow_enabled := FALSE;
Frame(screen_ptr,01,MAX_PATTERN_ROWS+12,MAX_COLUMNS,MAX_PATTERN_ROWS+22,
main_background+main_border,'',
main_background+main_title,
frame_double);
Frame(screen_ptr,01,01,MAX_COLUMNS,MAX_PATTERN_ROWS+12,
main_background+main_border,'- '+_ADT2_TITLE_STRING_+' -',
main_background+main_border,
frame_single);
Frame(screen_ptr,02,02,24,07,
status_background+status_border,' STATUS ',
status_background+status_border,
frame_double);
Frame(screen_ptr,25,02,25+MAX_ORDER_COLS*7-1+PATTORD_xshift*2,07,
order_background+order_border,' PATTERN ORDER ( ) ',
order_background+order_border,
frame_double);
fr_setting.shadow_enabled := TRUE;
area_x1 := 0;
area_y1 := 0;
area_x2 := 0;
area_y2 := 0;
ShowVStr(screen_ptr,02,MAX_PATTERN_ROWS+13,ExpStrL('',9,' '),
analyzer_bckg+analyzer);
ShowVStr(screen_ptr,03,MAX_PATTERN_ROWS+13,'MAX MiN',
analyzer_bckg+analyzer);
For temp := 05 to MAX_COLUMNS-6 do
ShowVStr(screen_ptr,temp,MAX_PATTERN_ROWS+13,
#242#224#224#224#224#224#224#224#243,
analyzer_bckg+analyzer);
ShowVStr(screen_ptr,04,MAX_PATTERN_ROWS+13,ExpStrL('',9,' '),
analyzer_bckg+analyzer);
ShowVStr(screen_ptr,MAX_COLUMNS-5,MAX_PATTERN_ROWS+13,ExpStrL('',9,' '),
analyzer_bckg+analyzer);
ShowVStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+13,ExpStrL('',9,' '),
analyzer_bckg+analyzer);
ShowVStr(screen_ptr,MAX_COLUMNS-3,MAX_PATTERN_ROWS+13,ExpStrL('',9,' '),
analyzer_bckg+analyzer);
ShowVStr(screen_ptr,MAX_COLUMNS-2,MAX_PATTERN_ROWS+13,ExpStrL('',9,' '),
analyzer_bckg+analyzer);
ShowVStr(screen_ptr,MAX_COLUMNS-1,MAX_PATTERN_ROWS+13,ExpStrL('',9,' '),
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+13,'dB',
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+14,#224'47',
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+15,#224,
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+16,#224'23',
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+17,#224,
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+18,#224'12',
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+19,#224'4',
analyzer_bckg+analyzer);
ShowStr(screen_ptr,MAX_COLUMNS-4,MAX_PATTERN_ROWS+20,#224'2',
analyzer_bckg+analyzer);
ShowCStr(screen_ptr,03,03,'~ORDER/PATTERN ~ /',
status_background+status_dynamic_txt,
status_background+status_static_txt);
ShowCStr(screen_ptr,03,04,'~ROW ~',
status_background+status_dynamic_txt,
status_background+status_static_txt);
ShowCStr(screen_ptr,03,05,'~SPEED/TEMPO ~ /',
status_background+status_dynamic_txt,
status_background+status_static_txt);
ShowStr(screen_ptr,02,08,patt_win[1],
pattern_bckg+pattern_border);
ShowStr(screen_ptr,02,09,patt_win[2],
pattern_bckg+pattern_border);
ShowStr(screen_ptr,02,10,patt_win[3],
pattern_bckg+pattern_border);
For temp := 11 to 11+MAX_PATTERN_ROWS-1 do
ShowStr(screen_ptr,02,temp,patt_win[4],
pattern_bckg+pattern_border);
ShowStr(screen_ptr,02,11+MAX_PATTERN_ROWS,patt_win[5],
pattern_bckg+pattern_border);
end;
procedure process_config_file;
var
data: String;
function check_number(str: String; base: Byte; limit1,limit2: Longint; default: Longint): Longint;
var
idx,temp: Byte;
temp2: Longint;
result: Longint;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT2.PAS:check_number';
{$ENDIF}
result := default;
temp2 := 1000000000;
For idx := 10 downto 1 do
begin
If (limit2 >= temp2) then
begin
temp := idx;
BREAK;
end;
temp2 := temp2 DIV 10;
end;
If SameName(str+'='+ExpStrL('',temp,'?'),data) and (Length(data) < Length(str)+temp+2) then
begin
result := Str2num(Copy(data,Length(str)+2,temp),base);
If (result >= limit1) and (result <= limit2) then
else result := default;
end;
check_number := result;
end;
function validate_number(var num: Longint; str: String; base: Byte; limit1,limit2: Longint): Boolean;
var
idx,temp: Byte;
temp2: Longint;
result: Boolean;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT2.PAS:validate_number';
{$ENDIF}
result := FALSE;
temp2 := 1000000000;
For idx := 10 downto 1 do
begin
If (limit2 >= temp2) then
begin
temp := idx;
BREAK;
end;
temp2 := temp2 DIV 10;
end;
If SameName(str+'='+ExpStrL('',temp,'?'),data) and (Length(data) < Length(str)+temp+2) then
begin
num := Str2num(Copy(data,Length(str)+2,temp),base);
If (num >= limit1) and (num <= limit2) then
result := TRUE;
end
else
result := TRUE;
validate_number := result;
end;
type
tRANGE = Set of 1..255;
function check_boolean(str: String; default: Boolean): Boolean;
var
result: Boolean;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT2.PAS:process_config_file:check_boolean';
{$ENDIF}
result := default;
If SameName(str+'=???',data) and
(Length(data) < Length(str)+5) then
begin
If (Copy(data,Length(str)+2,3) = 'on') then result := TRUE;
If (Copy(data,Length(str)+2,3) = 'off') then result := FALSE;
end;
check_boolean := result;
end;
procedure check_rgb(str: String; var default: tRGB);
var
result: tRGB;
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT2.PAS:process_config_file:check_rgb';
{$ENDIF}
If SameName(str+'=??,??,??',data) and
(Length(data) < Length(str)+10) then
begin
result.r := Str2num(Copy(data,Length(str)+2,2),10);
result.g := Str2num(Copy(data,Length(str)+5,2),10);
result.b := Str2num(Copy(data,Length(str)+8,2),10);
If (result.r <= 63) and (result.g <= 63) and (result.b <= 63) then
begin
default := result;
{$IFNDEF GO32V2}
default.r := default.r SHL 2;
default.g := default.g SHL 2;
default.b := default.b SHL 2;
{$ENDIF}
end;
end;
end;
procedure check_option_data;
var
temp: Byte;
{$IFNDEF GO32V2}
temp_str: String;
{$ENDIF}
begin
{$IFDEF GO32V2}
_last_debug_str_ := _debug_str_;
_debug_str_ := 'ADT2EXT2.PAS:check_option_data';
opl3port :=
check_number('adlib_port',16,1,$0ffff,opl3port);
typematic_rate :=
check_number('typematic_rate',10,0,31,typematic_rate);
typematic_delay:=
check_number('typematic_delay',10,0,3,typematic_delay);
mouse_hspeed :=
check_number('mouse_hspeed',10,0,65535,mouse_hspeed);
mouse_vspeed :=
check_number('mouse_vspeed',10,0,65535,mouse_vspeed);
mouse_threshold :=
check_number('mouse_threshold',10,0,65535,mouse_threshold);
screen_mode :=
check_number('screen_mode',10,0,5,screen_mode);
comp_text_mode :=
check_number('comp_text_mode',10,0,4,comp_text_mode);
opl_latency :=
check_number('opl_latency',10,0,1,opl_latency);
fps_down_factor :=
check_number('fps_down_factor',10,0,10,fps_down_factor);
mouse_disabled :=
check_boolean('mouse_disabled',mouse_disabled);
// validate custom SVGA text-mode configuration
custom_svga_mode :=
check_boolean('custom_svga_mode',custom_svga_mode);
_custom_svga_cfg[1].flag :=
validate_number(_custom_svga_cfg[1].value,'svga_txt_columns',10,80,180);
_custom_svga_cfg[2].flag :=
validate_number(_custom_svga_cfg[2].value,'svga_txt_rows',10,25,60);
_custom_svga_cfg[3].flag :=
validate_number(_custom_svga_cfg[3].value,'crtc_misc_out',16,0,255);
_custom_svga_cfg[4].flag :=
validate_number(_custom_svga_cfg[4].value,'crtc_h_total',16,0,255);
_custom_svga_cfg[5].flag :=
validate_number(_custom_svga_cfg[5].value,'crtc_h_disp_en_end',16,0,255);
_custom_svga_cfg[6].flag :=
validate_number(_custom_svga_cfg[6].value,'crtc_h_blank_start',16,0,255);
_custom_svga_cfg[7].flag :=
validate_number(_custom_svga_cfg[7].value,'crtc_h_blank_end',16,0,255);
_custom_svga_cfg[8].flag :=
validate_number(_custom_svga_cfg[8].value,'crtc_h_ret_start',16,0,255);
_custom_svga_cfg[9].flag :=
validate_number(_custom_svga_cfg[9].value,'crtc_h_ret_end',16,0,255);
_custom_svga_cfg[10].flag :=
validate_number(_custom_svga_cfg[10].value,'crtc_v_total',16,0,255);
_custom_svga_cfg[11].flag :=
validate_number(_custom_svga_cfg[11].value,'crtc_overflow_reg',16,0,255);
_custom_svga_cfg[12].flag :=
validate_number(_custom_svga_cfg[12].value,'crtc_preset_r_scan',16,0,255);
_custom_svga_cfg[13].flag :=
validate_number(_custom_svga_cfg[13].value,'crtc_max_scan_h',16,0,255);
_custom_svga_cfg[14].flag :=
validate_number(_custom_svga_cfg[14].value,'crtc_v_ret_start',16,0,255);
_custom_svga_cfg[15].flag :=
validate_number(_custom_svga_cfg[15].value,'crtc_v_ret_end',16,0,255);
_custom_svga_cfg[16].flag :=
validate_number(_custom_svga_cfg[16].value,'crtc_v_disp_en_end',16,0,255);
_custom_svga_cfg[17].flag :=
validate_number(_custom_svga_cfg[17].value,'crtc_offs_width',16,0,255);
_custom_svga_cfg[18].flag :=
validate_number(_custom_svga_cfg[18].value,'crtc_underline_loc',16,0,255);
_custom_svga_cfg[19].flag :=
validate_number(_custom_svga_cfg[19].value,'crtc_v_blank_start',16,0,255);
_custom_svga_cfg[20].flag :=
validate_number(_custom_svga_cfg[20].value,'crtc_v_blank_end',16,0,255);
_custom_svga_cfg[21].flag :=
validate_number(_custom_svga_cfg[21].value,'crtc_mode_ctrl',16,0,255);
_custom_svga_cfg[22].flag :=
validate_number(_custom_svga_cfg[22].value,'crtc_clock_m_reg',16,0,255);
_custom_svga_cfg[23].flag :=
validate_number(_custom_svga_cfg[23].value,'crtc_char_gen_sel',16,0,255);
_custom_svga_cfg[24].flag :=
validate_number(_custom_svga_cfg[24].value,'crtc_memory_m_reg',16,0,255);
_custom_svga_cfg[25].flag :=
validate_number(_custom_svga_cfg[25].value,'crtc_mode_reg',16,0,255);
_custom_svga_cfg[26].flag :=
validate_number(_custom_svga_cfg[26].value,'crtc_misc_reg',16,0,255);
_custom_svga_cfg[27].flag :=
validate_number(_custom_svga_cfg[27].value,'crtc_mode_control',16,0,255);
_custom_svga_cfg[28].flag :=
validate_number(_custom_svga_cfg[28].value,'crtc_screen_b_clr',16,0,255);
_custom_svga_cfg[29].flag :=
validate_number(_custom_svga_cfg[29].value,'crtc_colr_plane_en',16,0,255);
_custom_svga_cfg[30].flag :=
validate_number(_custom_svga_cfg[30].value,'crtc_h_panning',16,0,255);
_custom_svga_cfg[31].flag :=
validate_number(_custom_svga_cfg[31].value,'crtc_color_select',16,0,255);
{$ELSE}
sdl_screen_mode :=
check_number('sdl_screen_mode',10,0,2,sdl_screen_mode);
sdl_frame_rate :=
check_number('sdl_frame_rate',10,50,200,sdl_frame_rate);
sdl_timer_slowdown :=
check_number('sdl_timer_slowdown',10,0,50,sdl_timer_slowdown);
sdl_typematic_rate :=
check_number('sdl_typematic_rate',10,1,100,sdl_typematic_rate);
sdl_typematic_delay :=
check_number('sdl_typematic_delay',10,0,2000,sdl_typematic_delay);
If (Copy(data,1,18) = 'sdl_wav_directory=') and
(Length(data) > 18) then
begin
temp_str := Copy(data,19,Length(data)-18);
If (temp_str[1] = PATHSEP) then Delete(temp_str,1,1);
If (temp_str <> '') then
begin
If (Length(temp_str) > 4) then
If NOT (Lower(Copy(temp_str,Length(temp_str)-3,4)) = '.wav') then
temp_str := temp_str+PATHSEP
else opl3_flushmode := TRUE
else If (temp_str[Length(temp_str)] <> PATHSEP) then
temp_str := temp_str+PATHSEP;
end;
sdl_wav_directory := temp_str;
If NOT (Pos(':',sdl_wav_directory) <> 0) then
sdl_wav_directory := PathOnly(ParamStr(0))+PATHSEP+sdl_wav_directory;
end;
{$ENDIF}
init_tempo :=
check_number('init_tempo',10,1,255,Round(init_tempo));
init_speed :=
check_number('init_speed',16,1,255,init_speed);
init_macro_speedup :=
check_number('init_macro_speedup',10,1,calc_max_speedup(init_tempo),init_macro_speedup);
midiboard :=
check_boolean('midiboard',midiboard);
default_octave :=
check_number('octave',10,1,8,default_octave);
patt_len :=
check_number('patt_len',10,1,255,patt_len);
nm_tracks :=
check_number('nm_tracks',10,1,20,nm_tracks);
mod_description :=
check_boolean('mod_description',mod_description);
highlight_controls :=
check_boolean('highlight_controls',highlight_controls);
use_H_for_B :=
check_boolean('use_h_for_b',use_H_for_B);
linefeed :=
check_boolean('linefeed',linefeed);
lf_in_mboard_mode :=
check_boolean('lf_in_mboard_mode',lf_in_mboard_mode);
update_ins :=
check_boolean('update_ins',update_ins);
adjust_tracks :=
check_boolean('adjust_tracks',adjust_tracks);
cycle_pattern :=
check_boolean('cycle_pattern',cycle_pattern);
keep_track_pos :=
check_boolean('keep_track_pos',keep_track_pos);
remember_ins_pos :=
check_boolean('remember_ins_pos',remember_ins_pos);
backspace_dir :=
check_number('backspace_dir',10,1,2,backspace_dir);
scroll_bars :=
check_boolean('scroll_bars',scroll_bars);
fforward_factor :=
check_number('fforward_factor',10,1,5,fforward_factor);
rewind_factor :=
check_number('rewind_factor',10,1,5,rewind_factor);
ssaver_time :=
check_number('ssaver_time',10,0,1440,ssaver_time DIV 60)*60;
timer_fix :=
check_boolean('18hz_fix',timer_fix);
decay_bar_rise :=
check_number('decay_bar_rise',10,1,10,Round(decay_bar_rise));
If (check_number('decay_bar_fall',10,1,10,0) <> 0) then
decay_bar_fall := check_number('decay_bar_fall',10,1,10,0)/10;
force_ins :=
check_number('force_ins',10,0,2,force_ins);
keep_position :=
check_boolean('keep_position',keep_position);
alt_ins_name :=
check_boolean('alt_ins_name',alt_ins_name);
trace_by_default :=
check_boolean('trace_by_default',trace_by_default);
nosync_by_default :=
check_boolean('nosync_by_default',nosync_by_default);
pattern_layout :=
check_number('pattern_layout',10,0,2,pattern_layout);
command_typing :=
check_number('command_typing',10,0,2,command_typing);
mark_lines :=
check_boolean('mark_lines',mark_lines);
fix_c_note_bug :=
check_boolean('fix_c_note_bug',fix_c_note_bug);
accurate_conv :=
check_boolean('accurate_conv',accurate_conv);