MicrOS
vga.c File Reference
#include "vga.h"

Functions

uint8_t vga_init (uint8_t mode)
 Initialization of VGA. More...
 
void vga_printchar (char character)
 Print character on screen. More...
 
void vga_printchar_color (char character, vga_color *color)
 Print character on screen. More...
 
void vga_printstring (const char *str)
 Print string on screen. More...
 
void vga_printstring_color (const char *str, vga_color *color)
 Print string on screen. More...
 
void vga_set_char (uint16_t x, uint16_t y, char character)
 Set character on given point on screen. More...
 
void vga_set_char_struct (vga_screen_pos spos, char c)
 Set character on given point on screen. More...
 
char vga_get_char (uint16_t x, uint16_t y)
 Get character from given point on screen. More...
 
char vga_get_char_struct (vga_screen_pos spos)
 Get character from given point on screen. More...
 
void vga_set_color (uint16_t x, uint16_t y, vga_color col)
 Set character color on given point on screen. More...
 
void vga_set_color_struct (vga_screen_pos spos, vga_color col)
 Set character color on given point on screen. More...
 
vga_color vga_get_color (uint16_t x, uint16_t y)
 Get character color from given point on screen. More...
 
vga_color vga_get_color_struct (vga_screen_pos spos)
 Get character color from given point on screen. More...
 
void vga_set_character (uint16_t x, uint16_t y, vga_character character)
 Set character and character color on given point on screen. More...
 
void vga_set_character_struct (vga_screen_pos spos, vga_character character)
 Set character and character color on given point on screen. More...
 
vga_character vga_get_character (uint16_t x, uint16_t y)
 Get character and character color color from given point on screen. More...
 
vga_character vga_get_character_struct (vga_screen_pos spos)
 Get character and character color color from given point on screen. More...
 
void vga_set_cursor_pos (uint16_t x, uint16_t y)
 Set cursor position. More...
 
void vga_set_cursor_pos_struct (vga_screen_pos spos)
 Set cursor position. More...
 
vga_screen_pos vga_get_cursor_pos ()
 Get cursor position. More...
 
void vga_clear_screen ()
 Clear screen. More...
 
void vga_clear_given_screen (uint8_t screen)
 Clear given screen. More...
 
void vga_clear_all_screens ()
 Clear all screen. More...
 
void vga_change_printing_screen (uint8_t screen)
 Change printing screen. More...
 
void vga_copy_screen (uint8_t from, uint8_t to)
 Copy printing screen. More...
 
void vga_cursor_on ()
 Turn on cursor. More...
 
void vga_cursor_off ()
 Turn off cursor. More...
 
void vga_newline ()
 Print new line. More...
 
uint16_t __vga_calcualte_position_with_offset (uint16_t x, uint16_t y)
 Calculate position with offset. More...
 
uint16_t __vga_calcualte_position_without_offset (uint16_t x, uint16_t y)
 Calculate position without offset. More...
 
void __vga_enable_cursor (uint8_t cursor_start, uint8_t cursor_end)
 Turn on cursor. More...
 
void __vga_disable_cursor ()
 Disable cursor. More...
 
vga_color __vga_get_default_terminal_color (uint8_t vga_current_mode)
 Get default terminal color. More...
 

Variables

volatile screen_charvga_video
 Pointer to current screen. More...
 
uint8_t vga_current_printing_screen = 0
 Current video screen. More...
 
uint16_t vga_screen_offset = 0
 Current offset for screen. More...
 
uint8_t vga_current_mode = 0
 Current text mode. More...
 
uint16_t vga_current_columns = 0
 Number of columns screens for current text mode. More...
 
uint16_t vga_current_rows = 0
 Number of rows screens for current text mode. More...
 
uint16_t vga_current_max_screens = 0
 Number of max screens for current text mode. More...
 
uint16_t vga_current_screen_offset = 0
 Offset between screens for current text mode. More...
 

Function Documentation

◆ __vga_calcualte_position_with_offset()

