[comp.sys.ibm.pc] screen base address

ins_agwa@jhunix.UUCP (Gunther Wil Anderson) (10/02/87)

Does anyone know how to determine the screen base address from
within DOS, independent of screen type (i.e. not by determining
the screen type and then assuming that the base address is what
it should be for that type)?

				Many Thanks,
					Gunther W. Anderson
					ins_agwa@jhunix.bitnet

perkins@bnrmtv.UUCP (Henry Perkins) (10/09/87)

In article <5326@jhunix.UUCP>, ins_agwa@jhunix.UUCP (Gunther Wil Anderson) writes:
> Does anyone know how to determine the screen base address from
> within DOS, independent of screen type (i.e. not by determining
> the screen type and then assuming that the base address is what
> it should be for that type)?

The screen base address isn't dependent on DOS; it's dependent on
the display board you're using, and the BIOS which supports it.
It's the BIOS which usually generates the screen addresses that
are used.  There is no better way than (1) determining the
hardware which is installed; (2) finding out the display mode; and
(3) making a computation/lookup based on knowing how these two
pieces of information go together.

As an example, you might determine that (1) there's a CGA card
installed, and (2) it's in 80x25 color mode, on page 1.  Then
you'd "know" that the screen base address is B800:1000.  Now it
MIGHT actually be an AutoSwitch EGA card switched to Hercules mode
with base address (corresponding to the upper left corner of the
screen) B000:0000, but you can't determine that from software if
the configuration information available to your software is
incorrect.
-- 
{hplabs,amdahl,ames}!bnrmtv!perkins         --Henry Perkins

It is better never to have been born.  But who among us has such luck?
One in a million, perhaps.

djs@homxc.UUCP (D.SPATHIS) (10/12/87)

In article <2789@bnrmtv.UUCP>, perkins@bnrmtv.UUCP (Henry Perkins) writes:
> In article <5326@jhunix.UUCP>, ins_agwa@jhunix.UUCP (Gunther Wil Anderson) writes:
> > Does anyone know how to determine the screen base address from
> > within DOS, independent of screen type (i.e. not by determining
> > the screen type and then assuming that the base address is what
> > it should be for that type)?
> 
> The screen base address isn't dependent on DOS; it's dependent on
> the display board you're using, and the BIOS which supports it.
  . . . . .  
> {hplabs,amdahl,ames}!bnrmtv!perkins         --Henry Perkins


One thought for finding the screen address goes something like this:

IF one possible place for the screen buffer is B000:1000 then read this
absolute memory location saving the data byte that is there.  Now write
some other non-blank value there.  Call a BIOS clear screen function.
Lastly, check the location again - if blank it's part of the active
screen buffer.  Repeat with more gueses for screen address until happy.

-Dennis
...ihnp4!homxc!djs


PS. don't forget to re-write the data back into memory!


acm@bu-cs.BU.EDU (ACM) (10/13/87)

In article <1664@homxc.UUCP> djs@homxc.UUCP (D.SPATHIS) writes:
>In article <2789@bnrmtv.UUCP>, perkins@bnrmtv.UUCP (Henry Perkins) writes:
>> In article <5326@jhunix.UUCP>, ins_agwa@jhunix.UUCP (Gunther Wil Anderson) writes:
>> > Does anyone know how to determine the screen base address from
>> > within DOS, independent of screen type (i.e. not by determining
>> > the screen type and then assuming that the base address is what
>> > it should be for that type)?
>> 
>> The screen base address isn't dependent on DOS; it's dependent on
>> the display board you're using, and the BIOS which supports it.
>  . . . . .  
>> {hplabs,amdahl,ames}!bnrmtv!perkins         --Henry Perkins
>
>
>One thought for finding the screen address goes something like this:
>
>IF one possible place for the screen buffer is B000:1000 then read this
>absolute memory location saving the data byte that is there.  Now write
>some other non-blank value there.  Call a BIOS clear screen function.
>Lastly, check the location again - if blank it's part of the active
>screen buffer.  Repeat with more gueses for screen address until happy.

Yea, that works ok but it's not too reliable.  The way that I usually
do it is to ask the BIOS what the default screen mode is; if it's
color, I use $B800:0000 and if it's mono I use $B000:000.  Now, this
isn't completely reliable but it very, very seldom fails.  It would be
better to ask the board where its buffer is but I never did figure out
how to do that.

jim frost
madd@bucsb.bu.edu

smvorkoetter@watmum.UUCP (10/13/87)

In article <2789@bnrmtv.UUCP>, perkins@bnrmtv.UUCP (Henry Perkins) writes:
> In article <5326@jhunix.UUCP>, ins_agwa@jhunix.UUCP (Gunther Wil Anderson) writes:
> > Does anyone know how to determine the screen base address from
> > within DOS, independent of screen type (i.e. not by determining
> > the screen type and then assuming that the base address is what
> > it should be for that type)?
> 
> The screen base address isn't dependent on DOS; it's dependent on
> the display board you're using, and the BIOS which supports it.
  . . . . .  
> {hplabs,amdahl,ames}!bnrmtv!perkins         --Henry Perkins

The way I do it in a terminal emulator I wrote is to write the string "AZ"
in the top left corner of the screen using the appropriate BIOS calls.  I
don't know what these are since I let the compiler worry about it.  I then
read all the possible places where this could have been written to see 
where it is.  This has yet to fail me.  The only way it could fail is if
one of the places I check already has A in the first byte, and Z in the
third (the second and fourth are attributes).  Since I only check likely
possibilities, such as B000:0 and B800:0, this won't happen.



Stefan Vorkoetter
University of Waterloo

Steven_N_Jones@cup.portal.com (10/15/87)

    Jim Frost suggests finding the display base address by asking BIOS
for the display mode and then trying B000:0000 or B800:0000 depending
on the result.  This won't work on a Compaq, though, because it uses
a single offset for both the monochrome and color display modes.

connery@bnrmtv.UUCP (Glenn Connery) (10/16/87)

In article <965@cup.portal.com>, Steven_N_Jones@cup.portal.com writes:
>     Jim Frost suggests finding the display base address by asking BIOS
> for the display mode and then trying B000:0000 or B800:0000 depending
> on the result.  This won't work on a Compaq, though, because it uses
> a single offset for both the monochrome and color display modes.

Sorry, you are wrong.  If the Compaq did that then most software would not
run on it.  The Compaq dual mode monitors change the video memory address
when you switch modes, so that in 80 x 25 black and white the segment
address is B000 and in 640 x 200 graphics mode the segment address is
B800.  The method suggested (checking the mode to determine what screen
base address to use) is the one used by most software (in the absence of
a get_screen_address call which should have been added years ago) and
Compaq made their rep. on complete compatibility.
-- 

Glenn Connery, Bell Northern Research, Mountain View, CA
{hplabs,amdahl,3comvax}!bnrmtv!connery

Steven_N_Jones@cup.portal.com (10/20/87)

    Glenn Connery writes that the Compaq dual mode monitor cards switch
between base offsets when changing modes from monochrome to color.  I have
a Compaq plus which I bought in 1984, and its display card uses a single
base address for both modes.  I wrote a short test program which wrote
to offset b000:0 and nothing appeared on the screen in either mode.  When
I changed the address to b800:0, the text appeared in either the monochrome
or the color mode.

    steven.n.jones@cup.portal.com