Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __VGA_HXX__
- #define __VGA_HXX__
- #include <stdint.h> // ...
- #include <stddef.h> // Compiler-provided header files.
- namespace vga{
- enum color{ // Standard VGA colors.
- COLOR_BLACK = 0,
- COLOR_BLUE = 1,
- COLOR_GREEN = 2,
- COLOR_CYAN = 3,
- COLOR_RED = 4,
- COLOR_MAGENTA = 5,
- COLOR_BROWN = 6,
- COLOR_LIGHT_GREY = 7,
- COLOR_DARK_GREY = 8,
- COLOR_LIGHT_BLUE = 9,
- COLOR_LIGHT_GREEN = 10,
- COLOR_LIGHT_CYAN = 11,
- COLOR_LIGHT_RED = 12,
- COLOR_LIGHT_MAGENTA = 13,
- COLOR_LIGHT_BROWN = 14,
- COLOR_WHITE = 15
- };
- class vga{
- public:
- vga(); /* Constructor, sets up things such as the
- width and height of the VGA display. */
- void write(const char* data);
- /* Writes the specified string to the VGA display. Uses the
- current color scheme. */
- void write(const char* data, enum color fg, enum color bg);
- /* Writes the specified string to the VGA display.
- Takes colors as arguments to change the color scheme
- before writing. */
- void write(int val);
- // Mostly internal functions
- uint8_t make_color(enum color fg, enum color bg);
- /* Makes a color that can be written to the VGA memory. */
- uint16_t make_entry(char c, uint8_t color);
- /* Makes a character entry that can be written to VGA memory. */
- void putc(char c, int x, int y);
- /* Puts the character 'c' at positions 'x' and 'y' */
- void putc(char c);
- /* Puts the character 'c' at the current position. */
- void clear();
- /* Clears the screen all at once. */
- void clear(int line);
- /* Clears a specified line from the screen. */
- void nl();
- char* itoa(int value, int base);
- protected:
- int row; // Current character row.
- int column; // Current character column.
- uint8_t color; // Current colorscheme.
- int height; // Screen height.
- int width; // Screen width.
- private:
- uint16_t* buffer; // VGA memory.
- };
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement