Dec 092017
 
Video I/O function library for C.
File VIO.ZIP from The Programmer’s Corner in
Category C Source Code
Video I/O function library for C.
File Name File Size Zip Size Zip Type
VID_CLOK.C 21675 4762 deflated
VID_CLOK.EXE 5105 2470 deflated
VID_CLOK.PRJ 29 28 deflated
VID_SCRN.ASM 45220 5922 deflated
VID_SCRN.DOC 28690 4917 deflated
VID_SCRN.H 792 244 deflated
VID_SCRN.LIB 2575 1140 deflated

Download File VIO.ZIP Here

Contents of the VID_SCRN.DOC file


VID_SCRN.DOC
Jerry Joplin [70441,2627] CIS
Version 1.0 23-Nov-1987

VID_SCRN.ASM is the assembly language source to a set of very fast
video manipulation routines providing direct access to video memory
while maintaining Microsoft Windows and DESQview __good_screen_behavior__
compatibility. Also provided is VID_SCRN.LIB which contains the assembled
object module.

i) Many of the included functions directly access video memory, yet
remain Microsoft Windows and DESQview compatible by checking
to see if a virtual screen buffer has been established for
the current process. This enables programs written using
these techniques to run under these operating environments
in a well behaved window.
ii) Some functions are especially useful for an application
running under a control program, but all the functions will
perform identical operations when a control program is not
present.
iii) Snow suppression is used when non-monochrome real video memory
is accessed.
iv) Absolutely no error checking is done on any of the functions
in order to provide maximum throughput.
v) The functions have been designed to work with the small and
tiny models only. They also work fine with MSC V4.0 and 5.0
vi) I dont ask for any compensation for this library of routines
but would like to see any improvements or enhancements that
may come from them.
vii) Included functions -

vid_puts ;Write string w/attr
vid_readc ;Read char/attr

vid_memread ;Video memory block read
vid_memwrite ;Video memory block write

vid_putc ;Write character w/attr

vid_begin ;Begin a video update
vid_update ;End a video update
vid_buffc ;Write a char/attr in an update

vid_clearbox ;Clear a window
vid_scrollbox ;Scroll a window
vid_drawbox ;Draw a box around a window
vid_setbox ;Set a box character set

vid_setpage ;Set the active video page
vid_setmode ;Set the video mode
vid_poscurs ;Position the cursor

Released into the public domain by the author. Windows is a registered
trademark of Microsoft Corporation. DESQview is a registered trademark
of Quarterdeck.

/***********************************************************************/

function vid_puts


int vid_puts(string,row,col,attr)
char *string;
int row;
int col;
int attr;

Parameter descriptions
string - pointer to a null terminated character string
row - row at which to display string
col - column at which to display string
attr - video attribute for the displayed string

Summary
This function displays a null terminated string to
a row and column on the video screen with the
specified attribute.

Return values
none

Example
/*
Display a string at top left corner of screen
in reverse video
*/

#define REVERSE 0x0070
vid_puts("Hello world",0,0,REVERSE);


Notes for use under a control program
If a control program is present the string is written
to the process virtual screen. A request is then sent to
update the altered positions of the virtual screen onto
the real screen. Since several characters lying in a
contigious block of video memory can be included in one
real screen update request, this function is very fast.


/***********************************************************************/

function vid_readc


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

Parameter descriptions
row - row from which to read a character/attribute
col - column from which to read a character/attribute

Summary
This function reads a character and its attribute
from a row and column on the video screen.

Return values
Unsigned integer containing the character read from the
screen in the low byte of the word, and the attribute
in the high byte of the word.

Example
/*
Read character/attr from the top left corner of screen
*/

#define REVERSE 0x0070
unsigned char_attr;
char_attr = vid_readc(0,0);
if ( (char_attr & 0x00ff) == 'H') {
....
}
if ( (char_attr >> 8) == REVERSE) {
....
}

Notes for use under a control program
If a control program is present the char/attr is read
straight from the process virtual screen.


/***********************************************************************/

function vid_memread


int vid_memread(buffer,row,col,count)
void *buffer;
int row;
int col;
int count;

Parameter descriptions
buffer - near pointer to a buffer of size (count * 2)
where the block will be stored
row - row at which to start the video block read
col - column at which to start the video block read
count - number of CHARACTER positions to read

Summary
This function reads a block of memory from the video
screen. Each word of memory will contain both the
attribute and the character values for (count) positions
in the memory block.

Return values
none

