home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / drcpas10.zip / SCRSAVER.PAS < prev    next >
Pascal/Delphi Source File  |  1992-07-11  |  2KB  |  96 lines

  1. {$A+,B-,D-,E-,F-,I+,L-,N-,O-,R-,S+,V-}
  2. unit scrsaver;
  3.  
  4. interface
  5.  
  6. type
  7.   scrpos = 1..80;
  8.   charattr =
  9.     record
  10.       character, attribute : char;
  11.     end;
  12.   image = array[1..50,1..80] of charattr;
  13.   screen =
  14.     record
  15.       im : image;
  16.       x,y : scrpos;
  17.       ta : word;
  18.     end;
  19.  
  20. var
  21.   mono : image absolute $B000:0;
  22.   color : image absolute $B800:0;
  23.  
  24. procedure savescr;
  25. procedure savescreen (var scr : screen);
  26. procedure restorescreen (var scr : screen);
  27.  
  28. implementation
  29.  
  30. uses crt, keyboard, timer;
  31.  
  32. const
  33.   monochrome = 7;
  34.  
  35. var
  36.   scr : screen;
  37.  
  38. procedure savescreen (var scr : screen);
  39. begin
  40.   with scr do
  41.     begin
  42.       ta := textattr;
  43.       x := wherex;
  44.       y := wherey;
  45.       if lastmode = monochrome then
  46.         im := mono
  47.       else
  48.         im := color;
  49.     end;
  50. end;
  51.  
  52. procedure restorescreen (var scr : screen);
  53. begin
  54.   with scr do
  55.     begin
  56.       textattr := ta;
  57.       gotoxy (x,y);
  58.       if lastmode = monochrome then
  59.         mono := im
  60.       else
  61.         color := im;
  62.     end;
  63. end;
  64.  
  65. {$F+}
  66. procedure savescr;
  67. {$F-}
  68. var
  69.   i : byte;
  70.   last : longint;
  71. begin
  72.   savescreen (scr);
  73.   textcolor (lightgray);
  74.   textbackground (black);
  75.   clrscr;
  76.   gotoxy (20, 8);
  77.   write ('Press any key to restore screen');
  78.   i := 0;
  79.   last := ClockTix;
  80.   repeat
  81.     if difftix(last, ClockTix) > 36 then
  82.       begin
  83.         last := ClockTix;
  84.         gotoxy (20, i+8);
  85.         clreol;
  86.         i := (i+1) MOD 10;
  87.         gotoxy (20, i+8);
  88.         write ('Press any key to restore screen');
  89.       end;
  90.   until keypressed;
  91.   clearkeys;
  92.   restorescreen (scr);
  93. end;
  94.  
  95. end.
  96.