![]() |
|
![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
|
![]() |
![]() |
If you compare Listings 7.1 and 7.2, you will see that the Map Mask register setting used to load a given plane does not match the Read Map register setting used to read that plane. This is so because while only one plane can ever be read at a time, anywhere from zero to four planes can be written to at once; consequently, Read Map register settings are plane selections from 0 to 3, while Map Mask register settings are plane masks from 0 to 15, where a bit 0 setting of 1 enables writes to plane 0, a bit 1 setting of 1 enables writes to plane 1, and so on. Again, Chapter 6 provides a detailed explanation of the differences between the Read Map and Map Mask registers. Screen saving and restoring is pretty simple, eh? There are a few caveats, of course, but nothing serious. First, the adapters registers must be programmed properly in order for screen saving and restoring to work. For screen saving, you must be in read mode 0; if youre in color compare mode, theres no telling what bit pattern youll save, but it certainly wont be the desired screen image. For screen restoring, you must be in write mode 0, with the Bit Mask register set to 0FFH and Data Rotate register set to 0 (no data rotation and the logical function set to pass the data through unchanged).
Whats the solution? Frankly, the solution is to get VGA-specific. A TSR designed for the VGA can simply read out and save the state of the registers of interest, program those registers as needed, save the screen image, and restore the original settings. From a programmers perspective, readable registers are certainly near the top of the list of things to like about the VGA! The remaining installed base of EGAs is steadily dwindling, and you may be able to ignore it as a market today, as you couldnt even a year or two ago. If you are going to write a hi-res VGA version of the screen capture program, be sure to account for the increased size of the VGAs mode 12H bit map. The mode 12H (640×480) screen uses 37.5K per plane of display memory, so for mode 12H the displayed screen size equate in Listings 7.1 and 7.2 should be changed to: DISPLAYED_SCREEN_SIZE equ (640/8)*480 Similarly, if youre capturing a graphics screen that starts at an offset other than 0 in the segment at A000H, you must change the memory offset used by the disk functions to match. You can, if you so desire, read the start offset of the display memory providing the information shown on the screen from the Start Address registers (CRT Controller registers 0CH and 0DH); these registers are readable even on an EGA. Finally, be aware that the screen capture and restore programs in Listings 7.1 and 7.2 are only appropriate for EGA/VGA modes 0DH, 0EH, 0FH, 010H, and 012H, since they assume a four- plane configuration of EGA/VGA memory. In all text modes and in CGA graphics modes, and in VGA modes 11H and 13H as well, display memory can simply be written to disk and read back as a linear block of memory, just like a normal array. While Listings 7.1 and 7.2 are written in assembly, the principles they illustrate apply equally well to high-level languages. In fact, theres no need for any assembly at all when saving an EGA/VGA screen, as long as the high-level language youre using can perform direct port I/O to set up the adapter and can read and write display memory directly.
16 Colors out of 64How does one produce the 64 colors from which the 16 colors displayed by the EGA can be chosen? The answer is simple enough: Theres a BIOS function that lets you select the mapping of the 16 possible pixel values to the 64 possible colors. Lets lay out a bit of background before proceeding, however. The EGA sends pixel information to the monitor on 6 pins. This means that there are 2 to the 6th, or 64 possible colors that an EGA can generate. However, for compatibility with pre-EGA monitors, in 200-scan-line modes Enhanced Color Display-compatible monitors ignore two of the signals. As a result, in CGA-compatible modes (modes 4, 5, 6, and the 200-scan-line versions of modes 0, 1, 2, and 3) you can select from only 16 colors (although the colors can still be remapped, as described below). If youre not hooked up to a monitor capable of displaying 350 scan lines (such as the old IBM Color Display), you can never select from more than 16 colors, since those monitors only accept four input signals. For now, well assume were in one of the 350-scan line color modes, a group which includes mode 10H and the 350-scan-line versions of modes 0, 1, 2, and 3. Each pixel comes out of memory (or, in text mode, out of the attribute-handling portion of the EGA) as a 4-bit value, denoting 1 of 16 possible colors. In graphics modes, the 4-bit pixel value is made up of one bit from each plane, with 8 pixels worth of data stored at any given byte address in display memory. Normally, we think of the 4-bit value of a pixel as being that pixels color, so a pixel value of 0 is black, a pixel value of 1 is blue, and so on, as if thats a built-in feature of the EGA.
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
|