home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
vga
< prev
next >
Wrap
Text File
|
1990-01-04
|
34KB
|
824 lines
.VGA BIOS STARTING ADDRESS:
.VGA BIOS SIZE:
.VGA ROM BIOS main feature :
1. Video adapter diagnostic (self-test)
2. Video service routines
3. ASCII code table
4. Video parameter table
.I/O ROM construction:
1. The first word: 55 AA as identifier
2. Byte 02: total length /512
3. Jump instruction
.MAIN FEATURE:
1.DIAGNOSTIC:
2.SERVICE ROUTINE:
.BACKWARD CAPABILITY:
.MEMORY CONFIGURATION:
.NMI:
Sequence:
1. Disable VGA
2. Check if other display card exists?
write 4 words to VRAM (B000 & B800)
read back
If VRAM R/W O.K then set equip_flag and CF
3. Enable VGA and access I/O
4. Set fixed vector (Note 1)
INT 10h :
INT 1Fh : 2nd 128 8x8 ASCII code
INT 43h : 1st 128 8x8 ASCII code
INT 1Dh :
INT 6dh :
INT 42h : IBM (CGA,MDA,MGA) original INT 10 vector (F000:F065)
5. Test video RAM
By writing a pattern to VRAM then reading it back
If an error occurs, sound 1 long and 2 short error beeps.
6. Sense monitor type
R G B -- 12h,12h,12h : If port 3C2h bit 4 on, color monitor is attached
R G B -- 4,12h,4 : If port 3C2h bit 4 on, mono monitor is attached
else, no monitor is attached.
7. Dual (alternative) monitor test
Set corresponding and relative flags
8. Set CRT mode according to the current flags setting
9. Test vertical retrace signal
Read input status register, if an error occurrs, sound 1 long and 3 short
error beeps.
10. Show ACER copyright
****************************************
* *
****** INTRODUCTION ********
* *
****************************************
A. VIDEO MODE :
1. Text mode
2. Graphics mode
B. DISPLAY MEMORY ORGANIZATION
C. CHARACTER GENERATOR
D. COLOR PALETTE AND COLOR REGISTER
E. GRAPHICS READ AND WRITE MODES
1. Write modes : 0-3
2. Read modes : 0-1
F. VGA REGISTER
1. General or External registers
2. Sequencer registers
3. CRTC registers
4. Graphics registers
5. Attribute registers
G. VGA BIOS DATA AREA
H. VIDEO BIOS SERVICE ROUTINES
************************************
* *
******* TEXT MODES *******
* *
************************************
┌────────────────────────────────────────────────────────────────────────────────┐
│ Mode Type of #Chars Display Page Resolution Buffer │
│ Adapter (X/Y) Char Box Format no. in Pixels │
├────────────────────────────────────────────────────────────────────────────────│
│ 0,1 EGA/VGA 40/25 8 x 8 16/256K 8 320 x 200 B8000 │
├────────────────────────────────────────────────────────────────────────────────│
│ 0*,1* EGA/VGA 40/25 8 x 14 16/256K 8 320 x 350 B8000 │
├────────────────────────────────────────────────────────────────────────────────│
│ 0+,1+ VGA 40/25 8 x 16 16/256K 8 320 x 400 B8000 │
├────────────────────────────────────────────────────────────────────────────────│
│ 2,3 EGA/VGA 80/25 8 x 8 16/256K 8 640 x 200 B8000 │
├────────────────────────────────────────────────────────────────────────────────│
│ 2*,3* EGA/VGA 80/25 8 x 14 16/256K 8 640 x 350 B8000 │
├────────────────────────────────────────────────────────────────────────────────│
│ 2+,3+ VGA 80/25 8 x 16 16/256K 8 640 x 400 B8000 │
├────────────────────────────────────────────────────────────────────────────────│
│ 7 EGA/VGA 80/25 9 x 14 bw 8 720 x 350 B0000 │
├────────────────────────────────────────────────────────────────────────────────│
│ 7+ VGA 80/25 9 x 16 bw 8 720 x 400 B0000 │
└────────────────────────────────────────────────────────────────────────────────┘
Notes:
1. The asterisk (*) in the display mode indicates that the VGA is in a text mode
with 350 vertical lines.
2. The plus (+) in the display mode indicates that the VGA is in a text mode
with 400 vertical lines.
3. Display modes 0 through 6 emulate the Color Graphics Adapter(CGA).
Mode 7 emulates the IBM Monochrome MDA or Hercules Monochrome graphics.
4. The code "bw" stands for black and white or synonymously monochrome.
************************************
* *
******* GRAPHICS MODES *******
* *
************************************
┌─────────────────────────────────────────────────────────────────────────────┐
│ Mode #Chars Display Page Resolution Buffer │
│ (Hex) Adapter (X/Y) Char Box Format no. in Pixels │
├─────────────────────────────────────────────────────────────────────────────│
│ 4,5 EGA/VGA 40/25 8 x 8 4/256K 1 320 x 200 B8000 │
├─────────────────────────────────────────────────────────────────────────────│
│ 6 EGA/VGA 80/25 8 x 8 2/256K 1 640 x 350 B8000 │
├─────────────────────────────────────────────────────────────────────────────│
│ D EGA/VGA 40/25 8 x 8 16/256K 8 320 x 200 A0000 │
├─────────────────────────────────────────────────────────────────────────────│
│ E EGA/VGA 80/25 8 x 8 16/256K 4 640 x 200 A0000 │
├─────────────────────────────────────────────────────────────────────────────│
│ F EGA/VGA 80/25 8 x 14 bw 2 640 x 350 A0000 │
├─────────────────────────────────────────────────────────────────────────────│
│ 10 EGA/VGA 80/25 8 x 14 16/256K 2 640 x 350 A0000 │
├─────────────────────────────────────────────────────────────────────────────│
│ 11 VGA 80/30 8 x 16 2/256K 1 640 x 480 A0000 │
├──────────────────────────────────────────────────────────────────────────── │
│ 12 VGA 80/30 8 x 16 16/256K 1 640 x 480 A0000 │
├─────────────────────────────────────────────────────────────────────────────┤
│ 13 VGA 40/25 8 x 8 256/256K 1 320 x 200 A0000 │
└─────────────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────────┐
│ MODE │
│ (Hex) # of Colors # Bits per Plane Bit Planes Affected Notes │
├────────────────────────────────────────────────────────────────────────┤
│ 4,5 4 2 0,1 1 │
├────────────────────────────────────────────────────────────────────────│
│ 6 2 1 0 2 │
├────────────────────────────────────────────────────────────────────────│
│ D 16 1 0,1,2,3 3 │
├────────────────────────────────────────────────────────────────────────│
│ E 16 1 0,1,2,3 3 │
├────────────────────────────────────────────────────────────────────────│
│ F 4 1 0,2 4 │
├────────────────────────────────────────────────────────────────────────│
│ 10 16 1 0,1,2,3 3 │
├────────────────────────────────────────────────────────────────────────│
│ 11 2 1 0 2 │
├────────────────────────────────────────────────────────────────────────│
│ 12 16 1 0,1,2,3 3 │
├────────────────────────────────────────────────────────────────────────┤
│ 13 256 8 0,1,2 or 3 5 │
└────────────────────────────────────────────────────────────────────────┘
Notes:
1.In modes 4 and 5, alternate bytes of data, each containing four pixels,
are stored in bit plane 0 and bit plane 1. Bit plane 0 contributes to the
low-order bit, and bit plane 1 contributes to the high-order bit of the
two-bit pixel.
2.In modes 6 and 11 hex, each pixel consists of one bit in bit plane 0.
3.In mode D,E,10,12 hex, each pixel corresponds to one bit in each of the
four bit planes. Bit plane 0 contributes to the low-order bit, followed by
bit plane 1, and bit plane 2. Bit plane 3 contributes to the high-order
bit of the four bit pixel.
4.In mode F hex, bit plane 0 contributes to the low-order bit and bit plane
2 contributes the high-order bit of the two bit pixel.
5.In mode 13 hex, all four bit planes are chained together and each pixel
consists of eight bits. The plane in which a pixel resides depends on the
position of the pixel on the display. Each plane holds one-quarter of
the pixels.
************************************
* *
******* CHARACTER FONTS *******
* *
************************************
There are 5 character fonts set supported:
8 by 8 ,8 by 14, 8 by 16, 9 by 14, and 9 by 16.
The 9 by 14 and 9 by 16 character font are referred to as the supplement
character set. It is called supplemental because not all of the 256
characters are provided. Typical characters that are included in the
supplement are quotation marks ("),the plus sign (+), the minus sign (-),
M,T,V,W,X,Y,Z,m,v,w and line-drawing symbols.
************************************
* *
**** CHARACTER ATTRIBUTE ****
* *
************************************
A. MONOCHROME MODE
Mode 7: Monochrome Attributes
──────────────────────────────────────────────────────────────────────────────
Background (bits 6-4) Foreground (bits 2-0) Attribute
──────────────────────────────────────────────────────────────────────────────
0 0 Black
0 1 Underline
0 7 Normal (white on black)
7 0 Reversed (black on white)
7 7 White
Mode 7: Examples of Monochrome Attributes
────────────────────────────────────────────────────────────────────────
Blink Background Intens Foreground Code
(Bit 7) (bits 6-4) (Bit 3) (Bit 2-0) (Hex) Attribute
────────────────────────────────────────────────────────────────────────
0 0 0 1 1 Underline
0 0 1 1 9 Intense Underline
0 7 0 0 70 Reversed
0 7 1 0 74 Intense Reversed
1 7 0 0 F0 Blinking Reversed
1 7 1 0 F1 Intense Blinking Reserved
Mode 7: Palette Registers
───────────────────────────────────────────────────────────────────────
Register # Register Value Register # Register Value
───────────────────────────────────────────────────────────────────────
0 00 8 10
1 08 9 18
2 08 A 18
3 08 B 18
4 08 C 18
5 08 D 18
6 08 E 18
7 08 F 18
B. SIXTEEN-COLOR MODE
Default Colors for a 16-color Palette
────────────────────────────────────────────────
Palette Register (Hex) Color
────────────────────────────────────────────────
0 Black
1 Blue
2 Green
3 Cyan
4 Red
5 Magenta
6 Brown
7 White
8 Gray
9 Light Blue
A Light Green
B Light cyan
C Light red
D Light Magenta
E Light Brown (yellow)
F Bright White
C. ATTRIBUTE BYTE IN THE 16-COLOR MODE
7 6 5 4 3 2 1 0
┌──────────────────────┬──────────────────────┐
│ │ │
└──────────────────────┴──────────────────────┘
Background Foreground
7 6 5 4 3 2 1 0
┌──────────────────────┬────┬─────────────────┐
│ │ │ │
└──────────────────────┴─┼──┴─────────────────┘
Background │ Forground
Font #
7 6 5 4 3 2 1 0
┌───┬──────────────────┬──────────────────────┐
│ │ │ │
└─┼─┴──────────────────┴──────────────────────┘
│ Background Foreground
Blinking
7 6 5 4 3 2 1 0
┌───┬──────────────────┬───┬──────────────────┐
│ │ │ │ │
└─┼─┴──────────────────┴─┼─┴──────────────────┘
│ Background │ Foreground
Blinking Font #
Note:
1. The character attribute byte determines the character color,
blinking status and selects from one of the two character
sets.
Bit 3 of the character attribute byte is used either to select one of
16 foreground colors for the associated character or to choose from one
of two resident character sets.
Bit 7 is selected for dual function; either being part of the
background color code or being a switch for the blinking feature.
2. The default alphanumeric characters are defined by the bit patterns in the
first table in MAP 2, regardless of the value of bit 3 of the attribute
bytes of the characters displayed.
Changing the value in the Character Map Select register, changes the
character definition tables associated with bit 3 of the attribute bytes.
If two different values appear in the bit fields in the Character Map
Select register, the value of bit 3 designates one of the two different character
definition tables.
************************************
* *
******* VGA REGISTERS ******
* *
************************************
General or External Registers
_____________________________________________________________________________
Name Write (Hex) Read (Hex)
Misc. Output 3C2 3CC
Feature Control 3DA/3BA 3CA
Input Status #0 3C2
Input Status #1 3DA/3BA
_____________________________________________________________________________
Sequencer Registers
_____________________________________________________________________________
Name Index R/W Port(Hex)
Address x 3C4
Reset 0 3C5
Clocking Mode 1 3C5
Map Mask 2 3C5
Character Map Select 3 3C5
Memory Mode 4 3C5
_____________________________________________________________________________
Attribute Controller Registers
_____________________________________________________________________________
Name Index R/W Port(Hex)
Address x 3C0
Palette 0-F 3C1
Mode Control 10 3C1
Overscan Color 11 3C1
Color Plane Enable 12 3C1
Horizontal Pixel Panning 13 3C1
Color Select 14 3C1
_____________________________________________________________________________
Graphics Control Registers:
_____________________________________________________________________________
Name Index R/W Port(Hex)
Graphics Address x 3CE
Set/Reset 0 3CF
Enable Set/Reset 1 3CF
Color Compare 2 3CF
Data Rotate 3 3CF
Read Map Select 4 3CF
Mode 5 3CF
Miscellaneous 6 3CF
Color Don't Care 7 3CF
Bit Mask 8 3CF
_____________________________________________________________________________
CRT Controller Registers
_____________________________________________________________________________
Name Index R/W Port(Hex)
Address
Horizontal Total
Horizontal Display End
Start Horizontal Blank
End Horizontal Blank
Start Horizontal Retrace
End Horizontal Retrace
Vertical Total
Overflow
Preset Row Scan
Max Scan Line
Cursor Start
Cursor End
Start Address High
Start Address Low
Cursor Location High
Cursor Location Low
Vertical Retrace Start
Vertical Retrace Low
Vertical Display End
Offset
Underline Location
Start Vertical Blank
End Vertical Blank
Mode Control
Line Compare
_____________________________________________________________________________
************************************
* *
******* MEMORY MAPPING ******
* *
************************************
The video buffer can be configured as the following :
1). A000:0 ------- 128K for mode D,E,F,10,11,12 and 13
2). A000:0 ------- 64K for character generator for text modes
3). B000:0 ------- 32k for mode 7 and 7+
4). B800:0 ------- 32K for text mode 0,1,2,3 and graphics modes 4,5,6
************************************
* *
******* CHARACTER GENERATOR ******
* *
************************************
The character generator consists of the dot patterns that represent each
character in the character set.
The character dot patterns are stored in character boxes, each of which is
32 bytes long.
Bits set to 1 in the character font will be displayed in the foreground color,
and bits reset to 0 will be displayed in the background color.
The display memory consists of four display planes called bit planes, each
being 64K bytes long.
VGA supports eight font tables. Each table consists of 256 32-byte bit patterns,
so the character box height is 32 scan lines. When the displayed character box contains
fewer than 32 lines, the character generator ignores the extra bytes in each character
definition.
The character generator has 8 blocks as shown below:
A000:0 ╔═════════╗ ┌────────────────────┐
║ Font 0 ─╫──────── 0 │ 0 │
2000 ╟─────────║ ├────────────────────│
║ Font 4 ║ 1 │ 1 │
4000 ╠═════════╣ ├────────────────────│ character 0
║ Font 1 ║ │ . │
6000 ╟─────────║ │ . │
║ Font 5 ║ │ . │
8000 ╠═════════╣ ├────────────────────│
║ Font 2 ║ 31 │ 31 │
A000 ╟─────────║ ─────┼────────────────────┼─────────
║ Font 6 ║ 32 │ 0 │
C000 ╠═════════╣ ├────────────────────│
║ Font 3 ║ │ . │ character 1
E000 ╟─────────║ │ . │
║ Font 7 ║ │────────────────────│
╙═════════╝ 63 │ 31 │
─────┼────────────────────┼─────────
64 │ . │
│ . │
│ . │
────┼────────────────────┼──────────
│ 0 │
├────────────────────│
│ │
│ │ character 255
├────────────────────┤
8191 │ 31 │
└────────────────────┘
***************************************************
* *
******* GRAPHICS MODES PIXEL PROGRAMMING ******
* *
***************************************************
A. Relative Registers Accessed:
Graphics Control Registers:
Name Index R/W Port(Hex)
Graphics Address x 3CE
Set/Reset 0 3CF
Enable Set/Reset 1 3CF
Color Compare 2 3CF
Data Rotate 3 3CF
Read Map Select 4 3CF
Mode 5 3CF
Miscellaneous 6 3CF
Color Don't Care 7 3CF
Bit Mask 8 3CF
B. Read/Write Mode
1. Write Mode 0 (EGA/VGA)
2. Write Mode 1 (EGA/VGA)
3. Write Mode 2 (EGA/VGA)
4. Write Mode 3 (VGA Only)
5. Read Mode 0 (EGA/VGA)
6. Read Mode 1 (EGA/VGA)
***************************************
* *
******* PALETTE/COLOR REGISTER ******
* *
***************************************
Palette Utilization
───────────────────────────────────────────────────────────────────────
Display Mode (hex) Number of Colors Palette Register Affected
0,1 16 0-15
2,3 16 0-15
4,5 4 0,1,2,3
6 2 0,1
7 4 0,1,4,5
D 16 0-15
E 16 0-15
F 4 0,1,4,5
10 16 0-15
11 2 0,1
12 16 0-15
13 256 0-15
Mode 7 Palette Defult Values
──────────────────────────────────────────────────────────
Register 0 1 2 3 4 5 6 7 8 9 A B C D E F
Value 0 8 8 8 8 8 8 8 10 18 18 18 18 18 18 18
───────────────────────────────────────────────────────────
Mode F Palette Default Values
──────────────────────────────────────────────────────────
Register 0 1 2 3 4 5 6 7 8 9 A B C D E F
Value 0 8 - - 18 18 - - - - - - - - - -
───────────────────────────────────────────────────────────
Mode 0,1,2,3 Palette Default Values
──────────────────────────────────────────────────────────
Register 0 1 2 3 4 5 6 7 8 9 A B C D E F
Value 0 1 2 3 4 5 14 7 38 39 3A 3B 3C 3D 3E 3F
───────────────────────────────────────────────────────────
CGA-compatible Color Selection
────────────────────────────────────────────────────────────────
ATR 1 ATR 0 Set 1 Set 0 VGA Palette Register
0 0 Background Background 0
0 1 Cyan Green 1
1 0 Magenta Red 2
1 1 White Brown 3
Mode 6 Palette Default Values
──────────────────────────────────────────────────────────
Register 0 1 2 3 4 5 6 7 8 9 A B C D E F
Value 0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17
───────────────────────────────────────────────────────────
Mode 11 Palette Default Values
──────────────────────────────────────────────────────────
Register 0 1 2 3 4 5 6 7 8 9 A B C D E F
Value 0 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
───────────────────────────────────────────────────────────
Mode D,E,10 and 12 Palette Default Values
──────────────────────────────────────────────────────────
Register 0 1 2 3 4 5 6 7 8 9 A B C D E F
Value 0 1 2 3 4 5 14 7 38 39 3A 3B 3C 3D 3E 3F
───────────────────────────────────────────────────────────
Mode 13 Palette Default Values
──────────────────────────────────────────────────────────
Register 0 1 2 3 4 5 6 7 8 9 A B C D E F
Value 0 1 2 3 4 5 6 7 8 9 A B C D E F
───────────────────────────────────────────────────────────
COLOR REGISTERS
The VGA is equipped with 256 Color Registers. A pixel or character in
display memory consists of one to eight bits of data. This data is
used to address the 16 palette registers. The output of these palette
registers is used in conjunction with the data in displaying memory to
address the color registers. The color registers contain the color codes
that are output to the digital-to-analog converters (DAC). The output of
the DAC are sent to the monitor. Each of the color registers consists of
a red, green, and blue component. Each of these color components is six bits
wide.
************************************
* *
******* VGA BIOS CALLS ******
* *
************************************
CONTROL
___________________________________________________________
Mode Set
Select Active Display Page
Select Alternate Print Screen Routine
Video Enable/Disable
Display Switch
Video Screen On/Off
RETURN STATE
___________________________________________________________
Return Curren Video State
Return Video Information
Read/Write Displat Combination Code
Return Functionality/State Information
Save/Restore Video State
INTERACTIVE
___________________________________________________________
Set Cursor Type
Set Cursor Position
Read Cursor Position
Cursor Emulation
TEXT
___________________________________________________________
Scroll Active Page Up
Scroll Active Page Down
Read Character/Attribute
Write Character/Attribute
Write Character Only
Write Teletypewriter to Active Page
Select Scan Lines for Text Modes
Write String
GRAPHICS
___________________________________________________________
Write Dot
Read Dot
PALETTE
___________________________________________________________
Set Color Palette
Set Individual Palette Register
Set Overscan (Boarder) Register
Set All Palette Registers and Overscan
Toggle Intensity/Blinking Bit
Read Individual Palette Register
Read Overscan Resister
Read all Palette Registers and Overscan
Default Palette Loading During Mode Set
COLOR REGISTERS
___________________________________________________________
Set Individual Color Register
Set block of Color Registers
Select Color Page
Read Individual Color Register
Read Block of Color Registers
Read Current Color Page Number
Sum Color Values to Gray Scale
Default Palette Loading During Mode Set
Summing to Gray Scales
CHARACTER GENERATOR
___________________________________________________________
User text Load with Reset
ROM Monochrome Set with Reset
ROM 8x8 Character Set Load with Reset
Set Block Specifier
ROM 8x16 Character Set Load with Reset
User Alpha Load
ROM Monochrome Set
ROM 8x8 Character Set Load
ROM 8x16 Character Set Load
User Graphics Characters INT 1FH (8x8)
User Graphics Characters
Graphics Mode ROM 8x14 Character Set Load
Graphics Mode ROM 8x8 Character Set Load
Graphics Mode ROM 8x16 Character Set Load
Return Character Generator Information