home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac / bkgrnd.zip / VIDEO.PAS < prev   
Pascal/Delphi Source File  |  1994-08-07  |  3KB  |  98 lines

  1. { Contains routines and data to directly access video memory
  2.   Written by Tim J. Duncan
  3.   Compuserve 72603,3616
  4. }
  5. unit Video;
  6.  
  7. {}Interface{}
  8.  
  9. uses
  10.   Crt;  {  Borland unit  }
  11.  
  12. const
  13.   MaxTextRows = 50;
  14.   MaxTextColumns = 80;
  15.  
  16. type
  17.   {  Define record to access single location in video memory  }
  18.   TVideoMemRecord =
  19.     record
  20.     Character : byte;
  21.     Attribute : byte;
  22.     end;  {  of TVideoMemRecord  }
  23.  
  24.   {  Type to hold entire contents of video memory  }
  25.   PVideoMem = ^TVideoMem;
  26.   TVideoMem = array [0..MaxTextRows] of array [0..MaxTextColumns] of TVideoMemRecord;
  27.  
  28. var
  29.   {  Holds entire contents of video memory  }
  30.   VideoMemoryCopy : PVideoMem;
  31.  
  32. {  Frees the memory allocated to make a copy of video memory  }
  33. procedure FreeVideoMemoryCopy;
  34. {  Saves a copy of video memory  }
  35. procedure SaveDOSScreen;
  36. {  Updates video memory with the previously saved copy  }
  37. procedure UpdateDOSScreen;
  38. {  Updates the copy of video memory with the current contents of video memory  }
  39. procedure UpdateVideoMemoryCopy;
  40.  
  41. {}Implementation{}
  42.  
  43. var
  44.   {  Holds the amount of memory allocated to make a copy of video memory  }
  45.   VideoMemorySize : word;
  46.   {  Holds where video memory begins  }
  47.   VideoMemoryLocation : pointer;
  48.  
  49. {  Determines the location of video memory for color or monochrome cards  }
  50. procedure GetVideoMemoryLocation;
  51.  
  52.   var
  53.     {  Accesses info from video BIOS  }
  54.     {  From PC System Programming, pg 560  }
  55.     CRTC_Port : word absolute $0040:0063;
  56.  
  57.   begin
  58.   if CRTC_Port = $3B4
  59.     then begin
  60.     {  Monochrome card exists  }
  61.     VideoMemoryLocation := Ptr (SegB000, $0);
  62.     end  {  then  }
  63.     else begin
  64.     {  Color card exists  }
  65.     VideoMemoryLocation := Ptr (SegB800, $0);
  66.     end;  {  else }
  67.   end;  {  of procedure GetMemoryLocation  }
  68.  
  69. {  Frees the memory allocated to copy video memory  }
  70. procedure FreeVideoMemoryCopy;
  71.   begin
  72.   FreeMem (VideoMemoryCopy, VideoMemorySize);
  73.   end;  {  procedure FreeVideoMemoryCopy  }
  74.  
  75. {  Saves a copy of video memory  }
  76. procedure SaveDOSScreen;
  77.   begin
  78.   GetVideoMemoryLocation;
  79.   VideoMemorySize := (lo (WindMax) + 1) * (hi (WindMax) + 1) * 2;
  80.   GetMem (VideoMemoryCopy, VideoMemorySize);
  81.   UpdateVideoMemoryCopy;
  82.   end;  {  of procedure SaveDOSScreen  }
  83.  
  84. {  Updates video memory with the previously saved copy  }
  85. procedure UpdateDOSScreen;
  86.   begin
  87.   move (VideoMemoryCopy^, VideoMemoryLocation^, VideoMemorySize);
  88.   end;  {  of procedure RestoreDOSScreen  }
  89.  
  90. {  Updates the copy of video memory with the current contents of video memory  }
  91. procedure UpdateVideoMemoryCopy;
  92.   begin
  93.   move (VideoMemoryLocation^, VideoMemoryCopy^, VideoMemorySize);
  94.   end;  {  of procedure UpdateVideoMemoryCopy  }
  95.  
  96. begin
  97. end.  {  unit  }
  98.