[comp.lang.pascal] address screen memory

nveldhov@gara.une.oz.au (Kick_Butt alias of nICK ) (10/15/90)

Hello

I am only new at TURBO PASCAL, and just starting to write programs in this
great language.

Getting to the point, does somebody out there have any code that can read the
character and color at any location on the screen.  I thought that this could
be done by getting directly into the screen memory. I would appreciate any help
    
   THANK YOU.

(uses TURBO PASCAL version 5.5)

abcscnuk@Twg-S5.uucp (Naoto Kimura (ACM)) (10/15/90)

In article <4249@gara.une.oz.au> nveldhov@gara.une.oz.au (Kick_Butt alias of nICK ) writes:
]Hello
]
]I am only new at TURBO PASCAL, and just starting to write programs in this
]great language.
]
]Getting to the point, does somebody out there have any code that can read the
]character and color at any location on the screen.  I thought that this could
]be done by getting directly into the screen memory. I would appreciate any help
]    
]   THANK YOU.
]
](uses TURBO PASCAL version 5.5)

Get the book "Programmers Guide to PC/AT/PS2 Video Systems" by Richard
Wilton(?) printed by Microsoft Press.  It discusses techniques for
detecting, reading from, and writing to the video display.  I found it
to be a great source of information about the different video display
hardware systems that can be installed on the IBM-PC.

Here's a bits of code that you could probably use until you get the
book:

---- CUT HERE ----
    unit Screen;

    interface

    uses
	Dos;

    const
	MDA_seg	= $b000;
	CGA_seg	= $b800;

    type
	ScreenChar = record
	    Ch	: Char;
	    Attr	: Byte
	    end;

    const
	ScrnSeg	: Word = CGA_seg;

    var
	ScreenRows	: Word;
	ScreenColumns	: Word absolute $40:$4A;

    procedure ScreenPeek( x,y : Integer;  var S : ScreenChar );
    procedure ScreenPoke( x,y : Integer;  S : ScreenChar );

    implementation

    procedure ScreenPeek( x,y : Integer;  var S : ScreenChar );
	begin
	    if (x>0) and (x<=ScreenColumns)
	     and (y>0) and (y<=ScreenRows) then
		S := ScreenChar(memw[ScrnSeg:
				    (y-1)*ScreenColumns + (x-1)])
	end;

    procedure ScreenPoke( x,y : Integer;  S : ScreenChar );
	begin
	    if (x>0) and (x<=ScreenColumns)
	     and (y>0) and (y<=ScreenRows) then
		memw[ScrnSeg:(y-1)*ScreenColumns + (x-1)] := Word(S)
	end;

    var
	regs:Registers;
    begin
	ScreenRows := 25;
	intr($11,regs);
	if (regs.ax and $30) = $30 then begin
	    ScrnSeg := MDA_seg
	  end
	else begin
	    ScrnSeg := CGA_seg
	  end
    end.
---- CUT HERE ----

                //-n-\\			 Naoto Kimura
        _____---=======---_____		 (abcscnuk@csuna.csun.edu)
    ====____\   /.. ..\   /____====
  //         ---\__O__/---         \\	Enterprise... Surrender or we'll
  \_\                             /_/	send back your *&^$% tribbles !!