25
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

Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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

Page 2: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Outline®Principle®Video Adapters®Text Mode Programming®Graphic Mode®Line Segment and Circle® INT 21H® INT 10H

Page 3: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Video Buffer

Page 4: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Graphic Adapter

Page 5: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

RAMDAC

Page 6: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Video Card

Page 7: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Video Standard

Page 8: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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

Page 9: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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

Page 10: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Character Box

Page 11: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Text Mode Programming®Video Memory:

High Byte Low Byte

Attribute Byte Character Byte

Page 12: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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

Page 13: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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

Page 14: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Text Mode Programming (4)®Example:®mov ax, b800h®mov es, ax®mov bx, 0®mov [es:bx], 1E41h

Page 15: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Graphic Mode

Page 16: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Graphic Mode (2)

Page 17: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Graphic Mode (3)

Page 18: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Bresenham Algorithm

3 4 5 6 7 8 9 10111213

23456789

10

Page 19: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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)

Page 20: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Bresenham Algorithm (3)

3 4 5 6 7 8 9 10111213

23456789

10

Page 21: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Midpoint Circle Algorithm

3 4 5 6 7 8 9 10111213

23456789

101112

Page 22: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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

Page 23: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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

Page 24: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

Midpoint Circle Algorithm

3 4 5 6 7 8 9 10111213

23456789

101112

Y=X

Page 25: Lecture 3 : Personal Computer Systems II · 2005. 9. 12. · Computer Engineering Lecture 3 : Personal Computer Systems II Video and Video Adapters Professor Ming-Jer Tsai 붲ꧺ귵

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