diff options
-rw-r--r-- | src/kernel.c | 52 | ||||
-rw-r--r-- | src/vga.c | 16 | ||||
-rw-r--r-- | src/vga.h | 3 |
3 files changed, 44 insertions, 27 deletions
diff --git a/src/kernel.c b/src/kernel.c index ce6bb1a..a18e2d2 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -9,43 +9,43 @@ void entry( void ) vga_set_color( &vga, VGA_COLOR_LIGHT_GREY ); vga_set_background_color( &vga, VGA_COLOR_BLACK ); - // again volatile? const results in garbage on clang - volatile char msg[] = "ABAOS"; - vga_put_string_at( &vga, 0, 0, (const char *)msg ); - // doesn't work - //~ vga_put_string_at( &vga, 0, 1, "ABAOS2" ); + + volatile char msg[] = "ABAOS 0.0.1 STARTING"; + vga_put_string( &vga, (const char *)msg ); // clang 4.0.0 needs volatile otherwise it takes a random value // from the register in the second vga_put_char_at below??! volatile char bar[] = "\\|/-"; - int pos = 5; + int y_pos = vga_get_cursor_y( &vga ); + int x_pos = vga_get_cursor_x( &vga ); int i = 0; for( i = 0; i < 10000; i++ ) { if( i % 1000 == 0 ) { - vga_put_char_at( &vga, pos, 0, '.' ); - pos++; + vga_put_char_at( &vga, x_pos, y_pos, '.' ); + x_pos++; } - vga_put_char_at( &vga, pos, 0, bar[i%4] ); + vga_put_char_at( &vga, x_pos, y_pos, bar[i%4] ); for( int j = 0; j < 1500; j++ ) { } } - vga_put_char_at( &vga, pos, 0, '.' ); + vga_put_char_at( &vga, x_pos, y_pos, '.' ); + vga_put_newline( &vga ); - vga_set_color( &vga, VGA_COLOR_WHITE ); - vga_set_background_color( &vga, VGA_COLOR_RED ); - vga_clear_screen( &vga ); + //~ vga_set_color( &vga, VGA_COLOR_WHITE ); + //~ vga_set_background_color( &vga, VGA_COLOR_RED ); + //~ vga_clear_screen( &vga ); - for( int i = 0; i < 50; i++ ) { - for( int j = 0; j < i; j++ ) { - vga_put_char( &vga, '-' ); - } - vga_put_char( &vga, '>' ); - vga_put_string( &vga, (const char *)msg ); - vga_put_newline( &vga ); - } - for( int j = 0; j < 50; j++ ) { - vga_put_char( &vga, '-' ); - } - vga_put_char( &vga, '>' ); - vga_put_string( &vga, (const char *)msg ); + //~ for( int i = 0; i < 50; i++ ) { + //~ for( int j = 0; j < i; j++ ) { + //~ vga_put_char( &vga, '-' ); + //~ } + //~ vga_put_char( &vga, '>' ); + //~ vga_put_string( &vga, (const char *)msg ); + //~ vga_put_newline( &vga ); + //~ } + //~ for( int j = 0; j < 50; j++ ) { + //~ vga_put_char( &vga, '-' ); + //~ } + //~ vga_put_char( &vga, '>' ); + //~ vga_put_string( &vga, (const char *)msg ); } @@ -19,7 +19,7 @@ void vga_init( vga_t *vga ) vga->background_color = VGA_COLOR_BLACK; // TODO: get current position from VGA hardware - //~ vga_set_cursor( vga, 0, 0 ); + vga_set_cursor_from_hardware( vga ); }; void vga_clear_screen( vga_t *vga ) @@ -43,6 +43,20 @@ void vga_set_cursor( vga_t *vga, const int x, const int y ) vga->cursor_y = y; } +void vga_set_cursor_from_hardware( vga_t *vga ) +{ +} + +int vga_get_cursor_x( vga_t *vga ) +{ + return vga->cursor_x; +} + +int vga_get_cursor_y( vga_t *vga ) +{ + return vga->cursor_y; +} + void vga_set_color( vga_t *vga, const vga_color_t color ) { vga->color = color; @@ -37,6 +37,9 @@ typedef struct vga_t { void vga_init( vga_t *vga ); void vga_clear_screen( vga_t *vga ); void vga_set_cursor( vga_t *vga, const int x, const int y ); +void vga_set_cursor_from_hardware( vga_t *vga ); +int vga_get_cursor_x( vga_t *vga ); +int vga_get_cursor_y( vga_t *vga ); void vga_set_color( vga_t *vga, const vga_color_t color ); void vga_set_background_color( vga_t *vga, const vga_color_t color ); void vga_put_char_at( vga_t *vga, const int x, const int y, const char c ); |