Dec 132017
 
Video and BIOS routines for Turbo C.
File TCUTIL.ZIP from The Programmer’s Corner in
Category C Source Code
Video and BIOS routines for Turbo C.
File Name File Size Zip Size Zip Type
DEMO.C 2290 939 deflated
DEMO.EXE 8964 5523 deflated
DEMO.PRJ 24 24 stored
SOURCE.ZIP 18739 14665 deflated
TCMAKE.BAT 184 77 deflated
TCUTIL.DOC 21504 5062 deflated
TCUTIL.H 846 341 deflated
TCUTIL.MAK 2012 598 deflated
TCUTILS.LIB 16896 5122 deflated
TCUTILT.LIB 16896 5122 deflated

Download File TCUTIL.ZIP Here

Contents of the TCUTIL.DOC file


TCUTIL

TurboC Utilities
Developed By Jim Derr
2425 Santa Cruz Ct.
Santa Rosa, Ca. 95401


This is may first attempt at distributing software. I have found
numerous execelate software tools and packages on BBS's and I hope
that someone can find these routines usefull.

After I received TURBOC in the mail I was dismayed to find out that
it did not contain any video or bios routines. So in order to use
TURBOC I set out looking for a commerical package and/or a shareware
package to meet my needs. The commerical packages were a little steep
in price and the most of the shareware packaged were overkill.

I decided to develop a set of my own routines and distribute them to
the BBS community. This is my first cut at the routines with more
and better things to come. I have included the source code for all
the routines. All the routines have been tested using the tiny and
small memory models.

Just to protect myself I do not guarentee these routines and use them
at your own risk. They have been tested on PC/XT's, 3270-PC's,
Personal System/2 model 60, and Compaq Portables. They should
work on any good clone that is BIOS compatable.

I have also included the tiny and small library files for those of
you that do not have access to a lib program. Also included is
the Make file to compile and reproduce the lib files.


PLEASE NOTE THAT IF YOU LIKE THESE ROUTINES AND FIND THEM USEFULL
ANY DONATIONS WILL BE GLADLY ACCEPTED. JUST DROP THEM IN THE MAIL
TO THE ADDRESS SHOWN ON PAGE 1 OF THIS DOCUMENT.

Files Included are:

tcutil.doc the documentation file
demo.exe a short demo program
demo.c the source code to the demo program
tcutil.h the header file required by the routines
tcutilt.lib the tiny model library file
tcutils.lib the small model library file
tcutil.mak the make file to compile the routines
tcmake.bat the batch file to run the tcutil.mak file
source.arc the source code for all the routines


Notes on Using these routines:


Most of these routines are fairly self explanitory. However a few
need some additional comments.

BEFORE USING ANY OF THESE ROUTINES IN YOUR PROGRAM YOU MUST!!!!!!!!!!!
USE THE VIDEO_TYPE ROUTINES. This routine sets up some global
variables that the other routines will use. If you complie your
program and get an undefined refenece to any one of the following
you forgot to use the video_type routine.
bios, cga, ega, color, mono, scrseg.


The make_window routine does not save the portion of the screen it
is writing over. There are times when I don't want to save the area
and I don't want a routine assuming I want to save it. If you want
to save the information under the window use the save_scr and rest_scr
functions to save and restore the information.

The save_scr function does not allocate memory for you you must do
it yourself. This allows you the freedom to either allocate is
statically or dynamically. Included in the tcutil header file are
two macros that will correctly calculate the amount of memory you
need to allocate to save the information under a given window.
The following two examples show how to use these macros:

STATIC ALLOCATION:------------------------------------------------------
#define screen1_size setsize_w(0,0,24,79) /*number of bytes needed to
char save_screen1[screen1_size]; save a full screen with
. no shadow */
.
.
save_scr(0,0,24,79,save_screen1);



