Anda di halaman 1dari 70

# CHAPTER 8 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

## PRINCIPLES OF MONITORS AND VIDEO ADAPTER

Video

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

## How to judge a monitor

The resolution of the screen depend upon the following factor; 1) The number of pixels (dots) per scanned line. 2) The speed at which the gun can turn on and off the phosphorus coating on the surface of the tube. 3) The speed at which it can scan and retrace a horizontal line. 4) The number of scan line per scan (frame) 5) The speed at which it finishes one frame and performs the vertical retrace.

Example1

In a IBM monochrome monitor with HF= 18.432KHz =50Hz, calculate the number of scanned per screen.

## Solution; HF- horizontal frequency / VF-vertical frequency 18432/50=368 line.

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.

## The number of pixels (dots)

Can be calculate by dividing the video frequency ( Sometimes called dot frequency ) by the horizontal frequency.

## Dot pitch and monitor size

Monitors, like televisions, are advertised according to their diagonal size. For example, a 14-inch monitor means that its diagonal measurement is 14 inches. Smaller size and smaller space can higher the number of pixel it's better the resolution.

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

## Video boards can be programmed in two modes: text and graphics.

graphics

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.

## Analog and digital monitor

In digital monitors such as the MDAand CGA-based monitors, one uses a number of bits to specify variations of color and intensity.

## Video display RAM and video controller.

Communication between the system board (motherboard) and the video display monitor is through the video adapter board Among the components every video board must have is a video controller and video display RAM The information displayed on the monitor (either text or graphics) is stored in memory called video display RAM (VDR), also called video buffer

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.

## SECTION 16.2: VIDEO ADAPTERS AND TEXT MODE PROGRAMMING

had two video monitor options 1981

## MDA (monochrome display adapter) and CGA (color graphics adapter )

Although CGA had color for both graphics and text, the text was not vary crisp

## CGA allowed both graphics and text mode options

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)

## CGA (color graphics adapter)

CGA had the capability of providing both text and graphic on the screen CGA displays a maximum of 80 characters per line and 25 lines per screen with a resolution of only 640 x 200. Programming modes are selected INT I0H video subroutines contained in the ROM BIOS.

## Video RAM in CGA

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.

## Attribute byte in CGA text mode

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 (monochrome display adapter)

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.

## Video RAM in MDA

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.

## Attribute byte in IBM MDA

The attribute byte for the characters of MDA uses the same backgroundforeground scheme as CGA; however, since it supports only black and white, not all possible combinations can be used. Figure 16-4 shows bit definitions of the monochrome byte attribute.

## EGA (enhanced graphics adapter)

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.

## EGA video memory and attribute

Although the EGA video board can accommodate a maximum of 256K bytes of memory, it can use only 128K bytes of memory space from AOOOOH to BFFFFH. When in graphics mode, the starting address is at AOOOOH, but in text mode the address location varies depending on which mode it is emulating, as shown in Table 16-5. EGA can emulate both CGA and MDA. When EGA is programmed to emulate CGA text, the address for the video is B8000H, but for the MDA emulation the address is BOOOOH. EGA in graphics mode can display 16 colors out of 64 possible colors. Section 16.4 will discuss relating the number of colors supported to memory installed on the video boards.

## MCGA (multicolor graphics array)

The MCGA video system is used with analog monochrome or color monitors on PS/2 models 25 and 30. It has improved resolution and color selection over CGA. The advantage of analog systems is their improved color and shading capabilities. In MCGA there are up to 64 brightness levels in monochrome monitors and in color monitors there are up to 262,144 colors of which 256 at a time can be selected for a palette. Table 16-6 gives video modes for MCGA. Notice that it emulates all of CGA modes 0 - 6 in addition to two new modes, 11H and 13H,

## VGA (video graphics array)

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.

## Video memory and attributes in VGA

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.

## Super VGA (SVGA) and other video adapter.

Aside from video standards mentioned so far there are some other adapters that are widely used.

## SECTION 16-4 GRAPHICS AND GRAPHICS PROGRAMMING

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.

## Graphics: pixel resolution, color, and video memory

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.

## The case of CGA

The CGA board can have a maximum of 16K bytes of video memory since the 6845 has only 14 address pins (214 =16K). We showed in Section 16.2 how this 16K bytes of memory can hold up to 4 pages of data, where each page represents one full screen of 80 x 25 characters. In graphics mode, the number of colors supported varies depending on the resolution, as shown next.

## 320 x 200 (Medium resolution)

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.

## 640 x 200 (High resolution)

In this mode there are a total of 128,000 pixels (200 x 640 =128,000). Dividing the 16K bytes of memory by this gives 1 bit (128,000/128,000 =1) for color. The bit can be on (white) or off (black). Therefore, the 640 x 200 high-resolution CGA can support only two colors: black and white. To select this mode, use set mode option AH = 0 of INT 10H with AL = 06 for mode.

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.

## The case of EGA

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.

## Video memory size and color relation for EGA

In EGA, to support 640 x 350 pixels with 16 colors requires a minimum of 640 x 350 x 4 = 896,000 bits of memory, but because of the concept of the plane and the 64K-byte address space of AOOOOH - AFFFFH, the memory must be 256K bytes, although some portions of video memory are unused. In EGA, one can use 64K bytes for the video RAM, making only 16K bytes available for each color plane, but this results in reducing the number of colors supported. EGA is downwardly compatible with CGA in graphics mode, the same as in text mode. To program the palette registers of the EGA, use option AL =0 of INT 10H.10H has many options for pixel programming of EGA and VGA.

## The case of VGA

In VGA, the number of pixels was increased to 640 x 480 with support for 256 colors displayed at one time. The color palette was increased to 218 = 262,144 hues. The number of palette registers was also increased to 256. Each palette register holds 18 bits, 6 bits for each of the red, green, and blue colors. VGA was the first analog monitor introduced by IBM. All previous monitors were digital. In analog VGA, the analog colors of red, green, and blue replace the digital red, green, and blue of the digital display, allowing substantial increases on the number of colors supported.

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.

## Video memory size and color relation for VGA

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.

## The case of SVGA

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).

## INT 10H and pixel programming

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.

## Drawing horizontal or vertical lines in graphics mode

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.