brados/include/video/vga.h

65 lines
1.4 KiB
C
Raw Normal View History

#ifndef __brados_video_vga_h__
#define __brados_video_vga_h__
#include <stddef.h>
#include <stdint.h>
#define VGA_BUF 0xB8000
#define VGA_WIDTH 80
#define VGA_HEIGHT 24
// VGA State
struct vgastate {
size_t term_row, term_col;
uint8_t term_color;
uint16_t *term_buf;
};
// Color constants
enum vga_color
{
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA_COLOR_MAGENTA = 5,
VGA_COLOR_BROWN = 6,
VGA_COLOR_LIGHT_GREY = 7,
VGA_COLOR_DARK_GREY = 8,
VGA_COLOR_LIGHT_BLUE = 9,
VGA_COLOR_LIGHT_GREEN = 10,
VGA_COLOR_LIGHT_CYAN = 11,
VGA_COLOR_LIGHT_RED = 12,
VGA_COLOR_LIGHT_MAGENTA = 13,
VGA_COLOR_LIGHT_BROWN = 14,
VGA_COLOR_WHITE = 15
};
// Create a VGA color
uint8_t make_color(enum vga_color fg, enum vga_color bg);
// Create a VGA character
uint16_t make_vgaEntry(char c, uint8_t color);
// Initialize a VGA term
void term_init(struct vgastate *state);
// Write a character to a VGA term
void term_putChar(struct vgastate *state, char c);
// Place a character in a VGA term's buffer
void term_putEntryAt(struct vgastate *state, char c, uint8_t color, size_t x, size_t y);
// Scroll the term down 1 line
void term_scroll(struct vgastate *state);
// Set VGA term color
void term_setColor(struct vgastate *state, uint8_t color);
// Write a string to a VGA term
void term_writeStr(struct vgastate *state, const char *data);
#endif