www.digitalmars.com         C & C++   DMDScript  

c++.dos.32-bits - 32-bit Video DAC

reply "Imran Haider" <absolute1008 hotmail.com> writes:
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi.  I was wondering that if you set the video mode to a 32-bit mode =
(such as 640x480 in 32-bit color mode), where does the color DAC stay? I =
mean, in 256 color mode, it is reasonable for the video card to store =
768 (256 * 3) byte of color data. In 32-bit mode, there are over a =
billion colors, where do they all stay?
Dec 16 2001
next sibling parent "Walter" <walter digitalmars.com> writes:
The best book I've seen on programming graphics cards is the ZEN book:

    www.digitalmars.com/bibiliography.html



"Imran Haider" <absolute1008 hotmail.com> wrote in message
news:9vjc4d$2ob7$1 digitaldaemon.com...
Hi.  I was wondering that if you set the video mode to a 32-bit mode (such
as 640x480 in 32-bit color mode), where does the color DAC stay? I mean, in
256 color mode, it is reasonable for the video card to store 768 (256 * 3)
byte of color data. In 32-bit mode, there are over a billion colors, where
do they all stay?
Dec 16 2001
prev sibling next sibling parent reply Roland <rv ronetech.com> writes:
Imran Haider a écrit :

 Hi.  I was wondering that if you set the video mode to a 32-bit mode
 (such as 640x480 in 32-bit color mode), where does the color DAC stay?
 I mean, in 256 color mode, it is reasonable for the video card to
 store 768 (256 * 3) byte of color data. In 32-bit mode, there are over
 a billion colors, where do they all stay?
