{***********************************************************************}
{									}
{ This file contains the procedures SaveVideo and RestoreVideo.  These	}
{ procedures are used to save and restore parts of the BIOS data area	}
{ which contain various data defining the current video state.		}
{ SaveVideo is called by __NewDvScn and __ChgDvScn while RestoreVideo	}
{ is called  by __ChgDvScn.  Saving the video device information allows }
{ you to switch between devices and be assured that the state can be	}
{ restored upon return. 						}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

  {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  { SaveVideo Save the BIOS video state variables			}
  {_____________________________________________________________________}

  procedure SaveVideo(Device : byte);

    var
      Video    : array[1..30] of byte absolute _BIOSSEG:$0049;
      EGAReset : word		      absolute _BIOSSEG:$0072;
      EGAArea  : array[1..5] of byte  absolute _BIOSSEG:$0084;
      EGAPtr   : pointer	      absolute _BIOSSEG:$00A8;
      EGAState : byte		      absolute _BIOSSEG:$0100;

    begin {SaveVideo}

      { If the record structure for the state variables has not been	}
      { allocated, do so here and set the saved flag to TRUE		}

      if (not StateSaved_[Device]) then
	 begin
	   New(ScnState_[Device]);
	   StateSaved_[Device] := TRUE
	 end;

      { Now save the information in the record structure.  __ChgDvScn	}
      { uses this information when moving to the other device.		}

      with ScnState_[Device]^ do
	begin
	  CurPage_  := _CurDisplayPage;
	  Move(Video,Video_,SizeOf(Video));
	  EGAReset_ := EGAReset;
	  Move(EGAArea,EGAArea_,SizeOf(EGAArea));
	  EGAPtr_   := EGAPtr;
	  EGAState_ := EGAState
	end;

    end;  {SaveVideo}


  {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  { RestoreVideo  Restore the BIOS video state variables		}
  {_____________________________________________________________________}

  procedure RestoreVideo(Device : byte);

    var
      Video    : array[1..30] of byte absolute _BIOSSEG:$0049;
      EGAReset : word		      absolute _BIOSSEG:$0072;
      EGAArea  : array[1..5] of byte  absolute _BIOSSEG:$0084;
      EGAPtr   : pointer	      absolute _BIOSSEG:$00A8;
      EGAState : byte		      absolute _BIOSSEG:$0100;

    begin {RestoreVideo}

      { If the record structure for the state variables has not been	}
      { allocated, just return; otherwise copy to the BIOS area.	}

      if (StateSaved_[Device]) then
	 with ScnState_[Device]^ do
	   begin
	     _CurDisplayPage := CurPage_;
	     Move(Video_,Video,SizeOf(Video));
	     EGAReset := EGAReset_;
	     Move(EGAArea_,EGAArea,SizeOf(EGAArea));
	     EGAPtr   := EGAPtr_;
	     EGAState := EGAState_
	   end;

    end;  {RestoreVideo}