DYNAMIC ALLOCATION:-----------------------------------------------------
#define screen2_size setsize_ws(0,0,10,20) /*number of bytes needed to
char *save_point; save a screen with the
save_point = (char *)malloc(screen2_size); coordinated of 0,0,10,20
. that will have a shadow */
.
.
save_scr(0,0,10,20,save_point);


There is also another macro in the TCUTIL.H file to aid you in
defining attribute bytes. To use it code your attributes as
follows:

int attr1 = setatr(BLUE,BLACK,0,0);
| | | |
forground color-----+ | | |
background color----------+ | |
blink-------------------------+ | (where blink and bold is 0 or 1)
bold----------------------------+


Most of the routines do not return any values. However if they do
the value returned and it's type is shown in the documentation of
the function. I have not yet put the function prototypes in the
header file but I will as soon as I get some free time.


If you find any error or bugs please drop me a line on the
CC-BBS. (707) 792-0963.
Also if there is some function
you would like added to this library also drop me a line.


!!!!ENJOY!!!!!

Jim Derr
2425 Santa Cruz Ct.
Santa Rosa, Ca. 95401

box [BOX.CC]

void box(int trow, int tcol, int lrow, int lcol, int wattr, int battr)
/* This will draw a box using upper left row,col and lower right row,col
wattr is attribute character for center of box, battr is the border attr.
*/


--------------------------------------------------------------------------




ccolor [CCOLOR.CC]

ccolor(int row, int col, int attr, int len)
/* This routine will change the color attributes of a column of characters.
row=row to start changing color
col=col to start changing color
attr=attribute to change to
len=number of rows down the screen to change.
*/


--------------------------------------------------------------------------




clr [CLR.CC]

void clr(wattr)
/* CLear the screen using the attribute passed */


--------------------------------------------------------------------------




clr_eol [CLREOL.CC]

clr_eol(int last_col)
/* This will clear from the current cursor location the the end of the line.
The last column of the line is specified as last_col
*/



--------------------------------------------------------------------------









- 1 -



clrarea [CLRAREA.CC]

void clrarea(int trow,int tcol,int lrow,int lcol,int wattr)
/* Clear a portion of the screen using the passed attribute
trow = upper left row of area
tcol = upper left col of area
lrow = lower right row of area
lcol = lower right col of area
*/


--------------------------------------------------------------------------




clrbox [CLRBOX.CC]

void clrbox(int trow,int tcol,int lrow,int lcol,int wattr)
/* Clear the area inside the box built by the BOX function to the
specified attribute
*/


--------------------------------------------------------------------------




cur_dn [CURDN.CC]

cur_dn()
/* Move the down one row. This will wrap the cursor to the top of
the screen if the cursor is on the last row
*/


--------------------------------------------------------------------------




cur_lf [CURLF.CC]

cur_lf()
/* Move the cursor one col to the left */


--------------------------------------------------------------------------










- 2 -



cur_nl [CURNL.CC]

cur_nl()
/* Move the cursor to the beginning of the next row */


--------------------------------------------------------------------------




cur_rt [CURRT.CC]

cur_rt()
/* Move the cursor one col to the right */


--------------------------------------------------------------------------




cur_up [CURUP.CC]

cur_up()
/* Move the cursor one row up */


--------------------------------------------------------------------------




file_exist [FILEXIST.CC]

file_exist(char *fn)
/* Check to see of a Find exists.
RETURN 1 if exist 0 if not.
*/


--------------------------------------------------------------------------




flush_key [FLUSHKEY.CC]

flush_key()
/* This will flush the keyboard buffer */


--------------------------------------------------------------------------






- 3 -



get_akey [GETAKEY.CC]

get_akey(char *ch, char *list)
/* Wait until one of the charaacters in the list is pressed. ch will be set
to the upper case value of the key pressed.
*/


--------------------------------------------------------------------------




get_attr [GETATTR.CC]

