home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / magn / magn.pas < prev   
Pascal/Delphi Source File  |  1995-08-01  |  2KB  |  66 lines

  1. uses crt;
  2. var x,y:Integer;                                {counter and mouse coordinates}
  3.  
  4. Procedure magn_asm(zx,zy:Integer);external;
  5. {draws the magnifying glass effect}
  6. Procedure ReadGif;external;
  7. {reads a 320x200x256 Gif image from "GifName"}
  8. Procedure Setpal;external;
  9. {sets the palette of the Gif image}
  10.  
  11. {$l magn.obj}
  12. {$l gif}
  13.  
  14.  
  15. type tbuffer=Array[0..199,0..319] of Byte;
  16. {structure of image buffer 320x200}
  17. Var buffer,backgnd:^tbuffer;    {Pointer to buffer and background}
  18.   errorno:word;               {Error message}
  19.   gifname:String;               {Name, extended by #0}
  20.   Circle_Start:Array[0..48] of Integer;    {Description of circle shape}
  21.   Circle_End:Array[0..48] of Integer;
  22.  
  23. Procedure Prep_Circle;
  24. {loads the Circle array}
  25. var b:Word;
  26. Begin
  27.     For y:=0 to 48 do Begin                                {calculate 49 rows}
  28.       b:=Trunc(Sqrt(Sqr(24)-Sqr(y-24)));   {Width= Sqrt(r^2-y^2)}
  29.       Circle_Start[y]:=24-b;               {Beginning of a row}
  30.     Circle_End[y]:=49-Circle_Start[y];       {End of a row}
  31.   End;
  32. End;
  33.  
  34. Procedure Show_Buffer;        {displays buffer on screen}
  35. Begin
  36.     Move(Buffer^,Ptr($a000,0)^,64000);
  37. End;
  38.  
  39. begin
  40.   getmem(backgnd,64000);    {Get memory for background}
  41.   getmem(buffer,64000);         {Get memory for image buffer}
  42.   asm mov ax,13h; int 10h End;  {Set graphic mode 13h}
  43.   asm mov ax,0; int 33h End;    {Reset mouse driver}
  44.  
  45.   GifName:='magn.gif'+#0;    {Define name of image}
  46.   ReadGif;                      {Read Gif image}
  47.   move(buffer^,backgnd^,64000); {save as background}
  48.   SetPal;                       {Set palette}
  49.   Prep_Circle;
  50.  
  51.   repeat
  52.     asm
  53.       mov ax,0003h              {Function 03h: read absolute coordinates}
  54.       int 33h                   {Get mouse coordinates}
  55.       mov x,cx                  {save in variables}
  56.       mov y,dx
  57.     End;
  58.         if y>200-49 Then y:=200-50;{check variables}
  59.       if x>320-49 Then x:=320-50;
  60.     move(backgnd^,buffer^,64000); {Background to buffer}
  61.     magn_asm(x,y);             {Draw magnifying glass}
  62.     Show_Buffer;               {and put on screen}
  63.   Until KeyPressed;            {until key pressed}
  64.   TextMode(3);                 {Set text mode}
  65. End.
  66.