Mail Archives: djgpp/1997/10/21/23:01:50
John Patton writes:
>So, what you're saying is,I'm limited to 64 shades of gray by the way
>Allegro handles the color hardware? I thought it was possible to have
>256 different colors by updating the color DACs with the appropriate
>color values?
This is nothing to do with Allegro: it is the way the VGA hardware
works. The hardware palette registers (port 0x3C8 and 0x3C9) only use 6
bits of color, and ignore the top two bits (so 0=64=128=196, the colors
will wrap and start counting up again from zero if you use intensities
greater than 63).
This is also generally true for SVGA cards, because they are built on
top of the standard VGA register set. There is a VESA function (0x4F08)
for selecting an 8 bit DAC mode, but it is only supported on some
graphics cards so I don't use it. If you really need this and don't care
about your code working on all hardware, you could try calling this
yourself after you set an Allegro video mode, as long as you are sure
that Allegro is using one of the VESA drivers...
>I also thought you could choose between a total of 262,000+ (IOW 2^18)
>different colors in 256-color mode, you were only able to use 256
>distinct colors because the 8-bit value is an offset into the VGA
>palette array, of which I thought held a value corresponding to the
>desired color.
That is exactly how it works: you are 100% correct. But just stop and
think through your math for a minute! 262144 = 2^18 = 2^(6+6+6). That
means 6 bits each for the red, green, and blue components of the color.
If you make it a greyscale palette by having all these set to the same
value, you only have an effective 6 bits of resolution, which gives 2^6
= 64 colors.
>One last thought: Does this mean Allegro loads a palette into the DACs
>that connot be changed?
What do you mean? Of course the DAC can be changed: that is what the
set_palette() function does...
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -