Stephen wrote:
I have some questions:
1. What is VBE?
VBE == VESA Bios Extensions.
It's the stuff in your bios that allows you to use a very high screen resolution in real mode.
2. What is the linear FrameBuffer?
It's telling the VBE code to not map in a small bit at 0xA0000 but instead to map it ALL at some place up high. It allows you to use the entire screen resolution in protected mode after setting it in real mode, without switching back.
3. How many colours are there in 8bpp?
8 bits per pixel, so that gives you 2^8 colors per pixel. Note, they don't all have to be different, you can just assign up to 2^8 colors.
4. How do you find these colours if you have the RGB values?
You can do either way. In 8bpp mode, request the values and transform your RGB to the nearest, or set one of the unused values to your value. In 16+ bits mode you always have a static palette and have to transform your data to that mode stuff, which is usually done by some magic code...
Code: Select all
#ifdef RGB_16_BITS_565
int shift[3] = {0, 5, 11};
int bits[3] = {5, 6, 5};
#else ifdef RGB_16_BITS_555
int shift[3] = {0, 5, 10};
int bits[3] = {5, 5, 5};
#else ifdef RGB_24_BITS || RGB_32_BITS /* identical */
int shift[3] = {0, 8, 16};
int bits[3] = {8, 8, 8};
#else ifdef CANDY_FREAKED_EXAMPLE
int shift[3] = {11, 0, 5};
int bits[3] = {5, 5, 6};
#endif
unsigned int getcolor(int r, int g, int b) {
/* assuming r/g/b each in 8-bits */
int fshift[3] = {8-bits[0], 8-bits[1], 8-bits[2]};
int mask[3] = {(1 << bits[0]) -1, (1 << bits[1]) -1, (1 << bits[1]) -1};
int rbits = ((r >> fshift[0]) & mask[0]) << shift[0];
int gbits = ((g >> fshift[1]) & mask[1]) << shift[1];
int bbits = ((b >> fshift[2]) & mask[2]) << shift[2];
return rbits | gbits | bbits;
}
This code generates a given mix of bits given the RGB values. It works for all but paletted modes.
PD hereby, hope it's of use for you. Non-tested as usual.