diff options
Diffstat (limited to 'os')
| -rw-r--r-- | os/main.c | 65 | ||||
| -rw-r--r-- | os/stdlib/sdtlib.h | 1 | ||||
| -rw-r--r-- | os/stdlib/stdlib.c | 21 |
3 files changed, 82 insertions, 5 deletions
@@ -2,13 +2,12 @@ #include "../kernel/gpu/text_mode/colours.h" #include "main.h" #include "./shell/shell.h" +#include "./stdlib/sdtlib.h" Program_t focused_program; void os_show_splash() { - scrn_enable_cursor(10, 12); - scrn_clear(); scrn_set_text_colour(COLOUR_LIGHT_GREEN, COLOUR_BLACK); scrn_println(" _ _ ____ _____ "); @@ -24,19 +23,75 @@ void os_show_splash() scrn_newline(); } -void os_start() +void line_pad(unsigned int width) { - os_show_splash(); + for(int i = 0; i < width; i++) + { + scrn_putchar(' '); + } +} + +void os_update_infobar_rc() +{ + + int curr_attr_byte = scrn_get_char_attr_byte(); + int curr_r = scrn_get_cursor_row(); + int curr_c = scrn_get_cursor_col(); + + scrn_set_text_colour(COLOUR_WHITE, COLOUR_BLUE); + scrn_set_cursor_pos(0, 64); + scrn_print("row "); + + if (curr_r < 9) { + scrn_print("0"); + } + scrn_print(int_to_str(curr_r +1)); + + scrn_print(", col "); + if (curr_c < 9) { + scrn_print("0"); + } + scrn_print(int_to_str(curr_c+1)); + + scrn_set_char_attr_byte(curr_attr_byte); + scrn_set_cursor_pos(curr_r, curr_c); +} + +void os_init_infobar() +{ + scrn_clear(); + scrn_set_cursor_pos(0, 0); + scrn_set_text_colour(COLOUR_WHITE, COLOUR_BLUE); + line_pad(80); // fill line + scrn_set_cursor_pos(0, 2); + scrn_print("tinyOS"); + scrn_set_cursor_pos(0, 30); + scrn_print("running: "); + scrn_print(focused_program.name); + + os_update_infobar_rc(); + scrn_set_text_colour(COLOUR_WHITE, COLOUR_BLACK); + scrn_set_cursor_pos(1, 0); } // TODO keep a stack of running programs void os_update_focused_program(Program_t program) { - focused_program = shell_run(); + focused_program = program; } // Send keypress from kernel to the currently focused programs keypress handler void os_proxy_keypress(unsigned char key) { (focused_program.keypress_handler)(key); + os_update_infobar_rc(); +} + +void os_start() +{ + os_update_focused_program(shell_run()); + scrn_enable_cursor(10, 12); + os_init_infobar(); + os_show_splash(); + os_update_infobar_rc(); } // TODO display handling
\ No newline at end of file diff --git a/os/stdlib/sdtlib.h b/os/stdlib/sdtlib.h new file mode 100644 index 0000000..a0b3402 --- /dev/null +++ b/os/stdlib/sdtlib.h @@ -0,0 +1 @@ +char* int_to_str(int i);
\ No newline at end of file diff --git a/os/stdlib/stdlib.c b/os/stdlib/stdlib.c new file mode 100644 index 0000000..465e978 --- /dev/null +++ b/os/stdlib/stdlib.c @@ -0,0 +1,21 @@ +char* int_to_str(int i) +{ + // Room for 4 byte int, -ve sign and null terminator + static char buf[12]; + char *p = buf + 11; // points to null terminator + if (i >= 0) { + do { + *--p = '0' + (i % 10); + i /= 10; + } while (i != 0); + return p; + } + else { + do { + *--p = '0' - (i % 10); + i /= 10; + } while (i != 0); + *--p = '-'; + } + return p; +}
\ No newline at end of file |