KernOS
vga.cpp
Go to the documentation of this file.
1 #include <vga.h>
2 
3 #ifdef TEST_BUILD
4 #include <iostream>
5 #endif
6 
7 namespace VGA
8 {
10 
11  void Vga::PutChar(unsigned char Char)
12  {
13  if (Char == '\n') { // new line
14 
15  m_Col = 0;
16  (m_Row == VGA_HEIGHT) ? m_Row = 0 : ++m_Row; // wrap around display
17 
18  } else {
19 
20  PutChar(Entry(Char, m_Color), m_Row, m_Col);
21 
22  if (++m_Col == VGA_WIDTH) { // wrap around display
23 
24  m_Col = 0;
25 
26  if (++m_Row == VGA_HEIGHT) {
27  m_Row = 0;
28  }
29  }
30  }
31  }
32 
33  void Vga::Fill(const VgaChar Char)
34  {
35  for (m_Row = 0; m_Row < VGA_HEIGHT; ++m_Row) {
36  for (m_Col = 0; m_Col < VGA_WIDTH; ++m_Col) {
37  PutChar(Char, m_Row, m_Col);
38  }
39  }
40 
41  m_Row = 0;
42  m_Col = 0;
43  }
44 
45  void Vga::Initialize()
46  {
48 
49  const auto Char = Entry(' ', m_Color);
50 
51  Fill(Char);
52  }
53 
54  void Vga::Puts(const char *Str)
55  {
56 #ifdef TEST_BUILD
57  std::cout << Str;
58 #else
59  for (size_t i = 0; i < Strlen(Str); ++i)
60  PutChar(Str[i]);
61 #endif
62  }
63 } // namespace VGA
64 
65 namespace INIT
66 {
67  void VGA()
68  {
69  VGA::Display.Puts("KernOS - v0.1\n");
70  VGA::Display.Puts("Hello World!\n");
71  }
72 }
void SetColor(VgaColor Color)
Set text color.
Definition: vga.h:112
Vga Display
Definition: vga.cpp:9
Video Graphics Array namespace.
Definition: vga.h:9
Manages access to VGA driver.
Definition: vga.h:47
contains all kernel initialization routines
Definition: cpu.h:10
void Puts(const char *Str)
Print string to display.
Definition: vga.cpp:54
uint16_t VgaChar
Definition: vga.h:42
size_t Strlen(const char *Str)
Count number of characters in string.
Definition: utilities.cpp:7
void VGA()
Clear VGA display, and print kernel banner.
Definition: vga.cpp:67