home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-07-23 | 69.4 KB | 2,735 lines |
-
- (c) JAZSOFT 1986 by Jack A. Zucker
-
- If you are interested in getting support for these
- routines or are just feeling plain guilty for using them
- without paying for them, feel free to send a donation of
- whatever you can afford. ($25.00 would be appreciated).
- My address is:
-
- JazSoft
- Jack A. Zucker
- 10318 Broom Lane
- Seabrook, Md. 20706
-
- You may leave messages to me concerning problems, advice, etc on
- Robert Blacher's Ibm Pc board at
- (301) 547-2008
- or if you are really desperate at my house at
-
- (301) 794-5950 or
- (301) 794-8763.
-
-
- If you get my answering machine, Please leave a message and your phone
- number, but be forewarned... I will not call you long distance unless
- you tell me to call collect. Sorry about this but I called one guy and
- spent a half hour talking to him then found out he lived in Ontario,Ca.!!!!
- Thanks, and I hope you enjoy.
- -Jaz
-
-
-
-
-
- DOS FUNCTIONS AND FILE HANDLING
-
- 1. JZCLSFIL Close a file handle
-
- This functions closes a previously opened file handle.
-
- werror = jzclsfil(whandle);
-
- int werror -1 if an error occurred,
- 0 if everything went according to plan.
-
- int whandle The opened file handle.
-
- 2. JZCPYFIL Copy a file
-
- This function copies one file spec to another file spec.
- Wildcards may also be used in the file spec.
-
- jzcpyfil(wsource,wdestin);
-
- char *wsource Source file specification
-
- char *wdestin Destination file specification
-
- 3. JZCRTFIL Create a file handle
-
- This function creates a file handle or truncates an existing
- one.
-
- werror = jzcrtfil(wname,wattr);
-
- int werror -1 if an error occurred,
- otherwise a valid dos file handle
-
- char *wname File spec to create/truncate
-
- int wattr File attribute to create file with.
- 0 or 32 is the normal file attribute.
-
- 4. JZDOSFLG Return the vector of the "in dos" flag.
-
- This function returns the address of the "in dos" flag. This
- is valuable in resident programs to determine whether or not
- dos commands can be run when a program is interupted. Normally,
- if the in dos flag <> 0 then a dos call is in progress and dos
- i/o may NOT be performed.
-
- jzdosflg(&wvector);
-
- TVECTOR wvector This struct is defined in JAZ.H and contains
- an segment and offset field. This can be
- converted to a far pointer and used to reference
- the in dos flag.
-
- EX.
-
- #include <jaz.h>
- TVECTOR wvector;
-
- jzdosflg(&wvector);
-
- if (memb(wvector.segment,wvector.offset))
- printf("\nIn the middle of a dos function call.");
-
- 5. JZDOSVER Return the dos major and minor version.
-
- This function returns an integer equal to the dos version.
- The Low byte will be the major version and the High byte will
- be the minor version.
-
- wversion = jzdosver();
-
- int wversion The version of dos you are running.
- i.e. 0A03 (hex) for dos 3.1
-
- EX.
-
- int wversion;
-
- wversion = jzdosver(); /* get dos version */
-
- /**
- ** exit this mythical program
- ** if the dos version is below 2.0
- **/
-
- if ((wversion & 0xFF) < 2) {
- printf("\nMust have 2.0 or greater to run this program.");
- exit(1);
- }
-
- 6. JZDSKFRE Return the free space remaining on the disk.
-
- This function returns file allocation table information regarding
- free space remaining on the specified disk.
-
- jzdskfre(&wfat,wdrive);
-
- TFAT wfat This structure is defined in JAZ.H. It
- contains fields for free, total, and
- used.
-
- int wdrive; This should be:
- 0 : default drive
- 1 : A:
- 2 : B:
- 3 : C:
- etc.
-
- EX.
-
- #include <jaz.h>
-
- TFAT wfat;
-
- jzdskfre(&wfat,0); /* get free space on default drive */
-
- if (wfat.free < 360000L)
- printf("\nThis disk is not empty!");
-
- 7. JZDSKSTS Return a disk status code
-
- Return a disk status code for the specified drive. This
- will not cause an "Abort , Retry, Ignore" error and is
- good for determining whether or not a disk is formatted
- or the drive door is open.
-
- wstatus = jzdsksts(wdrive);
-
- int wstatus $80 - Timeout
- $40 - Bad Seek
- $20 - Nec Controller failed
- $10 - Bad Crc
- $8 - Attempt to cross 64k boundry
- $4 - Sector not found
- $3 - write protect
- $2 - address mark not found
- $1 - bad command
- $0 - Succsessful
-
- int wdrive 0..3 for floppy diskette drives A,B,C,D
- $80..$83 for fixed disk drives C,D,E,F ETC.
-
-
- 8. JZFAT Get file allocation table information.
-
- Returns Sect/Allocation unit , total Clusters, bytes/sectors
- for the specified drive.
-
- wid = jzfat(wdrive,§_alloc,§_size,&cluster);
-
- char far *wid Far pointer to FAT id byte
-
- int wdrive 0 : Default drive
- 1 : Drive A
- 2 : Drive B
- 3 : Drive C
- etc
-
- unsigned
- int sect_alloc Sectors per allocation unit. (Sect/Cluster)
-
- unsigned
- int sect_size Bytes per sector
-
- unsigned
- int clusters Total Clusters on disk
-
- 9. JZFNDFST Find first matching file
-
- This function finds the first matching file given a file
- specification i.e. *.c
-
- werror = jzfndfst(wmask,wattr,&wdta);
-
- int werror returns 0 if a match was found, otherwise there
- are no files matching the mask specification.
-
- char *wmask File specification i.e. "*.DOC"
-
- int wattr Attribute to search for.
- 1 : Read Only
- 2 : Hidden
- 4 : System
- 8 : Volume Label
- 16 : Sub-Directory
- 32 : Archive
- These may be "OR"ed together to get combinations.
- Use 0 for normal files, 0xFF for ALL files
-
- TDIR wdta; Structure defined in jzdirect.h which defines the
- disk transfer address buffer, with various directory
- fields.
-
- 10. JZFNDNXT Find next matching file
-
- Find the next matching file after initially calling jzfndfst.
-
- werror = jzfndnxt(&wdta);
-
- int werror returns 0 if a match was found, otherwise ther
- are no more files matching the mask specification.
-
- TDIR wdta Structure defined in jzdirect.h which defines the
- disk transfer address buffer, with various directory
- fields.
-
-
- EX.
- #include <jzdirect.h>
-
- int werror; /* return error code */
- TDIR wdta; /* disk directory buffer */
-
- werror = jzfndfst("*.*",0,&wdta); /* list all files in directory */
-
- while (werror == 0) {
- printf("\n%s",wdir.name);
- werror = jzfndnxt(&wdta);
- }
-
- 11. JZGETATR Get a files attribute
-
- Return the attribute for a given file.
-
- wattr = jzgetatr(wfilename);
-
- int wattr Attribute returned for file
- -1 : Error (Probably file not found)
- 1 : Read Only
- 2 : Hidden
- 4 : System
- 8 : Volume Label
- 16 : Sub-Directory
- 32 : Archive
-
- char
- *wfilename File name to return attribute for
-
- 12. JZGETDAT Return the system date
-
- Return the system date as a string. i.e. 01-25-1986
- Make sure to reserve enough space for the entire date.
- at least 11 chars (including the null terminator)
-
- jzgetdat(wdate);
-
- char *wdate : date string returned here
-
- 13. JZGETDR Return the current working directory.
-
- Return the working sub-directory as a string.The string will
- not have a "\" char after it so if you want to use this for
- searches, you must concatenate a "\" to it, especially if you
- are in the root dir as it may return "".
-
- jzgetdr(wdir);
-
- char *wdir Current working sub-directory string on return
-
- 14. JZGETDRV Get logged drive
-
- Return the current logged drive.
-
- wdrive = jzgetdrv();
-
- int wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
- etc..
-
- 15. JZGETDTA Get the disk transfer address
-
- Return the current disk transfer address from Dos. This is needed
- by the directory routines which change the DTA. They save the address
- in a work variable , then change it for the directory call, then
- restore it. This is necessary 'cuz some of the high level file
- access routines use the DTA as the file buffer!
-
- jzgetdta(wofs,wseg);
-
- int wofs Offset of DTA address
-
- int wseg segment of DTA address
-
- 16. JZGETFCB Get an unopened FCB
-
- Return an unopened FCB record given a drive and file name.
- The unopened FCB contains detailed info on the file including
- the starting cluster number. See JZCHKDSK for info on where
- to use this routine.
-
- werror = jzgetfcb(&wfcb,wfilename,wdrive);
-
- int werror -1 if an error occurred,
- 0 if everything went according to plan.
-
- TFCB wfcb File control block record defined in JAZ.H
-
- char
- *wfilename File name to get FCB for. Paths are NOT allowed!
-
- int wdrive 1 : Drive A
- 2 : Drive B
- 3 : Drive C
- etc...
-
-
- 17. JZGETINT Get an interrupt vector
-
- Return the segment/offset address of a given interrupt number
-
- jzgetint(wint,&wvec);
-
- int wint Interrupt number to get address of
-
- TVEC wvec Segment offset record defined in JAZ.H
-
- 18. JZGETMEM Allocate memory
-
- Return a segment pointer to a block of free memory.
-
- werror = jzgetmem(wbytes,&wpointer);
-
- int werror -1 if an error occurred,
- 0 if everything went according to plan.
-
- unsigned
- int wbytes Number of bytes requested to allocate
-
- unsigned
- int wpointer Pointer to segment of free memory.
-
- 19. JZGETTIM Get the system time
-
- Return the system time as a string: 19:05:22 . Make sure to
- allocate at least 9 chars for the string length.
-
- jzgettim(wtime);
-
- char *wtime Time string to be returned.
-
- 20. JZGETVOL Get the volume label of a drive
-
- Get the volume label for the specified drive;
-
- wptr = jzgetvol(wdrive,wvolume);
-
- char *wptr Pointer to wvolume argument for using in
- expressions. Null pointer if error occured.
-
- wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
- etc.
-
- char
- *wvolume String for volume label. Make sure to allocate
- at least 13 chars for this string.
-
- 21. JZLOGDRV Change the logged drive.
-
- Set the current logged drive.
-
- wnumdrives = jzlogdrv(wdrive);
-
- int
- wnumdrives Returns the number of drives in the system
-
- int wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
- etc
-
- 22. JZOPNFIL Open a file handle
-
- Open a file handle for read/write access
-
- werror = jzopnfil(wname,wmode);
-
- int werror -1 if an error occurred,
- otherwise a valid dos file handle
-
- char *wname File name to open
-
- int wmode 0 : read only
- 1 : write only
- 2 : read/write
- et. al.
-
- 23. JZPOPDIR Pop a directory
-
- Pop a directory from the directory stack and change the
- current logged directory to it.
-
- jzpopdir(&whead,wpopdrive);
-
- TSTKHEAD
- whead Head of stack structure defined in JAZ.H
-
- int wpopdrive 1 : Pop the drive as well as the directory
- 0 : Don't pop the drive, Only the directory.
-
- 24. JZPSHDIR Push a directory
-
- Push a directory and drive onto the directory stack for subsequent
- use by jzpopdir.
-
- jzpshdir(&whead);
-
- TSTKHEAD
- whead Head of stack structure defined in JAZ.H
-
- 25. JZREDFIL Read from a file handle.
-
- Read data from a file handle into a buffer. This is a fairly
- high speed disk access method, very useful for copying files and
- such.
-
- wnum = jzredfil(whandle,wbuf,wamt);
-
- unsigned
- int wnum Actual number of bytes read from the file. A value
- of < wamt (or 0) means end of file.
-
- int whandle The handle of the previously opened file from a call
- to jzopnfil/jzcrtfil
-
- char *wbuf Buffer to read the data into. Usually an array or
- pointer to char.
-
- unsigned
- int wamt The number of bytes requested to read.
-
- 26. JZSEKFIL Seek into a file.
-
- Seek to a position into a file. (Random Access). There are 3
- methods of seeking:
- 0 : Seek relative to beginning of file.
- 1 : Seek relative to Current file position
- 2 : Seek relative to End of File
-
- Note that negative offsets are not allowed !.
-
- wpos = jzsekfil(whandle,woffset,wmethod);
-
- long wpos Position of the file pointer in bytes relative
- to the beginning of the file.
-
- int whandle The handle of the previously opened file from a call
- to jzopnfil/jzcrtfil
-
- unsigned int
- woffset Offset of bytes to seek from one of the
- methods specified in wmethod.
-
- int wmethod 0 : Seek relative to beginning of file.
- 1 : Seek relative to Current file position
- 2 : Seek relative to End of File
-
-
- EX.
-
- /* how to seek to the end of the file minus one */
- /* difficult 'cuz negative offsets not allowed */
-
- int whandle;
- long fsize,jzsekfil();
-
- . . . . .
-
- /* assume file was already opened at this point */
-
- fsize = jzsekfil(whandle,0L,2); /* seek to end of file */
- if (fsize) {
- fsize --; /* subtract 1 from size */
- jzsekfil(whandle,fsize,0); /* seek to eof - 1 */
- }
-
- 27. JZSETATR Set a files attributes
-
- Set the attributes of a given file .
-
- werror = jzsetatr(wname,wattr);
-
- int werror -1 if an error occurred,
- 0 if everything went according to plan.
-
- char *wname File name with which to set attributes
-
- int wattr Attribute used to set for file. These may
- be *or* ed together.
- 1 : Read Only
- 2 : Hidden
- 4 : System
- 8 : Volume Label
- 16 : Sub-Directory
- 32 : Archive
-
- 28. JZSETDTA Set the disk transfer address
-
- This function sets the disk transfer address to the given
- buffer (relative to DS). Used internally for jzfndfst &
- jzfndnxt.
-
- jzsetdta(&wdta);
-
- TDTA wdta Disk transfer structure to point DTA to.
-
- 29. JZSETINT Set an interrupt vector
-
- Set the vector for a particular interrupt of your specification.
- Useful for redirecting interrupts to your routines.
-
- jzsetint(wint,wvec);
-
- int wint Interrupt vector number to set.
-
- TVECTOR wvec Structure where segment and offset fields
- are already filled in.
-
- EX.
-
- TVECTOR wvec;
- int prtsc();
-
- wvec.segment = getcs();
- wvec.offset = prtsc; /* get address of new print screen */
-
- jzsetint(5,wvec);
-
- 30. JZTRMRES Terminate and stay resident
-
- Terminate the current process but leaving the program resident
- in memory.
-
- jztrmres();
-
- 31. JZUNQFIL Return a unique file handle/name.
-
- This routine is functionally equivalent to JZOPNFIL
- except it returns a handle pointing to a file name
- that does not already exist. Very useful for temp
- files.
-
- whandle = jzunqfil(wpath,wattr);
-
- int whandle -1 if an error occurred,
- otherwise a valid dos file handle.
-
- char *wpath String containing the path to put the
- unique file. This must end in a "\" and
- must be a variable as the file name will
- be placed in this variable.
-
- int wattr Attribute used to
- create the unique file name
- 1 : Read Only
- 2 : Hidden
- 4 : System
- 8 : Volume Label
- 16 : Sub-Directory
- 32 : Archive
-
- 32. JZWRTFIL Write data to a file handle.
-
- Write data from a buffer to a file handle. Like jzredfil, this
- routine is useful for high speed data transfer.
-
- wnum = jzwrtfil(whandle,wbuf,wamt);
-
- unsigned
- int wnum Actual number of bytes written to the file.
-
- int whandle The handle of the previously opened file from a call
- to jzopnfil/jzcrtfil
-
- char *wbuf Buffer to write the data from. Usually an array or
- pointer to char.
-
- unsigned
- int wamt The number of bytes requested to write.
-
-
- 33. TRUNCATE Truncate a file.
-
- Truncate a file to a certain size.
-
- werror = truncate(wname,wsize);
-
- int werror -1 if an error occurred,
- 0 if everything went according to plan.
-
- char *wname File name to truncate
-
- long wsize New Size of the file.
-
-
-
- STRING HANDLING
-
- 1. INDEX Return the index of a character in a string.
-
- Return the index position of the occurance of a character
- in a substring or -1 if the character was not found.
-
- wpos = index(wsource,wch);
-
- int wpos index of occurance of character wch in the string
- wsource. Returns -1 if no occurance.
-
- char *wsource Pointer to the source string to search.
-
- int wch Character to do the search for.
-
- 2. JZCHRPOS Return the index of a character in a string.
-
- Return the index position of the occurance of a character
- in a substring or -1 if the character was not found.
-
- wpos = jzchrpos(wsource,wch);
-
- int wpos index of occurance of character wch in the string
- wsource. Returns -1 if no occurance.
-
- char *wsource Pointer to the source string to search.
-
- int wch Character to do the search for.
-
- 3. JZCHRSTR Concatenate a character onto a string
-
- This function performs the task of appending a single char
- to a string (which strcat will not do). It appends a null
- terminating character to the end of the source string to
- maintain string compatibility.
-
- jzchrstr(wsource,wch);
-
- char *wsource Source string to concatenate character to
-
- int wch Character to concatenate to wsource.
-
- 4. JZCNTSTR Return a centered string.
-
- This function returns a string padded with blanks to be
- centered in a give field width. Note that the maximum limit
- on string size for this routine is 255. The routine itself
- does NO range checking so it is up to the application itself
- to insure that this does not happen. This routine uses a static
- buffer for the pointer to return so subsequent calls to the routine
- destroy the previous contents of the returned pointer!
-
- wptr = jzcntstr(wsource,wnum);
-
- char *wptr pointer to centered string.
-
- char *wsource String to have centered.
-
- wnum Width of field to center on.
-
- 5. JZDLTSTR Delete a substring from another string.
-
- Give a starting and ending position, this routine will remove
- a portion of a string.
-
- wnum = jzdltstr(wsource,wfrom,fto);
-
- int wnum Number of chars actually deleted.
-
- char *wsource String to delete chars from.
-
- int wfrom Starting index to delete from
-
- int wto Ending index to delete to
-
- 6. JZGETPCE Get delimited piece of substring
-
- This routine returns the "n"th piece of a delimited string.
- i.e. Jaz;10318 Broom Lane;Seabrook;Md;20706
- the 3rd ";" piece of the string is "Seabrook"
-
- wptr = jzgetpce(wsource,wdestin,wdel,wnum);
-
- char *wptr Pointer to wdestin, the destination piece.
-
- char *wsource The source string with delimiters
-
- char *wdestin The destination string.
-
- int wdel The character used as a delimiter
-
- int wnum Which piece do you want?
-
- 7. JZINSSTR Insert a string into another string.
-
- This routine does a string insert of one string into another at
- a given starting position. Note that if wstart is > than the
- length of the source string, blanks will be appended.
-
- jzinsstr(wdestin,wsource,wstart);
-
- char *wdestin Pointer to destination string (to be inserted).
-
- char *wsource Pointer to string to insert
-
- int wstart Index of position to start inserting.
-
- 8. JZLFTSTR Return the left n chars from a string
-
- This routine returns the left n chars of a given string.
- note that this routine uses a static 255 byte buffer for the pointer to
- return so subsequent calls to the routine destroy the
- previous contents of the returned pointer!
-
- wptr = jzlftstr(wstr,wnum);
-
- char *wptr Pointer to static buffer containing the left string.
-
- char *wstr Source string
-
- int wnum The number of chars you want from the source string.
-
- 9. JZMIDSTR Return the middle n chars from a string.
-
- Given a starting position and a length, return the mid chars from
- a given string.
- note that this routine uses a static 255 byte buffer for the pointer to
- return so subsequent calls to the routine destroy the
- previous contents of the returned pointer!
-
- wptr = jzmidstr(wstr,wstart,wlen);
-
- char *wptr pointer to static buffer containing the sub string
-
- char *wstr Source string
-
- int wstart Starting index of sub string
-
- int wlen Length of substring.
-
- 10. JZPAD Pad a string
-
- This routine pads a given string with a given char.
- Note that this routine uses a static 255 byte buffer for the pointer to
- return so subsequent calls to the routine destroy the
- previous contents of the returned pointer!
-
- wptr = jzpad(wstr,wch);
-
- char *wptr Pointer to static buffer containing padded string.
-
- char *wstr Source string to pad.
-
- int wch Character to pad with.
-
- 11. JZPRSFIL Parse a path\file
-
- This routine parses a path name into a seperate file name and
- path name with the path name ending in a "\".
-
- jzprsfil(wfull,wpath,wfile);
-
- char *wfull Full path. i.e. "\\MSC\\JAZ\\JZSEARCH.EXE"
-
- char *wpath Returned Path portion of wfull
-
- char *wfile Returned file name portion of wfull
-
- 12. JZRGTJST Right justify a string
-
- This routine right justifies a given string. Effectively padding to
- the right.
- Note that this routine uses a static 255 byte buffer for the pointer to
- return so subsequent calls to the routine destroy the
- previous contents of the returned pointer!
-
- wptr = jzrgtjst(wstr,wnum);
-
- char *wptr Pointer to static buffer containing padded string.
-
- char *wstr Source string to pad.
-
- int wch Character to pad with.
-
- 13. JZRGTSTR Return the right n chars of a string
-
- This routine returns the rightmost n chars of a given string.
- Note that this routine uses a static 255 byte buffer for the pointer to
- return so subsequent calls to the routine destroy the
- previous contents of the returned pointer!
-
- wptr = jzrgtstr(wstr,wnum);
-
- char *wptr Pointer to static buffer containing the left string.
-
- char *wstr Source string
-
- int wnum The number of chars you want from the source string.
-
- 14. JZRPLSTR Replace chars in a string.
-
- This routine replaces characters in a string with a given substring.
-
- jzrplstr(wdestin,wsource,wstart,wlen);
-
- char *wdestin Destination string to insert into.
-
- char *wsource Source string to insert.
-
- int wstart Starting index to replace.
-
- int wlen Length of chars to insert.
-
- 15. JZSTRCAT Concatenate multiple strings
-
- This routine concatenates multiple strings together in one shot.
-
- jzstrcat(wsource,wstr1,wstr2,NULL);
-
- char *wsource String to concatenate onto
-
- char *wstr1 Strings to concatenate
- *wstr2
- etc...
-
- char NULL The Routine stops when it detects a null string.
- You may use 0 here but it's less portable.
-
- 16. JZSTRPOS Return a pointer to a substring
-
- Returns a pointer to a substring within another string or null
- if not found.
-
- wptr = jzstrpos(wobject,wtarget);
-
- char *wptr Pointer to occurance of wobject in wtarget or null
- if not found.
-
- char *wobject String we are searching for
-
- char *wtarget String we are searching.
-
- 17. JZWLDCRD Wild card file search
-
- This routine implements a very simplistic wild card match on
- two strings.
-
- wmatch = jzwldcrd(wsource,wwild);
-
- int wmatch 1 : if match
- 0 : if no match
-
- char *wsource Source string we are checking
-
- char *wwild Wild card string
-
- 18. LITERAL Parse a user string
-
- Convert a user string with escape sequences to an internal string.
- /**/ delineate comments
- \x1b translates to char(0x1b)
- \27 translates to char(27)
- \" translates to "
- \' translates to '
- \\ translates to \
-
- literal(wsource,wdestin);
-
- char *wsource Original string with esc sequences
-
- char *wdestin Destination string with expansions.
-
- 19. RINDEX Return the rear index of a char in a string.
-
- Return the last occurance of a char within a string or
- -1 if not found.
-
- wpos = rindex(wsource,wch);
-
- int wpos index position of occurance of last wch in wsource
- or -1 if wch was not found.
-
- char *wsource String to do the search on
-
- int wch Char we are searching for.
-
- 20. TABTOSP Convert tabs to spaces
-
- Expand tab chars in a string to spaces given that the default tabs
- are 1,9,17,25,33,41 etc.
-
- wptr = tabtosp(wsource,wdestin);
-
- char *wptr Returned Pointer to wdestin.
-
- char *wsource Source string with tabs in it.
-
- char *wdestin Destination string without tabs.
-
-
-
- LOW LEVEL OPERATING SYSTEM ROUTINES
-
-
- 1. CLI Clear interrupts
-
- Clear the interrupt flag disabling interrupts
-
- cls();
-
- 2. DISKINFO Get low level disk info
- This routine gets low level disk info directly from the
- boot sector. This will NOT work on a ram disk. It will
- work only on MSDOS diskettes version 2.0 and above may not
- work on some variations of MSDOS.
-
- werror = diskinfo(&wdiskblk,wdrive);
-
- int werror Dos disk error code. Anything <> 0 means some
- kind of error occured.
-
- TDISKBLK
- wdiskblk Disk block structure defined in JAZ.H . This record
- contains fields for many low level disk paramters.
-
- int wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
- etc.
-
- 3. DOSREADS Read disk sectors
-
- Directly read sectors from the disk. This routine bypasses the
- Abort, Retry, Ignore message that you usually get from dos so
- you can use it as a disk status check.
-
- werror = dosreads(wdrive,wsector,wamt,wbuf);
-
- int werror Dos error code for read. It will be 0 if no error
- occurred, otherwise a dos error code.
-
- int wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
- etc.
-
- int wsector Starting sector number.
-
- int wamt Number of sectors to read
-
- char *wbuf Buffer to read data into.
-
- 4. DOSWRITS Write Disk Sectors
-
- Directly write sectors to the disk. This routine bypasses the
- Abort, Retry, Ignore message that you usually get from dos so
- you can use it as a disk status check.
-
- werror = doswrits(wdrive,wsector,wamt,wbuf);
-
- int werror Dos error code for write. It will be 0 if no error
- occurred, otherwise a dos error code.
-
- int wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
- etc.
-
- int wsector Starting sector number.
-
- int wamt Number of sectors to write
-
- char *wbuf Buffer to write data from
-
- 5. GETCS Get the code segment value
-
- Return the segment value for the code segment.
-
- wcode = getcs();
-
- int wcode Value to be returned for the code segment
-
- 6. GETDS Get the data segment value
-
- Return the segment value for the data segment.
-
- wcode = getds();
-
- int wcode Value to be returned for the data segment
-
- 7. GETES Get the extra segment value
-
- Return the segment value for the extra segment.
-
- wcode = getes();
-
- int wcode Value to be returned for the extra segment
-
- 8. GETSS Get the stack segment value
-
- Return the segment value for the stack segment.
-
- wcode = getss();
-
- int wcode Value to be returned for the extra segment
-
- 9. INSINT24 Install a critical error handler
-
- This routine installs the critical error handler in place
- of the normal one, eliminating those pesky abort, retry, ignore
- messages.
- Note that you must call int24err() after every i/o call or you
- run the risk of hanging your system on a critical error.
-
- insint24();
-
- 10. INT24ERR Return an int 24 error code
-
- This routine fetches the error code (if any) after an i/o call
- after. The insint24 routine must have been previously called.
-
- werror = int24err();
-
- int werror 0 if No i/o error otherwise a dos error code.
- Check the Dos Ref Manual for a description of
- error codes and thier meanings.
-
- 11. INT24HND Critical error dispatcher
-
- This is the internal low level critical error dispatcher.
- The file name is INT24HND.ASM
-
- 12. INTR Interrupt Gate
-
- This routine provides a way to make bios and dos calls in a similar
- fashion to Turbo Pascal (Tm). See also MSDOS (under MISC MACROS).
-
- intr(&wreg);
-
- TREG wreg Register structure for passing to dos or bios.
-
- 13. JZBIGFAT Determine FAT SIZE
-
- Return 1 if FAT is 16 bit, otherwise, return 0
- See JZCHKDSK.DMO for ideas on this one
-
- wbig = jzbigfat(wtotalsect,wsectsize);
-
- int wbig Returns
- 1 : 16 bit fat
- 0 : 12 bit fat
-
- int
- wtotalsect : This must be the total sectors on disk.
-
- int
- wsectsize : This must be the amount of bytes/sector on disk.
-
- 14. JZFATEOF Determine if at end of cluster chain for file
-
- Return true if at the end of a files cluster chain.
- See JZCHKDSK.DMO for ideas on this one
-
- weof = jzfateof(wcluster,wbig);
-
- int weof Returns:
- 1 : End of file cluster chain
- 0 : More to go.
-
- unsigned int
- wcluster Cluster number we are currently looking at
-
- int wbig 1 : 16 bit fat
- 0 : 12 bit fat
-
- 15. JZGETCLS Convert Fat index to Cluster number
-
- Given a FAT array, return the cluster number for a particular index.
- See JZCHKDSK.DMO for ideas on this one
-
- wcluster = jzgetcls(wfat,wcluster,wbig);
-
- int wcluster Returned cluster number
-
- char *wfat Buffer of file allocation stuff
-
- int wcluster Current cluster number
-
- int wbig 1 : 16 bit fat
- 0 : 12 bit fat
-
- 16. JZGETDIR Get a pointer to the disk directories
-
- Return pointer to disk directories and the number of root
- directory entires.
-
- jzgetdir(&wdir,wdrive,&wnum);
-
- TDIR *wdir Pointer to low level directory information.
- Note that we must supply the routine a pointer
- to a pointer.
-
- int wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
-
- int wnum Returned Number of root directory entries.
-
- 17. JZGETFAT Get a pointer to the FAT
-
- Return a pointer to the file allocation for the specified
- disk drive.
-
- jzgetfat(&wfat,wdrive);
-
- char *wfat Returned pointer to a file allocation table. Note
- that this argument is a pointer to a pointer.
-
- int wdrive 0 : Drive A
- 1 : Drive B
- 2 : Drive C
-
- 18. JZINSINT Install a generic interrupt handler
-
- This routine installs an interrupt into the generic interrupt
- handler routine: JZINTHND.
-
- jzinsint(wint,wfunction);
-
- int wint Interrupt number to define/redefine
-
- int
- wfunction() Address of function to call when this interrupt
- vector is invoked.
-
- EX.
-
- #include <jaz.h>
- #include <jzscreen.h>
-
- int clock();
- int gcount = 17; /* clock tic counter */
-
- #define TIMER 0x1C
-
- main()
- {
-
- jzinsint(TIMER,clock); /* install the new timer interrupt */
-
- jztrmres(); /* terminate but stay resident */
-
- }
-
- clock()
- {
- char wstr[9];
-
- /* clock tics 18.2 times a second */
- if (gcount >= 17) {
- jzbiostm(wstr);
- jzscrprn(wstr,0,72,RED);
- gcount = 0;
- }
- else
- gcount ++;
- }
-
-
- 19. JZINTHND Generic Interrupt Dispatcher
-
- This routine handles the low level pushes, pops, and stack
- manipulation for a generic interrupt handler.
- The file name is JZINTHND.ASM
-
-
- 20. READSECT Read sectors from bios
-
- This routine uses bios to directly read sectors from the disk.
- It bypasses dos so you don't get the abort, retry, ignore
- messages.
-
- werror = readsect(wnum,wtrack,wsector,whead,wdrive,wbuf)
-
- int werror 0 if no error occurred, otherwise one of the following
- error codes:
- $80 - Timeout
- $40 - Bad Seek
- $20 - Nec Controller failed
- $10 - Bad Crc
- $8 - Attempt to cross 64k boundry
- $4 - Sector not found
- $3 - write protect
- $2 - address mark not found
- $1 - bad command
-
- int wnum Number of sectors to read 0..255
-
- int wtrack Starting Track number
-
- int wsector Starting Sector number
-
- int whead Head number
-
- int wdrive Should be set to one of the following:
- 0..3 for floppy diskette drives A,B,C,D
- $80..$83 for fixed disk drives C,D,E,F ETC.
-
- char *wbuf Buffer to read data into. Make sure it is at least
- wnum * wsectorsize bytes long.
-
- 21. STI Set the interrupt flag
-
- Set the interrupt flag, enabling interrupts.
-
- sti();
-
-
- UTILITY ROUTINES
-
- 1. GETCRC Get a crc code for a buffer
-
- This routine returns a Cyclic Redundancy Check code for a given
- buffer.
-
- wcrc = getcrc(wbuf,wlen);
-
- unsigned int
- wcrc Crc Code returned from function.
-
- char *wbuf Pointer to data buffer to check.
-
- int wlen sizeof (wbuf)
-
- 2. JZBEEP Sound a beep to the console
-
- This routine sounds a slightly more pleasant beep to the
- console then the standard printf("%c",7);
-
- jzbeep();
-
- 3. JZBIOSTM Return a "bios" time string.
-
- This routine returns a time string using the bios tic
- count instead of the dos function. This is handy during
- interrupt handlers where we cannot make dos calls.
-
- jzbiostm(wtime);
-
- char *wtime Time string returned in the form HH:MM:SS
-
- 4. JZDELAY Delay program execution
-
- Delay the current program for the specified number of clock
- tics.
-
- jzdelay(wtics);
-
- long wtics Number of tics to delay. There are about 18
- clock tics in a second. Make sure you use a
- long value here or the high word may cause
- you to "hang" for a long time. (No Pun Intended)
-
- 5. JZINTDIR Initialize the directory stack.
-
- This routine initializes the directory head structure in
- preperation for a call to jzpshdir.
-
- jzintdir(&wdirhead);
-
- TDIRHEAD
- wdirhead Head of directory structure defined in JAZ.H
-
-
- 6. JZINTSTK Initialize user stack
-
- This routine initializes the user stack in preperation
- for a call to jzpush
-
- jzintstk(&whead);
-
- TSTKHEAD
- whead Record containing information pertaining
- to the user stack
-
- 7. JZPOP Pop data from the user stack
-
- This routine allows data from the user stack to be "popped" into
- a variable. This is useful because data type is not a consideration
- and therefore variables can be popped to variables of other types.
-
- jzpop(&whead,wdata,wsize);
-
- TSTKHEAD
- whead Record containing information pertaining
- to the user stack.
-
-
- char *wdata This can actually be a pointer to any type
- of data. If type checking is enabled, you
- may have to use a cast.
- unsigned int
- wsize Set this argument to 0 to receive the default
- size, which was specified when jzpush was
- called. Setting this value to something other
- than 0 will override the default and the number
- of bytes specified. Note that this does not pop
- other items off the stack, but merely takes more
- (or less) contiguous memory and places it in wdata.
-
-
- 8. JZPRNPTR Print data from any data type
-
- This function allows byte by byte printing of a struct useful
- usually for debugging purposes.
-
- jzprnptr(wptr,wctrl,wlength);
-
- char *wptr This can be any type of pointer to a structure,
- not just char. You may have to use a cast if
- you use strong type checking.
-
- char *wctrl This is the control string for the print.
- i.e.
- "\n%0004X" or
- "%c " or
- "%d " etc.
-
- int wlength The length of the data object to print. Typically
- it would be sizeof(wptr);
-
- 9. JZPUSH Push data onto the user stack
-
- This routine is used to push data onto the local stack where
- it can be popped off later.
-
- jzpush(&whead,wdata,wsize);
-
- TSTKPTR
- whead Record containing information pertaining
- to the user stack.
-
- char *wdata This can actually be a pointer to any type
- of data. If type checking is enabled, you
- may have to use a cast.
-
- unsigned int
- wsize Set this argument to sizeof(wdata) usually unless
- you want more or less bytes to be saved on the stack.
-
- 10. JZPUTPRN Put Data to the LPT1 device
-
- This routine writes chars to LPT1 using bios. It returns the
- printer status word.
-
- wstatus = jzputprn(wch);
-
- int wstatus Printer status word. See the bios tech ref manual
- for details about how to read this word.
-
- int wch Character to write to the printer
-
- 11. JZREBOOT Reboot the computer
-
- This routine allows you to either perform a warm boot or a
- cold boot of the machine. The warm boot simulates a Ctrl-Alt-Del,
- and the cold boot simulates a power on with a memory and
- diagnostics check.
-
- jzreboot(wcode);
-
- int wcode 1 : cold boot
- 0 : warm boot
-
- 12. JZTIMER Time an event
-
- This routine performs a timing of an event in seconds. This routine
- uses a static variable to store the bios tic count. Because of this
- it needs to be called once to initialize the tic count.
-
- welapse = jztimer();
-
- unsigned int
- welapse Returned seconds since the last call to this
- routine.
-
- EX.
-
- main()
- {
-
- unsigned int w;
-
- jztimer(); /* initialize the timer */
-
- for (w = 0 ; w < 0xFFFF ; w ++) /* loop for nothin' */
- ;
-
- printf("Execution of this loop took %d seconds!",jztimer());
- }
-
- 13. MEMB Return a byte of memory
-
- This function returns a byte of memory, given a segment,offset
- pair.
-
- wch = memb(wseg,wofs);
-
- int wch Char returned from memory
-
- wseg Segment value to read from
-
- wofs Offset value to read from
-
- EX.
-
- if (memb(0x40,0x49) == 3)
- printf("I detect a color card in this computer!");
-
- 14. MEMW Return a word of memory
-
- This function returns a word of memory, given a segment
- pair.
-
- wch = memw(wseg,wofs);
-
- int wch word returned from memory
-
- wseg Segment value to read from
-
- wofs Offset value to read from
-
- EX.
-
- wkeystatus = memw(0x40,0x17); /* get keyboard status word */
-
- 15. MEML Return a long of memory
-
- This function returns a long of memory, given a segment
- pair.
-
- wlong = meml(wseg,wofs);
-
- long wch long returned from memory
-
- wseg Segment value to read from
-
- wofs Offset value to read from
-
- 16. MODEMSTS Return the modem status register
-
- This function returns the modem status word from bios.
-
- wstatus = modemsts(wport);
-
- int wstatus Returned modem status word. Consult the bios tech
- ref manual for details.
-
- int wport 1 : port 1
- 2 : port 2
-
- 17. MOVE Move bytes from one location to another.
-
- This routine does a block move in memory of two variables.
- It does not handle overlap. This routine only handles near
- objects in the small model compiler.
-
- move(wdestin,wsource,wnum);
-
- char *wdestin Pointer to destin buffer. It can be any type of
- pointer.
-
- char *wsource Pointer to source buffer, It can be any type of
- pointer.
-
- unsigned int
- wnum Number of chars to move.
-
-
- 18. POKEB Poke a byte into memory
-
- This routine pokes a single byte into a specified memory location
- by segment,offset.
-
- poke(wseg,wofs,wch);
-
- int wseg Segment value to poke into
-
- int wofs Offset value to poke into
-
- int wch Character to poke into memory
-
-
- 19. POKEW Poke a word into memory
-
- This routine pokes a single word into a specified memory location
- by segment,offset.
-
- poke(wseg,wofs,wch);
-
- int wseg Segment value to poke into
-
- int wofs Offset value to poke into
-
- int wch Word to poke into memory
-
- 20. RSPLIST Create a list from response file
-
- This routine creates a linked list of data given a response
- file on the command line.
-
- whead = rsplist(wname);
-
- THEAD *whead Pointer to head of structure. Data type defined
- in JAZ.H
-
- char *wname File name to create the list from.
-
- 21. SOUNDOFF Turn the speaker off
-
- This routine turns the sound off after a call to soundon()
-
- soundoff();
-
- 22. SOUNDON Turn the speaker on
-
- This routine "Plays" the speaker at a specific frequency.
-
- soundon(whertz);
-
- int whertz Frequency of pitch. 440 = A
-
-
- VIDEO/SCREEN/WINDOWING ROUTINES
- (ibm or close compatibles only)
-
- 1. CLS Clear the display screen
-
- This function clears the display screen to a specified video
- attribute. This function does not home the cursor. The bit maps
- for an attribute can be determined based on the following bit
- pattern:
-
- BITS:
- 7 6 5 4 3 2 1 0
- BLINK,RED,GREEN,BLUE,INTENSITY,RED,GREEN,BLUE
-
- The left nibble except for bit 7, pertains to the background,
- and the right nibble except for bit 3, pertains to the foregound
- color. These can be combined for any combination.
-
- cls(wattribute);
-
- int
- wattribute The color attribute we want the screen cleared
- to.
-
- EX.
- cls(7); /* clear the screen to normal color */
-
- 2. COLOR Change the global color parameters
-
- This allows you to change the global foreground and background
- colors which are used by many of the windowing related routines.
- You will find various colors defined in JZSCREEN.H The are:
-
- BLACK 0
- BLUE 1
- GREEN 2
- CYAN 3
- RED 4
- MAGENTA 5
- BROWN 6
- LIGHTGRAY 7
- DARKGRAY 8
- LIGHTBLUE 9
- LIGHTGREEN 10
- LIGHTCYAN 11
- LIGHTRED 12
- LIGHTMAGENTA 13
- YELLOW 14
- WHITE 15
- BLINK 128
-
- color(wfore,wback);
-
- int wfore The foreground color you wish to set
-
- int wback The background color you wish to set
-
- 3. JZAPPEND Append a window to the window list
-
- This routine allows you to add a window onto the window list.
- It does not matter if the list is empty.
-
- savescreen = jzappend(&g_header,wattr,y1,x1,y2,x2,wnum);
-
- TWINDOW
- *savescreen Returned pointer will point to the window structure
- which contains the dimensions of the window, colors
- contents, et al.
-
- THEADER
- g_header This is the header record for the list. It is
- initialized in gscreen.h. If you want to use
- more than one window list, you must create your
- own header record and initialize it yourself.
-
- int wattr This is the color attribute stored for the window.
-
- int y1 Upper left row axis
-
- int x1 Upper left column axis
-
- int y2 Lower right row axis
-
- int x2 Lower right column axis
-
- int wnum This is an arbitrary number you assign to the window.
- After creating the window list, you can do searches
- on the list by number so it would be a good idea to
- have a unique number for each window.
-
- 4. JZBIGLTR Draw big letters on the screen
-
- This routine draws big letters 8 * 8 chars on the screen
- using the bit mapped character set in rom at address: 0xF000:FA6E.
- It prints the characters directly to the screen memory for speed.
-
- jzbigltr(wch,wrow,wcol,wdrawchr,wattr);
-
- int wch This is the character you want to draw to the screen.
-
- int wrow Row position to write to . 0..24
-
- int wcol Column position to write to 0..79
-
- int wdrawchr This is the character you want to use when drawing.
- For example, a good char to use on an IBM is 178
- which appears on the screen as '▓'.
-
- int wattr Color attribute for the screen write.
-
- 5. JZBIGSTR Draw a big string to the screen
-
- This routine calls jzbigltr to draw a string to the screen.
-
- jzbigstr(wstr,wrow,wcol,wdrawchr,wattr);
-
- char *wstr String we want to display on the screen. There is
- room for 10 characters on a line.
-
- int wrow Row position to write to . 0..24
-
- int wcol Column position to write to 0..79
-
- int wdrawchr This is the character you want to use when drawing.
- For example, a good char to use on an IBM is 178
- which appears on the screen as '▓'.
-
- int wattr Color attribute for the screen write.
-
- 6. JZCLREOL Clear to the end of the line
-
- This routine clears the line from the given position to the
- end of the line.
-
- jzclreol(wrow,wcol,wattr);
-
- int wrow Row position to clear from
-
- int wcol Column position to clear from
-
- int wattr Attribute to clear line with
-
- 7. JZCLRSCR Clear the current screen WINDOW
-
- This routine clears the ACTIVE window with the colors contained
- in the global color parameters . (You can change these with a
- call to color())
-
- jzclrscr();
-
- 8. JZCLRWND Change the color of a window
-
- This routine allows you to change a windows colors without
- changing it's contents.
-
- jzclrwnd(wwindow,wattr);
-
- TWINDOW
- *wwindow Pointer to window to change color of. Use wsearch()
- to return the pointer of a specified window #.
-
- int wattr The new color attribute you wish to change the
- window to.
-
- 9. JZCLSWND Close the current window
-
- Close a window, restore it's previous contents, and free up the
- memory taken up by the window struct and it's window buffer.
-
- wfound = jzclswnd(wnum);
-
- int wfound Returns 1 if window was found, 0 if not found.
-
- int wnum Number of the window to close.
-
- 10. JZCPYWND Copy one window to another.
-
- This procedure simply copies the window from the specified window
- number to the destination window.
-
- wcopy = jzcpywnd(worig,wnum);
-
- TWINDOW
- *wcopy Returns pointer to which a new copy of a window is
- assigned. Null if wnum was not found.
-
- TWINDOW
- *worig Original window to copy.
-
- wnum Window number to assign the copy.
-
- 11. JZDELETE Delete a window from the list.
-
- Delete the specified window number from the list.
-
- jzdelete(wnum);
-
- int wnum The number of the window which you wish to delete.
-
- 12. JZDRWBOX Draw a box to the display screen.
-
- This procedure draws a box on the screen like so...
-
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ │
- │ │
- │ │
- │ │
- │ │
- │ │
- │ │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
-
- jzdrwbox(wrow,wcol,wlen,wwidth,wattr);
-
- int wrow Starting row position of upper left corner of box
-
- int wcol Starting column position of upper left corner of box
-
- int wlen Length of horizontal axis
-
- int wwidth Width of vertical axis
-
- int wattr Color attribute of the window box.
-
- 13. JZDSPFLD Display a field on the screen
-
- This routine displays a field at a given row,column position and
- a given color attribute with a given field width. If the string
- to be displayed has a length of less than the width, then the
- string is padded to the right with blanks.
-
- jzdspfld(wstr,wlen,wrow,wcol,wattr);
-
- char *wstr String to display in the field.
-
- int wlen Max length of the field.
-
- int wrow Row position of the field
-
- int wcol Column position of the field.
-
- int wattr Color attribute of the field.
-
- 14. JZGETCUR Get cursor size and position
-
- Return the cursor starting and ending scan lines as well as
- it's absolute position on the screen.
-
- jzgetcur(&wrow,&wcol,&wstart,&wend);
-
- int wrow Pointer to returned row position
-
- int wcol Pointer to returned col position
-
- int wstart Pointer to starting scan line of cursor
-
- int wend Pointer to ending scan line of cursor
-
- 15. JZGETMOD Get the current screen mode
-
- Return the current screen mode.
-
- wmode = jzgetmod();
-
- int wmode The returned mode of the screen.
-
- 16. JZINSTR Edit a string with editing keys.
-
- This routine provides a formatted editing for a field.
- It is similar in style to DBASE or WORDSTAR.
-
- wkey = instr(wstr,wlen,wrow,wcol,wattr,wtime,wkeystr);
-
- int wkey This is the key that was pressed to end the input.
- It is usually the return key, but if you have
- activated other keys using wkeystr, it would be
- the scan code of an active key.
-
- int wlen Max length of the field.
-
- int wrow Starting row of field edit.
-
- int wcol Starting col of field edit.
-
- int wattr Color attribute of edit field.
-
- long wtime Maximum amount of time with no keys
- being pressed. Edit will time out after
- wtime worth of inactivity and a return
- key is returned.
-
- char *wkeystr String of scan codes to terminate the read on.
- i.e. If you want to activate the F1 key which
- would be "\x3B"
-
- EX.
-
- #define cESC "\001"
- #define ESCSCAN 1 /* scan code for escape code */
- main()
- {
- int w = 1,wch;
- char name[31],street[31],city[16],state[3],zip[6],phone[13];
-
- name[0] = 0;
- street[0] = 0;
- city[0] = 0;
- state[0] = 0;
- zip[0] = 0;
- phone[0] = 0;
-
- do {
- switch(w) {
- case 1 : wch = jzinstr(name,30,5,8,(CYAN << 4) + BLUE,60L,cESC);
- break;
- case 2 : wch = jzinstr(street,30,6,8,(CYAN << 4) + BLUE,60L,cESC);
- break;
- case 3 : wch = jzinstr(city,15,7,8,(CYAN << 4) + BLUE,60L,cESC);
- break;
- case 4 : wch = jzinstr(state,2,8,8,(CYAN << 4) + BLUE,60L,cESC);
- break;
- case 5 : wch = jzinstr(zip,5,9,8,(CYAN << 4) + BLUE,60L,cESC);
- break;
- case 6 : wch = jzinstr(phone,12,10,8,(CYAN << 4) + BLUE,60L,cESC);
- break;
- }
-
- switch (wch) {
- case CTRL_X :
- case CTRL_M : w = min(LAST,w+1);
- break;
- case CTRL_E : w = max(FIRST,w-1);
- break;
- case PGDN : w = LAST;
- break;
- case PGUP : w = FIRST;
- break;
- case ESCSCAN: return;
- }
- } while (-1);
- }
-
- 17. JZINTWND Initialize global window parms
-
- Initialize the various window parameters:
-
- jzintwnd(wrow1,wcol1,wrow2,wcol2,wattr)
-
- int wrow1 Set global upper left row position
-
- int wcol1 Set global upper right column position
-
- int wrow2 Set global lower right row position
-
- int wcol2 Set global lower right column position
-
- int wattr Color attribute to set the window to.
-
- 18. JZLOCCUR Position the cursor
-
- This function positions the cursor on the display screen.
- It is an absolute cursor positioning, independant of window
- dimension.
-
- jzloccur(wrow,wcol);
-
- int wrow Row position to set cursor to . 0..24
-
- int wcol Column position to set cursor to . 0..79
-
- 19. JZMENU Display a menu on the screen.
-
- This routine displays a menu and returns the users choice. The
- style of menu is similar to the lotus menus where you use the
- arrow keys to scroll through the choices and select an item
- by pressing <enter> when that item is highlighted. This routine
- saves the users screen so that when the item is selected, the
- screen is restored to it's previous contents and the cursor is
- brought back to it's original position.
-
- wchoice = jzmenu(wlist,wfore,wback,wkeys)
-
- int wchoice Returned value of the choice.
- 0 = option 1
- 1 = option 2
- 2 = option 3
- etc..
-
- char **wlist Pointer to a pointer of strings to display on
- the menu.
-
- int wfore Foreground color of menu
-
- int wback Background color of menu
-
- EX.
-
- char *wlist[] = {
- "THIS IS A TEST",
- "OF THE EMERGENCY",
- "BROADCAST SYSTEM",
- "IF THIS WERE A",
- "REAL EMERGENCY" ,
- "YOU WOULD HAVE",
- "BEEN NOTIFIED..." ,
- "WHY AM I TYPING THIS?",
- ""
- };
-
- #include <jzscreen.h>
- #include <gscreen.h>
-
- #define wkeystr "\x3B\x01" /* scan codes for F1 and ESC */
- #define ESC 1 /* scan code for ESC */
- #define F1 0x3b /* scan code for F1 */
-
- main()
- {
- int wchoice;
-
- wchoice = jzmenu(wlist,WHITE,BLUE,wkeystr);
-
- switch(wchoice) {
- case ESC : printf("\nThe Esc key was pressed");
- break;
- case F1 : printf("\nThe F1 key was pressed");
- break;
- default : printf("\nYou picked item %d",wchoice);
- break;
- }
- }
-
- 20. JZMOVWND Move a window on the screen.
-
- This routine moves a windows position on the screen. It does
- NOT restore the previous contents of the original position.
-
- jzmovwnd(wptr,wrow,wcol);
-
- TWINDOW
- *wptr Pointer to window structure to move.
-
- wrow Row position to move window to
-
- wcol Col position to move window to.
-
- 21. JZOPNWND Open a window on the screen
-
- This routine opens a screen window, drawing the box around the window,
- clearing the window screen to the selected attributes, and adding
- the window structure to the window list.
-
- wwindow = jzopnwnd(wnum,wrow,wcol,wlen,wwidth,wfore,wback);
-
- TWINDOW
- *wwindow Returned pointer to window structure just created
-
- int wnum Number to save for this window. This can be set
- to any number but you should have a unique number
- for each window you create.
-
- int wrow Starting upper left row position of window.
-
- int wcol Starting upper left col position of window
-
- int wwidth Horizontal length of window
-
- int wlen Vertical Length of window
-
- int wfore Foreground color of window
-
- int wback Background color of window
-
- 22. JZPGECLR Clear the given page
-
- This routine clears the given page to the specified color attribute.
-
- jzpgeclr(wpage,wattr);
-
- int wpage A valid page number. On the CGA adapter card, this
- would be 0..3. There is only one page on the Mono
- card.
-
- int wattr Color attribute to clear the screen to.
-
- 23. JZPGEPRN Print directly to a page
-
- This routine prints a string directly to video memory on
- the specified page number. This should not be used on a
- monochrome adapter.
-
- jzpgeprn(wstr,wrow,wcol,wattr,wpage);
-
- char *wstr String pointer to print to the given page
-
- int wrow Row position relative to page top to print to
-
- int wcol Col position relative to page top to print to
-
- int wattr Color attribute use when printing.
-
- int wpage A valid page number. 0..3
-
- 24. JZPLOT Plot a dot to the graphics screen
-
- This function plots a pixal to the color graphics screen.
-
- jzplot(wrow,wcol,wattr);
-
- int wrow Row position of pixel to plot
-
- int wcol Col position of pixel to plot
-
- int wattr Color attribute to plot dot with
-
- 25. JZREDCHR Read a char and attribute from screen
-
- This function reads a character and attribute from the current
- cursor position
-
- jzredchr(&wch,&wattr);
-
- int wch Pointer to the returned character.
-
- int wattr Pointer to the returned attribute
-
- 26. JZREDSCR Read a string from the screen.
-
- This function returns a string from a given screen position. It
- does not return attributes.
-
- jzredscr(wstr,wrow,wcol,wlen);
-
- char *wstr Pointer to the string to be returned.
-
- int wrow Starting row position to read from screen.
-
- int wcol Starting col position to read from screen.
-
- int wlen Length of string to read from screen.
-
- 27. JZRSTWND Restore a windows contents
-
- This routine restores a windows contents without removing the
- window from the window list.
-
- jzrstwnd(wwindow);
-
- TWINDOW
- *wwindow Pointer to window to restore contents of
-
- 28. JZSAVWND Save a windows contents
-
- Save a windows contents into an existing window structure. The
- window buffer is NOT resized so if you change sizes of windows,
- be careful to realloc() the window buffer before calling this
- routine. This routine is useful during window moves.
-
- jzsavwnd(wwindow);
-
- TWINDOW
- *wwindow Pointer to existing window struct to save.
-
- 29. JZSCRLDN Scroll a window down
-
- This routine calls bios to scroll a window down on the screen.
-
- jzscrldn(wyx1,wyx2,wnum,wattr);
-
- int wyx1 This integer contains the upper left row position
- of the window in the high byte and the upper left
- column position in the low byte.
-
- int wyx2 This integer contains the lower right row position
- of the window in the high byte and the lower right
- column position in the low byte.
-
- int wnum Number of lines to scroll. At maximum, this number
- should be Y2 - Y1. Specify 0 to scroll the whole
- window, effectively clearing it. Specifying :
- Y2 - Y1 + 1, which is the actual number of lines
- in the window will garble up the screen on an
- IBM pc.
-
- 30. JZSCRLUP Scroll a window up
-
- This routine calls bios to scroll a window up on the screen.
-
- jzscrlup(wyx1,wyx2,wnum,wattr);
-
- int wyx1 This integer contains the upper left row position
- of the window in the high byte and the upper left
- column position in the low byte.
-
- int wyx2 This integer contains the lower right row position
- of the window in the high byte and the lower right
- column position in the low byte.
-
- int wnum Number of lines to scroll. At maximum, this number
- should be Y2 - Y1. Specify 0 to scroll the whole
- window, effectively clearing it. Specifying :
- Y2 - Y1 + 1, which is the actual number of lines
- in the window will garble up the screen on an
- IBM pc.
-
- 31. JZSCROFF Disable the video screen (DO NOT USE WITH HERCULES CARDS)
-
- This disables the video signal to the screen, blanking (but not
- clearing) the display screen. This routine has been known to
- cause hardware damage to certain non - ibm video cards. I am
- not responsible if this happens to you!
-
- jzscroff();
-
- 32. JZSCRON Enable the video screen (DO NOT USE WITH HERCULES CARDS)
-
- This routine enables the video signal to the screen. Restoring
- it's previous contents. This routine has been known to
- cause hardware damage to certain non - ibm video cards. I am
- not responsible if this happens to you!
-
- jzscron();
-
- 33. JZSCRPRN Print directly to video memory
-
- This routine allows you to print directly to video memory
- specifying row,column and color. It also avoids snow on the
- ibm CGA card. It is a very fast routine, about 10 times faster
- than printf().
-
- jzscrprn(wstr,wrow,wcol,wattr);
-
- char *wstr String to print to screen.
-
- int wrow Row to print to
-
- int wcol Column to print to
-
- int wattr Color attribute to use when printing.
-
- 34. JZSETCUR Set the cursors size
-
- This routine allows you to adjust the cursors starting and
- ending scan lines. The cursor is mapped as follows:
-
- Default Scan Monochrome Color
-
- 0 . . . . . . . . . . . . . . . .
- 1 . . . . . . . . . . . . . . . .
- 2 . . . . . . . . . . . . . . . .
- 3 . . . . . . . . . . . . . . . .
- 4 . . . . . . . . . . . . . . . .
- 5 . . . . . . . . . . . . . . . .
- 6 . . . . . . . . Start ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- 7 . . . . . . . . End ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- 8 . . . . . . . .
- 9 . . . . . . . .
- 10 . . . . . . . .
- Start 11 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
- End 12 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
-
-
- jzsetcur(wstart,wend);
-
- int wstart Starting scan line of cursor
-
- int wend Ending scan line of cursor
-
- 35. JZSETMDE Set the screen mode
-
- Set the current screen mode.
-
- jzsetmde(wmode);
-
- int wmode Valid screen mode.
-
- 36. JZSETPGE Activate a page
-
- This function activates a page of video memory.
-
- jzsetpge(wpage);
-
- int wpage A page of CGA memory to activate. 0..3
-
- 37. JZWNDASN Assign values to a window structure
-
- This internal routine (used by jzappend) is a convenient way
- of assigning values to a window structure.
-
- jzwndasn(wwindow,wrow,wcol,wattr,wnum,wy1,wx1,wy2,wx2);
-
- TWINDOW
- *wwindow Pointer to window to assign values to
-
- wrow Row position to assign
-
- wcol Col position to assign
-
- wattr Attribute to assign
-
- wnum Window number to assign
-
- wy1 Upper left row to assign
-
- wx1 Upper left col to assign
-
- wy2 Lower right row to assign
-
- wx2 Lower right col to assign
-
- 38. JZWRITE Write to the current window
-
- This function writes a string to the current window in the
- using the global color and window parameters.
-
- jzwrite(fstr);
-
- char *wstr String to write
-
- 39. JZWRTCHR Write a char to the screen using bios
-
- This function writes a char to the screen using bios.
-
- jzwrtchr(wch,wattr,wnum);
-
- int wch Character to write
-
- int wattr Color attribute of char
-
- int wnum Number of copies to write
-
- 40. JZWRTSTR Write a string using bios
-
- This routine writes a string to the screen using the bios
- jzwrtchr call.
-
- jzwrtstr(wstr,wrow,wcol,wattr);
-
- char *wstr String to write to screen.
-
- int wrow Row to write to
-
- int wcol Column to write to
-
- int wattr Color attribute to use when writing.
-
- 41. LOCATE Position the cursor in the window
-
- This routine positions the cursor relative to the active window.
-
- locate(wrow,wcol);
-
- int wrow Row position of cursor in the window
-
- int wcol Col position of cursor in the window
-
- 42. MOVEATTR Move attributes to a screen window
-
- This routine move attributes only to a screen window which
- allows you to change the color of a window without affecting
- it's contents and avoiding snow.
-
- moveattr(wscreenseg,woffset,wnumrows,wnumcols,wattr);
-
- int
- wscreenseg Segment address of active screen. Should be
- 0xb800 for color, 0xb000 for mono.
-
- int woffset Offset of screen position. Computed by
- row * 160 + (col << 1)
-
- int wnumrows Number of rows in window
-
- int wnumcols Number of cols in window
-
- int wattr Attribute color of window
-
- 43. MOVEB Move a screen window to a buffer
-
- Internal routine (see jzsavwnd) to move screen memory to a
- buffer avoiding snow.
-
- moveb(wscreenseg,woffset,wbufseg,wbufofs,wnumrows,wnumcols);
-
- int
- wscreenseg Segment address of active screen. Should be
- 0xb800 for color, 0xb000 for mono.
-
- int woffset Offset of screen position. Computed by
- row * 160 + (col << 1)
-
- int wbufseg Segment address of destination buffer. getds()
- can be used here usually.
-
- int wbufofs Offset address of buffer.
-
- int wnumrows Number of rows in window
-
- int wnumcols Number of cols in window
-
- 44. MOVES Move a buffer to screen memory
-
- This routine moves a buffer to a screen window avoiding snow.
-
- moves(wbufseg,wbufofs,wscreenseg,woffset,wnumrows,wnumcols);
-
- int wbufseg Segment address of destination buffer. getds()
- can be used here usually.
-
- int wbufofs Offset address of buffer.
-
- int
- wscreenseg Segment address of active screen. Should be
- 0xb800 for color, 0xb000 for mono.
-
- int woffset Offset of screen position. Computed by
- row * 160 + (col << 1)
-
- int wnumrows Number of rows in window
-
- int wnumcols Number of cols in window
-
- 45. WINDOW Set the window dimensions
-
- This routine allows you to set the global window dimensions which
- are used for the various window write, and cursor positioning
- routines.
-
- window(wrow1,wcol1,wrow2,wcol2);
-
- int wrow1 Value to set upper left row
-
- int wcol1 Value to set upper left col
-
- int wrow2 Value to set lower right row
-
- int wcol2 Value to set lower right col
-
- 46. WPRINTF Printf function relative to window
-
- This routine provides for a printf that allows color and relativity
- to the current window dimension. It handles all data types except
- float. It does not allow redirection.
-
- wprintf("\n%d %c %s",wint,wchar,wstring);
-
- int wint Sample integer
-
- int wchar Sample char
-
- int wstring Sample string
-
- 47. WSEARCH Search for a window
-
- Search for a specified window number and return it's pointer
-
- wptr = wsearch(wnum);
-
- TWINDOW
- *wptr Returned pointer to window structure. Should be
- checked for null in case window is not found
-
- int wnum Number of the window to search for.
-
-
- KEYBOARD ROUTINES
-
- 1. JZINKEY Return the char and scan code of a key
-
- This routine waits until a key is pressed and returns
- it's character and scan code. The character can be
- examined and if it is 0, the key was one of the special
- function keys, cursor keys, alt sequences, or shift sequences.
-
- wch = jzinkey(&wscan);
-
- int wch Returned character that was pressed
-
- int wscan Scan code of character that was pressed.
-
- 2. JZKEYPRS Return 1 if a key is waiting
-
- This routine determines whether a key was pressed by calling
- a bios function to see whether a key is in the keyboard buffer.
-
- wkeypressed = jzkeyprs();
-
- int
- wkeypressed Returns 1 if a key is pressed, otherwise 0
-
- 3. JZKEYSTS Return the keyboard status record
-
- This routine returns a keyboard status record which can be looked
- at to determine which special keys are down such as insert, caps-lock,
- num-lock etc.
-
- jzkeysts(&wkey);
-
- TKEY wkey Pointer to record containing key status info.
-
-
- EX.
-
- #include <jaz.h>
-
- main()
- {
- KEYSTATE wkey;
-
- jzkeysts(&wkey); /* get key status */
-
- if (wkey.s.capslock)
- printf("\nCaps lock is on!");
- }
-
- 4. JZPUTKBD Write chars to the keyboard buffer
-
- This function is capable of writing a string to the keyboard
- buffer. A maximum of 16 chars will be written.
-
- jzputkbd(wstr);
-
- char *wstr String of chars to be written. If an extended char
- is to be written to the buffer, proceed it's scan code
- with a \xFF. i.e. jzputkbd("\xFF\x3B") would put
- the F1 key in the buffer. (0x3b is the scan code for
- the F1 key)
-
-
- MISC MACROS
-
- 1. LPOINTER Gain access to far memory locations. (JAZ.H)
-
- This macro allows access to far memory locations for useful
- in hardware intensize applications.
-
- wch = LPOINTER(char , wseg , wofs);
-
- char *wch Pointer to whatever type is specified
-
- type char This would be any valid type
-
- int wseg Segment value to get pointer for
-
- int wofs Offset value to get pointer for
-
- 2. MEMB Gain access to far char locations (JAZ.H)
-
- This macro allows access to far memory locations.
-
- wch = MEMB(wseg,wofs);
-
- int wch Value returned from pointer
-
- int wseg Segment value to point to
-
- int wofs Offset value to point to
-
- 3. MEMW Gain access to far word locations (JAZ.H)
-
- This macro allows access to far memory locations.
-
- wch = MEMW(wseg,wofs);
-
- int wch Value returned from pointer
-
- int wseg Segment value to point to
-
- int wofs Offset value to point to
-
- 4. MEML Gain access to far long locations (JAZ.H)
-
- This macro allows access to far memory locations.
-
- wch = MEML(wseg,wofs);
-
- long wch Value returned from pointer
-
- int wseg Segment value to point to
-
- int wofs Offset value to point to
-
- 5. SCROFS Convert row and column position to a screen offset (JZSCREEN.H)
-
- This macro converts row and column to an absolute screen offset.
-
- wofs = SCROFS(wrow,wcol);
-
- int wofs Returned offset
-
- int wrow row position
-
- int wcol Column position
-
- 6. MKATTR Make a color attribute given fore and back ground. (JZSCREEN.H)
-
- This macro converts a foreground and background color to a video
- attribute useful in many of the screen functions.
-
- wattr = MKATTR(wback,wfore);
-
- int wattr Returned video attribute
-
- int wback Background color
-
- int wfore Foreground color
-
- 7. CNTCOL Centering fields (JZSCREEN.H)
-
- This macro returns a column position with which to center a string
- in a given width.
-
- wcol = CNTCOL(wstr,wwidth);
-
- int wcol Returned centered column
-
- char *wstr String to provide centered column for
-
- int wwidth Width of field.
-
- 8. CLEARKBD Clear the keyboard buffer (KEYS.H)
-
- This macro clears the keyboard buffer
-
- CLEARKBD
-
- 9. MSDOS Provide an msdos function. (JAZ.H)
-
- This macro simulates the msdos call like in Turbo Pascal.
-
- MSDOS(&wreg);
-
- TREG wreg Pointer to structure of a register record.
-
-
- DEMO PROGRAMS
- Note:
- When compiling and linking these routines, make sure to use a compile spec
- similar to this :
- \msc\msc /Ox /Ze /Zp /I c:\msc\jaz %1/DLINT_ARGS;
-
- The "/Ze","/Zp" are absolutely neccessary for many of these programs.
-
- The link spec is not as critical (see link.bat) but many of the routines
- require a larger stack than the default. (Especially the interrupt handlers)
- Failure to use a large enough stack will result in the system hanging in
- many cases.
- -Jaz
-
- 1. BADSECT Check and List bad sectors on A:
-
- 2. COPYFILE Copy one file to another. Wildcards are supported.
- The syntax is COPYFILE <source spec> <destin spec>
-
- 3. DIRLST Demonstration of a disk directory places in a binary
- tree and printed out. Use "/st:12000" when linking
-
- 4. JAZPRINT Print multiple files with formatting. Demo of directory
- routines as well as buffer stream printing.
- formatting options.
- -d specifies double strike printing
- -e specifies emphasized printing
- -t specifies title of document + time and date
- -w specifies wide (compressed) listing
- -n specifies to number the lines
- -u specifies user chars to send (in hex). i.e jazprint *.* -u 1b471b45
- -mn specifies multiple copies where n is the number of copies
-
- 5. JZBACKGR This program plays a dumb tune in the background of a
- DBASE like editing screen. It is a good demo of interrupt
- handlers, Input screens, and the sound routines.
-
- 6. JZBIGLTR Demonstration of big printing.
-
- 7. JZCHKDSK Program is similar to chkdsk but with many option. It will
- report on contiguous files/non contiguous files, bad sectors,
- etc. Link with "/ST:12000"
- Usage: JZCHKDSK <Options> <Path>
- Options: -c List contiguous files
- -n List non - contiguous files only
- -q Quiet mode. Don't list files at all
- -b List Bad Sectors
-
- 8. JZCLOCK This program puts a resident clock on the screen in the upper
- right hand corner. It takes up a LOT of memory but is mainly
- a demo just to prove it can be done in MS-C. When I have 4.0,
- I will probably be able to significantly reduce the size of
- the resident code. Must be linked with "/ST:12000"
-
- 9. JZDIR Incomplete demo of directly reading disk directory sectors.
-
- 10. JZDIRLST Demo of sorted directory with binary tree. Link with
- "/st:12000"
-
- 11. JZEDTCHR Demonstration of how to access the character set in rom.
- This routine allows you to edit and change the upper
- 128 characters and install a pointer to your buffer. Use
- font.chr (a sample script char set) and have fun. Link
- with "/st:12000"
-
- 12. JZFIND This program finds files across sub-directories. It supports
- wild-cards in the file searches. i.e. jzfind *.doc
-
- 13. JZMENU Incomplete demo of menu routines and menu drivers.
-
- 14. MENU Simple demo of the jzmenu() function.
-
- 15. JZPSHDIR Demonstration of the jzpshdir,jzpopdir. This routine expects
- an A drive, B drive and C drive with the b:drive having a
- subdirectory named test. This routine simply does a few
- directory changes , pushing the dirs beforehand and poping
- them back to change directories and drives.
-
- 16. JZPUSH Simple demo of data conversion using jzpush and jzpop.
-
- 17. JZPUTKBD Demonstration of the jzputkbd routine allowing characters
- to be "written" to the keyboard buffer on IBM and close
- compatibles.
-
- 18. JZSCREEN Demo of big letters. Prints command line on screen.
-
- 19. JZSEARCH Search multiple files for the occurance of strings.
-
- Usage JZSEARCH [-uwcr] [filespec] [search string\\replace string]
- Options are as follows:\n");
- -u Uppercase (Ignores case on search)
- -c Display files on console
- -w Whole words only. "MEM" won't be found in "MEMORY"
- -r Replace string if found. Syntax for this is:"
- -p Prompt for change before replacing
-
- 20. JZSETATR Allows setting attributes of files. Supports wildcards.
- Syntax is JZSETATR <file spec> <attribute>
-
- 21. POPDIR Stand alone popdir program. Uses a virtual stack technique.
-
- 22. PUSHDIR Stand alone pushdir program. Uses a virtual stack technique.
-
- 23. RENFILE Allows renaming of files across subdirecties. Allows
- wildcards. This one is not thouroghly tested yet so
- make sure you have a backup before proceeding here!
-
- USAGE: renfile <old path\\old name> <new path>
-
- 24. SCREEN Demo of various screen and window related functions.
- This program is obsolete. Do NOT compile it. Run only
- if you received the executable along with the source.
- Calling conventions of many of the routines have changed
- since this was written.
-
- 25. TRUNCFIL Demo program to truncate a file. You specify the file name,
- the original size, and the new size.
-
- 26. VIEW This is a read only edit that saves the users screen before
- running. This means when you exit, your screen will appear
- just as it did before this program was run.
-
- 27. WINDOW This program demonstrates many of the screen and windowing
- functions available in the system. However the window moving
- is not very smooth at this point. I will be working on that
- very soon.
-
-
-