home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / tools.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-28  |  2KB  |  47 lines

  1. Unit Tools;
  2.  
  3. Interface
  4.  
  5. procedure sin_gen(var table:Array of word;period,amplitude,offset:word);
  6. Procedure Draw_Ansi(Name:String);
  7.  
  8.  
  9. Implementation
  10.  
  11. procedure sin_gen(var table:Array of word;period,amplitude,offset:word);
  12. {precalculates a sine table of the length period,
  13.  stores it in the Array table.
  14.  The "Height" in the variable Amplitude and the 
  15.  position of the null point in offset are required for this}
  16. Var i:Word;
  17. Begin
  18.   for i:=0 to period-1 do
  19.     table[i]:=round(sin(i*2*pi/period)*amplitude)+offset;
  20. End;
  21.  
  22. Procedure Draw_Ansi(Name:String);
  23. {outputs an Ansi file on the screen (requires ANSI.SYS !)}
  24. Var Ansi:File;                  {Ansi file}
  25.     StdOut:File;                {standard output file (Int 21h)}
  26.     Buffer:Pointer;             {buffer for screen}
  27.     Size:Word;                  {file size}
  28. Begin
  29.   Assign(Ansi,Name);            {open Ansi file}
  30.   Assign(StdOut,'CON');         {open output file}
  31.  
  32.   Reset(Ansi,1);                {initialize Ansi file with block size 1 byte.}
  33.   Size:=FileSize(Ansi);         {define size (in bytes)}
  34.   Reset(Ansi,Size);             {initialize file with this size again}
  35.   Reset(StdOut,Size);           {initialize output file}
  36.  
  37.   GetMem(Buffer,Size);          {allocate buffer}
  38.   BlockRead(Ansi,Buffer^,1);    {read file ...}
  39.   BlockWrite(StdOut,Buffer^,1); {... and output}
  40.   FreeMem(Buffer,Size);         {free buffer}
  41.   Close(Ansi);                  {close files}
  42.   Close(StdOut);
  43. End;
  44.  
  45. Begin
  46. End.
  47.