-

LIBRARIES PUBLIC DOCUMENT UTY

From HI-TECH C for CP/M Fan WIKI(EN)
Jump to: navigation, search

Manual of Extended Function Set for HI-TECH C V3.09 By Tatsuhiko Syoji 1995-2000

Files

UTY .H  
Heade files which devines functions.
UTY .TXT 
This file which you read now.
*.C , *.AS  
Source files of this library.
* .O  
Object files of this library.
INSTALL .BAT 
BAT file for convining objectfiles in this library to appropriate existedlibrary file.
REMAKE .BAT 
BAT file for re-compiling this library.

What is this library for

HI-TECH C V3.09 for CP/M

What is this library?

This library is a compilation of multi-purpose and useful functions for MSX programming with HI-TECH C library.

How to

First, copy UTY.H to working disk of HI-TECH C. Second prepare object files and INSTALL.BAT in current drive and current directory from this library, then type this.

>INSTALL LibraryFileName

You can append this library to existed library files by typing existed filename as argument LibraryFileName, or newly name filename and make it as a independent library file.

If you want name this library file as "LIBU.LIB", type this.

>INSTALL LIBU.LIB

Read UTY.H by #include in source file and link library file of this library before LIBC.LIB. This library uses "MSX-C Library" compatible library I made internally, so it should be linked before this library.

If name this library as "LIBU.LIB", command is like below.

>LINK -Z -Ptext=0,data,bss -C100H -OTEST.COM CRT.O TEST.O LIBU.LIB LIBM.LIB LIBC.LIB

Then you can make programs with these files in this package.

Re-compilling

Execute REMAKE.BAT to re-compile this library. Library module can be exchanged by executing INSTALL.BAT after that.

Reference for Functions

These functions below can be available by including uty.h.

unsigned char inkey(void);
Returns character by input and returns '\0' if there is no input.
int maxpos(int x,int lim);
Returns 0 when x>lim. Returns lim when x<0, otherwize returns x just as it is. This is for adjustment of coordinates etc.
void kbcom(unsigned char *buf);
void kbcomr(unsigned char *buf);
Stores content of "buf" in MSX's key buffer.
For example:
int main()
{ 
       printf("This is a test.\n");
       kbcomr("dir");
}
These codes above execute dir command of MSX-DOS after displayed "This is a test."
Difference between these two is the return key code. Kbcomr appends return kry code automatically, but kbcom does not.
void plxpal(unsigned int *dat,unsigned char tr,unsigned char pal);
Recognizes contents in memory provided by dat as a palette data of Graph Saurus format, and set data of palette number "pal" to data of palette number "pal" of the track "tr".
void plxset(unsigned int *dat,unsigned char tr);
Recognizes contents in memory provided by dat as a palette data of Graph Saurus format, and set data of all palettes of the track "tr".
For example:
for (i = 0;i < 8;i++){
       plxset(dat,i);
       /* Insert waits here*/
}
A sort of fade in/out effects are enabled by this sequence below.
Set palette data of "before" into track 0, set palette data of "after" into track 7 and set phased or intermedial parameters into palettes between these two.
void nrsort(void *base,size_t nel,size_t width,int (*compar)())
Function nrsort do ascending sort. Top address of the data is "base", number of data to sort is "nel", size of each elements by bytes is "width" and pointer to comparing function is "compar".
Function which compar defines should have two argument as pointer (x and y) and return these values.
<nowiki>*x > *y Positive number
<nowiki>*x = *y Zero
<nowiki>*x < *y Negative number
This function behaves same as qsort but does not recursive call and deals bigger data safely.
char bloads(char filename,unsigned int offset)
This function behaves like bload "filename",s,offset in MSX-BASIC.
Returned numbers mean as follows.
0 Success to load
1 Disk related error occured
2 Memory insufficient
3 File is not BSAVE formatted.
unsigned char getkmode(void)
Ckeck if kanji driver exists and uses which kanji mode.
Returned numbers mean as follows.
0 ANK mode
1 Kanji0 mode
2 Kanji1 mode
3 Kanji2 mode
4 Kanji3 mode
255 Kanji driver does not exist/is not installed
void setkmode(unsigned char mode)
Switch Kanji mode. Number of mode is same as return of getkmode() function.
Kanji driver should be installed first.
int grand(int range)
Returns pseudorandom number from 0 to (range-1).
Range is between 0 and 32767.
Function stand can be used to initialize randum number series.
It makes smart programs if range of randum number is fixed.

NOTE

These programs and source codes are unders BSD copyright. Refer LICENSE.TXT about BSD copyright in this package. Japanese translation of BSD copyright is published at this URL. http://openlab.etl.go.jp/freesoft/BSD-j.htm

/*
 * Copyright (c) 1998-2000 Tatsuhiko Syoji, Japan . All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are 
 * met:
 * 
 * 1 Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer as the first lines
 *  of this file unmodified.
 * 
 * 2 Redistributions in binary form must reproduce the above copyright 
 * notice, this list of conditions and the following disclaimer in the 
 * documentation and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY Tatsuhiko Syoji ``AS IS AND ANY EXPRESS 
 * ORIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *  DISCLAIMED. IN NO EVENT SHALL Tatsuhiko Syoji BE LIABLE FOR ANY DIRECT,
 *  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
 * IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
*/