aboutsummaryrefslogtreecommitdiff
path: root/os/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/main.c')
-rw-r--r--os/main.c65
1 files changed, 60 insertions, 5 deletions
diff --git a/os/main.c b/os/main.c
index 905b0f7..b04ee62 100644
--- a/os/main.c
+++ b/os/main.c
@@ -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