[comp.sys.ibm.pc] Direct Graphics with the EGA

kevin@uthub.toronto.edu (Kevin A. Stoodley) (02/17/88)

I'm looking for information on how the Tatung Supreme EGA's 350 by 640 16 
colour graphics mode can be used directly from an assembly language program
without using BIOS calls on an AT.  Specifically, I'd like to know how the EGA
stores the colours of each pixel.  All I can find out from my card's
documentation is that the mode is 16 and that the screen memory starts at
a000:0h.  I would really appreciate some information, if anyone knows this kind
of stuff.  Failing that, or if it's too involved to conveniently explain in a
reasonably short note, I would like a good reference to the material.
Thanks in advance.
-- 

		    Kevin A. Stoodley	University of Toronto, Dept. EE
		    {linus,ihnp4,uw-beaver,floyd,utzoo}!utcsri!uthub!kevin

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

From article <702@uthub.toronto.edu>, by kevin@uthub.toronto.edu (Kevin A. Stoodley):
> 
> I'm looking for information on how the Tatung Supreme EGA's 350 by 640 16 
> colour graphics mode can be used directly from an assembly language program
> without using BIOS calls on an AT.  Specifically, I'd like to know how the EGA
> stores the colours of each pixel.  All I can find out from my card's
> documentation is that the mode is 16 and that the screen memory starts at
> a000:0h.  I would really appreciate some information, if anyone knows this kind
> of stuff.  Failing that, or if it's too involved to conveniently explain in a
> reasonably short note, I would like a good reference to the material.
> Thanks in advance.
> -- 
> 
> 		    Kevin A. Stoodley	University of Toronto, Dept. EE
> 		    {linus,ihnp4,uw-beaver,floyd,utzoo}!utcsri!uthub!kevin


  For one thing it is generally referred to as 640x350 (x then y).
That understood, let's try to exaplain how to use it a little.

Basically the EGA does 16 colors by using 4 video planes mapped to the
same address space.  This is why the RAM onboard is 256Kx4 as opposed
to normal memory being 256Kx1...

              -----------------------
A000:0000---->|00000001         RED
              | ----------------------
              | |00000001       GREEN
              | | ---------------------
              | | |00000001     BLUE
              | | | --------------------
              | | | |00000001   INTENSITY
              | | | |
              | | | |
                | | |
                  | |
                    |


To plot a point in a color c at the coords x,y on the EGA do this.

the byte of memory you need to modify is at this location

A000:((y * 80) + (x div 8))

You must first read from this location, ignore what you read.

set the mask register to 100000000b (80h) shifted right (x mod 8)

set write mode 2

write the color (0..15) you want to the memory location above.


The three mysteries for you are:
  How to set the mask register...
   It is register 8 of the graphics controller whose address aludes me.
  How to set write mode 2.
   Again... register 5 of the graphics controller (see above)

I'll check my references and post a code fragment later...

I'm on my sun 3 not near my AT with all of the EGA code and docs....

till then...

-Patrick

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

Devin_E_Ben-Hur@cup.portal.com (02/21/88)

Direct graphic writes to EGA & VGA are a baroque affair.  I suggest
_Programmer's Guide to PC & PS/2 Video Systems_ by Richard Wilton
(Microsoft Press) for a reasonably complete discussion of all the
common PC graphic systems and basic raster graphics algorithms.