-
Notifications
You must be signed in to change notification settings - Fork 2
/
CDPLAYER.PAS
2232 lines (1932 loc) · 58.1 KB
/
CDPLAYER.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
{/////////////////////////////////////////////////////////////////////////
//
// Dos Navigator Version 1.51 Copyright (C) 1991-99 RIT Research Labs
//
// This programs is free for commercial and non-commercial use as long as
// the following conditions are aheared to.
//
// Copyright remains RIT Research Labs, and as such any Copyright notices
// in the code are not to be removed. If this package is used in a
// product, RIT Research Labs should be given attribution as the RIT Research
// Labs of the parts of the library used. This can be in the form of a textual
// message at program startup or in documentation (online or textual)
// provided with the package.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// "Based on Dos Navigator by RIT Research Labs."
//
// THIS SOFTWARE IS PROVIDED BY RIT RESEARCH LABS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// The licence and distribution terms for any publically available
// version or derivative of this code cannot be changed. i.e. this code
// cannot simply be copied and put under another distribution licence
// (including the GNU Public Licence).
//
//////////////////////////////////////////////////////////////////////////}
UNIT CDPlayer;
{.$DEFINE UPD}
INTERFACE
USES xTime, Dialogs, Drivers, Objects, Views, ObjType;
CONST
CDplace: Tpoint = ( X:0; Y:0 );
CDsize: Tpoint = ( X:0; Y:0 );
CDparams: array[ 1..3 ] of word = ( 3, 0, 0 );
CDmixer : string[80]= '';
CD_Player: PView = nil;
PROCEDURE RunPlayer;
PROCEDURE RegisterCDplayer;
{$IFDEF UPD}
PROCEDURE UpdateCDplayer;
{$ENDIF}
CONST
cpNormal = 0;
cpIntro = 1;
cpShuffle= 2;
cpOne = 3;
cpOrder = 4;
cpAutoplay = 1;
cpAutoEject = 2;
cpLockDoor = 4;
cpRepeat = 8;
cpTrack = 0;
cpLeftTrack = 1;
cpDisk = 2;
cpLeftDisk = 3;
TYPE
_Status = ( noDisk, Play, Stopped, Paused, newDisk );
_Err = record
Stat: byte;
Code: byte;
end;
_Diskinfo = record
FirstTrack, LastTrack: byte;
LeadStart: Longint;
end;
_TrackInfo = record
case Boolean of
True: ( CFrame: byte;
CSec: byte;
CMin: byte;
CC: byte;
CStat: byte );
False: ( Addr: longint;
Stat: byte )
end;
_TLen = record LSec, Lmin: byte end;
_Tracks = array[ 1..100 ] of _TrackInfo;
_Tlens = array[ 1..100 ] of _Tlen;
_Order = array[ 1..100 ] of byte;
_QChannel = record
ADR,
TNO,
IDX,
Rmin,
RSec,
Rfrm,
Rzero,
AMin,
Asec,
Afrm: byte;
Stat: word;
end;
_UpcCode = record
ADR: byte;
UPC: array[ 1..7 ] of byte;
ZERO,
AFrame: byte;
end;
PCounter = ^TCounter;
TCounter = object( TView )
Line: array[ 1..3 ] of string[ 30 ];
Constructor Init( R: Trect );
Procedure SetCounter( T, A, B: byte );
Destructor Done; virtual;
Procedure Draw; virtual;
procedure Awaken; virtual;
end;
PCdPlayer = ^TCdPlayer;
TCdPlayer = Object( TDialog )
DiskOk: boolean;
CdDisk: integer;
LowTrack,
HighTrack: byte;
DiskMin,
DiskSec: byte;
Tracks: _tracks;
{ new }
DiskId : Longint;
DiskTitle : PString;
Descr : PLineCollection ;
TrkDescr : String;
TrkOrder : String;
TrkPlay : String;
{ new }
TLen: _tlens;
Order: _Order;
Counter: PCounter;
Info0: PParamText;
Info1: PParamText;
Info2: PParamText;
Qchannel: _Qchannel;
UpdCnt: TEventTimer;
NewPlay: TEventTimer;
reqHdr: array[ 0..49 ] of byte;
Status: _Status;
Err: _Err;
LastShuffle: byte;
Parm: array[ 1..3 ] of longint;
Parmt: longint;
ParmD: longint;
{ Parm0: string[ 10 ];
Parm1: string[ 10 ]; }
Parm2: string[ 20 ];
CD_Loaded : boolean ;
Constructor Init( R: Trect; ACdDisk: integer );
Procedure InitInterior;
Procedure LoadDiskInfo;
Procedure Display( T, M, S: byte );
Destructor Done; virtual;
Procedure Update; virtual;
Procedure HandleEvent( var Event: Tevent );virtual;
Procedure Zoom; Virtual;
Function Valid( Command: Word ): Boolean; virtual;
procedure Store( var S: TStream ); virtual;
constructor Load( var S: TStream );
procedure Awaken; virtual;
procedure SizeLimits(var Min, Max: TPoint); virtual;
private
procedure _SetOrder;
procedure _Play;
procedure _Stop;
procedure _Next;
procedure _Prev;
procedure _Pause;
procedure _Eject;
procedure _Load;
procedure _FForward;
procedure _FRewind;
procedure _Setup;
procedure _Mix;
procedure _Door( DLock: Boolean );
procedure _Song( ASong : byte ) ;
function _DiskStatus: boolean;
function _DiskIsChanged: boolean;
Function MakeTrackList : PLineCollection ;
Procedure SelectTrack ;
Procedure SelectOrder ;
Procedure GetDescription ;
Function GetOrder : boolean ;
end;
CONST
RCdplayer: TStreamRec = (
ObjType: otCdplayer;
VmtLink: Ofs( TypeOf( TCdPlayer )^ );
Load: @TCDplayer.Load;
Store: @TCDplayer.Store );
RCDCounter: TStreamRec = (
ObjType: otCDCounter;
VmtLink: Ofs( TypeOf( TCounter )^ );
Load: @TCounter.Load;
Store: @TCounter.Store );
IMPLEMENTATION
USES Advance, Messages, Commands, RStrings, DNHelp, DOS, DnApp, Startup,
CDUtil ;
CONST
cdDrive: integer = -1;
PROCEDURE RegisterCDplayer;
begin
RegisterType( RCdPlayer );
RegisterType( RCdCounter );
end;
const
Crc32Table : array[0..255] of LongInt = (
$00000000, $77073096, $ee0e612c, $990951ba, $076dc419, $706af48f, $e963a535,
$9e6495a3, $0edb8832, $79dcb8a4, $e0d5e91e, $97d2d988, $09b64c2b, $7eb17cbd,
$e7b82d07, $90bf1d91, $1db71064, $6ab020f2, $f3b97148, $84be41de, $1adad47d,
$6ddde4eb, $f4d4b551, $83d385c7, $136c9856, $646ba8c0, $fd62f97a, $8a65c9ec,
$14015c4f, $63066cd9, $fa0f3d63, $8d080df5, $3b6e20c8, $4c69105e, $d56041e4,
$a2677172, $3c03e4d1, $4b04d447, $d20d85fd, $a50ab56b, $35b5a8fa, $42b2986c,
$dbbbc9d6, $acbcf940, $32d86ce3, $45df5c75, $dcd60dcf, $abd13d59, $26d930ac,
$51de003a, $c8d75180, $bfd06116, $21b4f4b5, $56b3c423, $cfba9599, $b8bda50f,
$2802b89e, $5f058808, $c60cd9b2, $b10be924, $2f6f7c87, $58684c11, $c1611dab,
$b6662d3d, $76dc4190, $01db7106, $98d220bc, $efd5102a, $71b18589, $06b6b51f,
$9fbfe4a5, $e8b8d433, $7807c9a2, $0f00f934, $9609a88e, $e10e9818, $7f6a0dbb,
$086d3d2d, $91646c97, $e6635c01, $6b6b51f4, $1c6c6162, $856530d8, $f262004e,
$6c0695ed, $1b01a57b, $8208f4c1, $f50fc457, $65b0d9c6, $12b7e950, $8bbeb8ea,
$fcb9887c, $62dd1ddf, $15da2d49, $8cd37cf3, $fbd44c65, $4db26158, $3ab551ce,
$a3bc0074, $d4bb30e2, $4adfa541, $3dd895d7, $a4d1c46d, $d3d6f4fb, $4369e96a,
$346ed9fc, $ad678846, $da60b8d0, $44042d73, $33031de5, $aa0a4c5f, $dd0d7cc9,
$5005713c, $270241aa, $be0b1010, $c90c2086, $5768b525, $206f85b3, $b966d409,
$ce61e49f, $5edef90e, $29d9c998, $b0d09822, $c7d7a8b4, $59b33d17, $2eb40d81,
$b7bd5c3b, $c0ba6cad, $edb88320, $9abfb3b6, $03b6e20c, $74b1d29a, $ead54739,
$9dd277af, $04db2615, $73dc1683, $e3630b12, $94643b84, $0d6d6a3e, $7a6a5aa8,
$e40ecf0b, $9309ff9d, $0a00ae27, $7d079eb1, $f00f9344, $8708a3d2, $1e01f268,
$6906c2fe, $f762575d, $806567cb, $196c3671, $6e6b06e7, $fed41b76, $89d32be0,
$10da7a5a, $67dd4acc, $f9b9df6f, $8ebeeff9, $17b7be43, $60b08ed5, $d6d6a3e8,
$a1d1937e, $38d8c2c4, $4fdff252, $d1bb67f1, $a6bc5767, $3fb506dd, $48b2364b,
$d80d2bda, $af0a1b4c, $36034af6, $41047a60, $df60efc3, $a867df55, $316e8eef,
$4669be79, $cb61b38c, $bc66831a, $256fd2a0, $5268e236, $cc0c7795, $bb0b4703,
$220216b9, $5505262f, $c5ba3bbe, $b2bd0b28, $2bb45a92, $5cb36a04, $c2d7ffa7,
$b5d0cf31, $2cd99e8b, $5bdeae1d, $9b64c2b0, $ec63f226, $756aa39c, $026d930a,
$9c0906a9, $eb0e363f, $72076785, $05005713, $95bf4a82, $e2b87a14, $7bb12bae,
$0cb61b38, $92d28e9b, $e5d5be0d, $7cdcefb7, $0bdbdf21, $86d3d2d4, $f1d4e242,
$68ddb3f8, $1fda836e, $81be16cd, $f6b9265b, $6fb077e1, $18b74777, $88085ae6,
$ff0f6a70, $66063bca, $11010b5c, $8f659eff, $f862ae69, $616bffd3, $166ccf45,
$a00ae278, $d70dd2ee, $4e048354, $3903b3c2, $a7672661, $d06016f7, $4969474d,
$3e6e77db, $aed16a4a, $d9d65adc, $40df0b66, $37d83bf0, $a9bcae53, $debb9ec5,
$47b2cf7f, $30b5ffe9, $bdbdf21c, $cabac28a, $53b39330, $24b4a3a6, $bad03605,
$cdd70693, $54de5729, $23d967bf, $b3667a2e, $c4614ab8, $5d681b02, $2a6f2b94,
$b40bbe37, $c30c8ea1, $5a05df1b, $2d02ef8d
);
var
Crc32TableOfs : Word;
function UpdateCrc32(CurByte : Byte; CurCrc : LongInt) : LongInt;
{-Returns an updated crc32}
(* Model for inline code below
UpdateCrc32 := Crc32Table[Byte(CurCrc xor LongInt(CurByte))] xor
((CurCrc shr 8) and $00FFFFFF);
*)
Inline(
{;Get args -- DX:BX = CurCrc, CX = CurByte;}
$5B/ { POP BX}
$5A/ { POP DX}
$59/ { POP CX}
$52/ { PUSH DX}
$53/ { PUSH BX ;Save original CurCrc}
{;CX:AX := Get Crc32Table[CurCrc xor CurByte];}
$31/$CB/ { XOR BX,CX ;DX:BX = CurCrc xor CurByte}
$30/$FF/ { XOR BH,BH ;Byte(DX:BX)}
$D1/$E3/ { SHL BX,1 ;LongInt index}
$D1/$E3/ { SHL BX,1}
$03/$1E/>CRC32TABLEOFS/{ ADD BX,[>Crc32TableOfs]}
$8B/$07/ { MOV AX,[BX]}
$8B/$4F/$02/ { MOV CX,[BX+2]}
{;DX:BX := (CurCrc shr 8) and $00FFFFFF;}
$5B/ { POP BX ;Get original CurCrc}
$5A/ { POP DX}
$51/ { PUSH CX ;Save CX}
$B9/$08/$00/ { MOV CX,8 ;Shift 8 bits}
$D1/$EA/ {C1: SHR DX,1 ;Hi reg into carry}
$D1/$DB/ { RCR BX,1 ;Carry into lo reg}
$E2/$FA/ { LOOP C1 ; for 8 bits}
$81/$E2/$FF/$00/ { AND DX,$00FF}
{;DX:AX := ES:AX xor DX:BX (sets function result)}
$59/ { POP CX}
$31/$D8/ { XOR AX,BX}
$89/$CB/ { MOV BX,CX}
$31/$DA); { XOR DX,BX}
Function GetCrc( var Buf ; BufSize : word ) : Longint ;
type
AA = array[1..$F000] of byte ;
var CNT : word;
CRC : Longint;
begin
Crc32TableOfs := Ofs(Crc32Table);
CRC := 0;
GetCrc := 0;
if BufSize = 0 then Exit;
for CNT :=1 to BufSize do
CRC := UpdateCrc32(AA(Buf)[CNT] , Crc );
GetCrc := CRC ;
end;
FUNCTION CD_GetFirstDrive( var firstDrive: Integer ): integer; assembler;
asm
mov ax, $1500
mov bx, 0
int $2f
mov ax, bx {;# of drives }
les bx, firstDrive
mov es:[ bx ].word, cx
end;
FUNCTION CD_Req( drv: integer;
cmd: byte;
size: integer;
Var reqHdr: array of byte ):boolean;
var Buf: Pointer;
begin
reqHdr[ 1 ] := 0;
reqHdr[ 2 ] := cmd;
reqHdr[ 0 ] := 20;
Buf := System.Addr( reqHdr[ 20 ] );
move( Buf, reqHdr[ 14 ], sizeOf( Buf ));
reqHdr[ 18 ]:= lo( size );
reqHdr[ 19 ]:= hi( size );
asm
les bx, reqHdr
mov cx, drv
mov ax, $1510
int $2f
end;
CD_req := reqHdr[ 4 ] and $80 = $80;
(*
if ( reqHdr[ 4 ] and $80 ) > 0 { Error! } then begin
if ( reqHdr[ 3 ] = 2 ) or ( reqHdr[ 3 ] = 12 ) then begin
Writeln( 'Error: no disk in drive' );
exit;
end else
Writeln( 'Error ', reqHdr[ 3 ], ' cmd ', reqHdr[ 20 ] );
end
*)
end;
FUNCTION CD_IsChanged( drive: integer ): boolean;
var
reqHdr: array[ 0..39 ] of byte;
Err: byte;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
reqHdr[ 20 ] := 9; { Changed? cmd }
CD_Req( drive, 3, 1, reqHdr );
CD_IsChanged := ( reqHdr[ 21 ] = $FF );
end;
FUNCTION CD_IsPaused( drive: integer ): boolean;
var
reqHdr: array[ 0..39 ] of byte;
Err: byte;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
reqHdr[ 20 ] := 15; { AudioStat cmd }
CD_Req( drive, 3, 3, reqHdr );
CD_IsPaused := ( reqHdr[ 21 ] and 1 = 1 );
end;
FUNCTION CD_IsDiskPresent( drive: integer ): boolean;
var
reqHdr: array[ 0..39 ] of byte;
Err: byte;
devpar: WORD;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
reqHdr[ 20 ] := 6; { DiskStat cmd }
Err := 0;
if CD_Req( drive, 3, 5, reqHdr ) then Err := reqHdr[ 3 ];
move( reqHdr[ 21 ], devpar, sizeOf( devPar ));
{ CD_IsDiskPresent := (( reqHdr[ 22 ] and $1 ) = 1 ) and}
CD_IsDiskPresent := ( DevPar and { $801} 1 = 0 ) and
(( Err <> 2 ) and ( Err <> 12 ))
end;
PROCEDURE CD_DiskInfo( drive: integer; var buf );
var
reqHdr: array[ 0..39 ] of byte;
Err: byte;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
reqHdr[ 20 ] := 10; { Disk Info cmd }
CD_Req( drive, 3, 7, reqHdr );
move( reqHdr[ 21 ], buf, 6 );
end;
PROCEDURE CD_TrackInfo( drive, track: integer; var buf );
var
reqHdr: array[ 0..39 ] of byte;
Err: byte;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
reqHdr[ 20 ]:= 11; { Track Info cmd }
reqHdr[ 21 ]:= track;
CD_Req( drive, 3, 7, reqHdr );
move( reqHdr[ 22 ], buf, 5 );
end;
PROCEDURE CD_Status( drive: integer; var buf: _Qchannel );
var
reqHdr: array[ 0..39 ] of byte;
Err: byte;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
reqHdr[ 20 ]:=12; { Track Info cmd }
reqHdr[ 21 ]:=1;
CD_Req( drive, 3, 11, reqHdr );
move( reqHdr[ 21 ], buf, 10 );
with Buf do
begin
TNO :=(( TNO and $f )+(( TNO and $f0 )) * 10 div 16 );
Move( reqHdr[ 3 ], STAT, sizeof( STAT ));
end;
end;
(*
PROCEDURE CD_UpcCode( drive: integer; var buf: array of byte );
var
reqHdr: array[ 0..39 ] of byte;
UP: _UpcCode;
Err: byte;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
reqHdr[ 20 ]:=14; { UPC Info cmd }
reqHdr[ 21 ]:=1;
CD_Req( drive, 3, 11, reqHdr );
move( reqHdr[ 21 ], UP, SizeOF( UP ));
move( UP.UPC, buf, 7 );
end;
*)
FUNCTION CD_Stop( drv: integer; var reqHdr: array of byte ): word;
var
statBuf: array[ 0..19 ] of byte;
C: word;
CC: array[ 1..2 ] of byte absolute C;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 10 );
reqHdr[ 1 ]:=0;
reqHdr[ 2 ]:=133;
reqHdr[ 0 ]:=$5;
asm
les bx, reqHdr
mov cx, drv
mov ax, $1510
clc
int $2f
end;
Move( reqHdr[ 3 ], CC, 2 );
CD_Stop := C;
(*
if ( reqHdr[ 4 ] and $80 ) > 0 { Error! } then
begin
if ( reqHdr[ 3 ] = 2 ) or ( reqHdr[ 3 ] = 12 ) then
begin
Writeln( 'Error: no disk in drive' );
exit;
end else
Writeln( 'Error ', reqHdr[ 3 ], ' cmd ', reqHdr[ 20 ] );
end;
*)
end;
(*
FUNCTION CD_PlayTracks( drv , fromTrack, toTrack: integer ): boolean;
var
reqHdr: array[ 0..39 ] of byte;
SAddr ,
TAddr: _TrackInfo;
DM, DS, DF: integer;
TL: longint;
begin
fillchar( reqHdr, SizeOf( reqHdr ), 0 );
CD_PlayTracks := false;
if ( fromTrack > toTrack ) or
( fromTrack < diskInfo.firstTrack ) or
( toTrack > diskInfo.lastTrack ) then
begin
Writeln( 'Bad track #' ); exit;
end;
if ( til[ fromTrack ].stat and $40 > 0 ) then
begin
Writeln( 'track ', fromTrack, ' is data' );
exit;
end;
if not ( CD_IsPaused( drv )) then
begin
CD_Stop( drv ); { Always stop before playing! }
CD_Stop( drv ); { Always stop before playing! }
end;
reqHdr[ 1 ] := 0;
reqHdr[ 2 ] := 132;
reqHdr[ 0 ] := $16;
reqHdr[ $d ] := 1; { Red book address mode }
SAddr := til[ fromTrack ];
move( Saddr, reqHdr[ $E ], 4 );
Taddr := til[ toTrack+1 ];
DM := Taddr.CMin - SAddr.Cmin;
DS := Taddr.CSec - SAddr.CSec;
DF := Taddr.CFrame - SAddr.CFrame;
if DF < 0 then begin Dec( DS ); inc( DF, 75 ) end;
if DS < 0 then begin Dec( DM ); inc( DS, 60 ) end;
TAddr.CMin := DM;
TAddr.Csec := DS;
TAddr.Cframe := DF;
TL := Longint( Longint( DM ) * 4500 + Longint( DS ) * 75 + DF - 150 );
move( TL, reqHdr[ $12 ] , 4 );
writeln( 'track ', fromTrack, '-', toTrack, ' at ', Saddr.Cmin,
':', Saddr.CSec, ' len ', DM, ':', DS );
asm
mov ax, ss
mov es, ax
lea bx, reqHdr
mov cx, drv
mov ax, $1510
int $2f
end;
end;
*)
FUNCTION CD_Play( drv: integer; FromTrack, toTrack: _TrackInfo;
var reqHdr: array of byte ): boolean;
var
{reqHdr: array[ 0..39 ] of byte;}
DM, DS, DF: integer;
TL: longint;
begin
fillchar( reqHdr, SizeOf( reqHdr ), $12 );
CD_Play := false;
if ( fromTrack.stat and $40 > 0 ) then Exit;
if not ( CD_IsPaused( drv )) then
begin
CD_Stop( drv, reqHdr ); { Always stop before playing! }
CD_Stop( drv, reqHdr ); { Always stop before playing! }
end;
reqHdr[ 1 ] := 0;
reqHdr[ 2 ] := 132;
reqHdr[ 0 ] :=$16;
reqHdr[ $d ] := 1; { Red book address mode }
move( FromTrack, reqHdr[ $E ], 4 );
DM := toTrack.CMin - FromTrack.Cmin;
DS := toTrack.CSec - FromTrack.CSec;
DF := toTrack.CFrame - FromTrack.CFrame;
if DF < 0 then begin Dec( DS ); inc( DF, 75 ) end;
if DS < 0 then begin Dec( DM ); inc( DS, 60 ) end;
TL := Longint( Longint( DM ) * 4500 + Longint( DS ) * 75 + DF - 150 );
move( TL, reqHdr[ $12 ] , 4 );
asm
les bx, reqHdr
mov cx, drv
mov ax, $1510
int $2f
end;
end;
FUNCTION CD_GetDriverVersion:integer;assembler;
asm
mov ax, $150C
int $2f
mov ax, bx
end;
PROCEDURE TimeSub( var M1, S1: integer; M2, S2: byte );
begin
Inc( S1, 60 );
Dec( S1, S2 );
Dec( M1, M2 );
if S1>59 then DEC( S1, 60 )
else DEC( M1 );
end;
PROCEDURE TimeAdd( var M1, S1: integer; M2, S2: byte );
begin
Inc( S1, S2 );
Inc( M1, M2 );
if S1>59 then begin
DEC( S1, 60 );
Inc( M1 );
end;
end;
(*
PROCEDURE CD_ShowInf( drive: integer );
var i, m, s, mb, ml, sb, sl: integer;
statBuf: _Qchannel;
dig: array[ 1..7 ] of byte;
begin
I := CD_GetDriverVersion;
Writeln( ^M^J'Drier version is ', hi( I ), '.', lo( I ));
Writeln( 'Tracks ', diskInfo.firstTrack, ' to ', diskInfo.lastTrack );
Writeln( 'track: start len' );
for i := diskInfo.firstTrack to diskInfo.lastTrack do
begin
M := til[ i ].cmin;
S := til[ i ].csec;
Mb := til[ i+1 ].cmin;
Sb := til[ i+1 ].csec;
ml:=mb-m;
sl:=sb-s;
if ( sl < 0 ) then begin inc( sl, 60 ); dec( ml ); end;
Writeln( i:3, ': ', m:2, ':', s:2, ' ', ml:2, ':', sl:2 );
end;
CD_Status( drive, statBuf );
Writeln( 'status =', statBuf.Stat );
if ( CD_IsPaused( cdDrive )) then
write( ^M^J^M^J'CD Paused at' )
else
write( ^M^J^M^J'Now playing' );
Writeln( ' track ', statBuf.TNO, ' at ', statBuf.Rmin, ':', statBuf.Rsec );
CD_UpcCode( drive, Dig );
Write( 'Universal Product Code is :' );
for I := 0 to 12 do
begin
m := Dig[ 1+ ( i shr 1 ) ];
if i and 1 = 0 then m := m shr 4;
m := m and $f;
Write( m );
end;
Writeln;
end;
*)
PROCEDURE GetDigit( Dig: byte; var S: string );
begin
case Dig of
0: S := 'ÜÜÜÛ ÛÛÜÛ';
1: S := ' Ü Û Û';
2: S := 'ÜÜÜÜÜÛÛÜÜ';
3: S := 'ÜÜÜÜÜÛÜÜÛ';
4: S := 'Ü ÜÛÜÛ Û';
5: S := 'ÜÜÜÛÜÜÜÜÛ';
6: S := 'ÜÜÜÛÜÜÛÜÛ';
7: S := 'ÜÜÜ Û Û';
8: S := 'ÜÜÜÛÜÛÛÜÛ';
9: S := 'ÜÜÜÛÜÛÜÜÛ';
{n} $6E: S := ' ÜÜÜÛ Û';
{o} $6F: S := ' ÜÜÜÛÜÛ';
{C} { $43: S := 'ÜÜÜÛ ÛÜÜ';}
{D} { $44: S := 'ÜÜ Û ÛÛÜß';}
{C} $43: S := ' ÜÜÜÛÜÜ';
{D} $44: S := ' ÜÜ ÛÜÛ';
else S := ' ';
end;
end;
{
ÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜ Ü Ü ÜÜÜ
ÛÜÛ ÛÜÛ Û ÛÜÜ ÛÜÜ ÛÜÛ ß ÜÜÛ
ÛÜÛ ÜÜÛ Û ÛÜÛ ÜÜÛ Û ß ÜÜÛ
ÜÜÜ ÜÜÜ ÜÜÜ ÜÜ
Û Û ÛÜÛ ÛÜÜ ÛÜÛ
}
Constructor TCounter.Init;
var I: byte;
begin
R.B.Y := R.A.Y + 3;
R.B.X := R.A.X + 18 + 9;
inherited Init( R );
for I := 1 to 3 do Line[ i ] := Strg(' ', Pred( SizeOf( Line[ i ] )));
end;
PROCEDURE TCounter.Awaken;
var I: byte;
begin
inherited Awaken;
for I := 1 to 3 do Line[ i ] := Strg(' ', Pred( SizeOf( Line[ i ] )));
end;
PROCEDURE TCounter.SetCounter( T, A, B: byte );
var S: String[ 9 ];
I: byte;
PROCEDURE InsertText( From: byte );
var I: byte;
begin
for I := 1 to 3 do Move( S[ pred( I )*3+1 ], Line[ I, From ], 3 );
end;
begin
for I:=1 to 3 do fillChar( Line[ I, 1 ], Length( Line[ I ] ), 32 );
if T < $FF then
begin
GetDigit( T div 10, S ); InsertText( 1 );
GetDigit( T mod 10, S ); InsertText( 5 );
if T > 0 then
begin
S := Strg(' ', 9 ); if A > 9 then GetDigit( A div 10, S );
InsertText( 10 );
GetDigit( A mod 10, S ); InsertText( 14 );
GetDigit( B div 10, S ); InsertText( 20 );
GetDigit( B mod 10, S ); InsertText( 24 );
Line[ 2, 9+9 ] := 'ß';
Line[ 3, 9+9 ] := 'ß';
end;
end
else
begin
GetDigit( $6E, S ); InsertText( 1 );
GetDigit( $6F, S ); InsertText( 5 );
GetDigit( $43, S ); InsertText( 10 );
GetDigit( $44, S ); InsertText( 14 );
end;
end;
PROCEDURE TCounter.Draw;
var C, I: byte;
T: TdrawBuffer;
begin
C := GetColor( 1 );
for I := 0 to Pred( Size.Y ) do
begin
MoveStr( T, Line[ I+1 ], C );
WriteLine( 0, I, Size.X, Succ( I ), T );
end;
end;
Destructor TCounter.Done;
begin
Inherited Done;
end;
CONSTRUCTOR TCdPlayer.Init;
var
R1: Trect;
TR : word ;
begin
{if CD_GetFirstDrive( cdDrive ) = 0 then Fail;}
R1 := R;
R1.B.X := R1.A.X + 36;
R1.B.Y := R1.A.Y + 8;
if R.B.Y - R.A.Y > 8 then begin
R.B.X := R.A.X + 36;
R.B.Y := R.A.Y + {10}15;
end else
R := R1;
{R.Assign( 1, 4, 35, 9 ); } { 34 7 59 12 }
{R.Assign( 1, 4, 60, 14 ); }
inherited Init( R, GetString( dlCDPlayer ));
{Options := Options or ofCentered;}
Flags := Flags or wfZoom;
ZoomRect := R1;
CdDisk := ACDdisk;
{$ifdef upd}
NewTimer( UpdCnt, 18 );
{$else}
UpdTicks := 18;
RegisterToBackGround( @Self );
{$endif}
HelpCTX := hcCDplayer;
DiskId := 0 ;
DiskTitle := Nil;
New(Descr,Init(100,10));
for TR :=1 to 100 do Descr^.Insert(Nil);
InitInterior;
LoadDiskInfo;
end;
PROCEDURE TCdPlayer.Awaken;
begin
inherited Awaken;
end;
PROCEDURE TCdPlayer.Store;
begin
inherited Store( S );
PutSubViewPtr( S, Counter );
PutSubViewPtr( S, Info0 );
PutSubViewPtr( S, Info1 );
PutSubViewPtr( S, Info2 );
S.Write( Order, SizeOf( Order ));
S.Write( LastShuffle, SizeOf( LastShuffle ));
S.Write( CDParams, SizeOf( CDParams));
{!!SF}
S.Write( DiskId , SizeOF(DiskId) ) ;
S.WriteStr( DiskTitle );
S.Put( Descr );
S.WriteStr( @TrkOrder );
S.WriteStr( @TrkPlay );
end;
constructor TCdPlayer.Load;
var P : PString;
begin
inherited Load( S );
GetSubViewPtr( S, Counter );
GetSubViewPtr( S, Info0 );
GetSubViewPtr( S, Info1 );
GetSubViewPtr( S, Info2 );
S.Read( Order, SizeOf( Order ));
S.Read( LastShuffle, SizeOf( LastShuffle ));
S.Read( CDParams, SizeOf( CDParams ));
{!!SF}
S.Read( DiskId , SizeOF(DiskId) ) ;
DiskTitle := S.ReadStr;
Descr := PLineCollection(S.Get);
P := S.ReadStr; TrkOrder := CnvString(P); DisposeStr(P);
P := S.ReadStr; TrkPlay := CnvString(P); DisposeStr(P);
UpdTicks := 18;
RegisterToBackGround( @Self );
CD_Player := @Self;
{Coder := GlobalMessage( evCommand, cmXdata+1, nil );}
CD_GetFirstDrive( CdDisk );
LoadDiskInfo;
Update;
Redraw;
end;
PROCEDURE TCdPlayer.InitInterior;
var
R: TRect;
Control, Labl, Histry: PView;
D: array[ 1..2 ] of PString;
Y : byte ;
begin
Y := 6;
R.Assign( 1, Y, 7, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonRew), cdFRew, bfBroadcast ));
Insert( Control );
R.Assign( 7, Y, 12, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonPrev), cdPrev, bfBroadcast ));
Insert( Control );
R.Assign( 12, Y, 23, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonPlay), cdPlay, bfBroadcast ));
Insert( Control );
R.Assign( 23, Y, 28, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonNext), cdNext, bfBroadcast ));
Insert( Control );
R.Assign( 28, Y, 34, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonFFwd), cdFFwd, bfBroadcast ));
Insert( Control );
inc(Y,2);
R.Assign( 1, Y, 10, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonPause), cdPause, bfBroadCast ));
Insert( Control );
R.Move(9,0); Inc(R.B.X,6);
Control := New( PButton, Init( R, GetString(dlCDButtonStop), cdStop, bfBroadcast ));
Insert( Control );
R.Move(15,0); Dec(R.B.X,6);
Control := New( PButton, Init( R, GetString(dlCDButtonEject), cdEject, bfBroadCast ));
Insert( Control );
inc(Y,2);
R.Assign( 1, Y, 12, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonSet), cdSetup, bfBroadCast ));
Insert( Control );
R.Move( 11, 0 );
Control := New( PButton, Init( R, GetString(dlCDButtonTime), cdDisplay, bfBroadCast ));
Insert( Control );
R.Move( 11, 0 );
Control := New( PButton, Init( R, GetString(dlCDButtonMode), cdMode, bfBroadCast ));
Insert( Control );
inc(Y,2);
R.Assign( 1, Y, 12, Y+2 );
Control := New( PButton, Init( R, GetString(dlCDButtonMix), cdMix, bfBroadCast ));
Insert( Control );