aboutsummaryrefslogtreecommitdiff
path: root/kernel/io/text_mode_display.c
blob: 514ba9fedb118ffa273de973f0842111ecbe4081 (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
#define COLS 80
#define ROWS 25
#define FRAME_SIZE (ROWS * COLS * 2) // 2 bytes per char

char *video_ram = (char *)0xB8000;
int cursor_pos = 0;

void clear_screen()
{
  for (int i = 0; i < FRAME_SIZE; i = i + 2)
  {
    video_ram[i] = ' ';
    video_ram[i + 1] = 0x07;
  };
  cursor_pos = 0;
}

void print(char *msg)
{
  int j = 0;
  while (msg[j] != '\0')
  {
    video_ram[cursor_pos++] = msg[j];
    video_ram[cursor_pos++] = 0x07;
    ++j;
  }
}

void print_ln(char *msg)
{
  print(msg);
  int current_line = cursor_pos / COLS;
  cursor_pos = (current_line + 1) * (COLS*2);
}