MentOS  0.8.0
The Mentoring Operating System
Classes | Macros | Functions | Variables
video.c File Reference

Video functions and costants. More...

Classes

struct  ansi_color_map_t
 Stores the association between ANSI colors and pure VIDEO colors. More...
 

Macros

#define HEIGHT   25
 The height of the.
 
#define WIDTH   80
 The width of the.
 
#define W2   (WIDTH * 2)
 The width of the.
 
#define TOTAL_SIZE   (HEIGHT * WIDTH * 2)
 The total size of the screen.
 
#define ADDR   (char *)0xB8000U
 The address of the.
 
#define STORED_PAGES   3
 The number of stored pages.
 

Functions

static unsigned __get_x (void)
 Get the current column number. More...
 
static unsigned __get_y (void)
 Get the current row number. More...
 
static void __draw_char (char c)
 Draws the given character. More...
 
static void __set_color (uint8_t ansi_code)
 Sets the provided ansi code. More...
 
static void __move_cursor_backward (int erase, int amount)
 Moves the cursor backward. More...
 
static void __move_cursor_forward (int erase, int amount)
 Moves the cursor forward. More...
 
static void __video_set_cursor (unsigned int x, unsigned int y)
 Issue the vide to move the cursor to the given position. More...
 
void video_init (void)
 Initialize the video.
 
void video_update (void)
 Updates the video.
 
void video_putc (int c)
 Print the given character on the screen. More...
 
void video_puts (const char *str)
 Prints the given string on the screen. More...
 
void video_set_cursor_auto (void)
 When something is written in another position, update the cursor.
 
void video_move_cursor (unsigned int x, unsigned int y)
 Move the cursor at the position x, y on the screen. More...
 
void video_get_cursor_position (unsigned int *x, unsigned int *y)
 Returns cursor's position on the screen. More...
 
void video_get_screen_size (unsigned int *width, unsigned int *height)
 Returns screen size. More...
 
void video_clear (void)
 Clears the screen.
 
void video_new_line (void)
 Move to the following line (the effect of
character).
 
void video_cartridge_return (void)
 Move to the up line (the effect of
character).
 
void video_shift_one_line_up (void)
 The whole screen is shifted up by one line. Used when the cursor reaches the last position of the screen.
 
void video_shift_one_page_up (void)
 The whole screen is shifted up by one page.
 
void video_shift_one_page_down (void)
 The whole screen is shifted down by one page.
 

Variables

struct ansi_color_map_t ansi_color_map []
 The mapping.
 
char * pointer = ADDR
 Pointer to a position of the screen writer.
 
unsigned char color = 7
 The current color.
 
int escape_index = -1
 Used to write on the escape_buffer. If -1, we are not parsing an escape sequence.
 
char escape_buffer [256]
 Used to store an escape sequence.
 
char upper_buffer [STORED_PAGES *TOTAL_SIZE] = { 0 }
 Buffer where we store the upper scroll history.
 
char original_page [TOTAL_SIZE] = { 0 }
 Buffer where we store the lower scroll history.
 
int scrolled_page = 0
 Determines if the screen is currently scrolled.
 

Detailed Description

Video functions and costants.

Function Documentation

◆ __draw_char()

static void __draw_char ( char  c)
inlinestatic

Draws the given character.

Parameters
cThe character to draw.

◆ __get_x()

static unsigned __get_x ( void  )
inlinestatic

Get the current column number.

Returns
The column number.

◆ __get_y()

static unsigned __get_y ( void  )
inlinestatic

Get the current row number.

Returns
The row number.

◆ __move_cursor_backward()

static void __move_cursor_backward ( int  erase,
int  amount 
)
inlinestatic

Moves the cursor backward.

Parameters
eraseIf 1 also erase the character.
amountHow many times we move backward.

◆ __move_cursor_forward()

static void __move_cursor_forward ( int  erase,
int  amount 
)
inlinestatic

Moves the cursor forward.

Parameters
eraseIf 1 also erase the character.
amountHow many times we move forward.

◆ __set_color()

static void __set_color ( uint8_t  ansi_code)
inlinestatic

Sets the provided ansi code.

Parameters
ansi_codeThe ansi code describing background and foreground color.

◆ __video_set_cursor()

static void __video_set_cursor ( unsigned int  x,
unsigned int  y 
)
inlinestatic

Issue the vide to move the cursor to the given position.

Parameters
xThe x coordinate.
yThe y coordinate.

◆ video_get_cursor_position()

void video_get_cursor_position ( unsigned int *  x,
unsigned int *  y 
)

Returns cursor's position on the screen.

Parameters
xThe output x coordinate.
yThe output y coordinate.

◆ video_get_screen_size()

void video_get_screen_size ( unsigned int *  width,
unsigned int *  height 
)

Returns screen size.

Parameters
widthThe screen width.
heightThe screen height.

◆ video_move_cursor()

void video_move_cursor ( unsigned int  x,
unsigned int  y 
)

Move the cursor at the position x, y on the screen.

Parameters
xThe x coordinate.
yThe y coordinate.

◆ video_putc()

void video_putc ( int  c)

Print the given character on the screen.

Parameters
cThe character to print.

◆ video_puts()

void video_puts ( const char *  str)

Prints the given string on the screen.

Parameters
strThe string to print.