-

LIBRARIES PUBLIC DOCUMENT MCLIB GRAPHIC

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

Lower compatible library of MSX-Graphic library in "MSX-C Library" By Tatsuhiko Syoji(Tatsu) 1999-2000

About This Library

This library is compatible to Graphic library in "MSX-C Library". Source codes are consisted from totally confirmed free codes. Functions very complicated but not used so much is not implemented.

Files

* .AS  
Source files of this library.
GLIB.TXT  
This file.
GLIB.H  
Header file of this library.

Assembling

Source files of this library can be compiled by executing MKGLIB.BAT. Library file is generated as "LIBM.LIB". In addition, copy GLIB.H to directory where header files exist and copy library file to where other library files exist.

Functions

void ginit(void);
Initializes graphic library. It should be called once, before using these functions below.
void interlace(char mode);
Sets interrace mode. Values of modes are below.
0 Noninterlaced
1 Interlaced
2 Noninterlaced and displays odd and even pages by turns.
3 Interlaced and displays odd and even pages merged.
  • When you use mode 2 or 3, display odd page.
void setrd(unsigned addr);
Sets VDP to read mode and prepare reading from address "adde" of VRAM using I/O port.
Reading itself is executed by invdp() function.
char invdp(void);
Reads 1 byte from address of VRAM set by setrd() function.
Address counter is automatically incremented after reading and you can read from continued range of VRAM repeatedly.
void setwrt(unsigned addr);
Sets VDP to write mode and prepare writing from address "adde" of VRAM using I/O port.
Writing itself is executed by outvdp() function.
void outvdp(unsigned char ch);
Write 1 byte of "ch" into address of VRAM set by setwrt() function.
Address counter is automatically incremented after writing and you can write into continued range of VRAM repeatedly.
unsigned char vpeek(unsigned int addr);
Reads 1 byte from address "addr" of VRAM.
You can read with invdp() function by next bytes.
void vpoke(unsigned int addr,unsigned char ch);
Writes 1 byte into address "addr" of VRAM.
You can write with outvdp() function by next bytes.
void wrtvdp(char no,unsigned char val)
Writes value "val" to VDP register number "reg".
It can be called with function name as vdp which is for compatibility with SOLID C's slib.irl.
unsigned char rdvdp(char no)
Reads from VDP control register number "no".
It simply returns value stored on work area which has been set while writing.
unsigned char rdvsts(char no)
Reads from VDP status register number "no".
It can be called with function name as vdpstat which is for compatibility with SOLID C's slib.irl.
void color(char fg,char bg,char bd);
Sets foregrand color to "fg", backgroud color to "bg" and border color to "bd".
Values are stored in c_fore, c_back and c_bord simultaneously.
void iniplt(void);
Initializes palette.
It does not save palette data onto VRAM.
void setplt(char no,unsigned int dat);
Sets palette of number "no".
Palette itself is set with "dat".
Depth of color is set with combination of green (bit10-8), red (bit7-4) and blue(3-0).
void inispr(char mode);
Initializes sprites with mode number "mode".
Modes mean as follows.
0 8*8 Not expanded
1 8*8 Expanded
2 16*16 Not expanded
3 16*16 Expanded
4 Prohibit sprites (and execution time of VDP commands become faster)
unsigned int calpat(char num);
Returns address of sprite generator table of number "num".
unsigned int calatr(char plane);
Returns address of sprite attribute table of sprite plane of number "plane".
void sprite(char no,void *data);
Sets sprite patterns of number "no" with "data".
void colspr(char plane,void *data);
Sets display color of sprite which displayed with plane number "plane".
This is available if screen number is more than 4.
void putspr(char plane,int x,int y,char color,char pat);
Displays sprites of pattern number "pat" on coordinate (x,y) of plane number "plane".
Displayed color should be set with :"color" on screen 1-3.
Sprite number is not effected by sprite size like BIOS or MSX-BASIC.
void totext(void);
Revert display mode into text mode which is previously used.
If program ended on graphic mode, characters are not displayd on screen.
You should call it before ends program in case program uses graphic mode.
void grpprt(char ch,char logop);
Display character "ch" on screen of graphic mode.
You can set logical operation if screen number is more than 5.
void glocate(int x,int y);
Specifies coordinates which grpprt() function displays character.
void setpg(char dp,char ap);
Set display page on screen 5 or higer.
Displayed page number is set with "dp" and active page (actually drawable page) is set with "ap".
void fsetrd(char bit16,unsigned int bitf0);
Ignores value set with setpg() funciton unlike setrd(), changes VDP to read mode and makes readable using I/O port.
Address is set with bit 16 and bitf(bit15-0).
Actual reading is executed with invdp() function.
This function does not exist in MSX-C library.
void fsetwt(char bit16,unsigned int bitf0);
Ignores value set with setpg() funciton unlike setwrt(), changes VDP to write mode and makes writable using I/O port.
Address is set with bit 16 and bitf(bit15-0).
Actual writing is executed with invdp() function.
This function does not exist in MSX-C library.
void lsetrd(unsigned long addr);
Ignores value set with setpg() funciton unlike setrd(), changes VDP to read mode and make readable from address "addr" of VRAM using I/O port.
Address is set with bit 16 and bitf(bit15-0).
Actual reading is executed with invdp() function.
This function does not exist in MSX-C library.
void lsetwt(unsigned long);
Ignores value set with setpg() funciton unlike setwrt(), changes VDP to write mode and make writable into address "addr" of VRAM using I/O port.
Address is set with bit 16 and bitf(bit15-0).
Actual writing is executed with invdp() function.
This function does not exist in MSX-C library.
void vdpcom(void *dat);
Executes VDP command regarding contents of memory at address "dat" and after as VDP registers #32-#46.
This function does not exist in MSX-C library.
This function is effective if size of source is fixed.
;Copyright (c) 1999-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.