Program for manipulate with CD-ROM

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: Source in Pascal

Program: Cedecko.pas
File exe: Cedecko.exe

Program for manipulate with CD-ROM. Get how much CD-ROM you have, letter of CD-ROM, run/stop audio playing.
{ CEDECKO.PAS                                                       }
{ Program na ovladanie CD-ROM.                                      }
{ Spusti/zastavi prehravanie CD-Rom.                                }
{                                                                   }
{ Datum:28.05.2004                             http://www.trsek.com }
 
program Ovladanie_CD;
uses dos;
 
const RequestHeader:record
        Dlzka,SubUnit,Prikaz:byte;
        Status:word;
        Rezerva:array[1..8] of byte;
      end = (Dlzka:13; SubUnit:0; Prikaz:$88);
 
{ Priklad: $85: pri hrajucom CD je to PAUSE
                v stave PAUSE je to STOP
           $88  RESUME AUDIO - to iste ako $85 }
 
{ zisti kolko je CD-Rom }
function CD_Count:byte;
var reg:registers;
begin
  reg.ah:=$15;
  reg.al:=$00;
  reg.bx:=0;
  intr($2F,reg);
 
  { BX - pocet CD, CX - pismeno prveho CD (0=A, .. 3=D) }
  CD_Count:=reg.bx;
end;
 
 
{ Ake pismeno ma ktora CD-Rom                    }
{ Ak vrati A CD-Rom na dannej pozicii neexistuje }
function CD_Letter(order:byte):char;
var reg:registers;
    Letters:array[1..255] of byte;
    i:byte;
begin
  for i:=1 to 255 do Letters[i]:=0;   { zmaz }
 
  reg.ah:=$15;
  reg.al:=$0d;
  reg.es:=seg(Letters);
  reg.bx:=ofs(Letters);
  intr($2f,reg);
 
  { pismeno CD }
  CD_Letter:=chr(Letters[order]+ord('A'));
end;
 
 
{ Spusti/zastavi prehravanie CD-Rom }
procedure CD_Play;
var reg:registers;
begin
  reg.ah:=$15;
  reg.al:=$10;
  reg.ch:=0;
  reg.cl:=ord(CD_Letter(1)) - ord('A');
  reg.es:=seg(RequestHeader);
  reg.bx:=ofs(RequestHeader);
  intr($2f,reg);
end;
 
BEGIN
  WriteLn('Pocet CD je:', CD_Count);
  WriteLn('Pismeno prvej je:', CD_Letter(1));
 
  WriteLn('Teraz spustim play na CD');
  CD_Play;
END.