Sei sulla pagina 1di 4

SVGA (Super Video Graphics Array) Library

Introduction to SVGA
A long time ago, IBM defined the first video standards, MDA (monochrome), CGA, EGA and the
MCGA. In 1987 the VGA was released. As the computer market grew, more video card
manufactures created hi-res cards. However, they were not created after any kind of standard.
640x480x256, for example, had, and still has, number 32h on one card, 63h on another and 45h
on a third. That was not all, the bank size (refer section 4) differed, they were overlapping... You
get the picture, NO STANDARD!
Programmers therefore had to write several different drivers for each and every card, and ask the
computer or the user what driver to use. The manufacturers got together and created the Video
Electronics Standards Association (VESA). VESA defined a new standard so that programmers
just had to write a single set of graphic routines. They called it VESA VBE (VESA Video Bios
Extensions), and has nothing to do with VESA Local Bus, witch also is a standard from the same
group about a completely other hardware problem.
To become a good SVGA programmer one should know all the information about the following
items.
1. Video Buffer
The video buffer is the location where the graphic information is stored. Its address is
0xA000:0000- 0xA000:FFFF. All the information we see on the computer screen is actually
stored in this buffer.
2. The interrupt 0x10h
All the ROM-BIOS video services so called VESA interrupts are performed using the interrupt
0x10 with sub function 4F(AH=4F).All functions return 004F in AX if they are successful. The
sub function value is stored in AL register.
Sub function 00 - get VESA information
Sub function 01 - get VESA mode information
Sub function 02 - set VESA video mode
Sub function 03 - get current video mode
Sub function 04 - save/restore VESA video state
Sub function 05 - bank switching
Sub function 06 - get/set logical scan line length
Sub function 07 - get/set display start
Sub function 08 - get/set DAC palette control
3. Video Modes:
Mode Resolution Colors Banks Memory
00h

640x400

256

256Kb

101h 640x480

256

320Kb

102h 800x600

16

256Kb

103h 800x600

256

512Kb

104h 1024x768 16

192Kb

105h 1024x768 256

12

768Kb

106h 1280x1024 16

10

0.7Mb

107h 1280x1024 256

20

1.3Mb

108h 80x60

text

109h 132x25

text

10Ah 132x43

text

10Bh 132x50

text

10Ch 132x60

text

10Dh 320x200

32k

128Kb

10Eh 320x200

64k

128Kb

10Fh 320x200

16.8M 3

192Kb

110h 640x480

32k

10

0.7Mb

111h 640x480

64k

10

0.7Mb

112h 640x480

16.8M 15

1.0Mb

113h 800x600

32k

15

1.0Mb

114h 800x600

64k

15

1.0Mb

115h 800x600

16.8M 22

1.4Mb

116h 1024x768 32k

24

1.5Mb

117h 1024x768 64k

24

1.5Mb

118h 1024x768 16.8M 36

2.3Mb

119h 1280x1024 32k

40

2.5Mb

11Ah 1280x1024 64k

40

2.5Mb

11Bh 1280x1024 16.8M 60

3.7Mb

To set desired mode set AX to 0x4F02 and BX to the mode number.


4. Bank Switching:
We will be having an address space that is less than the accessible memory. Thus you need to
shift the beginning of the window to access certain parts of the memory.
5. SVGA Mode Info:
The SVGA Mode info block is used to hold the information returned by the interrupt 0x10h when
subfunction 0x01 is used. This block is used for addressing the pixels, calculate bank size,etc
The SVGA Mode Info table is given below.
Name
ModeAttributes
WinAAttributes
WinBAttributes
WinGranularity
WinSize
WinASegment

Offset
0
2
3
4
6
8

Size(Bytes)
2
1
1
2
2
2

Description
Mode Attributes
Window A attributes
Window B attributes
Window granularity
Window size
Segment address of Window A

WinBSegment
WinFuncPtr
BytesPerScanLine
XResolution
YResolution
XCharSize
YCharSize
NumberOfPlanes
BitsPerPixel
NumberOfBanks
MemoryModel
BankSize
NumberOfPages
Reserved1
RedMaskSize
RedMaskPosition
GreenMaskSize
GreenMaskPosition
BlueMaskSize
BlueMaskPosition
ReservedMaskSize
ReservedMaskPosition
DirectScreenModeInfo
Reserved2

10
12
16
18
20
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

2
4
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
216

Segment address of window B


Address of the Window Function Call
Bytes per scan line
Horizontal resolution
Vertical resolution
Character cell width
Character cell height
Number of bit planes
Total number of bits per pixel
Number of memory banks
Memory model type
Size of memory bank in Kb
Number of display pages available
Reserved
Number of bits used for Red mask
RedMaskposition
Number of bits used for Green mask
GreenMaskposition
Number of bits used for Blue mask
BlueMaskPosition
ReservedMasksize
ReservedMaskPosition
DirectScreenModeInfo
Reserved

6. TrueColor modes (16.7M) or 24-bit mode


The Pixel address is calculate as (ypos*bytesperscanline)+(xpos*3).
Pixel 1
Byte 1

Byte 2

Pixel 2
Byte 3

Byte 4

Byte 5

Byte 6

BBBBBBBB GGGGGGGG RRRRRRRR BBBBBBBB GGGGGGGG RRRRRRRR


7. High Color Modes:
The Pixel address is calculated as y*bytesperline+(x*2).
64K or 16-bit color modes:
64k and 32k are tougher to understand. The bytes come in the wrong order. Note that there is
one extra bit for green.
Pixel
Byte 2

Byte 1

RRRRRGGG GGGBBBBB
When it is put in memory it looks like this:

Pixel 1
Byte 1

Pixel 2
Byte 2

Byte 3

Byte 4

GGGBBBBB RRRRRGGG GGGBBBBB RRRRRGGG


32K or 15-bit color modes: One pixel looks like this. Note that the highest bit in byte two
doesn't affect the pixels color. It can be used for transparency etc.
Pixel
Byte 2

Byte 1

0RRRRRGG GGGBBBBB
Pixel 1
Byte 1

Pixel 2
Byte 2

Byte 3

Byte 4

GGGBBBBB 0RRRRRGG GGGBBBBB 0RRRRRGG


8. 256/256K color modes: As the famous mode 13h all 256 color modes are indexed. The Pixel
address is calculated as y*bytesperline+x
Pixel
Byte 1
IIIIIIII

9. The VGA Register Set


The registers which are common to all VGAs fall into six major groups:
Sequencer registers control memory access, timing, and data flow among the other registers.
CRTC (Cathode Ray Tube Controller) registers deal with the timing related to the monitor.
External registers provide some miscellaneous functions. Graphics Controller registers support
graphics mode functions. Attribute Controller registers handle the color palette selections. DAC
(Digital to Analog Converter) registers convert the color code to a voltage for your analog
monitor. The external registers and Color Select Registers block in the Attribute Controller are
accessed directly, as each of them has a unique host port. All the others are accessed indirectly.
Address of register groups
Register Group
Sequencer
CRTC Mono
Color
External Mono
Color
Graphics Controller
Attribute Controller
DAC

Direct I/O Port


------------3BAh,3CAh
3DAh,3CAh
--------3C6h,3C7h

Address port
3C4h
3B4h
3D4h
--------3CEh
3C0h
-----

Data port
3C5h
3B5h
3D5h
3C2h,3CCh
3C2h,3CCh
3CFh
3C1h
3C8h,3C9h

Potrebbero piacerti anche