Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!bu-cs!madd
From: madd@bu-cs.BU.EDU (Jim Frost)
Newsgroups: comp.sys.ibm.pc
Subject: Re: PCs screen memory
Message-ID: <23500@bu-cs.BU.EDU>
Date: 25 Jun 88 19:32:18 GMT
References: <13766@santra.UUCP>
Reply-To: madd@bu-it.bu.edu (Jim Frost)
Followup-To: comp.sys.ibm.pc
Organization: Boston University Distributed Systems Group
Lines: 56

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