aboutsummaryrefslogtreecommitdiffstats
path: root/vgaterminal.hpp
blob: 9f8d5f3d6833b2afdc3f8d799b5eafb26887ab52 (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
#ifndef VGATERMINAL_HPP
#define VGATERMINAL_HPP

#include "textoutput.hpp"

#include <cstddef>
#include <cstdint>

class VGATerminal : public TextOutput
{
public:
    enum class Color : std::uint8_t
    {
    	Black = 0,
    	Blue,
    	Green,
    	Cyan,
    	Red,
    	Magenta,
    	Brown,
    	LightGray,
    	DarkGray,
    	LightBlue,
    	LightGreen,
    	LightCyan,
    	LightRed,
    	LightMagenta,
    	LightBrown,
    	White
    };

    using enum Color;

    virtual void write(char c) noexcept final;

private:
    static constexpr std::uintptr_t Videoram = 0xB8000;
    static constexpr unsigned Width = 80;
    static constexpr unsigned Height = 25;

    unsigned offset = 0;
    Color foreground = LightGray;
    Color background = Black;

    void put(char c) noexcept;
    void checkpos() noexcept;
    void updatecursor() const noexcept;
};

#endif // VGATERMINAL_HPP