summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/video/vga.c235
-rw-r--r--src/drivers/video/vga.h23
-rw-r--r--src/drivers/video/video.c75
-rw-r--r--src/drivers/video/video.h29
-rw-r--r--src/gui/desktop.c4
-rw-r--r--src/gui/window.c8
-rw-r--r--src/kernel/kernel.c10
7 files changed, 223 insertions, 161 deletions
diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c
index 094a117..c38bee1 100644
--- a/src/drivers/video/vga.c
+++ b/src/drivers/video/vga.c
@@ -11,10 +11,83 @@
static vga_vtable_t const vga_vtable = {
{
- vga_activate,
- vga_deactivate,
- vga_deinit,
- vga_print_info
+ {
+ vga_activate,
+ vga_deactivate,
+ vga_deinit,
+ vga_print_info
+ },
+ video_register_mode,
+ video_supports_mode,
+ video_set_mode,
+ vga_switch_mode
+ }
+};
+
+// from http://files.osdev.org/mirrors/geezer/osd/graphics/modes.c
+static vga_mode_t modes[] = {
+ { { VIDEO_MODE_TYPE_TEXT, 640, 480, 4 },
+ {
+ /* MISC */
+ 0x67,
+ /* SEQ */
+ 0x03, 0x00, 0x03, 0x00, 0x02,
+ /* CRTC */
+ 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F,
+ 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x50,
+ 0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
+ 0xFF,
+ /* GC */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00,
+ 0xFF,
+ /* AC */
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+ 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
+ 0x0C, 0x00, 0x0F, 0x08, 0x00
+ },
+ NULL
+ },
+ { { VIDEO_MODE_TYPE_GRAPHICS, 320, 200, 8 },
+ {
+ /* MISC */
+ 0x63,
+ /* SEQ */
+ 0x03, 0x01, 0x0F, 0x00, 0x0E,
+ /* CRTC */
+ 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F,
+ 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3,
+ 0xFF,
+ /* GC */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+ 0xFF,
+ /* AC */
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x41, 0x00, 0x0F, 0x00, 0x00
+ },
+ NULL
+ },
+ { { VIDEO_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
}
};
@@ -22,7 +95,7 @@ void vga_init( vga_t *vga, interrupt_t *interrupt, void *context )
{
memset( vga, 0, sizeof( vga_t ) );
- driver_init( (driver_t *)vga, DRIVER_TYPE_VIDEO, interrupt, context );
+ video_init( (video_t *)vga, interrupt, context );
port8_init( &vga->misc_port, 0x3C2 );
port8_init( &vga->crtc_index_port, 0x3D4 );
@@ -37,6 +110,11 @@ void vga_init( vga_t *vga, interrupt_t *interrupt, void *context )
port8_init( &vga->attribute_controller_reset_port, 0x3DA );
((driver_t *)vga)->vtable = (driver_vtable_t *)&vga_vtable;
+
+ // register modes
+ for( int i = 0; modes[i].base.x != 0; i++ ) {
+ ((video_vtable_t *)(vga->base.base.vtable))->register_mode( vga, (const video_mode_t *)&modes[i] );
+ }
}
void vga_activate( void *obj )
@@ -106,113 +184,7 @@ static void write_registers( vga_t *vga, uint8_t *regs )
(void)port8_read( &vga->attribute_controller_reset_port );
port8_write( &vga->attribute_controller_index_port, 0x20 );
}
-
-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;
-
- return mode;
-}
-// from http://files.osdev.org/mirrors/geezer/osd/graphics/modes.c
-static vga_mode_t modes[] = {
- { VGA_MODE_TYPE_TEXT, 640, 480, 4,
- {
- /* MISC */
- 0x67,
- /* SEQ */
- 0x03, 0x00, 0x03, 0x00, 0x02,
- /* CRTC */
- 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F,
- 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x50,
- 0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
- 0xFF,
- /* GC */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00,
- 0xFF,
- /* AC */
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
- 0x0C, 0x00, 0x0F, 0x08, 0x00
- },
- NULL
- },
- { VGA_MODE_TYPE_GRAPHICS, 320, 200, 8,
- {
- /* MISC */
- 0x63,
- /* SEQ */
- 0x03, 0x01, 0x0F, 0x00, 0x0E,
- /* CRTC */
- 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F,
- 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3,
- 0xFF,
- /* GC */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
- 0xFF,
- /* AC */
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 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.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;
- }
- }
-
- return false;
-}
-
-static int get_matching_mode_idx( const vga_mode_t mode )
-{
- for( int i = 0; modes[i].x != 0; i++ ) {
- 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;
- }
- }
-
- return -1;
-}
static uint8_t *get_frame_buffer_segment( vga_t *vga )
{
@@ -273,27 +245,22 @@ static size_t get_frame_buffer_segment_size( vga_t *vga )
return segment_size;
}
-bool vga_set_mode( vga_t *vga, const vga_mode_t mode )
+bool vga_switch_mode( void *obj, const video_mode_t *mode )
{
- // do not allow unknown timings!
- if( !vga_supports_mode( mode ) ) {
- return false;
- }
-
- vga_mode_t matching_mode = modes[get_matching_mode_idx( mode )];
+ vga_t *vga = (vga_t *)obj;
+ vga_mode_t *vga_mode = (vga_mode_t *)mode;
- write_registers( vga, matching_mode.regs );
+ write_registers( vga, vga_mode->regs );
- vga->mode = mode;
- vga->mode.segment = get_frame_buffer_segment( vga );
- vga->mode.segment_size = get_frame_buffer_segment_size( vga );
+ vga->mode = (vga_mode_t *)mode;
+ vga->mode->segment = get_frame_buffer_segment( vga );
+ vga->mode->segment_size = get_frame_buffer_segment_size( vga );
vga_use_z_buffer( vga, false );
return true;
}
-
vga_color_t vga_make_RGB( int R, int G, int B )
{
vga_color_t c;
@@ -336,7 +303,7 @@ static uint8_t get_color_index( const vga_color_t c )
static bool params_ok( vga_t *vga, const int x, const int y )
{
- if( x < 0 || x > vga->mode.x || y < 0 || y > vga->mode.y ) {
+ if( x < 0 || x > vga->mode->base.x || y < 0 || y > vga->mode->base.y ) {
return false;
}
@@ -347,12 +314,12 @@ void vga_set_pixel( vga_t *vga, const int x, const int y, const vga_color_t colo
{
if( !params_ok( vga, x, y ) ) {
kernel_panic( "Pixel coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
- x, y, vga->mode.x, vga->mode.y );
+ x, y, vga->mode->base.x, vga->mode->base.y );
}
uint8_t color_idx = get_color_index( color );
- uint8_t *addr = vga->base_addr + vga->mode.x * y + x;
+ uint8_t *addr = vga->base_addr + vga->mode->base.x * y + x;
*addr = color_idx;
}
@@ -361,18 +328,18 @@ void vga_draw_rectangle( vga_t *vga, const int x, const int y, const int w, cons
{
if( !params_ok( vga, x, y ) ) {
kernel_panic( "Rectangle start coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
- x, y, vga->mode.x, vga->mode.y );
+ x, y, vga->mode->base.x, vga->mode->base.y );
}
if( !params_ok( vga, x + w, y + h ) ) {
kernel_panic( "Rectangle end coordinates are out of bounds: (%d, %d), resolution is only (%d, %d)",
- x + w, y + h, vga->mode.x, vga->mode.y );
+ x + w, y + h, vga->mode->base.x, vga->mode->base.y );
}
uint8_t color_idx = get_color_index( color );
for( int yy = y; yy < y + h; yy++ ) {
- uint8_t *addr = vga->base_addr + vga->mode.x * yy + x;
+ uint8_t *addr = vga->base_addr + vga->mode->base.x * yy + x;
memset( addr, color_idx, w );
}
}
@@ -380,7 +347,7 @@ 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 )
{
memset( vga->base_addr, get_color_index( color ),
- vga->mode.x * vga->mode.y );
+ 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 )
@@ -412,7 +379,7 @@ void vga_draw_char( vga_t *vga, const unsigned char c, const int x, const int y,
data[vga_font.Width-1-xx] = fg_color_idx;
}
}
- uint8_t *addr = vga->base_addr + vga->mode.x * ( y + yy ) + x;
+ uint8_t *addr = vga->base_addr + vga->mode->base.x * ( y + yy ) + x;
memcpy( addr, data, vga_font.Width );
}
}
@@ -432,14 +399,14 @@ void vga_use_z_buffer( vga_t *vga, bool use )
vga->use_z_buffer = use;
if( vga->use_z_buffer ) {
- vga->zbuffer = (uint8_t *)malloc( vga->mode.segment_size );
+ vga->zbuffer = (uint8_t *)malloc( vga->mode->segment_size );
vga->base_addr = &vga->zbuffer[0];
} else {
if( vga->zbuffer != NULL ) {
free( vga->zbuffer );
vga->zbuffer = NULL;
}
- vga->base_addr = vga->mode.segment;
+ vga->base_addr = vga->mode->segment;
}
}
@@ -447,7 +414,7 @@ void vga_refresh( vga_t *vga )
{
if( vga->use_z_buffer ) {
vga_wait_for_retrace( vga );
- memcpy( vga->mode.segment, vga->zbuffer, vga->mode.segment_size );
+ memcpy( vga->mode->segment, vga->zbuffer, vga->mode->segment_size );
}
}
diff --git a/src/drivers/video/vga.h b/src/drivers/video/vga.h
index 600180a..fed47a1 100644
--- a/src/drivers/video/vga.h
+++ b/src/drivers/video/vga.h
@@ -9,28 +9,19 @@
#include "interrupts.h"
#include "port.h"
-#include "driver.h"
+#include "video.h"
#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;
+ video_mode_t base;
uint8_t regs[NOF_MODE_REGS];
uint8_t *segment;
size_t segment_size;
} vga_mode_t;
typedef struct {
- driver_t base;
- interrupt_t *interrupts;
+ video_t base;
port8_t misc_port;
port8_t crtc_index_port;
port8_t crtc_data_port;
@@ -42,7 +33,7 @@ typedef struct {
port8_t attribute_controller_read_port;
port8_t attribute_controller_write_port;
port8_t attribute_controller_reset_port;
- vga_mode_t mode;
+ vga_mode_t *mode;
bool use_z_buffer;
uint8_t *zbuffer;
// stores either the address to the beginning of the segment
@@ -51,7 +42,7 @@ typedef struct {
} vga_t;
typedef struct {
- driver_vtable_t base;
+ video_vtable_t base;
} vga_vtable_t;
void vga_init( vga_t *vga, interrupt_t *interrupt, void *context );
@@ -60,9 +51,7 @@ void vga_deactivate( void *obj );
void vga_deinit( void *obj );
void vga_print_info( void *obj );
-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 );
+bool vga_switch_mode( void *obj, const video_mode_t *mode );
typedef struct {
int R;
diff --git a/src/drivers/video/video.c b/src/drivers/video/video.c
index eb12272..7e062a5 100644
--- a/src/drivers/video/video.c
+++ b/src/drivers/video/video.c
@@ -20,6 +20,8 @@ void video_init( video_t *video, interrupt_t *interrupt, void *context )
driver_init( (driver_t *)video, DRIVER_TYPE_VIDEO, interrupt, context );
+ video->nof_modes = 0;
+
((driver_t *)video)->vtable = (driver_vtable_t *)&video_vtable;
}
@@ -42,3 +44,76 @@ void video_print_info( void *obj )
{
kernel_panic( "Printing info of generic video driver should not be called directly." );
}
+
+video_mode_t video_make_mode( const video_mode_type_t mode_type, const int x, const int y, const int color_depth )
+{
+ video_mode_t mode;
+
+ mode.mode_type = mode_type;
+ mode.x = x;
+ mode.y = y;
+ mode.color_depth = color_depth;
+
+ return mode;
+}
+
+void video_register_mode( void *obj, const video_mode_t *mode )
+{
+ video_t *video = (video_t *)obj;
+
+ if( video->nof_modes >= MAX_NOF_VIDEO_MODES ) {
+ kernel_panic( "Trying to register too many video modes, see MAX_NOF_VIDEO_MODES: %d", MAX_NOF_VIDEO_MODES );
+ }
+
+ video->modes[video->nof_modes++] = mode;
+}
+
+static int get_matching_mode_idx( video_t *video, const video_mode_t mode )
+{
+ for( int i = 0; video->modes[i]->x != 0; i++ ) {
+ if( mode.mode_type == video->modes[i]->mode_type &&
+ mode.x == video->modes[i]->x &&
+ mode.y == video->modes[i]->y &&
+ mode.color_depth == video->modes[i]->color_depth ) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+bool video_supports_mode( void *obj, const video_mode_t mode )
+{
+ video_t *video = (video_t *)obj;
+
+ for( int i = 0; video->modes[i]->x != 0; i++ ) {
+ if( mode.mode_type == video->modes[i]->mode_type &&
+ mode.x == video->modes[i]->x &&
+ mode.y == video->modes[i]->y &&
+ mode.color_depth == video->modes[i]->color_depth ) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool video_set_mode( void *obj, const video_mode_t mode )
+{
+ video_t *video = (video_t *)obj;
+
+ // do not allow unknown timings!
+ if( !((video_vtable_t *)(video->base.vtable))->supports_mode( obj, mode ) ) {
+ return false;
+ }
+
+ const video_mode_t *matching_mode = video->modes[get_matching_mode_idx( video, mode )];
+
+ return ((video_vtable_t *)(video->base.vtable))->switch_mode( obj, matching_mode );
+}
+
+bool video_switch_mode( void *obj, const video_mode_t *mode )
+{
+ kernel_panic( "Switching mode function of abstract video driver should not be called directly." );
+}
+
diff --git a/src/drivers/video/video.h b/src/drivers/video/video.h
index 713aa4f..d17a51d 100644
--- a/src/drivers/video/video.h
+++ b/src/drivers/video/video.h
@@ -3,12 +3,34 @@
#include "driver.h"
+#include <stdbool.h>
+
+typedef enum {
+ VIDEO_MODE_TYPE_TEXT,
+ VIDEO_MODE_TYPE_GRAPHICS
+} video_mode_type_t;
+
+#define MAX_NOF_VIDEO_MODES 255
+
+typedef struct {
+ video_mode_type_t mode_type;
+ int x;
+ int y;
+ int color_depth;
+} video_mode_t;
+
typedef struct {
driver_t base;
+ unsigned int nof_modes;
+ const video_mode_t *modes[MAX_NOF_VIDEO_MODES];
} video_t;
typedef struct {
driver_vtable_t base;
+ void (*register_mode)( void *obj, const video_mode_t *mode );
+ bool (*supports_mode)( void *obj, const video_mode_t mode );
+ bool (*set_mode)( void *obj, const video_mode_t mode );
+ bool (*switch_mode)( void *obj, const video_mode_t *mode );
} video_vtable_t;
void video_init( video_t *video, interrupt_t *interrupt, void *context );
@@ -17,4 +39,11 @@ void video_deactivate( void *obj );
void video_deinit( void *obj );
void video_print_info( void *obj );
+video_mode_t video_make_mode( const video_mode_type_t mode_type, const int x, const int y, const int color_depth );
+
+void video_register_mode( void *obj, const video_mode_t *mode );
+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 );
+
#endif // VIDEO_H
diff --git a/src/gui/desktop.c b/src/gui/desktop.c
index 9851b78..e0cb69b 100644
--- a/src/gui/desktop.c
+++ b/src/gui/desktop.c
@@ -49,13 +49,13 @@ void desktop_draw( void *obj, graphics_context_t *context )
if( desktop->mouse_x > i ) {
vga_set_pixel( context, desktop->mouse_x - i, desktop->mouse_y, VGA_COLOR_WHITE );
}
- if( desktop->mouse_x < context->mode.x - i ) {
+ if( desktop->mouse_x < context->mode->base.x - i ) {
vga_set_pixel( context, desktop->mouse_x + i, desktop->mouse_y, VGA_COLOR_WHITE );
}
if( desktop->mouse_y > i ) {
vga_set_pixel( context, desktop->mouse_x, desktop->mouse_y - i, VGA_COLOR_WHITE );
}
- if( desktop->mouse_y < context->mode.y - i ) {
+ if( desktop->mouse_y < context->mode->base.y - i ) {
vga_set_pixel( context, desktop->mouse_x, desktop->mouse_y + i, VGA_COLOR_WHITE );
}
}
diff --git a/src/gui/window.c b/src/gui/window.c
index fd53920..681c3b7 100644
--- a/src/gui/window.c
+++ b/src/gui/window.c
@@ -39,14 +39,14 @@ void window_draw( void *obj, graphics_context_t *context )
if( ((widget_t *)widget)->x < 0 ) {
((widget_t *)widget)->x = 0;
}
- if( ((widget_t *)widget)->x > context->mode.x - ((widget_t *)widget)->w ) {
- ((widget_t *)widget)->x = context->mode.x - ((widget_t *)widget)->w;
+ if( ((widget_t *)widget)->x > context->mode->base.x - ((widget_t *)widget)->w ) {
+ ((widget_t *)widget)->x = context->mode->base.x - ((widget_t *)widget)->w;
}
if( ((widget_t *)widget)->y < 0 ) {
((widget_t *)widget)->y = 0;
}
- if( ((widget_t *)widget)->y > context->mode.y - ((widget_t *)widget)->h ) {
- ((widget_t *)widget)->y = context->mode.y - ((widget_t *)widget)->h;
+ if( ((widget_t *)widget)->y > context->mode->base.y - ((widget_t *)widget)->h ) {
+ ((widget_t *)widget)->y = context->mode->base.y - ((widget_t *)widget)->h;
}
composite_widget_draw( obj, context );
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index 4f68f18..102fb69 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -348,7 +348,8 @@ static void switch_to_graphics_mode( global_context_t *global_context )
mouse_t *mouse = global_context->mouse;
desktop_t *desktop = &global_context->desktop;
- if( vga_set_mode( vga, vga_make_mode( VGA_MODE_TYPE_GRAPHICS, 320, 200, 8 ) ) ) {
+ video_mode_t mode = video_make_mode( VIDEO_MODE_TYPE_GRAPHICS, 320, 200, 8 );
+ if( ((video_vtable_t *)(vga->base.base.vtable))->set_mode( vga, mode ) ) {
vga_text_save( vga_text );
desktop_init( desktop, 320, 200, VGA_COLOR_BLUE );
@@ -368,13 +369,13 @@ static void switch_to_graphics_mode( global_context_t *global_context )
}
*p = '\0';
- window_init( &global_context->window3, (widget_t *)desktop, 55, 5, vga->mode.x - 65, 100, VGA_COLOR_CYAN );
+ window_init( &global_context->window3, (widget_t *)desktop, 55, 5, vga->mode->base.x - 65, 100, VGA_COLOR_CYAN );
((composite_widget_vtable_t *)global_context->desktop.base.base.vtable)->add_child( desktop, (widget_t *)&global_context->window3 );
text_widget_init( &global_context->widget3, (widget_t *)&global_context->window3, 1, 1, global_context->window3.base.base.w - 2, global_context->window3.base.base.h - 2, VGA_COLOR_RED, s );
((composite_widget_vtable_t *)global_context->window3.base.base.vtable)->add_child( (composite_widget_t *)&global_context->window3, (widget_t *)&global_context->widget3 );
- ((mouse_vtable_t *)(mouse->base.vtable))->set_resolution( mouse, vga->mode.x, vga->mode.y );
+ ((mouse_vtable_t *)(mouse->base.vtable))->set_resolution( mouse, vga->mode->base.x, vga->mode->base.y );
// enable Z buffering
vga_use_z_buffer( global_context->vga, true );
@@ -391,7 +392,8 @@ static void switch_to_text_mode( global_context_t *global_context )
vga_text_restore( vga_text );
- if( vga_set_mode( vga, vga_make_mode( VGA_MODE_TYPE_TEXT, 640, 480, 4 ) ) ) {
+ video_mode_t mode = video_make_mode( VIDEO_MODE_TYPE_TEXT, 640, 480, 4 );
+ if( ((video_vtable_t *)(vga->base.base.vtable))->set_mode( vga, mode ) ) {
vga_text_set_cursor( vga_text, vga_text->cursor_x, vga_text->cursor_y );
((mouse_vtable_t *)(mouse->base.vtable))->set_resolution( mouse, vga_text->res_x, vga_text->res_y );
global_context->mode = MODE_TEXT;