From eace3b5f238e5e4eaf4c2ffcbf741616a0d6a25f Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 17 Jun 2017 08:47:07 +0200 Subject: added the most complex VGA mode (640x480x4, only timings for now) added graphics and text mode type parameter to vga_mode_t --- src/drivers/video/vga.c | 34 +++++++++++++++++++++++++++++----- src/drivers/video/vga.h | 8 +++++++- 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c index bb73f1e..0d3c49a 100644 --- a/src/drivers/video/vga.c +++ b/src/drivers/video/vga.c @@ -101,10 +101,11 @@ static void write_registers( vga_t *vga, uint8_t *regs ) port8_write( &vga->attribute_controller_index_port, 0x20 ); } -vga_mode_t vga_make_mode( const int x, const int y, const int color_depth ) +vga_mode_t vga_make_mode( const vga_mode_type_t mode_type, const int x, const int y, const int color_depth ) { vga_mode_t mode; + mode.mode_type = mode_type; mode.x = x; mode.y = y; mode.color_depth = color_depth; @@ -114,7 +115,7 @@ vga_mode_t vga_make_mode( const int x, const int y, const int color_depth ) // from http://files.osdev.org/mirrors/geezer/osd/graphics/modes.c static vga_mode_t modes[] = { - { 640, 480, 4, + { VGA_MODE_TYPE_TEXT, 640, 480, 4, { /* MISC */ 0x67, @@ -135,7 +136,7 @@ static vga_mode_t modes[] = { }, NULL }, - { 320, 200, 8, + { VGA_MODE_TYPE_GRAPHICS, 320, 200, 8, { /* MISC */ 0x63, @@ -155,13 +156,35 @@ static vga_mode_t modes[] = { 0x41, 0x00, 0x0F, 0x00, 0x00 }, NULL + }, + { VGA_MODE_TYPE_GRAPHICS, 640, 480, 4, + { + /* MISC */ + 0xE3, + /* SEQ */ + 0x03, 0x01, 0x08, 0x00, 0x06, + /* CRTC */ + 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, + 0xFF, + /* GC */ + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F, + 0xFF, + /* AC */ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, + 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x01, 0x00, 0x0F, 0x00, 0x00 + }, + NULL } }; bool vga_supports_mode( const vga_mode_t mode ) { for( int i = 0; modes[i].x != 0; i++ ) { - if( mode.x == modes[i].x && + if( mode.mode_type == modes[i].mode_type && + mode.x == modes[i].x && mode.y == modes[i].y && mode.color_depth == modes[i].color_depth ) { return true; @@ -174,7 +197,8 @@ bool vga_supports_mode( const vga_mode_t mode ) static int get_matching_mode_idx( const vga_mode_t mode ) { for( int i = 0; modes[i].x != 0; i++ ) { - if( mode.x == modes[i].x && + if( mode.mode_type == modes[i].mode_type && + mode.x == modes[i].x && mode.y == modes[i].y && mode.color_depth == modes[i].color_depth ) { return i; diff --git a/src/drivers/video/vga.h b/src/drivers/video/vga.h index 8b7ebdc..86897c4 100644 --- a/src/drivers/video/vga.h +++ b/src/drivers/video/vga.h @@ -12,7 +12,13 @@ #define NOF_MODE_REGS 66 +typedef enum { + VGA_MODE_TYPE_TEXT, + VGA_MODE_TYPE_GRAPHICS +} vga_mode_type_t; + typedef struct { + vga_mode_type_t mode_type; int x; int y; int color_depth; @@ -48,7 +54,7 @@ void vga_deactivate( void *obj ); void vga_deinit( void *obj ); void vga_print_info( void *obj ); -vga_mode_t vga_make_mode( const int x, const int y, const int color_depth ); +vga_mode_t vga_make_mode( const vga_mode_type_t mode_type, const int x, const int y, const int color_depth ); bool vga_set_mode( vga_t *vga, const vga_mode_t mode ); bool vga_supports_mode( const vga_mode_t mode ); -- cgit v1.2.3-54-g00ecf