rab@mimsy.UUCP (01/17/88)
I am trying to write some graphics functions using an ega card in 640x350 mode. Can anyone provide me with the gory details about the memory mapping scheme that these cards use. In particular I need to know how to do the memory bank switching for the different bit planes. I understand the theory but I don't have the port addresses or the bit patterns that need to be written to them. If you can tell me a good reference to look this stuff up that would be nice too. Most of the books that I have don't go into enough detail to be useful. (Please don't write to tell me that I can do all of this with bios interrupt 0x10. I know that. I am looking for a more efficient alternative.) Thanks in advance, bob arpa: rab@mimsy.umd.edu uucp: uunet!mimsy!rab
mcdonald@uxe.cso.uiuc.edu (01/18/88)
>I am trying to write some graphics functions using an ega card >in 640x350 mode. Can anyone provide me with the gory details >about the memory mapping scheme that these cards use. In >particular I need to know how to do the memory bank switching >for the different bit planes. I understand the theory but >I don't have the port addresses or the bit patterns that >need to be written to them. >If you can tell me a good reference to look this stuff up that >would be nice too. Most of the books that I have don't go into >enough detail to be useful. Gory is right, and as far as I know, there is no good reference available easily. You will need the appropriate Tech Reference manual and lots of example code. There was a fairly good graphics package posted in comp.sources. misc many moons ago; you could get it from the archives. I will post my own there soon. You are warned that my package uses the "set/reset" register method of using colors. This is not how the BIOS works normally; hence you must be carefull about cntl-breaking out of graphics programs. My programs will be called "egafast". If they don't appear soon, I could e-mail them to you. Doug McDonald (mcdonald@uiucuxe)
jru@etn-rad.UUCP (John Unekis) (01/19/88)
In article <10216@mimsy.UUCP> rab@mimsy.UUCP (Bob Bruce) writes: >I am trying to write some graphics functions using an ega card >in 640x350 mode. Can anyone provide me with the gory details >about the memory mapping scheme that these cards use. In ... The EGA card is one of the most difficult graphics devices that I have ever seen, and I have seen quite a few. Basically it has four bit planes for every pixel on the screen. The displayed color at each pixel is the result of a lookup table operation, where one bit each of the four bit planes is combined into a 4bit nybble, which is then used as an offset(0-15) into a lookup table which produces 6 bits of output, giving the infamous 16 out of a possible 64 colors on the display. The six bits of output are hardwired as 2 bits per color, giving four shades of each color(off,low,medium,intense), but the bits are ordered as rgbRGB. The bit plane memories are easy to find in memory, they are all at starting address hex A000:0000. The problem is that they are ALL at that address, overlapping each other. Arbitration between these memories is handled by a whole bunch of control registers. These control registers are themselves overlapped onto common I/O bus addresses. The procedure for writing to EGA memory is something like what follows: 1)decide what mode you want to write to memory in, with your choices being something like - each byte I write contains one bit for each bitplane- or- each byte I write contains 8 bits for one bitplane- or- each byte only gets written if that pixel conatins a value which passes comparison with the magical "color compare register". 2) Find the register which arbitrates access to the address on the I/O bus where the write mode register is mapped. Write the value to this arbitration register to give you access to the write mode register. 3) Write the value to the write mode register which corresponds to the write mode you selected in step 1. 4) Select the appropriate value for the map mask register, which governs access to the bit planes. This value has one bit set in the low nybble for each bit plane you wish to enable writing to. Bitplanes not activated are not changed. If you are writing eight bit wide data, these 8 bits are replicated in every enabled bitplane. If you are writing four bit deep data, only the bits that fall on enabled bitplanes are changed. 5) Repeat steps 2 and 3, substituting map mask register for write mode register. 6) select the value for the pixel mask register which governs access to the eight possible pixels contained in each byte. If you are writing eight bit wide data, enable all the bits with ones, if you are writing four bit deep data, your 4 bits will be placed in each enabled bitplane, at each pixel position which is enabled in this register, within the eight pixels contained in the byte that falls at the adress offset which you write to. If you are trying to make a dot at a particular x,y address on the screen (upper left corner being 0,0) , enable the bit which corresponds to x mod 8 (or is it 7 - (x mod 8) ?). 7) repeat steps 2 and 3, substituting pixel mask register for write mode register. 8) You are now ready to write a pixel to memory. The address to use is calculated as hex A000:0000 + 80*y + x/8. Remember that you can only set a value directly at this point, using a machine MOV instruction. If you attempt to use AND, OR, or even EOR, you will get unpredictable results, because the logic circuits used to read the contents of screen memory are governed by a whole different set of registers which are equally complex but subtly different from the write control registers. If you think this is bad, the only complete documentation available for the EGA card is the IBM technical reference manual for EGA, which costs the better part of a gillion dollars, and requires a PHD in both Electrical Engineering and Doublespeak to interpret. Only a company that would use an INTEL 8088 as a main CPU would have a collective mind perverse enough to inflict a graphics standard this bad upon a meek and trusting public. If you want to do serious graphics on the EGA - buy a commercial package and let someone else do all the work. I just got done writing an image processing package for the MASER Research CLARITY board which uses the EGA memory, and I wish I could have left it up to someone else.
831059l@aucs.UUCP (STEVEN LUCIEN LANGLOIS) (01/19/88)
In article <10216@mimsy.UUCP> rab@mimsy.UUCP writes: >I am trying to write some graphics functions using an ega card >in 640x350 mode. Can anyone provide me with the gory details >about the memory mapping scheme that these cards use. >... I would also like to receive responeses to this request. Thanx. Steven Langlois Acadia Univ. Wolfville NS Canada B0P1X0 UUCP:{uunet|watmath|utai|garfield}dalcs!aucs!831059L
wtm@neoucom.UUCP (Bill Mayhew) (01/20/88)
"Turbo C Programming for the IBM" by Robert Lafore has a very nice chapter on programming EGA graphics. You can, of course, ignore whatever Tubo C-specific commnets there are. Actually, there aren't terribly many Tubo C-specific comments. Turbo C Programming for the IBM Robert Lafore Howard W. Sams & Company Idianapolis, IN 46268 USA ISBN: 0-672-22614-6 LCC: 87-62166 Dewey Decimal: who cares --Bill