You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.9 KiB

#ifndef KERNEL_VGA_H
#define KERNEL_VGA_H
// Base memory address for MM VGA
#define VGA_ADDRESS 0xb8000
// Max character cell dimensions
#define VGA_MAX_ROWS 25
#define VGA_MAX_COLS 80
// Default color scheme
#define VGA_WHITE_ON_BLACK 0x0f
// Screen device I/O ports
#define REG_VGA_CTL 0x3d4
#define REG_VGA_DATA 0x3d5
class VGA {
protected:
/**
* Given a column and row of a VGA character cell, compute the memory
* offset from the beginning of the VGA video memory of its char and
* attr bytes.
* @param col
* @param row
* @return the computed offset
*/
int getOffset(int col, int row);
int getOffsetRow(int offset);
int getOffsetCol(int offset);
/**
* Get the memory offset of the character cell where the cursor is.
*
* 1. Ask for the high-byte of the offset (data 14)
* 2. Ask for the low-byte (data 15)
*
* @return
*/
int getCursorOffset();
/**
* Given a VGA memory offset, set the cursor to that offset's character cell.
* @param offset
*/
void setCursorOffset(int offset);
/**
* Print a character to the specified position.
*
* If col/row are negative, print to the current cursor position.
* If attribute_byte is 0, default white on black.
*
* @param character
* @param col
* @param row
* @param attribute_byte
*/
int printChar(char character, int col, int row, char attrs);
int adjustScrolling(int offset);
/**
* Scrolls all the character cells up one row, replacing the top
* row and creating a new empty row on the bottom.
*/
void advanceScrolling();
public:
/**
* Resets all video memory characters to empty space and all formatting
* to the default white on black. Then, reset the cursor to the first cell.
*/
void clearScreen();
void printAt(char* string, int col, int row);
void print(char* string);
};
#endif //KERNEL_VGA_H