summaryrefslogtreecommitdiff
path: root/src/kernel/vgatext.h
blob: c0bfbdc262ded2c76317250ff9247880d4fb1a06 (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
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef VGA_TEXT_H
#define VGA_TEXT_H

#include <stdbool.h>

#include "port.h"

enum {
	VGA_TEXT_DEFAULT_RES_X = 80,
	VGA_TEXT_DEFAULT_RES_Y = 25
};

typedef enum {
	VGA_TEXT_COLOR_BLACK = 0,
	VGA_TEXT_COLOR_BLUE = 1,
	VGA_TEXT_COLOR_GREEN = 2,
	VGA_TEXT_COLOR_CYAN = 3,
	VGA_TEXT_COLOR_RED = 4,
	VGA_TEXT_COLOR_MAGENTA = 5,
	VGA_TEXT_COLOR_BROWN = 6,
	VGA_TEXT_COLOR_LIGHT_GREY = 7,
	VGA_TEXT_COLOR_DARK_GREY = 8,
	VGA_TEXT_COLOR_LIGHT_BLUE = 9,
	VGA_TEXT_COLOR_LIGHT_GREEN = 10,
	VGA_TEXT_COLOR_LIGHT_CYAN = 11,
	VGA_TEXT_COLOR_LIGHT_RED = 12,
	VGA_TEXT_COLOR_LIGHT_MAGENTA = 13,
	VGA_TEXT_COLOR_LIGHT_BROWN = 14,
	VGA_TEXT_COLOR_WHITE = 15
} vga_text_color_t;

typedef struct {
	int res_x;	// resolution, default 80
	int res_y;	// resolution, default 25
	int cursor_x;	// current cursor position X
	int cursor_y;	// current cursor position Y
	vga_text_color_t color;
	vga_text_color_t background_color;
	port8_t crtc_misc_port;
	port8_t crtc_index_port;
	port8_t crtc_data_port;
	bool show_mouse_cursor;
	int mouse_cursor_x;
	int mouse_cursor_y;
	// TODO: actually restore a proper, for now we
	// remember the whole video area during mode switch
	uint8_t buf[2*65535];
} vga_text_t;

void vga_text_init( vga_text_t *vga_text );
void vga_text_clear_screen( vga_text_t *vga_text );
void vga_text_set_cursor( vga_text_t *vga_text, const int x, const int y );
void vga_text_set_cursor_from_hardware( vga_text_t *vga_text );
void vga_text_set_cursor_on_hardware( vga_text_t *vga_text );
int vga_text_get_cursor_x( vga_text_t *vga_text );
int vga_text_get_cursor_y( vga_text_t *vga_text );
void vga_text_set_color( vga_text_t *vga_text, const vga_text_color_t color );
void vga_text_set_background_color( vga_text_t *vga_text, const vga_text_color_t color );
void vga_text_put_char_at( vga_text_t *vga_text, const int x, const int y, const char c );
void vga_text_put_string_at( vga_text_t *vga_text, const int x, const int y, const char *s );
void vga_text_put_char( vga_text_t *vga_text, const char c );
void vga_text_put_string( vga_text_t *vga_text, const char *s );
void vga_text_put_newline( vga_text_t *vga_text );
void vga_text_set_background_color_at( vga_text_t *vga_text, const int x, const int y, vga_text_color_t color );
vga_text_color_t vga_text_get_background_color_at( vga_text_t *vga_text, const int x, const int y );
void vga_text_inverse_colors_at( vga_text_t *vga_text, const int x, const int y );
void vga_text_show_mouse_cursor( vga_text_t *vga_text );
void vga_text_move_mouse_cursor( vga_text_t *vga_text, const int x, const int y );
void vga_text_hide_mouse_cursor( vga_text_t *vga_text );
void vga_text_save( vga_text_t *vga_text );
void vga_text_restore( vga_text_t *vga_text );
 
#endif /* VGA_TEXT_H */