Example
/*
Save 20 characters and attributes from the top left
corner of the screen
*/

void *buffer;

void = malloc( 20 * 2);
vid_memread(buffer,0,0,20);

Notes for use under a control program
If a control program is present the block is read
straight from the process virtual screen.


/***********************************************************************/

function vid_memwrite


int vid_memwrite(buffer,row,col,count)
void *buffer;
int row;
int col;
int count;

Parameter descriptions
buffer - near pointer to a buffer of size (count * 2)
which will be transfered to video memory
row - row at which to start the video block write
col - column at which to start the video block write
count - number of CHARACTER positions to write

Summary
This function writes a block of video memory from a saved
buffer. Each word of memory should contain both the
attribute and the character values for (count) positions
in the memory block. The buffer is generally created
using a call to vid_memread.

Return values
none

Example
/*
Save 20 characters and attributes from the top left
corner of the screen then write the same block of
memory to row 1 column 5 of the screen
*/

void *buffer;

void = malloc( 20 * 2);
vid_memread(buffer,0,0,20);
vid_memwrite(buffer,1,5,20);


Notes for use under a control program
If a control program is present the block is written
to the process virtual screen. A request is then
sent to update the altered positions of the virtual
screen onto the real screen. All positions written to
the screen will lie in a contigious block of video memory
making this function very fast.


/***********************************************************************/

function vid_putc


int vid_putc(chr,row,col,attr)
char chr;
int row;
int col;
int attr;

Parameter descriptions
chr - character to display
row - row at which to display chr
col - column at which to display chr
attr - video attribute for the displayed chr

Summary
This function displays a character to a row and
column on the video screen with the specified attribute.

Return values
none


Example
/*
Display a 'H' to the top left corner of screen
in reverse video
*/

#define REVERSE 0x0070
vid_putc('H',0,0,REVERSE);


Notes for use under a control program
If a control program is present the character is written
to the process virtual screen. A request is then sent to
update the altered position of the virtual screen onto
the real screen. There is a small amount of overhead
for updating the character onto the real screen. Thus
this function probably shouldn't be used if more chars
are going to be displayed that will lie in a contigious
block of video memory OR if they are clustered together
in a small block of contigious video memory.


/***********************************************************************/

function vid_begin


int vid_begin()

Parameter descriptions
none

Summary
This function is used to mark the begining of
a video update. It is especially useful under
environments running Microsoft Windows or DESQview
and has no effect if neither is detected.

Return values
none

Example
/*
See vid_update
*/


Notes for use under a control program
This is especially designed for environments running
Microsoft Windows or DESQview. It can be used in
conjuction with vid_buffc, and vid_update to obtain
high performance displays under these control programs.
See example under vid_update.

/***********************************************************************/

function vid_buffc


int vid_buffc(chr,row,col,attr)
char chr;
int row;
int col;
int attr;

Parameter descriptions
chr - character to write to video buffer
row - row at which to place chr
col - column at which to place chr
attr - video attribute for the buffered chr

Summary
This function places a character with attribute to
a row and column on the video buffer. It is especially
useful under environments running Microsoft Windows or
DESQview. Otherwise the function is functionally
equivalent to to vid_putc since the location of the
video buffer is the real video screen.

Return values
none

Example
/*
See vid_update
*/

Notes for use under a control program
This is especially designed for environments running
Microsoft Windows or DESQview. It can be used in
conjuction with vid_begin, and vid_update to obtain
high performance displays under these control programs.
See example under vid_update.


/***********************************************************************/

function vid_update


int vid_update()

Parameter descriptions
none

Summary
This function is used to mark the end of a video
update and to transfer all the changed positions of
the process video buffer to the real video screen.
It is especially useful under environments running
Microsoft Windows or DESQview and has no effect if
neither is detected.

Return values
none

Example
/*
Case 1 : vid_begin, vid_buffc, and vid_update are
used to build a portion of the video screen that is
a closely contigious portion of video memory. This is
comparared to a slower usage of vid_putc to achieve
the same output.
*/

/* display message at the top left corner of screen */
#define REVERSE 0x0070
vid_puts("Hello world",0,0,REVERSE);

vid_begin(); /* Mark start of update */
vid_buffc('J',0,0,REVERSE); /* Change */
vid_buffc('B',0,6,REVERSE); /* "Hello world" */
vid_buffc('w',0,8,REVERSE); /* to */
vid_buffc(' ',0,10,REVERSE); /* "Jello Bowl " */
vid_update(); /* Move Jello Bowl to */
/* the real video screen*/
/* The control program, */
/* if present, will move*/
/* 10 characters on the */
/* call to vid_update. */


