[comp.lang.pascal] Capturing a ega text screen.

gt0652b@prism.gatech.EDU (I don't know man, he was just here) (03/27/91)

I am writing a program that needs to be able to shell out to dos and then come
back again with the screen intact. There must be some way to store the 
contents of the screen in ram and then redisplay the screen quickly
when the shell is done.

Any Help would be appreciated

Josh Guttman

-- 
*****************************************************************************
* Joshua I. Guttman	   (404)355-3908 Home      **    Norm Is Lord! 	    *
* gt0652b@prism.gatech.edu (404)355-0001 Business  ************************** 
* josh@triad.com           (404)242-1922 Triad Technologies                 *

cd5340@mars.njit.edu (David Charlap) (03/28/91)

In article <25045@hydra.gatech.EDU> gt0652b@prism.gatech.EDU writes:
>I am writing a program that needs to be able to shell out to dos and then come
>back again with the screen intact. There must be some way to store the 
>contents of the screen in ram and then redisplay the screen quickly
>when the shell is done.

Simple.  Any 80 column screen is 4000 bytes long (80x25 characters + 80x25
attributes).  A color mode screen (CGA, EGA, VGA text) begins at location
$B800:0000, and a monochrome screen (MDA, EGA mono, VGA mono) begins at
location $B000:0000.

All you need to do is declare 4000 bytes like this:

Var
	Buffer : Array[1..4000] of byte;

and move the screen data into it like this:

Move (Mem[$B800:0], Buffer, 4000);

Restore the screen by moving it back.  Like this:

Move (Buffer, Mem[$B800:0], 4000);

It's that simple.  If you're in a monochrome mode (check if lastmode=7)
then use address $B000:0 instead of $B800:0, and it'll still work OK.

--
David Charlap                   "Invention is the mother of necessity"
cd5340@mars.njit.edu            "Necessity is a mother"
Operators are standing by	"mother!" - Daffy Duck

dave@tygra.UUCP (David Conrad) (03/28/91)

In article <25045@hydra.gatech.EDU> gt0652b@prism.gatech.EDU (I don't know man, he was just here) writes:
>I am writing a program that needs to be able to shell out to dos and then come
>back again with the screen intact. There must be some way to store the 
>contents of the screen in ram and then redisplay the screen quickly
>when the shell is done.

type
  letter = record ch, attr : char; end;
  screen = array[1..80][1..25] of letter;

var
  colorscreen : screen absolute $B800:0;
  monoscreen : screen absolute $B000:0;
  savedscreen : screen;

begin
  (* save screen *)
  if lastmode = 7 then (* monochrome *)
    savedscreen = monoscreen
  else
    savedscreen = colorscreen;
  (* ...whatever... *)
  (* restore screen *)
  if lastmode = 7 then
    monoscreen = savedscreen
  else
    colorscreen = savedscreen;
end.
 
(* you may also want to store the cursor position, and a few changes are
   necessary to support 80x43, 80x50, 132x25, 132x43, but this is left
   as an exersize for the reader. *)

Dave Conrad
dave%tygra@sharkey.cc.umich.edu
-- 
=  CAT-TALK Conferencing Network, Computer Conferencing and File Archive  =
-  1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new'    - 
=  as a login id.  AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET")        =
   E-MAIL Address: dave%tygra@sharkey.cc.umich.edu