summaryrefslogtreecommitdiff
path: root/src/drivers/video/vga.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-21 17:39:00 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-21 17:39:00 +0200
commitf05524445914e31891ec227520d9bb3fe5857e2c (patch)
tree219f38ac0d3be60dda3613b892b51cae0fee9ec9 /src/drivers/video/vga.c
parente158c4832aa1d5dc8603fb9c33cac3f7cc19abc9 (diff)
downloadabaos-f05524445914e31891ec227520d9bb3fe5857e2c.tar.gz
abaos-f05524445914e31891ec227520d9bb3fe5857e2c.tar.bz2
improved VGA colors
added basics of a desktop widget class
Diffstat (limited to 'src/drivers/video/vga.c')
-rw-r--r--src/drivers/video/vga.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c
index 0d3c49a..5da642a 100644
--- a/src/drivers/video/vga.c
+++ b/src/drivers/video/vga.c
@@ -268,13 +268,32 @@ vga_color_t vga_make_RGB( int R, int G, int B )
return c;
}
-static uint8_t get_color_index( const vga_color_t c )
+const vga_color_t VGA_COLOR_BLACK = { 0x00, 0x00, 0x00 };
+const vga_color_t VGA_COLOR_BLUE = { 0x00, 0x00, 0xAA };
+const vga_color_t VGA_COLOR_GREEN = { 0x00, 0xAA, 0x00 };
+const vga_color_t VGA_COLOR_CYAN = { 0x00, 0xAA, 0xAA };
+const vga_color_t VGA_COLOR_RED = { 0xAA, 0x00, 0x00 };
+const vga_color_t VGA_COLOR_MAGENTA = { 0xAA, 0x00, 0xAA };
+const vga_color_t VGA_COLOR_BROWN = { 0xAA, 0x55, 0x00 };
+const vga_color_t VGA_COLOR_LIGHT_GREY = { 0xAA, 0xAA, 0xAA };
+const vga_color_t VGA_COLOR_WHITE = { 0xFF, 0xFF, 0xFF };
+
+static bool is_same( const vga_color_t c1, const vga_color_t c2 )
{
- // TODO: for now white and black, standard VGA palette entries?
- if( c.R == 0x00 && c.G == 0x00 && c.B == 0x00 ) return 0x00;
- if( c.R == 0x00 && c.G == 0x00 && c.B == 0xA8 ) return 0x01;
- if( c.R == 0xFF && c.G == 0xFF && c.B == 0xFF ) return 0x3F;
+ return c1.R == c2.R && c1.G == c2.G && c1.B == c2.B;
+}
+static uint8_t get_color_index( const vga_color_t c )
+{
+ if( is_same( c, VGA_COLOR_BLACK ) ) return 0x00;
+ if( is_same( c, VGA_COLOR_BLUE ) ) return 0x01;
+ if( is_same( c, VGA_COLOR_GREEN ) ) return 0x02;
+ if( is_same( c, VGA_COLOR_CYAN ) ) return 0x03;
+ if( is_same( c, VGA_COLOR_RED ) ) return 0x04;
+ if( is_same( c, VGA_COLOR_MAGENTA ) ) return 0x05;
+ if( is_same( c, VGA_COLOR_BROWN ) ) return 0x06;
+ if( is_same( c, VGA_COLOR_LIGHT_GREY ) ) return 0x07;
+ if( is_same( c, VGA_COLOR_WHITE ) ) return 0x3F;
return 0x00;
}