/* redisplay original message at the top left corner */
#define REVERSE 0x0070
vid_puts("Hello world",0,0,REVERSE);

vid_putc('J',0,0,REVERSE); /* Change */
vid_putc('B',0,6,REVERSE); /* "Hello world" */
vid_putc('w',0,8,REVERSE); /* to */
vid_putc(' ',0,10,REVERSE); /* "Jello Bowl "*/
/* This is slower than */
/* above use since each */
/* character is updated */
/* to the real screen as*/
/* it is written. */


/*
Case 2 : vid_begin, vid_buffc, and vid_update are
used to build a portion of the video screen that is
not in a closely contigious portion of video memory.
This is comparared to a faster usage of vid_putc to
achieve the same output.
*/

/* define normal attribute */
#define NORM 7
/* define the characters of the corners of a box */
#define UPLEFT 218
#define UPRIGHT 191
#define LOWLEFT 217
#define LOWRIGHT 192

/* display the corners of a box characters */

vid_begin(); /* Mark start of update */
vid_buffc(UPLEFT,0,0,NORM); /* Buffer upper left, */
vid_buffc(UPRIGHT,0,19,NORM); /* upper right, */
vid_buffc(LOWLEFT,19,0,NORM); /* lower left */
vid_buffc(LOWRIGHT,19,19,NORM);/* and lower right. */
vid_update(); /* Move the chracters to*/

/* the real video screen*/
/* The control program, */
/* if present, will move*/
/* (20 * 20) = 400 words*/
/* at call to vid_update*/
/* This causes noticable*/
/* flicker under Windows*/


/* redisplay the corners of a box using vid_putc */
vid_buffc(UPLEFT,0,0,NORM); /* Display upper left, */
vid_buffc(UPRIGHT,0,19,NORM); /* upper right, */
vid_buffc(LOWLEFT,19,0,NORM); /* lower left */
vid_buffc(LOWRIGHT,19,19,NORM);/* and lower right. */
/* Here the screen is */
/* updated 4 times but */
/* the control program, */
/* if present, will only*/
/* move 4 words to the */
/* real screen. */


Notes for use under a control program
This is especially designed for environments running
Microsoft Windows or DESQview. It can be used in
conjuction with vid_begin, and vid_buffc to obtain
high performance displays under these control programs.


/***********************************************************************/

function vid_clearbox


int vid_clearbox(toprow,leftcol,lowrow,rightcol,attr)
int toprow;
int leftcol;
int lowrow;
int rightcol;
int attr;

Parameter descriptions
toprow - top row of the window to be cleared
leftcol - left column of the window to be cleared
lowrow - bottom row of the window to be cleared
rightcol - right column of the window to be cleared
attr - video attribute of the cleared area

Summary
This function clears a window of the video screen
and sets it to a specified video attribute.

Return values
none

Example
/*
Clear the entire 80 X 25 screen and set it to
a normal video attribute
*/

#define NORM 7
vid_clearbox(0,0,24,79,NORM);


Notes for use under a control program
No special action is taken if a control program is
present since this calls on the BIOS scroll box
video function to clear the area of the screen and
both Windows and DESQview do an excellant job of
intercepting this call and performing it quickly.



/***********************************************************************/

function vid_scrollbox


int vid_scrollbox(toprow,leftcol,lowrow,rightcol,attr,direct,lines)
int toprow;
int leftcol;
int lowrow;
int rightcol;
int attr;
int direct;
int lines;

Parameter descriptions
toprow - top row of the window to be scrolled
leftcol - left column of the window to be scrolled
lowrow - bottom row of the window to be scrolled
rightcol - right column of the window to be scrolled
attr - video attribute for new lines
direct - direction of the scroll
0 = scroll up
1 = scroll down
lines - number of lines to scroll


Summary
This function scrolls a window of the video screen
a certain number of lines in a specified direction,
setting the new lines from the scroll to an attribute.
If the number of lines is given as 0 then this becomes
a functional equivalent to vid_clearbox.

Return values
none

Example
/*
Scroll a box down by 3 lines setting the new lines
in the top of the window to normal video attributes
*/

#define NORM 7
#define TOP 0
#define LEFT 0
#define BOTTOM 19
#define RIGHT 50
vid_clearbox(TOP,LEFT,BOTTOM,RIGHT,NORM,1,3);


