Video and Video Adapter
Video and Video Adapter
8.1 Principles of monitors and video adapters 8.2 Video Adapters and text mode programming 8.3 Graphics and graphic programming
monitors use a method call raster scanning to display image on the monitor screen. This method uses a beam of electrons to illumine phosphorus dots , call pixels, on the screen. Raster from the top left corner to the bottom right.(one line at a time).
As the gun turn on and off, its moves from left to right toward the end of the line. which time it is turned off to move back to the beginning of the next line. This moving back while the gun is off is call horizontal retrace. When it reaches the bottom right of the screen, the guns turned off and move to the top left of the screen. Its turning off and moving back to the top is called vertical retrace.
Methods of scanning
Non-interlaced (normal)
Monitor
interlaced scanning
PCs Flicker-free
Use
Example1
In a IBM monochrome monitor with HF= 18.432KHz =50Hz, calculate the number of scanned per screen.
Not all 368 line are visible in the screen. Some line are for over scan and vertical retrace time. Over scan refer to the line or below the visible portion of the screen. Only 350 line are visible in the screen. The remaining (368-350) 18. About 3 or 4 is used for over scanning. The time that would have been taken for scanning the rest (approximately 14) .
Dot pitch
Dot pitch is the distance in between adjacent pixel (dots) / between two dots as same colors. And its given in mm. 0.6 inch for high resolution and 0.2 inch for lower resolution.
Can be calculate by dividing the video frequency ( Sometimes called dot frequency ) by the horizontal frequency.
Example 16-2 A manufacturer has advertised a 14-inch monitor of 1024 x 768 resolution with a . Calculate the diagonal size of the image on the screen. It must be less than 14 inches. Solution: The calculation is as follows: (diagonal size)2 = (1024 x 0.28 mm) 2 + (768 x 0.28 mm) 2 diagonal size (inches) = 358 mm x 0.039 inch per mm = 13.99
Phosphorous material
Another factor that determines the quality of the monitor is the phosphorus material used, since the brightness of the pixels depends on two factors 1) The intensity of the electron beam. (controlled by software). 2) The phosphorous material used.
Color monitor
Every phosphorus dot is made of three colors: red, green, and blue, hence the name RGB . Color monitors require three different wires to carry three electronic beams. In composite monitors there is one single wire that carries all three colors. Monochrome monitor display two color; 1) background-graphic 2)foreground-display image
Character box
text
group of pixels, are accessed The individual pixels are horizontal and vertical pixels are accessed and manipulated grouped into what are called character boxes Each character box can display a single character The size of the character box matrix varies from adapter to adapter.
In digital monitors such as the MDAand CGA-based monitors, one uses a number of bits to specify variations of color and intensity.
In order for the information to be displayed, it must be written first into video RAM by the CPU. then it is the job of the video adapter's controller (processor) to read the information from video RAM and convert it to the appropriate signals to be displayed on the screen.
Example 16-3 If the MDA character box is 9 x 14 (9 pixels wide and 14 pixels high) and the resolution of MDA is 720 x 350, verify the fact that MDA in text mode can display 80 x 25 characters per screen. Solution: 720 horizontal scan lines divided by 9, the width of character box, gives 80 columns of characters. Dividing 350 vertical pixels by 14, the height of the character box, results in 25 rows
Example 16-4 In a given adapter, the character box is 8 x 14 and the adapter in text mode displays 80 x 25 characters. Calculate the pixel resolution. Solution: The total number of horizontal pixels is 640 (8 x 80) and the vertical number is 350 (14 x 25). Therefore, it has 640 x 350 resolution.
Although CGA had color for both graphics and text, the text was not vary crisp
until 1985 was EGA (enhanced graphics adapter) provided both graphics and text on the same monitor In 1987, when IBM introduced the new PS/2 line of products, they also introduced new video standards called VGA (video graphics adapter) and MCGA (multicolor graphics array)
The video display RAM of the CGA starts at B8000H and goes up to 16K bytes. However, to implement the entire 16K bytes of video RAM using static RAM would be too expensive and for that reason DRAM is used. For the CGA at memory location B800:0000, even addresses hold the characters to be displayed and odd addresses the attributes of characters as shown next
If the full screen text of 80 x 25 takes 4K bytes (2K bytes for the characters and 2K bytes for the attributes), then 16K bytes of memory can hold 4 pages of text at any given time Only one page can be viewed at a time, and one can switch to one of the other 3 pages at any time without delay The page that is being displayed at any given time is commonly referred to as the active page Since the 40 x 25 text option requires only 2000 bytes for both characters and attributes, the 16K bytes of VDR can hold a maximum of 8 pages of text.
As mentioned earlier, even addresses are for the characters to be displayed and odd addresses are for the attributes The bit definition of the attribute byte in text mode of CGA is as shown in Figure 16-3. From the above bit definition it can be seen that the background and foreground can take 8 and 16 different colors, respectively, by combining the primary colors red, blue, and green. Table 16-3 lists those possible colors
MDA was one of two display adapters offered with the IBM PC when it was introduced to the market in 1981. It supported a monochrome monitor which displayed 80 alphanumeric characters per line and 25 lines per screen. The resolution of MDA proved very useful for text applications, but users who needed to use graphics had to use the other adapter offered with the IBM PC at that time, CGA. MDA characteristics are shown in Table 16-4.
MDA uses video RAM addresses starting at B0000H. This is in contrast to CGA, with memory starting at B8000H. As shown below, the starting physical address of the video RAM in the monochrome is B0000H or B000:0000 using segment: offset. Starting at B0000H, the contents of even locations are the characters to be displayed and the odd locations are the attributes of each character.
The EGA adapter, introduced in 1985, gave the PC user the best characteristics of both MDA and CGA, since it could be configured to emulate either. It had graphics and 16 color capabilities, like the CGA but with much improved resolution. Although its resolution of 640 x 350 was still not as good as MDA, it was a significant improvement over the resolution of CGA. IBM used a set of proprietary LSI chips as a CRT controller instead of the Motorola 6845 chip. As shown in Table 16-5, all previous modes of CGA and MDA (modes 0 - 7) are supported in addition to new modes ODH 10H.
VGA is a single-chip video controller designed by IBM which performs many tasks previously done by several chips in EGA. However, many use the term VGA to refer to the entire adapter. VGA is used with analog monochrome or color monitors on PS/2 models 50, 60, 80, and 90. It has excellent resolution of up to 720 x 400 for text modes and 640 x 480 for graphics modes. In many PC and compatible computers, VGA is already on the motherboard, but it can also be purchased as an adapter board to be plugged into one of the expansion slots. Table 16-7 shows video modes for VGA. Notice that it emulates all the modes of CGA, MDA, EGA, plus new modes 11H, 12H, and 13H, which are not available with the earlier adapters.
Up to 1 megabyte of DRAM can be installed on VGA boards. This extra memory is used to store pixels and their attributes. Since in graphics mode, VGA can display up to 256 colors out of 262,144 possible colors at once, it requires 1 megabyte of DRAM to store them. How the 1M of memory is mapped into the 128K-byte address space A00000 - BFFFFH is discussed in Section 16.3, which covers text mode programming. When VGA is programmed to emulate CGA text, the address for the video is B8000H, but for MDA emulation the address is BOOOOH. This is in order to be compatible with previous adapters. When VGA is in text mode it uses mode 3, as we will see in the next section.
Aside from video standards mentioned so far there are some other adapters that are widely used.
In all the video programming examples given so far, characters have been used as units to be addressed and a character was treated as a group of pixels. In this section, programming individual pixels will be discussed. In graphics mode, pixel accessing is also referred to as bit-mapped graphics. IBM refers to it as APA (all points addressable) versus AN (alpha-neumerical) for text mode. First, the relationship between pixel resolution, the number of colors supported, and the amount of video memory in a given video board is clarified.
There are two facts associated with every pixel on the screen: The location of the pixel Its attributes: color and intensity These two facts must be stored in the video RAM. The higher the number of pixels and colors options, the larger the amount of memory that is needed to store them. In other words, the memory requirement goes up as the resolution and the number of colors supported go up. The number of colors displayed at one time is always 2n where n is the number of bits set aside for the color. For example when 4 bits are assigned for the color of the pixel, this allows 16 combinations of colors to be displayed at one time because 24 = 16. The relation between the video memory, resolution, and color for each video adapter is discussed separately.
In this mode there are a total of 64,000 pixels (320 columns x 200 rows 64,000). Dividing the total video RAM memory of 128K bits (16K x 8 bits = 128K bits) by the 64,000 pixels gives 2 bits for the color of each pixel. These 2 bits give rise to 4 colors since 22 = 4. Therefore, the 320 x 200 resolution CGA can support only up to 4 different colors at a time. See Figure 16-8. These 4 colors can be selected from a palette of 16 possible colors. To select this mode, use set mode option AH= 0 of INT 10H with AL = 04 for mode. After setting the video mode to AL = 04, we must use option OBH of INT 10H to select the color of the pixel displayed on the screen.
Note that for a fixed amount of video RAM, as the resolution increases, the number of supported colors decreases. This discussion bypasses 16-color 160 x 100 low resolution, which is used with color TV sets since no PC supports it.
In the EGA board, the memory buffer was increased to a maximum of 256K bytes. This allowed both the number of colors and the number of pixels supported in graphics mode to increase. Although EGA can have up to 64 colors, only 16 of them can be displayed on the screen at a time. This is in contrast to CGA, which displayed only 4 colors of a 16-color palette. EGA graphics memory starts at AOOOOH and goes to a maximum of AFFFFH, using only 64K bytes of the PC's memory space. How is this 256K bytes of memory accessed through a 64K-byte address window? To solve this problem, IBM designers used 4 parallel planes, each 64K bytes, to access the entire 256K bytes of video RAM. In this scheme, each plane holds one bit of the 4-bit color. The assignment of 4 bits for color allows a maximum of 16 colors to be displayed at any given time. In the EGA card, IBM introduced what are called palette registers. There are a total of 16 palette registers in the EGA, each holding 8 bits. EGA uses only 6 bits out of the 8 bits of the palette register, giving rise to a maximum of 64 hues.
This gives rise to the use of what is called a video DAC (digital-to-analog converter). Each color of red, green, and blue has a 6-bit D/A converter, allowing 64 combinations for each color, making a total of 18 bits used for the palette which gives rise to total of 262,144 (218) hues. If the video DAC size is expanded from 6 to 8, the number of combinations for the three signals will be 256 x 256 x 256 = 224 = 16,777,216 hues for the color palette, which is referred to as 16.7 million colors in many advertisements.
In VGA, 640 x 480 resolution with support for 256 colors displayed at one time will require a minimum of 640 x 480 x 8 = 2,457,600 bits of memory, but due to the architectural design of VGA, there must be 256K bytes of memory available on the video board. Using the concept of planes means that each plane has 64K bytes. See Figure 16-9. VGA is downward compatible with both CGA and EGA in graphics mode. To access one of the 256 palette registers of VGA, set AH = I OH and use option AL =I OH of INT I OH. As mentioned earlier, for the AH=10H mode there are many options available for pixel programming of both EGA and VGA. These options are selected through register AL.
In SVGA and IBM's XGA, all the resolutions of 800 x 600, 1024 x 768, and 1024 x 1024 are supported. The memory requirement for these boards can reach millions of bytes, depending on the number of colors supported. For example, SVGA of 800 x 600 pixels with 256 colors displayed at the same time requires a minimum of 800 x 600 x 8 =3,840,000 bits of memory, or a total of 480,000 bytes. Due to the use of bit planes, a total of 512K bytes of DRAM is needed. See Table 16-9. Another example is the total memory required by 800 x 600 resolution with 16 million colors. In this case we need 800 x 600 x 24 = 11,520,000 bits or 1,440,000 bytes, or 1406K bytes. Due to the use of bit planes, it uses 1.5M bytes of DRAM (see Table 16-9).
To address a single pixel on the screen, use INT I OH with AH = OCH. To do that, X and Y coordinates of the pixel must be known. The values for X (column) and Y (row) vary depending on the resolution of the monitor. CX holds the column point (the X coordinate) and DX the row point (Y coordinate). If the display mode supports more than one page, then BH=page number; otherwise, it is ignored. To turn the pixel on or off, AL = 1 or AL = 0 for black and white. The value of AL can be modified for various colors.
To draw a horizontal line, choose values for the row and column points at the beginning of the line and then continue to increment the column until it reaches the end of line as shown in Example 16-18.