Program fill buffer of keyboard in pascal

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

Program: Simf2.pas
File exe: Simf2.exe

As if it pressed F2 key. Nothing extraordinary. However, the interesting point about it is that it does it in the way which involves storing the information in the keyboard buffer. It also includes the functions which display the buffer condition. By the way, it can still be used as the buffer actually fills BIOS and not the operating system. I used routines as an automatic Log on user, which carried out all the necessary operations for me. However it couldn't take more than 32 keystrokes as this corresponds to the size of the buffer.
{ SIMF2.PAS                 Copyright (c) TrSek alias Zdeno Sekerak }
{ Simuluje stlacenie klavesy F2 tak ze ju zapise do buffera         }
{ klavesnice. Chytre a pomoze. Moze sa tak odsimulovat viacero      }
{ stlaceni klavesnice.                                              }
{                                                                   }
{ Datum:15.12.1995                             http://www.trsek.com }
 
program simulF2;
 
uses crt,dos;
var REG:registers;
    i,p:integer;
    memy:array[0..$20] of byte;
 
procedure vypis;
begin
  p:=p+1;
  writeln('Poradie [',p,']');
  writeln('mem 41A-41D= [',mem[0:$41a],':',mem[0:$41b],'] - [',mem[0:$41c],':',mem[0:$41d],']');
  writeln('mem 480-483= [',mem[0:$480],':',mem[0:$481],'] - [',mem[0:$482],':',mem[0:$483],']');
  for i:=0 to $20 do begin
      if memy[i]<>mem[0:$41E+i] then textbackground(blue)
                                else textbackground(black);
      if (i+$20>=mem[0:$41a]) and (i+$20<=1+mem[0:$41c]) then
                                     textcolor(Yellow)
                                else textcolor(white);
      write(mem[0:$41E+i]:3,',');
      end;
  textbackground(black);
  textcolor(white);
  writeln;
  writeln;
end;
 
procedure uchovaj;
begin
  for i:=0 to $20 do memy[i]:=mem[0:$41E+i];
end;
 
procedure cle;
begin
  for i:=0 to $20 do mem[0:$41E+i]:=255;
end;
 
begin
 clrscr;p:=0;
{  tato cast vypisuje obsah buffera klavesnice,                   }
{  ak chcete odchytit neake klavesy odkomentujte nasledujucu cast }
{ cle;
 uchovaj;
 repeat
  vypis;
  uchovaj;
  delay(100);
  reg.ah:=$10;
  reg.al:=0;
  intr($16,reg);
 until (1=2);
 exit;
 repeat
  reg.ax:=$100;
  intr($16,reg);
  write  (reg.ah,'  ');
  writeln(reg.al,'  ');
  writeln;
 until(1=2);
 
 uchovaj;
 vypis;}
 
 REG.AX:=0;
 REG.AH:=5;
 REG.CL:=0;
 REG.CH:=0;
 intr($16,REG);
 
 REG.AX:=0;
 REG.AH:=5;
 REG.CL:=0;
 REG.CH:=60;
 intr($16,REG);
 mem[0:$400+mem[0:$41a]+2]:=224;
end.