Notes for use under a control program
No special action is taken if a control program is
present since this calls on the BIOS scroll box
video function to scroll the area of the screen and
both Windows and DESQview do an excellant job of
intercepting this call and performing it quickly.




/***********************************************************************/

function vid_drawbox


int vid_drawbox(toprow,leftcol,lowrow,rightcol,attr,boxset)
int toprow;
int leftcol;
int lowrow;
int rightcol;
int attr;
int boxset;

Parameter descriptions
toprow - top row of the box
leftcol - left column of the box
lowrow - bottom row of the box
rightcol - right column of the box
attr - video attribute for characters of the box
boxset - character set to use for the box
use vid_setbox to establish a character set
default boxsets are set as
1 = single line box
2 = double line box
up to 8 box sets can be created ( 0 thru 7 )

Summary
This function draws a border around a specified window
of the video screen. The characters to use for the
border are specified as a box set number from 0 to 7.
These characters can be set using vid_setbox.

Return values
none

Example
/*
Draw a double line box around a window setting the box
characters to reverse video
*/

#define REVERSE 0x70
#define TOP 0
#define LEFT 0
#define BOTTOM 19
#define RIGHT 50
vid_drawbox(TOP,LEFT,BOTTOM,RIGHT,REVERSE,2);


Notes for use under a control program
This function calls upon vs_begin, vs_buffc, and
vs_update to draw the top and bottom lines of the
box. The right and left edges of the box are drawn
using vs_putc.


/***********************************************************************/

function vid_setbox


int vid_setbox(set,topleft,top,topright,right,lowright,low,lowleft,left)
int set;
int topleft;
int top;
int topright;
int right;
int lowright;
int low;
int lowleft;
int left;

Parameter descriptions
set - number of the boxset to establish
must be a value from 0 to 7 .
two default boxsets are initialized :
1 = single line box
2 = double line box
topleft - the character for the top left corner
top - the character for the top side
topright - the character for the top right corner
right - the character for the right side
lowright - the character for the bottom right corner
low - the character for the bottom side
lowleft - the character for the bottom left corner
left - the character for the left side

Summary
This function establishes a character set to use for
drawing a border around a specified window of the video
screen using vid_drawbox.

Return values
none

Example
/*
Establish box set 0 with the top and bottom lines
as double line characters and the sides of the box as
single line characters. Then draw the box around a window
in reverse video.
*/

#define REVERSE 0x70
#define NORMAL 0x07
#define TOP 0
#define LEFT 0
#define BOTTOM 19
#define RIGHT 59
vid_setbox(0,213,205,184,179,190,205,212,179);
vid_clearbox(TOP,LEFT,BOTTOM,RIGHT,NORMAL);
vid_drawbox(TOP,LEFT,BOTTOM,RIGHT,REVERSE,0);


Notes for use under a control program
This function doesn't actually perform any video
screen IO.


/***********************************************************************/

function vid_poscurs


int vid_poscurs(row,col)
int row;
int col;

Parameter descriptions
row - row to position cursor
col - column to position cursor

Summary
This function sets the cursor to row and
column on the video screen.

Return values
none

Example
/*
Hide the cursor by positioning it to row 25 column 0
*/

vid_poscurs(25,0);


Notes for use under a control program
No special action is taken if a control program is
present since this calls on the BIOS set cursor position
video function, which both Windows and DESQview
intercept nicely.


/***********************************************************************/

function vid_setpage


int vid_setpage(vidpage)
int vidpage;

Parameter descriptions
vidpage - video page

Summary
This function sets the current video page. The only
supported page in this library is page 0. The function
is only provided to make sure the video page has been
initialized to zero.

Return values
none

Example
/*
Initialize the video page to 0
*/

vid_setpage(0);


Notes for use under a control program
No special action is taken if a control program is
present since this calls on the BIOS set video page
video function, which both Windows and DESQview
intercept nicely.



/***********************************************************************/

function vid_setmode


int vid_setmode(vidmode)
int vidmode;

Parameter descriptions
vidmode - video mode

Summary
This function establishes the current video mode.
The following modes are supported in this library
2 80 X 25 blank and white text
3 80 X 25 color text
7 80 X 25 monochrome text

Return values
none

Example
/*
Set the video mode to 80 X 25 color text
*/

vid_setmode(3);


Notes for use under a control program
No special action is taken if a control program is
present since this calls on the BIOS set video mode
video function, which both Windows and DESQview
intercept nicely.

/***********************************************************************/



 December 9, 2017  Add comments

Leave a Reply