Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
EE103000 Practice of Electrical and Computer Engineering
Lecture 3 : Personal Computer Systems II
Video and Video Adapters
Professor Ming-Jer Tsai 蔡明哲Department of Computer Science
Outline®Principle®Video Adapters®Text Mode Programming®Graphic Mode®Line Segment and Circle® INT 21H® INT 10H
Video Buffer
Graphic Adapter
RAMDAC
Video Card
Video Standard
VGA Graphic Mode® Int 10h (ah=00h)
al pixels colorsbuffer pages start
04h 320*200 4 1 B8000h06h 640*400 2 1 B8000h
0fh 640*350 1 2 A0000h0eh 640*200 16 4 A0000h0dh 320*200 16 8 A0000h
10h 640*350 16 2 A0000h11h 640*480 2 1 A0000h12h 640*480 16 1 A0000h13h 320*200 256 1 A0000h
VGA Text Mode® Int 10h (ah=00h)
al pixels colorsbuffer pages start
01h 360*400 16 8 B8000h
03h 720*400 16 8 B8000h
07h 720*400 1 8 B0000h
Character Box
Text Mode Programming®Video Memory:
High Byte Low Byte
Attribute Byte Character Byte
Text Mode Programming (2)®Attribute Byte:®Blink: 1=blink on, 0=off.®Background: Selects a color from the first
eight colors in the palette.®Foreground: Selects one of the 16 colors in
the palette
7 6 5 4 3 2 1 0
Blink Background Foreground
Text Mode Programming (3)® Color Palette
® 0 — Black 8 — Dark Gray® 1 — Blue 9 — Light Blue® 2 — Green 10 — Light Green® 3 — Cyan 11 — Light Cyan® 4 — Red 12 — Light Red® 5 — Magenta 13 — Light Magenta® 6 — Brown 14 — Yellow® 7 — Light Gray 15 — White
Text Mode Programming (4)®Example:®mov ax, b800h®mov es, ax®mov bx, 0®mov [es:bx], 1E41h
Graphic Mode
Graphic Mode (2)
Graphic Mode (3)
Bresenham Algorithm
3 4 5 6 7 8 9 10111213
23456789
10
Bresenham Algorithm (2)1. ∆X=Xend-Xstart; ∆Y=Yend-Ystart; P=2∆Y-
∆X; X=Xstart; Y=Ystart; Count=∆X.2. Repeat
1) PIXELWR(X,Y);2) WHILE (P>=0) DO {Y=Y+1;P=P-2∆X;}3) X=X+1; P=P+2∆Y;4) Count--;Until (Count==0)
Bresenham Algorithm (3)
3 4 5 6 7 8 9 10111213
23456789
10
Midpoint Circle Algorithm
3 4 5 6 7 8 9 10111213
23456789
101112
Midpoint Circle Algorithm (2)1. X=0; Y=radius; P=1-radius;2. call PLOTPTS(Xcenter, Ycenter, X, Y);3. While (X<Y) DO
1) X=X+1;2) IF (P<0) THEN P=P+2X+1;
ELSE {Y=Y-1; P=P+2(X-Y)+1;}3) call PLOTPTS(Xcenter, Ycenter, X, Y);
Midpoint Circle Algorithm (3)® PLOTPTS(Xcenter, Ycenter, X, Y)
® PIXELWR(Xcenter+X, Ycenter+Y);® PIXELWR(Xcenter-X, Ycenter+Y);® PIXELWR(Xcenter+X, Ycenter-Y);® PIXELWR(Xcenter-X, Ycenter-Y);® PIXELWR(Xcenter+Y, Ycenter+X);® PIXELWR(Xcenter-Y, Ycenter+X);® PIXELWR(Xcenter+Y, Ycenter-X);® PIXELWR(Xcenter-Y, Ycenter-X);
Midpoint Circle Algorithm
3 4 5 6 7 8 9 10111213
23456789
101112
Y=X
INT 10H1. Place the function number in ah.2. Set the other input register.3. Call the function with int 10h.® Example:® mov ah, 00h® mov al, 01h® int 10h