SlideServe
Menu
Préférences
© SlideServe · v2026

VGA Color Registers

kimj avatar
12 diapositives · 195 Views · Jan 01, 2020

Learn how to reprogram a VGA's Digital-to-Analog Converter color-table registers for enhanced color schemes and experiment with 256 simultaneous colors. Understand the format of a color-register, I/O port addresses, and coding techniques using C++. Explore creating different color intensities and building custom color schemes for photorealistic images.

VGA Color Registers - slide 1
01 / 12VGA Color Registers
1 / 17

Télécharger la présentation

VGA Color Registers
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. VGA Color Registers How we can reprogram the Digital-to-Analog Converter’s 256 color-table registers

  2. VGA’s color-innovation • The VGA introduced display-mode 19 • Allowed showing 256 simultaneous colors • Used one byte of VRAM for every pixel • Convenient addressing for programming • Screen-resolution was only 320-by-200 • But SVGA offers improved resolutions: • VESA mode 0x101: 640-by-480 • VESA mode 0x103: 800-by-600

  3. ‘digital’ versus ‘analog’ • MDA and CGA used ‘digital’ cable-signals • VGA introduced ‘analog’ cable-signals • Special hardware needed: DAC controller • Implements a table of 256 color-registers • Supports primary colors: red, green, blue • Supports 64 different intensities per color • So each color-register implements 18-bits

  4. Format of a color-register 17 12 11 6 5 0 I/O port-addresses (for DAC programming): 0x03C8: index-register 0x03C9: data-register for writes 0x03C7: data-register for reads

  5. Data-structure for colors typedef struct { char r, g, b; } rgb_t; rgb_t red = { 63, 0, 0 }; rgb_t green = { 0, 63, 0 }; rgb_t blue = { 0, 0, 63 }; rgb_t white = { 63, 63, 63 };

  6. Writing to a color-register rgb_t color = { 32, 48, 16 ); int index = 15; // example: reprogramming a DAC register outb( index, 0x03C8 ); // select register outb( color.r, 0x3C9 ); // set r-component outb( color.g, 0x3C9 ); // set g-component outb( color.b, 0x3C9 ); // set b-component

  7. Reading a color register rgb_t color; int index = 14; // example: reading a DAC color-register outb( index, 0x3C8 ); // select register color.r = inb( 0x3C7 ); // get r-component color.g = inb( 0x3C7 ); // get g-component color.b = inb( 0x03C7 );// get b-component

  8. Demo: ‘studydac.cpp’ • This is a ‘testbed’ for color experiments • It uses VESA display-mode 0x4101 (i.e., 640-by-480, in 256 simultaneous colors) • It draws a 16-by-16 grid of color-boxes • Each box shows a color-register’s value • Initially we see the ‘default’ color-values • Then the 256 registers are reprogrammed’ • But you can try out different color schemes

  9. An array of color intensities • Each color-component is a 6-bit number • So there are 26 = 64possible intensities • (This applies to each color-component) • So here’s how to build all the cyan-values: rgb_t table[ 64 ]; for (int i = 0; i < 64; i++) { table[i].b = i; table[i].g = i; table[i].r = 0; }

  10. Why do we need to do this? • We will soon study lighting and shadows, in order to create ‘photorealistic’ images • It requires showing varied color-intensity • We’ll want to be sure our hardware can display all intensities a given image needs • We’ll want to arrange needed colors in an array, for conveniently accessing a given color-intensity in terms of its array-index

  11. In-class exercise #1 • Modify the ‘studydac.cpp’ demo-program so that it will simultaneously display: • 32 intensities of blue • 32 intensities of cyan • 32 intensities of green • 32 intensities of magenta • 32 intensities of red • 32 intensities of yellow • 64 intensities of white

  12. In-class exercise #2 • Modify the ‘studydac.cpp’ demo-program so it will simultaneously display intensity-arrays for several ‘pastel’ colors. • You can build these colors by “mixing” a pure color with the color white • For example: pink = ½ red + ½ white