int get_attr(int row, int col)
/* Get the attribute at the specified row and col.
RETURNED is attr
*/


--------------------------------------------------------------------------




get_ca [GETCA.CC]

get_ca(char *ch, char *scan)
/* Read a keystroke. ch=character code or zero if extended code
scan=extended code or scan code
*/


--------------------------------------------------------------------------




get_chars [GETCHARS.CC]

int get_chars(int row, int col, int leng, char *string)
/* This will read leng characters from the screen at the location specified
by row,col and will place the characters (not the attr bytes) into the
string pointed to by *string.
*/


--------------------------------------------------------------------------










- 4 -



get_cur [GETCUR.CC]

get_cur(int *row, int *col)
/* return the current cursor location into row,col */


--------------------------------------------------------------------------




get_line [GETLINE.CC]

get_line(char *str, int leng, int attr)
/* This will read a string from the screen starting at the current cursor
location for leng characters.
RETURN = the character code that terminated the input string.
I.E. 0x0d for the enter key, 0x1b for the ESC key, 0x3b for F1.
(Note that this character is not returned as part of the string)
*/


--------------------------------------------------------------------------




hide_cur [HIDECUR.CC]

hide_cur()
/* Turn the cursor off */


--------------------------------------------------------------------------




left_str [LEFTSTR.CC]

left_str(int x, char *str, char *new_str)
/* Please the left x number of character from *str into *new_str */


--------------------------------------------------------------------------




locate [LOCATE.CC]

locate(int row, int col)
/* Position the cursor at row,col */


--------------------------------------------------------------------------



- 5 -



make_shadow [SHADOW.CC]

make_shadow(int trow, int tcol, int brow, int bcol)
/* This will create the illusion of a shadow under the window specified by:
trow=upper left row
tcol=upper left col
brow=lower right row
bcol=lower right col
*/


--------------------------------------------------------------------------




make_window [MAKEWIND.CC]

make_window(int trow, int tcol, int brow, int bcol, int wattr, int battr, int shadow, char *title, char *footer)
/* Make a window at the specified location.
trow=upper left row of window range 0-24
tcol=upper left col of windoe range 0-79
brow=lower right row of window
bcol=lower right col of window
wattr=attribute of window
battr=attribute of border of window
shadow=0=no shadow =1=make a shadow
title=title for window
footer=bottom footer for window
Needs the following golbal data defined:
int color, mono, cga, ega, scrseg, bios;
*/



--------------------------------------------------------------------------




mid_str [MIDSTR.CC]

mid_str(int begin, int leng, char *o_str, char *n_str)
/* Extract the characters from *o_str starting at position begin for leng
number of characters and place them into *n_str.
*/


--------------------------------------------------------------------------










- 6 -



parse_fn [PARSEFN.CC]

parse_fn(char *fspec,char *fdrive, char *fpath, char *fn, char *fe)
/* This function will parse and break apart the filespec pointed to
by *fspec.It will pass back the drive, directory, filename, extension.
If a given part does not exist a NULL character string will be passed
back.
*/


--------------------------------------------------------------------------




put_ca [PUTCA.CC]

put_ca(char ch, int attr, int count)
/* This will put the specified charater and attribute on the screen at
the current cursor location.
*/


--------------------------------------------------------------------------




put_sa [PUTSA.CC]

put_sa(char *ch, int attr)
/* This will put the character string pointer to by *ch on the screen
at the current cursor location using attribute attr.
*/


--------------------------------------------------------------------------




rcolor [RCOLOR.CC]

void rcolor(int row, int col, int attr, int len)
/* This routine will change the color attribute of a row of character.
row=row to change range 0-24
col=beginning col to changerange 0-79
attr=attribute to change to
len=num of characters to change
*/


--------------------------------------------------------------------------






- 7 -



rest_scr [RESTSCR.CC]

rest_scr(int trow, int tcol, int brow, int bcol, char *array)
/* Restore an area of the current screen that was saved via save_scr.
To determine num of chars for array use the following formula:
*/