uint16_t __vga_calcualte_position_with_offset ( uint16_t  x,
uint16_t  y 
)

Calculate position with offset.

Calculate position on screen takes into account the current offset. Which means function return value that added to base address will give you position of current character on current screen in memory.

Parameters
xx coordinate.
yy coordinate.
Returns
Calculated position on screen.

◆ __vga_calcualte_position_without_offset()

uint16_t __vga_calcualte_position_without_offset ( uint16_t  x,
uint16_t  y 
)

Calculate position without offset.

Calculate position on screen doesn't take into account the current offset. Which means function return value that added to base address will give you position of current character on first screen in memory.

Parameters
xx coordinate.
yy coordinate.
Returns
Calculated position on screen.

◆ __vga_disable_cursor()

void __vga_disable_cursor ( )

Disable cursor.

◆ __vga_enable_cursor()

void __vga_enable_cursor ( uint8_t  cursor_start,
uint8_t  cursor_end 
)

Turn on cursor.

Turn on cursor with given size and position.

Parameters
cursor_startScanline where cursor should start.
cursor_endScanline where cursor should end.

◆ __vga_get_default_terminal_color()

vga_color __vga_get_default_terminal_color ( uint8_t  vga_current_mode)

Get default terminal color.

Get default terminal color for mode.

Parameters
vga_modeCurrent mode of graphic card.
Returns
Default terminal letter and background color. When wrong mode given returns default color for mode 3h.

◆ vga_change_printing_screen()

void vga_change_printing_screen ( uint8_t  screen)

Change printing screen.

Change screen where text are printing. /param screen New screen for printing. Value valid for current text mode.

◆ vga_clear_all_screens()

void vga_clear_all_screens ( )

Clear all screen.

Clears letters and colors from all screens. Set colors to default.

◆ vga_clear_given_screen()

void vga_clear_given_screen ( uint8_t  screen)

Clear given screen.

Clears letters and colors from given screen. Set colors to default.

Parameters
screenScreen to clear. Value valid for current text mode.

◆ vga_clear_screen()

void vga_clear_screen ( )

Clear screen.

Clears letters and colors. Set colors to default.

◆ vga_copy_screen()

void vga_copy_screen ( uint8_t  from,
uint8_t  to 
)

Copy printing screen.

Copy screen from one to another. /param from Screen to copy. Value valid for current text mode. /param to Destination screen. Value valid for current text mode.

◆ vga_cursor_off()

void vga_cursor_off ( )

Turn off cursor.

◆ vga_cursor_on()

void vga_cursor_on ( )

Turn on cursor.

Turn on cursor with default size and position.

◆ vga_get_char()

char vga_get_char ( uint16_t  x,
uint16_t  y 
)

Get character from given point on screen.

Get character on given point on screen.

Parameters
xx coordinate.
yy coordinate.
Returns
Character.

◆ vga_get_char_struct()

char vga_get_char_struct ( vga_screen_pos  spos)

Get character from given point on screen.

Get character on given point on screen.

Parameters
sposPosition on screen.
Returns
Character.

◆ vga_get_character()

vga_character vga_get_character ( uint16_t  x,
uint16_t  y 
)

Get character and character color color from given point on screen.

Get character and character color color on given point on screen.

Parameters
xx coordinate.
yy coordinate.
Returns
Character and character color.

◆ vga_get_character_struct()

vga_character vga_get_character_struct ( vga_screen_pos  spos)

Get character and character color color from given point on screen.

Get character and character color color on given point on screen.

Parameters
sposPosition on screen.
Returns
Character and character color.

◆ vga_get_color()

vga_color vga_get_color ( uint16_t  x,
uint16_t  y 
)

Get character color from given point on screen.

Get character color on given point on screen.

Parameters
xx coordinate.
yy coordinate.
Returns
Color.

◆ vga_get_color_struct()

vga_color vga_get_color_struct ( vga_screen_pos  spos)

Get character color from given point on screen.

Get character color on given point on screen.

Parameters
sposPosition on screen.
Returns
Color.

◆ vga_get_cursor_pos()

