< -->

Program OscilFile;
Uses Graph, CRT;
{$L C:\PROGRA~2\BP70\BIN\EGAVGA.OBJ}
Procedure EGAVGA; External;
var
  f : file;
  PP : Pointer;
  Np : Byte;
  FSz, i : Longint;
  Data : array[1..60000] of Byte;
  D, R, e : Integer;
Procedure OscilloFile(Mode : Boolean);
var
  i, j : Word;
  N : Word;
begin
  FSz := FileSize(f);
  if (FSz <= 60000) then if (FSz<>0) then
   begin
    BlockRead(f, Data, FSz);
    N := FSz;
    Fsz := 0;
   end;
  if (FSz > 60000) then
   begin
    BlockRead(f, Data, 60000);
    N := 60000;
    dec(FSz, 60000);
   end;
  ClearDevice;
  While Keypressed do ReadKey;
  SetColor(LightGray);
  i := 0;
  j := 1;
  MoveTo(i, 480-Round(Data[j]*1.875));
  While True do
   begin
    if KeyPressed then if ReadKey=#27 then
      Break;
      SetColor(Black);
      Line(i, 0, i, 639);
      SetColor(LightGray);
      case Mode of
       False:
         LineTo(i, 480-Round(Data[j]*1.875));
       True:
         PutPixel(i, 480-Round(Data[j]*1.875), LightRed);
       end;
      inc(i);
      inc(j);
     if (j > N) and (FSz=0)
     then
     begin
      ReadKey;
      Exit;
     end;
      if i >=639 then
      begin
       SetColor(Black);
       Line(i, 0, i, 639);
       SetColor(LightGray);
       i := 0;
       MoveTo(i, 480-Round(Data[j]*1.875));
      end;
      if j > N then
      begin
       j := 1;
  if (FSz <= 60000) then if (FSz<>0) then
   begin
    BlockRead(f, Data, FSz);
    N := FSz;
    Fsz := 0;
   end;
  if (FSz > 60000) then
   begin
    BlockRead(f, Data, 60000);
    N := 60000;
    dec(FSz, 60000);
   end;
      end;
   end;
  While Keypressed do ReadKey;
end;
begin
  Np := ParamCount;
  if Np = 0 then
   begin
    WriteLn('Файл отсутствует...');
    Halt;
   end;
  PP := @EGAVGA;
  D := Detect;
  if RegisterBGIdriver(PP) < 0 then
  begin
    Writeln('Ошибка регистрации драйвера: ',
    GraphErrorMsg(GraphResult));
    Halt(1);
  end;
  InitGraph(D, R, '');
  e := GraphResult;
  if e <> grOk then
  begin
    WriteLn('Произошла ошибка графики!!!');
    WriteLn(GraphErrorMsg(e));
  end;
  Assign(f, ParamStr(0));
  Reset(f,1);
  if NP=1 then
  OscilloFile(False)
  else
  OscilloFile(True);
  Close(f);
  CloseGraph;
end.

Назад