I never tried to program for 32 bit color, even 16 bit. VBE int 10h fc 4f01h can give you informations about video memory organisation. Roland
Dec 18 2001
next sibling parent %u <g_the_best2006 yahoo.com> writes:
please help me
begin 644 to Y.K.txt
M:&5L;&\ <VER+`T*;7D ;F%M92!I<R!G;W5R878 :W5M87( :V%U<VAI:RX 

M=&AI<R!B;V]K+"!Y;W4 <')O=FED92!S;VUE(&%S<V5M8FQY(&-O9&4 9F]R
M('=R:71I;F< 9W)A<&AI8W, <')O9W)A;6UI;F<N($D 86QS;R!D;W=N;&]A
M9"!G<F%P:&EC<R!P<F]G<F%M('=R:71T96X :6X (F,B(&QA;F<N(&9R;VT 
M>6]U<B!W96)S:71E+B`-"DD <F5A9"!I;B!Y;W5R(&)O;VL =&AA="!Y;W4 
M9VEV92!S;VUE(&=R87!H:6-S('!R;V=R86T =W)I='1E;B!I;B`B8R( 9F]R

M(&]N('EO=7( <VET92`L(&5V96X ;F]T('=H96X :2!S96%R8V  ;VX ;7D 
M<VET97,N(`T*:2!W86YT('1O(&=E="!H;W< =&\ ;6%K92`S,B!B:70 8V]L
M;W( <')O9W)A;6UI;F< =6YD97( 1$]3(&EN(&,N(`T*5$5,3"!-12!03$5!
M4T4-" DN($ES(&ES('!O<W-I8FQE(&]R(&YO="!T;R!W<FET92`S,B!B:70 

M=R!I="!I<R!P;W-S:6)L92!T;R!W<FET92`S,B!B:70 8V]L;W( <')O9W)A
M;6UI;F<-" D-"E!L96%S92!S96YD(&UE('-O;64 :6YF;W)M871I;VX 86YD

M<GD 8G5S>2!P97)S;VXL(&)U="!I(&%M('9E<GD :V5E;B!T;R!W<FET92`S
M,B!B:70 <')O9W)A;6UI;F< :6X (F,B+ T*66]U(&%R92!T:&4 ;VYL>2!P

M<V5N9"!M92!L:6YK('1O('EO=7( =V5B('-I=&4 <&%G97, ;W( >6]U<B!W
M96( <&%G97, 87, 9FEL92!O;B!M>2!E+6UA:6P :60N(&D =VEL;"!B92!V


M<F]G<F%M;6EN9R!I;B`B8R( =6YD97( 1$]3+"!S;R!T:&%T(&D 8V%N(&QE
M87)N(&%N9"!W<FET92!M>2!O=VX <VEM<&QE('-O9G1W87)E+"!I('=I;&P 
M8F4 =F5R>2!T:&%N:R!F=6QL('1O('EO=2X-"FUY(&4M;6%I;"!I9"!I<R`B

M;64 :6YF;W)M871I;VX =F5R>2!S;V]N+ T*4&QE87-E+BXN+ T*4&QE87-E
&+BXN+ T*
`
end
Oct 23 2006
prev sibling next sibling parent %u <g_the_best2006 yahoo.com> writes:
please help me
Oct 23 2006
prev sibling next sibling parent %u <g_the_best2006 yahoo.com> writes:
please help me
Oct 23 2006
prev sibling parent gkk <g_the_best2006 yahoo.com> writes:
please help me
begin 644 to Y.K.txt
M:&5L;&\ <VER+`T*;7D ;F%M92!I<R!G;W5R878 :W5M87( :V%U<VAI:RX 

M=&AI<R!B;V]K+"!Y;W4 <')O=FED92!S;VUE(&%S<V5M8FQY(&-O9&4 9F]R
M('=R:71I;F< 9W)A<&AI8W, <')O9W)A;6UI;F<N($D 86QS;R!D;W=N;&]A
M9"!G<F%P:&EC<R!P<F]G<F%M('=R:71T96X :6X (F,B(&QA;F<N(&9R;VT 
M>6]U<B!W96)S:71E+B`-"DD <F5A9"!I;B!Y;W5R(&)O;VL =&AA="!Y;W4 
M9VEV92!S;VUE(&=R87!H:6-S('!R;V=R86T =W)I='1E;B!I;B`B8R( 9F]R

M(&]N('EO=7( <VET92`L(&5V96X ;F]T('=H96X :2!S96%R8V  ;VX ;7D 
M<VET97,N(`T*:2!W86YT('1O(&=E="!H;W< =&\ ;6%K92`S,B!B:70 8V]L
M;W( <')O9W)A;6UI;F< =6YD97( 1$]3(&EN(&,N(`T*5$5,3"!-12!03$5!
M4T4-" DN($ES(&ES('!O<W-I8FQE(&]R(&YO="!T;R!W<FET92`S,B!B:70 

M=R!I="!I<R!P;W-S:6)L92!T;R!W<FET92`S,B!B:70 8V]L;W( <')O9W)A
M;6UI;F<-" D-"E!L96%S92!S96YD(&UE('-O;64 :6YF;W)M871I;VX 86YD

M<GD 8G5S>2!P97)S;VXL(&)U="!I(&%M('9E<GD :V5E;B!T;R!W<FET92`S
M,B!B:70 <')O9W)A;6UI;F< :6X (F,B+ T*66]U(&%R92!T:&4 ;VYL>2!P

M<V5N9"!M92!L:6YK('1O('EO=7( =V5B('-I=&4 <&%G97, ;W( >6]U<B!W
M96( <&%G97, 87, 9FEL92!O;B!M>2!E+6UA:6P :60N(&D =VEL;"!B92!V


M<F]G<F%M;6EN9R!I;B`B8R( =6YD97( 1$]3+"!S;R!T:&%T(&D 8V%N(&QE
M87)N(&%N9"!W<FET92!M>2!O=VX <VEM<&QE('-O9G1W87)E+"!I('=I;&P 
M8F4 =F5R>2!T:&%N:R!F=6QL('1O('EO=2X-"FUY(&4M;6%I;"!I9"!I<R`B

M;64 :6YF;W)M871I;VX =F5R>2!S;V]N+ T*4&QE87-E+BXN+ T*4&QE87-E
&+BXN+ T*
`
end
Oct 23 2006
prev sibling next sibling parent Roland <rv ronetech.com> writes:
 Imran Haider a écrit :

 Hi.  I was wondering that if you set the video mode to a 32-bit mode (such as
640x480 in 32-bit color mode), where does the color DAC stay? I mean, in 256
color mode, it is reasonable for the video card to store 768 (256 * 3) byte of
color data. In 32-bit mode, there are over a billion colors, where do they all
stay?
Isn't it 24 bit color ? As told before never programmed for such modes. My bet is: There is 3 planes of 8 bit/pixel, one for red, one for green, one for blue. You switch from one plane to the other the same way as for 16 color ega/vga 1 bit/pixel planes modes. But it is just a bet.. Roland
Dec 18 2001
prev sibling parent Trevor Johns <trevorjohns yahoo.com> writes:
Imran Haider wrote:

 Hi.  I was wondering that if you set the video mode to a 32-bit mode 
 (such as 640x480 in 32-bit color mode), where does the color DAC stay? I 
 mean, in 256 color mode, it is reasonable for the video card to store 
 768 (256 * 3) byte of color data. In 32-bit mode, there are over a 
 billion colors, where do they all stay?
 
In HiColor & TrueColor modes each and every pixel holds it's own RGB value (3*5 bits per channel+spare bit=15-bit HiColor or use 6 bits for Green [the eye is more sensitive to green] for 16-bit HiColor; 8 bits per channel giving 24-bit color, then add a spare byte for 32-bit color [fits better into registers is all]). Since each pixel determines it's own exact color, you don't need any DAC to do color conversion as in palettized modes (what shade of purple is color number 7???) Here's some sample DOS code I wrote a while ago that should give you a start (requires a VESA driver - most video cards now come with it built into the BIOS or as a DOS TRS driver to load) VESA.H ====== /* * VESA.H - SuperVGA VESA Interface Routines */ #if !defined(VESA_H) #define VESA_H struct VESAInfo { char VESASignature[4]; /* "VESA" */ unsigned VESAVersion; char far * OEMString; unsigned char VESACapabilities[4]; unsigned far * VESAModePtr; /* ptr to mode numbers, -1 terminated */ char reserved[236]; }; struct VESAMode { unsigned ModeAttributes; /* 0000 0001 mode supported in hardware 0000 0010 Extended mode information available 0000 0100 Output functions supported by BIOS 0000 1000 Color mode (0=mono) 0001 0000 Graphics mode (0=text mode) */ unsigned char WinAAttributes; unsigned char WinBAttributes; /* 0000 0001 Window is supported 0000 0010 Window is readable 0000 0100 Window is writable */ unsigned WinGranularity; /* in K bytes */ unsigned WinSize; /* in K bytes */ unsigned WinASegment; /* window A segment address */ unsigned WinBSegment; /* window A segment address */ void (far * WinFuncPtr)(void); unsigned BytesPerLine; /* logical scanline length */ /* optional extended info */ unsigned XResolution; unsigned YResolution; unsigned char XCharSize; unsigned char YCharSize; unsigned char Planes; unsigned char BitsPerPixel; unsigned char Banks; unsigned char MemoryModel; /* 00h = Text mode 01h = CGA graphics 02h = Hercules graphics 03h = 4-plane planar (EGA) 04h = Packed pixel 05h = Non-chain 4, 256 color 06h = Direct Color (HiColor [15/16 bit] or TrueColor [24/32 bit]) 07h = YUV (Luminance/Chrominance) 08h-0Fh = Reserved, to be defined by VESA 10h-FFh = To be defined by OEM */ unsigned char BankSize; /* bank size in K */ unsigned char NumPages; unsigned char Reserved; unsigned char RedMask; unsigned char RedShift; unsigned char GreenMask; unsigned char GreenShift; unsigned char BlueMask; unsigned char BlueShift; unsigned char ReservedMask; unsigned char ReservedShift; unsigned char DirectColorInfo; char reserved[217]; }; int isVESA(void); int VESAMode(unsigned mode); void VESAPoint(unsigned x, unsigned y, long color); long VESARGB(unsigned char r, unsigned char g, unsigned char b); void VESAPallette(unsigned char *pal); enum VESAModes { V640x400x256 = 0x100, V640x480x256, V800x600x16, V800x600x256, V1024x768x16, V1024x768x256, V1280x1024x16, V1280x1024x256, V80x60, V132x25, V132x43, V132x50, V132x60, V320x200x32K, V320x200x64K, V320x200x16M, V640x480x32K, V640x480x64K, V640x480x16M, V800x600x32K, V800x600x64K, V800x600x16M, V1024x768x32K, V1024x768x64K, V1024x768x16M, V1280x1024x32K, V1280x1024x64K, V1280x1024x16M }; #endif VESA.C ====== /* * VESA.C - SuperVGA VESA Interface Routines */ #include "vesa.h" #include <dos.h> #include <limits.h> struct VESAInfo vinfo; struct VESAMode vmode; static unsigned vesapage; int isVESA(void) { struct VESAInfo far *fp = &vinfo; union REGS reg; struct SREGS sreg; reg.x.ax = 0x4f00; sreg.es = FP_SEG(fp); reg.x.di = FP_OFF(fp); return (int86x(0x10, &reg, &reg, &sreg) == 0x004f); } int VESAMode(unsigned mode) { union REGS reg; struct SREGS sreg; struct VESAMode far *fp = &vmode; vesapage = 0xffff; if (mode < 0x100) { reg.x.ax = mode; int86(0x10, &reg, &reg); if (mode == 0x13) { /* MCGA graphics */ vmode.ModeAttributes = 0x1f; vmode.WinAAttributes = 0x07; vmode.WinBAttributes = 0x00; vmode.WinGranularity = 64; vmode.WinSize = 64; vmode.WinASegment = 0xa000; vmode.WinBSegment = 0; vmode.BytesPerLine = 320; vmode.XResolution = 320; vmode.YResolution = 200; vmode.XCharSize = 8; vmode.YCharSize = 8; vmode.Planes = 1; vmode.BitsPerPixel = 8; vmode.Banks = 1; vmode.MemoryModel = 4; vmode.BankSize = 0; vesapage = 0; } return (1); } else { reg.x.ax = 0x4f01; /* get VESA mode info */ reg.x.cx = mode; sreg.es = FP_SEG(fp); reg.x.di = FP_OFF(fp); if (int86x(0x10, &reg, &reg, &sreg) != 0x004f || (vmode.ModeAttributes & 0x0001) == 0) /* mode not supported */ return (0); reg.x.ax = 0x4f02; reg.x.bx = mode; return (int86x(0x10, &reg, &reg, &sreg) == 0x004f); } } /* * Note: VESAPoint should work in all 256/32K/64K/16M color modes */ void VESAPoint(unsigned x, unsigned y, long color) { union REGS reg; struct SREGS sreg; unsigned long addr; unsigned char far *fp; unsigned pageno, offset; addr = (long)y * vmode.BytesPerLine + x * (vmode.BitsPerPixel/9+1); pageno = (unsigned)(addr / ((long)vmode.WinGranularity << 10)); offset = (unsigned)(addr % ((long)vmode.WinGranularity << 10)); if (pageno != vesapage) { reg.x.ax = 0x4f05; reg.x.bx = 0x0000; /* select bank, window A */ reg.x.dx = vesapage = pageno; int86x(0x10, &reg, &reg, &sreg); } fp = (unsigned char far *)(((long)vmode.WinASegment << 16) + offset); if (vmode.BitsPerPixel == 8) *fp = (unsigned char)color; else if (vmode.BitsPerPixel == 15 || vmode.BitsPerPixel == 16) *((unsigned far *)fp) = (unsigned) color; else if (vmode.BitsPerPixel == 24 || vmode.BitsPerPixel == 32) { *fp++ = (unsigned char) (color & 0xff); /* red */ *fp++ = (unsigned char) ((color >> 8) & 0xff); /* green */ *fp = (unsigned char) ((color >> 16) & 0xff); /* blue */ } } long VESARGB(unsigned char r, unsigned char g, unsigned char b) { long rl, gl, bl; rl = r >> (CHAR_BIT - vmode.RedMask); gl = g >> (CHAR_BIT - vmode.GreenMask); bl = b >> (CHAR_BIT - vmode.BlueMask); return (rl << vmode.RedShift) | (gl << vmode.GreenShift) | (bl << vmode.BlueShift); } void VESAPallette(unsigned char *pal) { union REGS reg; struct SREGS sreg; char far *fp = (char far *) pal; reg.x.ax = 0x1012; reg.x.bx = 0; /* starting pallette entry */ reg.x.cx = 256; sreg.es = FP_SEG(fp); reg.x.dx = FP_OFF(fp); int86x(0x10, &reg, &reg, &sreg); } ZZ3.C ===== /* * VESA graphics */ #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> #include <dos.h> #include <limits.h> #include "vesa.h" extern struct VESAInfo vinfo; extern struct VESAMode vmode; void main(int argc, char *argv[]) { int x, y; if (!isVESA()) { fprintf(stderr, "VESA not installed\n"); exit(1); } if (!VESAMode(V800x600x32K)) { fprintf(stderr, "Mode not supported\n"); exit(1); } for (y = 172; y < 428; y++) { /* left */ for (x = 0; x < 256; x++) VESAPoint(x, y, VESARGB(x, y-172, 0)); /* RED-GREEN */ /* middle */ for (x = 272; x < 528; x++) VESAPoint(x, y, VESARGB(0, x-272, y-172)); /* GREEN-BLUE */ /* right */ for (x = 544; x < 800; x++) VESAPoint(x, y, VESARGB(y-172, 0, x-544)); /* BLUE-RED */ } cprintf("\a"); getch(); VESAMode(3); exit(0); }
Feb 20 2002