General Info

Interface: TextVideo
Files: textvideo.h
Last change: 22/06/2003
Author: Luiz Henrique Shigunov
Description
Structures
System Functions

0x00 - Clear - Clear screen region
0x01 - GetCurrentMode - Get current screen mode
0x02 - GetModeDesc - Get a mode description
0x09 - GetStatus - Get current mode status
0x03 - Scroll - Scroll screen

0x04 - SetAttrib - Set char attributes
0x05 - SetCursorPos - Set cursor position
0x06 - SetCursorType - Set cursor type
0x07 - SetMode - Set current screen mode
0x08 - Write - Print with current attributes
User Functions

0x0a - UClear - Clear screen region
0x0b - UGetCurrentMode - Get current screen mode
0x0c - UGetModeDesc - Get a mode description
0x0d - UGetStatus - Get current mode status
0x0e - UScroll - Scroll screen

0x0f - USetAttrib - Set char attributes
0x10 - USetCursorPos - Set cursor position
0x11 - USetCursorType - Set cursor type
0x12 - USetMode - Set current screen mode
0x13 - UWrite - Print with current attributes

Description

This page describes the TextVideo interface which provides access to a console.

This interface is used by programs that use a console.

The first line is line 0 and the first column is column 0.

Structures

typedef struct {
    unsigned int rows;
    unsigned int cols;
    int flags;
} TextVideo_ModeDesc;

Where rows is the number of rows and cols the number of columns.

flags is the sum of:

typedef struct {
    unsigned int row;
    unsigned int col;
    int attrib;
    int cursorType;
} TextVideo_Status;

Where row and col is the cursor position, attrib the char attributes and cursorType the cursor type.

System Functions

These functions are exclusive for system modules.

0x00 - Clear

Syntax

void TextVideo_Clear(unsigned int row, unsigned int col, unsigned int height, unsigned int width);

Properties

Description

This function clears screen region defined by row,col and size height lines and width columns.

The screen is cleared using space char with current attributes.

Return value

Nothing.

0x01 - GetCurrentMode

Syntax

unsigned int TextVideo_GetCurrentMode(void);

Properties

Description

This function gets current screen mode.

Returned value can be used with GetModeDesc to get mode description.

Return value

Current mode.

0x02 - GetModeDesc

Syntax

int TextVideo_GetModeDesc(unsigned int mode, TextVideo_ModeDesc *desc);

Properties

Description

This function gets mode description.

Return value

0x09 - GetStatus

Syntax

int TextVideo_GetStatus(TextVideo_Status *status);

Properties

Description

This function gets current mode status.

Return value

0x03 - Scroll

Syntax

int TextVideo_Scroll(unsigned int top, unsigned int bottom, unsigned int lines, int dir);

Properties

Description

This function scrolls the lines inside the region defined by lines top-bottom, including.

dir is the direction and lines the number of lines to scroll.

The opened space is filled the same way as Clear does.

dir must be 0 or:

For instance, to scroll the region 0-10, 5 lines up (moving lines 5-10 to 0-4) just call Scroll(0, 10, 5, 0).

Return value

0x04 - SetAttrib

Syntax

void TextVideo_SetAttrib(int attrib);

Properties

Description

This function sets char attributes to attrib, which has this format:

BitsDescription
0-1Intensity: 0 - half-bright; 1 - normal; 2 - bold
2Underline
3Blink
4Reverse
5-15Reserved
16-23Background color
24-31Foreground color

The following colors are defined:

ValueColor
0x00Black
0x01Red
0x02Green
0x03Brown
0x04Blue
0x05Magenta
0x06Cyan
0x07White

Not all attributes may be supported. Mode description tells what is supported.

For instance, to set normal, blink, black background and blue foreground: 0x04000009

Return value

Nothing.

0x05 - SetCursorPos

Syntax

void TextVideo_SetCursorPos(unsigned int row, unsigned int col);

Properties

Description

This function sets cursor position to row,col.

Return value

Nothing.

0x06 - SetCursorType

Sintaxe

void TextVideo_SetCursorType(int type);

Properties

Description

This functions sets cursor type to type.

type must be:

Return value

Nothing.

0x07 - SetMode

Syntax

int TextVideo_SetMode(unsigned int mode);

Properties

Description

This function sets current mode to mode.

Upon setting a mode the screen is cleared, cursor position is set to line 0 column 0 and default settings are restored (char attributes, cursor type).

Return value

0x08 - Write

Syntax

int TextVideo_Write(const char *text, int size);

Properties

Description

This function prints text with size in the current position and with current attributes.

text can be a pointer to user memory, and so it can generate an access violation exception.

If text reachs the end of line it goes to the start of a new line and if text reachs the end of the last line, lines are moved one line up.

This function supports two control chars: 0xd (\r) - return to the start of a line and 0xa (\n) - change of line and return to the start of line.

Return value

User Functions

These functions were designed for user modules.

0x0a - UClear

Syntax

int TextVideo_UClear(unsigned int row, unsigned int col, unsigned int height, unsigned int width);

Properties

User modules

Description

The same as Clear.

Return value

0x0b - UGetCurrentMode

Syntax

unsigned int TextVideo_UGetCurrentMode(void);

Properties

User modules

Description

The same as GetCurrentMode.

Return value

Current mode.

0x0c - UGetModeDesc

Syntax

int TextVideo_UGetModeDesc(unsigned int mode, TextVideo_ModeDesc *desc);

Properties

User modules

Description

The same as GetModeDesc.

Return value

The same as GetModeDesc, plus:

0x0d - UGetStatus

Syntax

int TextVideo_UGetStatus(TextVideo_Status *status);

Properties

User modules

Description

The same as GetStatus.

Return value

The same as GetStatus, plus:

0x0e - UScroll

Syntax

int TextVideo_UScroll(unsigned int top, unsigned int bottom, unsigned int lines, int dir);

Properties

User modules

Description

The same as Scroll.

Return value

The same as Scroll, plus:

0x0f - USetAttrib

Syntax

int TextVideo_USetAttrib(int attrib);

Properties

User modules

Description

The same as SetAttrib.

Return value

0x10 - USetCursorPos

Syntax

int TextVideo_USetCursorPos(unsigned int row, unsigned int col);

Properties

User modules

Description

The same as SetCursorPos.

Return value

0x11 - USetCursorType

Sintaxe

int TextVideo_USetCursorType(int type);

Properties

User modules

Description

The same as SetCursorType.

Return value

0x12 - USetMode

Syntax

int TextVideo_USetMode(unsigned int mode);

Properties

User modules

Description

The same as SetMode.

Return value

The same as SetMode, plus:

0x13 - UWrite

Syntax

int TextVideo_UWrite(const char *text, int size);

Properties

User modules

Description

The same as Write.

Return value

The same as Write, plus: