[comp.sys.ibm.pc] PCs screen memory

k34386t@kaira.HUT.FI (Petri Kruiseri Suominen) (06/14/88)

Does anyone know how to read PCs screen memory with turbo pascal 4.0 ?
My intension is to make a small editor which works so that it just
puts the characters on the screen, and then reads them to memory
from there ?

.

madd@bu-cs.BU.EDU (Jim Frost) (06/26/88)

In article <13766@santra.UUCP> k34386t@kaira.UUCP (Petri Kruiseri Suominen) writes:
|Does anyone know how to read PCs screen memory with turbo pascal 4.0 ?
|My intension is to make a small editor which works so that it just
|puts the characters on the screen, and then reads them to memory
|from there ?

Sure, no problem.  This code segment should give you a start.  You
should probably use the BIOS get screen mode function (part of int
$10) instead of get equipment, but this is what I had handy.

{ screen.pas:

  simple turbo pascal 4.0 unit to define an array over the screen
  memory for direct access.

  written by jim frost on 6.25.88.  this is in the public domain.
}

unit screen;

interface

const monoaddr = $B000;
const coloraddr = $B800;

type screenchar : record
  character : char;
  attribute : byte
end;

type screenarray : ^array[0..25,1..80] of screenchar;

{ this array will be overlaid on the screen memory.  note that it's
  y,x oriented and not x,y. }

var scrn : screenarray;

implementation

var r : registers;

{ initialization code:  ask BIOS get equipment function what kind of
  monitor we have }

begin
  intr($11,r);
  if (r.ax and $10) = 0 then
    scrn:= addr(mem[coloraddr:0])
  else
    scrn:= addr(mem[monoaddr:0])
end.

Enjoy,

jim frost
madd@bu-it.bu.edu