Hi, I was writing an extension for my kernel which would change the 16 VGA colors (for 80x25 text mode). I tried following Brackeen's tutorial on 256-color 0x13 mode, because in my old kernel (which I abandoned), I was able to set colors in 80x25 text mode in the exact same way. Now, the thing that goes wrong is that color 0 changes OK, but color 15 doesn't. I haven't tried other colors, but does anyone know how I should implement this correctly? Here's my extension:
Code:
/*
vgacol.h
Custom VGA colors kernel extension
This extension is "always enable". When it is
"disabled" (default ;)), it is only used to make
sure all colors are displayed appropriately on all
VGA screens (BIOS-independent).
Bibliography:
http://www.brackeen.com/vga/basics.html
http://www.brackeen.com/vga/bitmaps.html
*/
#ifndef _VGACOL_H
#define _VGACOL_H
#include <atom/kernel.h>
typedef struct color_struct
{
u8int red;
u8int green;
u8int blue;
} __attribute__ ((packed)) color_t;
color_t colors[16] = {
{1, 1, 1}, /* black */
{1, 1, 32}, /* blue */
{1, 32, 1}, /* green */
{1, 32, 32}, /* cyan */
{32, 1, 1}, /* red */
{32, 1, 32}, /* magenta */
{16, 16, 1}, /* brown */
{32, 32, 32}, /* light gray */
{16, 16, 16}, /* dark gray */
{1, 1, 63}, /* light blue */
{1, 63, 1}, /* light green */
{1, 63, 63}, /* light cyan */
{63, 1, 1}, /* light red */
{63, 1, 63}, /* light magenta */
{63, 63, 1}, /* yellow */
{63, 63, 63} /* white */
};
void vgacol()
{
/* write VGA colors */
while ((inb(0x03DA) & 0x08));
while (!(inb(0x03DA) & 0x08));
int i=0;
for (i=0; i<16; i++)
{
//outb(0x03C8, i);
printdec(colors[i].red); printk(" ");
printdec(colors[i].green); printk(" ");
printdec(colors[i].blue); printk("\n");
outb(0x03C9, colors[i].red);
outb(0x03C9, colors[i].green);
outb(0x03C9, colors[i].blue);
};
while (1);
};
#endif
When I change white and black, only black changes (to magenta) on the screen. The prindec()s print out the palette correctly.
And yes, I know that the palette I put there is exactly the same as VGA's original one, but when I change color 15 I don't see the effect, and that's why I'm asking. Is there something I'm doing wrong?
P.S. changing light red doesn't seem to work either... only color 0 is changing...