[comp.sys.ibm.pc] EGA's memory

pervect@bsu-cs.UUCP (Barrett Kreiner) (02/21/88)

Hello.  I'm a satisfied EGA user and was wondering a few things:

I understand about how there are the different bit planes and stuff,
but heres the deal:

My card has the full 256k, and you start counting at $A000, that means
that it runs to $DFFF.  This doesn't run true, because I have rom routines
for my hard disk at $C800.  So how does one access the high 128K of the card?
(I know that 128k runs from $A000 to $BFFF)
And what is it used for?
I know there are ram based fonts somewhere, but where? and how?
can you, in the 640 x 350 graphics mode, create text attributes?
(I'm looking for Blink if anyone knows).


Basically, what I'm looking for is a EGA guru to guide my studies into
it's mysteries.

Anyone out there fit the bill?

|---------------------------------------------------------------------------|
|Barrett Kreiner     UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!pervect |
| Assistant software tech,  |-----------------------------------------------|
| Ball State U. Muncie, IN  | "I'll tell ya kid, the main problem with      |
|---------------------------| Pervish food is keeping the goo from crawling |
| out of the bowl while you're eating it"|  TOON: THE game for modern times |
| CGA: Cute Greenback Accumulator  EGA: ENHANCED Greenback Accumulator      |
| Disclamer: "I don't know them!  I'm a student, nobody listens to ME!"     |
|---------------------------------------------------------------------------|

mcdonald@uxe.cso.uiuc.edu (02/21/88)

>I understand about how there are the different bit planes and stuff,
>but heres the deal:

>My card has the full 256k, and you start counting at $A000, that means
>that it runs to $DFFF.  This doesn't run true, because I have rom routines
>for my hard disk at $C800.  So how does one access the high 128K of the card?
>(I know that 128k runs from $A000 to $BFFF)

First you must understand the wierd way the EGA does colors, which
apparently you don't fully understand. The memory in a full 256k EGA, when
in mode 15 or 16, the ones for 350x640 pixels, runs from address 0xA0000 to
0xAFFFF. That is 65536 bytes of address space. It doesn't go any higher.
The trick is that at any given address, say 0xA0000 itself, there are actually
4 bytes. A memory reference instruction, say mov (memory),ax ,will load
zero, one, two, three or four of those bytes at once depending on how
the "plane mask" register is set. If you read them , you can do it in two ways:
set a read mask register to either 0, 1 , 2 or 3, and you will read 8 bits
from one plane. Or you can set the "color compare" register to a value from
0 to 15. In this case the four planes for each bit make a 4-bit word. That is,
there are 8 4 bit words at that address. Each one is compared to the register.
If a 4-bit word at, say, the 2 bit position of the 8-bit memory word
compares the same as the register, the 2-bit of the word you read from the
EGA is a 1, otherwise it is 0. I that clear? ( No, but it is all I can do in
one page.)

>And what is it used for?

You will note that 640X350 is only 28000. This means that there is room for
two full pictures at that resolution. There are two good uses for that.
One, used by Codeview (I presume), would allow you to store your picture
(or text) in one, and use the other for a debugging screen. The second use
is for animation. You draw a picture in page 0 while page one is displayed,
and vice-versa. This allows blinkless, seamless animation. This is used
(on a CGA) by , for example, Flight Simulator.

>I know there are ram based fonts somewhere, but where? 

There is a ROM bios call to tell you. Look in the manual (IBM Technical
Reference Manual, Options and Adapters.)

>and how?
>can you, in the 640 x 350 graphics mode, create text attributes?
>(I'm looking for Blink if anyone knows).

Oh my, you're in trouble. There is no blink in graphics mode! You set
the timer interrupt to point to your program, and at the appropriate
time, redraw the letter yourself (ugh.) In fact, the BIOS doesn't support
full text attributes in graphics mode. In particular, you can have any
background color you want as long as its color 0 (not necessarily black.)
Different characters cannot have different backgrounds. If you need this,
or if you need to draw characters over previously existing graphics,
you have to do it yourself.

Look in a graphics package I recently posted to comp.sources.misc
called "Egafast". This does the text bit. If you want a green letter with
a red background, overlaying anything previously there, draw a red
character 219, then a green letter.

Doug McDonald

naughton@sun.soe.clarkson.edu (Patrick Naughton) (02/22/88)

From article <2171@bsu-cs.UUCP>, by pervect@bsu-cs.UUCP (Barrett Kreiner):
> My card has the full 256k, and you start counting at $A000, that means
> that it runs to $DFFF.  This doesn't run true, because I have rom routines
> for my hard disk at $C800.  So how does one access the high 128K of the card?

All four planes are mapped by the EGA into the same 64K block from
$A000:0000 to $A000:FFFF.  The sequencer and graphics controller take
care of which planes are getting written to/read from.  This is what all
of the references to "latching" are all about.  when you do a "read"
from $A000:0000 the EGA actually "reads" 32 bits of data (one byte from
each of four planes) into internal RAM "latches" then the sequencer and
graphics controller can change this data (say...  AND it with something
and rotate it) then the next "write" to anywhere in the EGA map will put
all 32 bits into the planes.  All of this action may be enabled/disabled
with various incantations that I won't go into here... 

I hope this helped...

-Patrick	 ___________________________________________
		|                                           |
		|  Internet: naughton@sun.soe.clarkson.edu  |
		|  BITNET:   naughton@CLUTX.BITNET          |
		|  uucp:     {rpics, gould}!clutx!naughton  |
		|___________________________________________|