diff options
Diffstat (limited to 'driver/console.c')
-rw-r--r-- | driver/console.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/driver/console.c b/driver/console.c new file mode 100644 index 0000000..79f277c --- /dev/null +++ b/driver/console.c @@ -0,0 +1,61 @@ +/* console_cur.c - console functions */ + +#include <system.h> +#include <console.h> + +unsigned char console_flags = 0; +unsigned short console_cur_pos = 0; +unsigned char console_std_attr = 0x07; +unsigned char console_akt_char_attr = 0; +unsigned char cur_blink_counter = 0; + + +void console_cursor_on() { + if(console_flags & FLAG_BLINK_ON) {console_flags &= ~FLAG_BLINK_ON; console_cur_blink();} +} + +void console_cursor_off() { + if(console_flags & FLAG_BLINK_ON) {console_cur_blink(); console_flags |= FLAG_BLINK_ON;} +} + +void console_cur_blink() { + if(console_flags & FLAG_BLINK_ON) { + console_flags &= ~FLAG_BLINK_ON; + asm ( + "push %es\n" + "push %ebx\n" + "mov $32,%ax\n" + "mov %ax,%es\n" + "xor %ebx,%ebx\n" + "mov console_cur_pos,%bx\n" + "shl $1,%ebx\n" + "inc %ebx\n" + "mov console_akt_char_attr,%al\n" + "mov %al,%es:(%ebx)\n" + "pop %ebx\n" + "pop %es" + ); + } + + else { + console_flags |= FLAG_BLINK_ON; + asm ( + "push %es\n" + "push %ebx\n" + "mov $32,%ax\n" + "mov %ax,%es\n" + "xor %ebx,%ebx\n" + "mov console_cur_pos,%bx\n" + "shl $1,%ebx\n" + "inc %ebx\n" + "mov console_std_attr,%al\n" + "rol $4,%al\n" + "and $0b01110111,%al\n" + "mov %es:(%ebx),%ah\n" + "mov %ah,console_akt_char_attr\n" + "mov %al,%es:(%ebx)\n" + "pop %ebx\n" + "pop %es" + ); + } +} |