vga_screen_pos vga_get_cursor_pos ( )

Get cursor position.

Get cursor position on screen.

Returns
Position on screen.

◆ vga_init()

uint8_t vga_init ( uint8_t  mode)

Initialization of VGA.

Sets internal variables to given text mode and clear all screens.

Parameters
modeText mode you want to switch.
Returns
1 is succes, 0 is failure.

◆ vga_newline()

void vga_newline ( )

Print new line.

◆ vga_printchar()

void vga_printchar ( char  character)

Print character on screen.

Print character on screen without changing color of character and background.

Parameters
characterCharacter.

◆ vga_printchar_color()

void vga_printchar_color ( char  character,
vga_color color 
)

Print character on screen.

Print character on screen with given color of character and background.

Parameters
characterCharacter.
colorColor.

◆ vga_printstring()

void vga_printstring ( const char *  str)

Print string on screen.

Print string on screen without changing color of characters and background.

Parameters
strString.

◆ vga_printstring_color()

void vga_printstring_color ( const char *  str,
vga_color color 
)

Print string on screen.

Print string on screen with given color of characters and background.

Parameters
strString.
colorColor.

◆ vga_set_char()

void vga_set_char ( uint16_t  x,
uint16_t  y,
char  character 
)

Set character on given point on screen.

Set character on given point on screen without changing color of character and background.

Parameters
xx coordinate.
yy coordinate.
characterCharacter.

◆ vga_set_char_struct()

void vga_set_char_struct ( vga_screen_pos  spos,
char  character 
)

Set character on given point on screen.

Set character on given point on screen without changing color of character and background.

Parameters
sposPosition on screen.
characterCharacter.

◆ vga_set_character()

void vga_set_character ( uint16_t  x,
uint16_t  y,
vga_character  character 
)

Set character and character color on given point on screen.

Set character and character color on given point on screen.

Parameters
xx coordinate.
yy coordinate.
characterCharacter and character color.

◆ vga_set_character_struct()

void vga_set_character_struct ( vga_screen_pos  spos,
vga_character  character 
)

Set character and character color on given point on screen.

Set character and character color on given point on screen.

Parameters
sposPosition on screen.
characterCharacter and character color.

◆ vga_set_color()

void vga_set_color ( uint16_t  x,
uint16_t  y,
vga_color  col 
)

Set character color on given point on screen.

Set character color on given point on screen without changing letter.

Parameters
xx coordinate.
yy coordinate.
colColor.

◆ vga_set_color_struct()

void vga_set_color_struct ( vga_screen_pos  spos,
vga_color  col 
)

Set character color on given point on screen.

Set character color on given point on screen without changing letter.

Parameters
sposPosition on screen.
colColor.

◆ vga_set_cursor_pos()

void vga_set_cursor_pos ( uint16_t  x,
uint16_t  y 
)

Set cursor position.

Set cursor position on screen.

Parameters
xx coordinate.
yy coordinate.

◆ vga_set_cursor_pos_struct()

void vga_set_cursor_pos_struct ( vga_screen_pos  spos)

Set cursor position.

Set cursor position on screen.

Parameters
sposPosition on screen.

Variable Documentation

◆ vga_current_columns

uint16_t vga_current_columns = 0

Number of columns screens for current text mode.

◆ vga_current_max_screens

uint16_t vga_current_max_screens = 0

Number of max screens for current text mode.

◆ vga_current_mode

uint8_t vga_current_mode = 0

Current text mode.

◆ vga_current_printing_screen

uint8_t vga_current_printing_screen = 0

Current video screen.

◆ vga_current_rows

uint16_t vga_current_rows = 0

Number of rows screens for current text mode.

◆ vga_current_screen_offset

uint16_t vga_current_screen_offset = 0

Offset between screens for current text mode.

◆ vga_screen_offset

uint16_t vga_screen_offset = 0

Current offset for screen.

When we add this to vga_video we wil get address of screen we should work on.

◆ vga_video

volatile screen_char* vga_video

Pointer to current screen.

Points to array of characters