summaryrefslogtreecommitdiff
path: root/src/drivers/video/vga.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/video/vga.c')
-rw-r--r--src/drivers/video/vga.c60
1 files changed, 24 insertions, 36 deletions
diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c
index c38bee1..75e96e6 100644
--- a/src/drivers/video/vga.c
+++ b/src/drivers/video/vga.c
@@ -261,44 +261,32 @@ bool vga_switch_mode( void *obj, const video_mode_t *mode )
return true;
}
-vga_color_t vga_make_RGB( int R, int G, int B )
-{
- vga_color_t c;
-
- c.R = R;
- c.G = G;
- c.B = B;
-
- return 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 )
+static bool is_same( const video_rgb_color_t c1, const video_rgb_color_t c2 )
{
return c1.R == c2.R && c1.G == c2.G && c1.B == c2.B;
}
-static uint8_t get_color_index( const vga_color_t c )
+static uint8_t get_color_index( const video_rgb_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;
+ if( is_same( c, VIDEO_RGB_COLOR_BLACK ) ) return 0x00;
+ if( is_same( c, VIDEO_RGB_COLOR_BLUE ) ) return 0x01;
+ if( is_same( c, VIDEO_RGB_COLOR_GREEN ) ) return 0x02;
+ if( is_same( c, VIDEO_RGB_COLOR_CYAN ) ) return 0x03;
+ if( is_same( c, VIDEO_RGB_COLOR_RED ) ) return 0x04;
+ if( is_same( c, VIDEO_RGB_COLOR_MAGENTA ) ) return 0x05;
+ if( is_same( c, VIDEO_RGB_COLOR_BROWN ) ) return 0x06;
+ if( is_same( c, VIDEO_RGB_COLOR_GRAY ) ) return 0x07;
+ if( is_same( c, VIDEO_RGB_COLOR_WHITE ) ) return 0x3F;
return 0x00;
+/*
+0x8 0x38 21,21,21 85,85,85 #555555 dark gray
+0x9 0x39 21,21,63 85,85,255 #5555ff bright blue
+0xA 0x3A 21,63,21 85,255,85 #55ff55 bright green
+0xB 0x3B 21,63,63 85,255,255 #55ffff bright cyan
+0xC 0x3C 63,21,21 255,85,85 #ff5555 bright red
+0xD 0X3D 63,21,63 255,85,255 #ff55ff bright magenta
+0xE 0x3E 63,63,21 255,255,85 #ffff55 yellow
+*/
}
static bool params_ok( vga_t *vga, const int x, const int y )
@@ -310,7 +298,7 @@ static bool params_ok( vga_t *vga, const int x, const int y )
return true;
}
-void vga_set_pixel( vga_t *vga, const int x, const int y, const vga_color_t color )
+void vga_set_pixel( vga_t *vga, const int x, const int y, const video_rgb_color_t color )
{
if( !params_ok( vga, x, y ) ) {
kernel_panic( "Pixel coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
@@ -324,7 +312,7 @@ void vga_set_pixel( vga_t *vga, const int x, const int y, const vga_color_t colo
*addr = color_idx;
}
-void vga_draw_rectangle( vga_t *vga, const int x, const int y, const int w, const int h, const vga_color_t color )
+void vga_draw_rectangle( vga_t *vga, const int x, const int y, const int w, const int h, const video_rgb_color_t color )
{
if( !params_ok( vga, x, y ) ) {
kernel_panic( "Rectangle start coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
@@ -344,13 +332,13 @@ void vga_draw_rectangle( vga_t *vga, const int x, const int y, const int w, cons
}
}
-void vga_clear_screen( vga_t *vga, const vga_color_t color )
+void vga_clear_screen( vga_t *vga, const video_rgb_color_t color )
{
memset( vga->base_addr, get_color_index( color ),
vga->mode->base.x * vga->mode->base.y );
}
-void vga_draw_char( vga_t *vga, const unsigned char c, const int x, const int y, const vga_color_t background, const vga_color_t foreground )
+void vga_draw_char( vga_t *vga, const unsigned char c, const int x, const int y, const video_rgb_color_t background, const video_rgb_color_t foreground )
{
//const struct bitmap_font font = {