Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
{ SPEC.PAS                                                           }
{                                                                    }
{ Datum:14.12.2017                              http://www.trsek.com }
 
unit spec;
interface
uses crt;
procedure cursor(prepinac:byte);
function extkey:byte;
implementation
 
procedure cursor(prepinac:byte); {1 - cursor on, 0 - cursor off}
var zac,kon:byte;
  begin
   if prepinac=0 then
    begin
     zac:=$20;
     kon:=0
    end
   else
    begin
     zac:=$1e;
     kon:=$1f;
    end;
   asm
    mov ah,01
    mov ch,zac
    mov cl,kon
    int 10H
   end;
  end;
 
function extkey:byte;
{0 - nic, 1 - doleva, 2 - doprava, 3 - nahoru, 4 - dolu,
5 - PgUp, 6 - PgDn, 27 - escape}
var r1,r2:byte;
begin
if keypressed then
 begin
  r1:=ord(readkey);
  if r1=0 then
   begin
    r2:=ord(readkey);
    case r2 of
     75: extkey:=1;
     77: extkey:=2;
     72: extkey:=3;
     80: extkey:=4;
     73: extkey:=5;
     81: extkey:=6;
     else extkey:=0;
    end;
   end
  else if r1=27 then extkey:=27 else extkey:=0;
  end
 else extkey:=0;
end;
 
begin
end.