summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-30 20:45:37 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-30 20:45:37 +0200
commit25228d8927af801667d4be2ea85ee517d1916fc7 (patch)
treeaa5932cfec8b95acdf978e459c9850d1b4a11678 /src/kernel
parentc1bbac52d78b2e3e93fa43a5a7b3907073493216 (diff)
downloadabaos-25228d8927af801667d4be2ea85ee517d1916fc7.tar.gz
abaos-25228d8927af801667d4be2ea85ee517d1916fc7.tar.bz2
almost got a complete mode switch (vga graphics back to text) working
some cleanup in VGA driver code
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/kernel.c20
-rw-r--r--src/kernel/vgatext.c13
-rw-r--r--src/kernel/vgatext.h5
3 files changed, 25 insertions, 13 deletions
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index 9bd3d98..501ab90 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -143,6 +143,8 @@ void kernel_main( void )
switch( global_context.mode ) {
case MODE_TEXT:
+ // nothing to draw or refresh in text mode, the
+ // VGA card is doing that for us
break;
case MODE_GRAPHICS:
@@ -150,12 +152,6 @@ void kernel_main( void )
// events originating especially from the mouse
interrupts_disable( );
- // wait for VGA retrace, assume drawing the desktop
- // is fast enough to finish in time (so we don't recheck
- // for retrace), it Z-buffering, this is done in vga_refresh
- // directly, no need to do it here
-// vga_wait_for_retrace( &global_context.vga );
-
// as vga_t is equals to the graphical context for now
((widget_vtable_t *)global_context.desktop.vtable)->draw( &global_context.desktop, &global_context.vga );
@@ -230,6 +226,8 @@ static void handle_keyboard_event( keyboard_event_t *event, void *context )
switch( global_context->mode ) {
case MODE_TEXT:
if( vga_set_mode( vga, vga_make_mode( VGA_MODE_TYPE_GRAPHICS, 320, 200, 8 ) ) ) {
+ vga_text_save( vga_text );
+
desktop_init( &global_context->desktop, 320, 200, VGA_COLOR_BLUE );
window_init( &global_context->window1, (widget_t *)&global_context->desktop, 60, 90, 60, 70, VGA_COLOR_LIGHT_GREY );
@@ -258,13 +256,13 @@ static void handle_keyboard_event( keyboard_event_t *event, void *context )
// enable Z buffering
vga_use_z_buffer( &global_context->vga, true );
- // draw on mode switch
-// ((widget_vtable_t *)global_context->desktop.vtable)->draw( &global_context->desktop, &global_context->vga );
-
global_context->mode = MODE_GRAPHICS;
break;
case MODE_GRAPHICS:
+ vga_text_restore( vga_text );
+ vga_text_set_cursor( vga_text, vga_text->cursor_x, vga_text->cursor_y );
+
if( vga_set_mode( vga, vga_make_mode( VGA_MODE_TYPE_TEXT, 640, 480, 4 ) ) ) {
mouse_set_resolution( mouse, vga_text->res_x, vga_text->res_y );
global_context->mode = MODE_TEXT;
@@ -336,10 +334,6 @@ static void handle_mouse_event( mouse_event_t *event, void *context )
break;
}
- // alternative way of redrawing on mouse event
- // on qemu looses the mouse..
-// ((widget_vtable_t *)desktop->vtable)->draw( &global_context->desktop, &global_context->vga );
-
break;
}
}
diff --git a/src/kernel/vgatext.c b/src/kernel/vgatext.c
index 76bfd46..232d91a 100644
--- a/src/kernel/vgatext.c
+++ b/src/kernel/vgatext.c
@@ -262,3 +262,16 @@ void vga_text_hide_mouse_cursor( vga_text_t *vga_text )
}
}
+void vga_text_save( vga_text_t *vga_text )
+{
+ volatile uint8_t *VIDEO_MEMORY = (uint8_t *)0xA0000;
+
+ memcpy( vga_text->buf, VIDEO_MEMORY, 2*65535 );
+}
+
+void vga_text_restore( vga_text_t *vga_text )
+{
+ volatile uint8_t *VIDEO_MEMORY = (uint8_t *)0xA0000;
+
+ memcpy( VIDEO_MEMORY, vga_text->buf, 2*65535 );
+}
diff --git a/src/kernel/vgatext.h b/src/kernel/vgatext.h
index 499e3d8..c0bfbdc 100644
--- a/src/kernel/vgatext.h
+++ b/src/kernel/vgatext.h
@@ -42,6 +42,9 @@ typedef struct {
bool show_mouse_cursor;
int mouse_cursor_x;
int mouse_cursor_y;
+ // TODO: actually restore a proper, for now we
+ // remember the whole video area during mode switch
+ uint8_t buf[2*65535];
} vga_text_t;
void vga_text_init( vga_text_t *vga_text );
@@ -64,5 +67,7 @@ void vga_text_inverse_colors_at( vga_text_t *vga_text, const int x, const int y
void vga_text_show_mouse_cursor( vga_text_t *vga_text );
void vga_text_move_mouse_cursor( vga_text_t *vga_text, const int x, const int y );
void vga_text_hide_mouse_cursor( vga_text_t *vga_text );
+void vga_text_save( vga_text_t *vga_text );
+void vga_text_restore( vga_text_t *vga_text );
#endif /* VGA_TEXT_H */