--------------------------------------------------------------------------




right_str [RIGHTSTR.CC]

right_str(int x, char *str, char *new_str)
/* This will take the right x number of character from the string pointed
to by *str and place them into the string pointed to by *new_str.
*/


--------------------------------------------------------------------------




s_str_lf [SSTRLF.CC]

s_str_lf(int count, char *str)
/* This will shift the characters in the string pointed to by *str left
count number of characters. Blanks will be added in the positions where
character are shifted out. The leng of the string will not be changed.
*/


--------------------------------------------------------------------------




s_str_rt [SSTRRT.CC]

s_str_rt(int count, char *str)
/* This will shift the characters in the string pointed to by *str right
count number of characters. Blanks will be added in the positions where
character are shifted out
*/


--------------------------------------------------------------------------









- 8 -



save_scr [SAVESCR.CC]

save_scr(int trow, int tcol, int brow, int bcol, char *array)
/* Save an area of the current screen into a character array
To determine num of chars for array use the following formula:
num_chars=((brow-trow+1) * (bcol-tcol+1)) *2;
*/


--------------------------------------------------------------------------




scroll_dn [SCROLLDN.CC]

scroll_dn(int trow, int lcol,int brow, int rcol,int attr, int lines)

/* This will scroll the defined window down x number of lines:
trow=upper left row
lcol=upper left column
brow=lower right row
rcol=lower right col
lines=number of lines to scroll
/*


--------------------------------------------------------------------------




scroll_up [SCROLLUP.CC]

scroll_up(int trow, int lcol,int brow, int rcol,int attr, int lines)
/* This will scroll the specified window up the specified number of lines.
SEE SCROLL_DN FOR DESCP. IF ARGS PASSED
*/


--------------------------------------------------------------------------




set_mode [SETMODE.CC]

set_mode(int mode)
/* This will set the video mode to the mode passed */


--------------------------------------------------------------------------








- 9 -



show_cur [SHOWCUR.CC]

show_cur(int size)
/* This will make the cursor visiable.
size=1 = cursor uses scan lines 6-7.
size=9 = cursoe uses scan lines 0-7.
*/


--------------------------------------------------------------------------




strip [STRIP.CC]

strip(char *str, char c)
/* This will string all occurances of char c out of string pointed to by *str */


--------------------------------------------------------------------------




striprange [STRIPRNG.CC]

striprange(char *str,char clo,char chi)
/* This will strip all occurances of the characters that fall between
char clo and chi out of the string pointed to by *str.
*/


--------------------------------------------------------------------------




trim_l [TRIML.CC]

trim_l(char *str)
/* This will remove all blanks from the left side of the string
pointed to by *str.
*/


--------------------------------------------------------------------------












- 10 -



trim_r [TRIMR.CC]

trim_r(char *str)
/* This will trim all blanks characters from the rigth side of the
string pointed to by *str.
*/


--------------------------------------------------------------------------




upcase [UPCASE.CC]

upcase(char *str)
/* This will convert the string pointed to by *str to uppercase */


--------------------------------------------------------------------------




video_type [VIDEOTYP.CC]

video_type()
/* This will determine the Video type of the display.
This routine defines the following global definition.
int color, mono, cga, ega, bios, scrseg;
They can be used by other functions if you define them as external
definitions.
*/


--------------------------------------------------------------------------




writef [WRITEF.CC]

writef(int row, int col, int attr, char *line)
/* This will do a direct video write of the string pointed to by
*str at location row,col using attribute attr.
*/


--------------------------------------------------------------------------










- 11 -



writefc [WRITEFC.CC]

writefc(int row, int col, int attr, char ch)
/* This will do a direct video write of the character ch. It will be
placed at location row,col using attribute attr.
*/


--------------------------------------------------------------------------


















































- 12 -


 December 13, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)