summaryrefslogtreecommitdiff
path: root/src/drivers/video
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/video')
-rw-r--r--src/drivers/video/vga.c60
-rw-r--r--src/drivers/video/vga.h26
-rw-r--r--src/drivers/video/video.c30
-rw-r--r--src/drivers/video/video.h18
4 files changed, 76 insertions, 58 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 = {
diff --git a/src/drivers/video/vga.h b/src/drivers/video/vga.h
index fed47a1..6934856 100644
--- a/src/drivers/video/vga.h
+++ b/src/drivers/video/vga.h
@@ -53,28 +53,10 @@ void vga_print_info( void *obj );
bool vga_switch_mode( void *obj, const video_mode_t *mode );
-typedef struct {
- int R;
- int G;
- int B;
-} vga_color_t;
-
-extern const vga_color_t VGA_COLOR_BLACK;
-extern const vga_color_t VGA_COLOR_BLUE;
-extern const vga_color_t VGA_COLOR_GREEN;
-extern const vga_color_t VGA_COLOR_CYAN;
-extern const vga_color_t VGA_COLOR_RED;
-extern const vga_color_t VGA_COLOR_MAGENTA;
-extern const vga_color_t VGA_COLOR_BROWN;
-extern const vga_color_t VGA_COLOR_LIGHT_GREY;
-extern const vga_color_t VGA_COLOR_WHITE;
-
-vga_color_t vga_make_RGB( int R, int G, int B );
-
-void vga_set_pixel( vga_t *vga, const int x, const int y, 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 vga_color_t color );
-void vga_clear_screen( vga_t *vga, const vga_color_t color );
-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_set_pixel( vga_t *vga, const int x, const int y, const video_rgb_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 );
+void vga_clear_screen( vga_t *vga, const video_rgb_color_t color );
+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 );
void vga_wait_for_retrace( vga_t *vga );
void vga_use_z_buffer( vga_t *vga, bool use );
void vga_refresh( vga_t *vga );
diff --git a/src/drivers/video/video.c b/src/drivers/video/video.c
index bdadf53..ca57269 100644
--- a/src/drivers/video/video.c
+++ b/src/drivers/video/video.c
@@ -119,3 +119,33 @@ bool video_switch_mode( void *obj, const video_mode_t *mode )
return false;
}
+video_rgb_color_t video_make_rgb_color( const int R, const int G, const int B )
+{
+ video_rgb_color_t c;
+
+ c.R = R;
+ c.G = G;
+ c.B = B;
+
+ return c;
+}
+
+const video_rgb_color_t VIDEO_RGB_COLOR_BLACK = { 0x00, 0x00, 0x00 };
+const video_rgb_color_t VIDEO_RGB_COLOR_BLUE = { 0x00, 0x00, 0xAA };
+const video_rgb_color_t VIDEO_RGB_COLOR_GREEN = { 0x00, 0xAA, 0x00 };
+const video_rgb_color_t VIDEO_RGB_COLOR_CYAN = { 0x00, 0xAA, 0xAA };
+const video_rgb_color_t VIDEO_RGB_COLOR_RED = { 0xAA, 0x00, 0x00 };
+const video_rgb_color_t VIDEO_RGB_COLOR_MAGENTA = { 0xAA, 0x00, 0xAA };
+const video_rgb_color_t VIDEO_RGB_COLOR_BROWN = { 0xAA, 0x55, 0x00 };
+const video_rgb_color_t VIDEO_RGB_COLOR_GRAY = { 0xAA, 0xAA, 0xAA };
+const video_rgb_color_t VIDEO_RGB_COLOR_WHITE = { 0xFF, 0xFF, 0xFF };
+
+/*
+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
+*/
diff --git a/src/drivers/video/video.h b/src/drivers/video/video.h
index d17a51d..6da8e60 100644
--- a/src/drivers/video/video.h
+++ b/src/drivers/video/video.h
@@ -46,4 +46,22 @@ bool video_supports_mode( void *obj, const video_mode_t mode );
bool video_set_mode( void *obj, const video_mode_t mode );
bool video_switch_mode( void *obj, const video_mode_t *mode );
+typedef struct {
+ int R;
+ int G;
+ int B;
+} video_rgb_color_t;
+
+extern const video_rgb_color_t VIDEO_RGB_COLOR_BLACK;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_BLUE;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_GREEN;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_CYAN;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_RED;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_MAGENTA;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_BROWN;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_GRAY;
+extern const video_rgb_color_t VIDEO_RGB_COLOR_WHITE;
+
+video_rgb_color_t video_make_rgb_color( const int R, const int G, const int B );
+
#endif // VIDEO_H