Board index » delphi » read from screen

read from screen

How can I read a text character from the screen (e.g. xy 5,5)

or how can I save the whole screen (and display it later:-))

Please help me, BVD.

 

Re:read from screen


Quote
Hoekzema wrote:

> How can I read a text character from the screen (e.g. xy 5,5)

> or how can I save the whole screen (and display it later:-))

> Please help me, BVD.

Hello:
        I am a little rusty so some of the other pascal guru's can help me
out.  The characters and attributes of the screen are kept at segment
$B800.  (B800 is hex)  The first byte ($B800:0000) is the character at
the top left hand corner, in zero based x,y terms 0,0.  The next byte
($B800:0001)is the attributes for the first  character, such as
foreground backround colors and blinking.  To get these bytes use the
mem function.  I like to use mem[(y*160)+(x*2)].  this should get you
the character at screen location x,y.  Remember that 0,0 is top left
hand corner.  In other modes than real you might have problems with the
$B800 and have to use the Segb800 constants or something.  Hope that
helps.

Jake Richards
jac...@cs.clemson.edu

Re:read from screen


In article <01bc7f33$9351c300$ccea4fc1@hoekzema> of Sun, 22 Jun 1997
17:41:53 in comp.lang.pascal.borland, Hoekzema <gpv.Win...@net.hcc.nl>
wrote:

Quote
>How can I read a text character from the screen (e.g. xy 5,5)

>or how can I save the whole screen (and display it later:-))

For the latter, see    http://www.merlyn.demon.co.uk/programs/shower.pas
and look for SaveScreen & RestoreScr.  One should not blindly assume
that the screen is set to an 80*25 mode.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web URL: http://www.merlyn.demon.co.uk/ -- includes FAQqish topics and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)

Re:read from screen


Quote
Hoekzema wrote:

> How can I read a text character from the screen (e.g. xy 5,5)

> or how can I save the whole screen (and display it later:-))

> Please help me, BVD.

If you are using 80x25 -

                Type
                  Pbuf = ^Buf_Type;
                  Buf_Type = Array[0..3999] of byte;

                Var
                  Video_Buffer : PBuf;

                Begin
                  new(Video_Buffer);

                  {Transfer Video Memory to Video_Buffer}
                  move(mem[segB800:0000],Video_Buffer^,4000);

                  {Transfer Video_Buffer to Video Memory}
                  move(Video_Buffer^,mem[segB800:0000],4000);          
                  dispose(Video_Buffer);
                end.

Each Character contains an ascii code and an attribute byte, taking up 2
bytes for each position on the display.  To get a particular character,
you would simply do :

                character  := mem[$SegB800:y*160+(x shl 1)];
                attribute  := mem[$SegB800:y*160+(x shl 1)+1];

                I might have reversed the attribute and character locations, so if
that doesn't work, reverse the +1 in the memory reference.  This code
also assumes that the top left of the video display is 0,0, and then
bottom right is 79,24.

Other Threads