summaryrefslogtreecommitdiffstats
path: root/driver/console.c
blob: 79f277c5703c8863ebd54ff2581418f03fc34504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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"
		);
	}
}