[comp.lang.pascal] CRT equivalent to GetPixel

jerry@gumby.Altos.COM (Jerry Gardner) (04/23/91)

In article <1991Apr20.060956.4677@usenet.ins.cwru.edu> wct@po.CWRU.Edu (William C. Thompson) writes:

>Is there a CRT equivalent to GetPixel that lets you get what
>character is at a particular location on the screen.  There
>must be some way to do it if you want to do any windows type
>applications.


This is fairly easy to do:


{
	Return the character:attribute pair at coordinates x,y.
	Upper left corner of screen is at (0,0).

}


Function GetChar(x, y : Integer) : Word;

Var
  Offset : Word;

Begin

   Offset := (x + (y * 80)) * 2;
   GetChar := MemW($B800 : Offset);

End;


Of course, if your video adapter uses something other than B800 for its
segment address, substitute it appropriately in the call to MemW, or better
yet, dynamically detect the video segment address.


-- 
Jerry Gardner, NJ6A					Altos Computer Systems
UUCP: {sun|pyramid|sco|amdahl|uunet}!altos!jerry	2641 Orchard Parkway
Internet: jerry@altos.com				San Jose, CA  95134
Help stamp out vi in our lifetime.                      (408) 432-6200