Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-unix!hplabs!hao!gaia!zhahai From: zhahai@gaia.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Video Programming Message-ID: <278@gaia.UUCP> Date: Wed, 4-Feb-87 17:15:41 EST Article-I.D.: gaia.278 Posted: Wed Feb 4 17:15:41 1987 Date-Received: Sat, 7-Feb-87 12:21:28 EST References: <1929@uw-june.UUCP> Reply-To: zhahai@gaia.UUCP (Zhahai Stewart) Organization: Gaia Corp., Boulder, CO Lines: 76 Keywords: EGA graphics Summary: EGA mapping quite different than CGA In article <1929@uw-june.UUCP> roper@uw-june.UUCP (Michael Roper) writes: >1) Since only 128K of main memory is reserved for display buffers (from > A0000 to BFFFF), where do EGA's with "a full 256K of RAM", put the > other 128K? Or is it just bank-switched? The EGA can be mapped into memory space in several ways, such as B0000-B7FFF or B8000-BFFFF (for mono & CGA emulation, resp.), or A0000-AFFFF (for most non-emulation graphic modes), or theoretically A0000-BFFFF (I have not seen this used; it would conflict with another color/mono adapter). When in graphic mode 10h, 640x350 color, it's memory is mapped to A0000-AFFFF, which is only 64K. It can, however, support up to 4 bit planes in this address slot (256K Bytes total). There are various registers which allow one to read/write single or groups of planes. >2) By my calculations, 112K is required for a full page of graphics in > video mode 10h, using a 16-color palette. Is the rest of the (128K) > display memory wasted? You are right, with 16 colors any memory beyond 112K is not displayed; with 256K this leaves room for a second full page of graphics for ping ponging if you wish. Or one could scroll around within a picture larger than 640x350. (With only 64K of memory installed in the IBM EGA, only 56K is used, with 4 colors). >3) Advanced MS-DOS says that mode 10h uses either a 4- or 16-color palette, > depending upon the amount of display memory provided by the adapter. > Is this selection made automatically? What is the cut-off? Yes, it is automatic; 64K gets 4 colors, 128K or more gets 16. Handled by new BIOS (onboard EGA, C0000) during initialization. >4) Norton makes a vague reference to the difficulty of writing directly > to the EGA's display buffer. What's the story? Are the pros and cons > of accessing the EGA's buffer directly any different from say, the MA > or CGA? The major pros and cons are the same, speed versus portablility. All you get with the BIOS is dot plot/read. A line drawing primitive can run much faster if it directly accesses the screen. The major "con" with the EGA is that its mapping is more complex regarding multiple bit maps, although simpler regarding x,y to address translation (no "interleaving" like the CGA and Herc do in mapping memory to screen). In brief: The mode 10h screen is mapped as 4 bit maps, all at location A0000-A6FFF (28 KBytes). A0000 is the upper left byte (most significant bit leftmost, as with CGA/Herc; IBM displays are mixed-endian #%$@). A0001 is just to the right of that. A0050 (80 decimal after start of buffer) is just below the first byte, A00A0 just below that. You can write to any set of planes (all 4, just one, or anything between) without modifying the others - Provided you do a read of the location before writing (if writing all 4 it doesn't matter). You can read from any one plane, or from a comparison of any set of planes with a color compare register. You can mask which bits of the byte are changed and which are not (again, must read first unless writing to all bits). You can do an AND, OR, XOR or replace when writing (... must read first unless doing a replace). There is also a rotation function built in, which I have not found any way to use (the cpu rotate is more useful). Perhaps you can see why this aspect is more difficult to set up (especially with poor documentation) than CGA stuff. The good part is that sometime you can get a real speed gain (you can read from one location, (8 bits x 4 planes) and write the contents to another, thus transferring 32 bits in one byte copy). Good luck. I have not seen good documentation; IBM now sell the EGA tech ref material without the Options and Adapters Tech Ref Manuals set, I hear. PC tech journal has had some articles which cover everything in the IBM manuals; have to look in a library to find which issues. Be prepared to use a debugger and try things out to verify your guesses at to what the documentation means. A challenge: find out how to get a 1024x1024 virtual screen (4 colors). It can be done. (you only get a 640x350 window to display, of course, but you can move it around). ~z~ >---Michael Roper--- * -- Zhahai Stewart {hao | nbires}!gaia!zhahai