QLIB On-Line Help
QLIB is a 32bit programming Library with rich resources and many tools to develop the best in DOS extended applications. Indexes: Index of ANSI-C functions [incomplete] Index of QLIB functions [near complete] Index of DPMI 'C' functions [n/a] Index of all QLIB Utilities [near complete] Index of all header files (*.H) [incomplete] Notes: How to compile/link using QLIB BAT files [complete] How to use QLIB-DLL services [n/a] How to use grafix services [near complete] How to use PACK services [n/a] How to use compression services [n/a] Internet Links: Q-Force HomePage The birth place of QLIB

ANSI-C functions [incomplete]

The following functions are standard ANSI-C functions.

abort() [STDLIB.H, PROCESS.H] Abnormally terminates a process. Declaration: void abort(void); Input: nothing Output: Does not return (program terminated) Notes: o Returns error code 3 to DOS.
abs() [MATH.H, STDLIB.H] Computes absolute value of an integer. Declaration: int abs(int x); Input: x = value to compute absolute of Output: absolute of x Notes: o abs() is not a macro
assert() [ASSERT.H] Tests a condition and possibly aborts(assertion). Declaration: void assert(int test); Input: test = if evaluates to 0 then assertion is caused Output: On assertion : does not return - program terminates No assertion : does nothing Notes: o If assertion is caused then the following message is printed to stderr and abort() is called Assertion failed: test, file filename, line linenum o use '#define NDEBUG' before '#include ' to disable assert()
atexit() [STDLIB.H] Registers termination function. Declaration: int atexit(atexit_t func); Input: func = pointer to a function to register Output: On success: SUCCESS (0) On error : ERROR (-1) Cause(s): Function table full Notes: o atexit registers the function pointed to by func as an exit function. o Upon normal termination of the program, exit calls (*func)() just before returning to the operating system. o Each call to atexit registers another exit function. o Up to 32 functions can be registered. They are executed on a last-in, first-out basis (the last function registered is the first to be executed).
atof() [MATH.H, STDLIB.H] Converts a string to a floating point. Declaration: double atof(char *str); Input: str = string to convert Output: floating point number Notes: o atof() returns 0.0 if there was a problem
atoi() [STDLIB.H] Converts a string to an integer. Declaration: int atoi(char *str); Input: str = string to convert Output: integer Notes: o atoi() returns 0 if there was a problem o atoi() is the same as atol() in a 32bit environment See Also: str2num
atol() [STDLIB.H] Converts a string to an integer. Declaration: long int atol(char *str); Input: str = string to convert Output: integer Notes: o atol() returns 0 if there was a problem o atol() is the same as atoi() in a 32bit environment See Also: str2num
calloc() [ALLOC.H, STDLIB.H] Allocates memory and clears its contents (zero fill). Declaration: void *calloc(size_t nitems, size_t size); Input: nitems * size = # of bytes to allocate Output: On success: void* = pointer of new memory block On error : void* = NULL Cause(s): Not enough memory was available. Notes: o calloc() can alloc more than 64k of memory since QLIB is a 32bit environment. See Also: malloc coreleft free realloc _memavl _memmax _maxused _maxtotal _heapset _heapwalk _heapchk _heapfrag
ceil() [MATH.H] Rounds a float up. Declaration: double ceil(double x); Input: x = float to round Output: rounded float
chdir() [DIR.H] Changes current directory. Declaration: int chdir(const char *path); Input: path = new directory that must exist, may contain a drive letter but will not change current drive Output: On success: 0 On error : ERROR (-1) and sets errno to ENOENT (path or file name not found).
chmod() [IO.H] Sets file access permissions. Declaration: int chmod(const char *path, int amode); Input: path = filename of file to set attributes amode = contains constants defined in SYS\STAT.H S_IWRITE (Permission to write) S_IREAD (Permission to read) S_IREAD|S_IWRITE (Permission to read and write) Output: On success: 0 On error : ERROR (-1) and sets errno to one of following ENOENT (Path or file name not found) EACCES (Permission denied)
clearerr() [STDIO.H] Resets error indication. Declaration: void clearerr(FILE *stream); Input: FILE = pointer to a device stream Output: nothing Notes: o clears end-of-file and error bits in stream
clock() [TIME.H] Returns number of clock ticks since program start. Declaration: clock_t clock(void); Input: nothing Output: On success: returns processor time since program start On error : returns ERROR (-1) if time is unavailable on system Notes: o Divide return value by CLK_TCK to find the number of seconds since program start.
close() [DOS.H, IO.H] Closes a file associated with a handle. Declaration: int close(int handle); Input: handle = file handle to close Output: On success: 0 On error : ERROR (-1) and set errno to EBADF (Bad file number) See Also: open creat
clrscr() [CONIO.H] Clears the current screen and position cursor in upper-left corner (1,1). Declaration: void clrscr(void); Input: nothing Output: nothing See Also: window gotoxy
floor() [MATH.H] Rounds a float down. Declaration: double floor(double x); Input: x = float to round Output: rounded float
malloc() [ALLOC.H, STDLIB.H] Allocates memory. Declaration: void *malloc(size_t size); Input: size = # of bytes to allocate Output: On success: void* = pointer of new memory block On error : void* = NULL Cause(s): Not enough memory was available. Notes: o malloc() can alloc more than 64k of memory since QLIB is 32bit. See Also: calloc coreleft free realloc _memavl _memmax _maxused _maxtotal _heapset _heapwalk _heapchk _heapfrag
signal() [SIGNAL.H] Specifies signal-handling actions. Declaration: void (*signal(int sig, (void*) func (int sig))) (int); Input: sig = signal type to define, see signals func = new function handler or one of the following: func | Meaning ---------------------------------------------------------------------------- SIG_DFL | Restore exception handler with default handler SIG_IGN | Ignores exception. Output: On success: void* = old handler On error : void* = SIG_ERR Notes: o Warning, most exceptions execute during an 'CPU Exception handler' and therefore are using a small locked stack provided by the DPMI host. Try to keep your code to a minimal or switch to your own stack (but you must switch back before returning). o All exceptions by default are assigned a simply exception handler that will either pass the exception down the chain or terminate the program immediately. In either case the program will terminate, either by QLIB or by the DOS extender (or DPMI host). ANSI-C: o When the exception handler is called it is passed one parameter that is the signal # (SIGABRT, SIGFPE, etc.). ANSI-C declaration: func(int sig); Borland C++ extensions: o Borland has created some 'extensions' to the ANSI-C exception handler parameters passed. QLIB supports them with some modification. o All exception are called with one extra parameter (subcode) QLIB Declaration: func(int sig, int subcode); o If the exception is SIGSEGV, SEGILL or SIGFPE (only FPE_INTDIV0 or FPE_INTOVFLOW) it is also passed a reglist. QLIB Declaration: func(int sig, int subcode, int *reglist) Where: sig - the usually sig # subcode - exact cause of signal (see tables below) reglist - a pointer to a list of registers that the func may modify These regs are used when the exception returns to the interrupted code. NOTE : When modifying the values in the reglist you MUST do so thru the stack. Therefore you must insert ASM {} into your C code to do so. See \test\signal.c for an example. The reglist looks like this: EBP, EDI, ESI, DS, ES, EDX, ECX, EBX, EAX, EIP, CS, EFLAGS, ESP, SS, FS ,GS Everything from ESP to GS is a QLIB extension and is not supported by BC. o The sig # is given to the func so that you could create one function to handle many exceptions. The subcode is provided to further indicate the cause of the exception.

QLIB functions

The following functions pertain to QLIB only. These functions are only available while programming in the QLIB enviroment.

dma_alloc64() dma_alloc128() [QLIB.H] Allocates memory suitable for DMA transfers. Declaration: sbyte dma_alloc(struct dma_s *dma_info); struct dma_s { dword siz; dword off; word sel; word id; dword phys; word dmach; }; Input: dma_info = pointer to a dma_s structure dma_s.siz = # of bytes to allocate dma_s.dmach = DMA channel # that buffer will be used for Output: On success: 0 and dma_s structure holds updated info dma_s.off = linear offset to access buffer dma_s.phys = physical offset to program into DMA controller dma_s.id = VDS handle (do not touch) dms_s.sel = selector of memory allocated (to be used by dma_free()) On error : ERROR (-1) cause not enough DOS memory is available. Notes: o dma_alloc64() allocates memory that will not cross a 64k boundry which is suitable for 8bit transfers. o dma_alloc128() allocates memory that will not cross a 128k boundry and will be WORD aligned which is suitable for 16bit transfers. o dma_s.siz must not be greater then 64k for dma_alloc64() or 128k for dma_alloc128() o currently QLIB does not support VDS (virtual DMA specs - a method to allocate DMA services under strict OSes, like Windoze or OS/2). You still must fill in dma_s.dmach because dma_setup() requires it and when VDS is supported it will need to know this too. See Also: dma_free Example: #include <qlib.h> #include <stdio.h> #include <process.h> void main(void) { struct dma_s dma_info; dma_info.siz = 1024; //allcate a 1K DMA buffer dma_info.dmach = 1; //for DMA #1 if (dma_alloc64(&dma_info)==ERROR) { printf("dma_alloc64() failed!\n"); exit(0); } printf("DMA buffer info:\n"); printf("Linear offset = %#x\n",dma_info.off); printf("Physical offset = %#x\n",dma_info.phys); //this is where you can program the DMA controller here as you like // using the buffer allocated from dma_alloc...() dma_setup(&dma_info,0,1024,DMA_MODE_WRITE | DMA_MODE_AUTO); //here you may want to stop the your device and then quit. dma_free(&dma_info); //release buffer }
dma_free() [QLIB.H] Frees a memory buffer allocated by dma_alloc...(). Declaration: sbyte dma_free(struct dma_s *dma_info); Input: dma_info = pointer to a dma_s structure that was filled in by dma_alloc...() Output: On success: 0 On error : ERROR (-1) if invalid info See Also: dma_alloc64 dma_alloc128
dma_setup() [QLIB.H] Sets up the DMAC to start a DMA transfer. Supports 8/16 bit DMAC. Declaration: sbyte dma_setup(struct dma_s *dma_info,dword bufstart, dword buflen,byte mode); Input: dma_info = pointer to a dma_s structure that was filled in by dma_alloc...() bufstart = offset within buffer to start transfer from buflen = length of buffer to send (bytes for 8bit, words for 16bit) mode = DMA mode to use, see DMA Modes Output: On success: SUCCESS (0) On error : ERROR (-1) if dma_info.dmach is invalid. See also: DMA Example
ERRORPROC() [QLIB.H] Function that does nothing. Declaration: sbyte ERRORPROC(void); Input: nothing Output: ERROR (-1) Notes: o This function is usually used to replace unused function pointers to prevent system crashes.
g_alloc() [VIDEO.H] Allocates memory to be used with g_setbuf. g_alloc() uses the current video mode to determine how much memory to allocate. Declaration: void *g_alloc(void); Input: nothing Output: On success: pointer to memory On error : NULL Notes: o This func uses malloc() to allcate the buffer o The pointer should be used with g_setbuf() See also: How to use grafix services malloc g_setbuf
g_box() [VIDEO.H] Draws a simple box in the grafix temp screen. Declaration: void g_box(dword x1,dword y1,dword x2,dword y2,dword clr); Input: (x1,y1)-(x2,y2) = dimensions of box to draw clr = color to draw box in Output: nothing Notes: o g_box() simply calls g_vline() and g_hline() See also: How to use grafix services g_boxfill g_hline g_vline
g_boxfill() [VIDEO.H] Draws a simple filled box in the grafix temp screen. Declaration: void g_boxfill(dword x1,dword y1,dword x2,dword y2,dword clr); Input: (x1,y1)-(x2,y2) = dimensions of box to draw clr = color to draw box in Output: nothing See also: How to use grafix services g_box
g_cls() [VIDEO.H] Clears the grafix temp screen and then calls g_copy(). Declaration: void g_cls(void); Input: nothing Output: nothing See also: How to use grafix services g_copy
g_copy() [VIDEO.H] Copys memory from the grafix temp screen to the video memory for display. Declaration: void g_copy(void); Input: nothing Output: nothing Notes: o It is not necessary to hide the mouse cursor. See also: How to use grafix services
g_copyblk() [VIDEO.H] Copys a rectangular block of the grafix temp screen to the video memory. Declaration: void g_copyblk(dword x1,dword y1,dword x2,dword y2); Input: (x1,y1)-(x2,y2) = define rectangular area to copy Output: nothing Notes: o It is not necessary to hide the mouse cursor. See also: How to use grafix services
g_copybuf() [VIDEO.H] Copys a rectangular block from a buffer to the video memory. Declaration: void g_copyblk(void *buf,dword x1,dword y1,dword x2,dword y2); Input: buf = memory buffer holding video image data (x1,y1)-(x2,y2) = define rectangular area to copy Output: nothing Notes: o It is not necessary to hide the mouse cursor. See also: How to use grafix services
g_get() [VIDEO.H] Gets a rectangular image from the grafix temp screen. Declaration: void g_get(void *buf,dword x1,dword y1,dword x2,dword y2); Input: buf = memory buffer to hold video image data (x1,y1)-(x2,y2) = define rectangular area Output: nothing See also: How to use grafix services g_put
g_getbuf() [VIDEO.H] Returns the current set grafix temp screen buffer pointer. Declaration: void *g_getbuf(void); Input: nothing Output: void* = pointer of current grafix temp screen See also: How to use grafix services
g_getmode() [VIDEO.H] Returns the availability of a desired video mode. Declaration: sdword g_getmode(word x,word y,byte bpp); Input: x = horizontal resolution desired y = vertical resolution desired bpp = bits per pixel desired Output: On success: Returns adapter type, see adapter types On error : ERROR (-1) if mode not available. Notes: o This function does not disturb the current grafix mode o You must call this function before calling g_setmode() See also: How to use grafix services g_setmode
g_getpixel() [VIDEO.H] Gets a pixel from the grafix temp screen. Declaration: dword g_getpixel(dword x,dword y); Input: (x,y) = coordinates of pixel to get Output: Pixel color See also: How to use grafix services g_putpixel
g_hline() [VIDEO.H] Draws a horizontal line. Declaration: void g_hline(dword x1,dword y,dword x2,dword clr); Input: (x1,y) = starting pos. to draw line x2 = ending pos. to draw line clr = color to draw line Output: nothing Notes: o This function was developed before g_line() was created. See also: How to use grafix services g_line g_vline
g_line() [VIDEO.H] Draws a line on the grafix temp screen. Declaration: void g_line(dword x1,dword y1,dword x2,dword y2,dword clr); Input: (x1,y1)-(x2,y2) = define line to draw clr = color to draw with Output: nothing See also: How to use grafix services
() [VIDEO.H] Loads a QLIB bitmap font file (*.FNT). Declaration: void *g_loadfnt(char *fn); Input: fn = filename Output: On success: Memory pointer to loaded font On error : NULL See also: How to use grafix services g_printf g_setfnt
g_setbuf() [VIDEO.H] Sets the current grafix temp screen. This screen is used by all g_...() grafix functions. Declaration: void g_setbuf(void *buf); Input: buf = memory pointer of buffer Output: nothing Notes: o You must alloc this buffer yourself or with g_alloc. o The size of this buffer should be (X * Y * BYPP), where: X = horizontal pixels Y = vertical pixel BYPP = bytes per pixel See also: How to use grafix services g_alloc
g_setcol() [VIDEO.H] Changes a color in VGA palatte look up table. Declaration: void g_setcol(byte clr,byte red,byte green,byte blue); Input: clr = color to change (0-255) red,green,blue = new color intensities (0-63) Output: nothing Notes: o Should only be used in 8bpp video modes. o g_setcol() does not wait for a Vsync See also: How to use grafix services g_setpal g_waitvsync
g_setfnt() [VIDEO.H] Changes the current font used by g_...() functions. Declaration: void g_setfnt(void *fnt); Input: fnt = font pointer returned by g_loadfnt() Output: nothing See also: How to use grafix services g_printf
g_setfntcolor() [VIDEO.H] Changes the color used when printing mono-colored fonts. Declaration: void g_setfntcolor(dword clr); Input: clr = new color to use Output: nothing See also: How to use grafix services g_printf
g_setmode() [VIDEO.H] Changes the video card into the last successful mode checked with g_getmode(). Declaration: void g_setmode(void); Input: nothing Output: nothing Notes: o You must call g_getmode() before calling g_setmode() or nothing will happen See also: How to use grafix services g_getmode
g_setpal() [VIDEO.H] Changes the entire 256 color VGA palette look up table. Declaration: void g_setpal(void *lut); Input: lut = pointer to a 768 byte buffer holding the entire palette Each color in the table is represent as follows: byte = red intensity (0-63) byte = green intensity (0-63) byte = blue intensity (0-63) Output: nothing Notes: o Should only be used in 8bpp video modes. o g_setpal() does not wait for a Vsync See also: How to use grafix services g_setcol g_waitvsync
g_printf() [VIDEO.H] Prints a formatted string to the grafix temp screen. Declaration: void g_printf(dword x,dword y,char *str,...); Input: (x,y) = coordinates to starting printing at str = formatting string to print ... = items to be printed just as in printf() Output: nothing Notes: o g_printf() does not wrap around the screen. See also: How to use grafix services printf g_putch g_printxy
g_printxy() [VIDEO.H] Prints a string to the grafix temp screen. Declaration: void g_printxy(dword x,dword y,char *str); Input: (x,y) = coordinates to starting printing at str = string to print Output: nothing Notes: o g_printxy() does not wrap around the screen. See also: How to use grafix services g_putch g_printf
g_put() [VIDEO.H] Puts a rectangular image to the grafix temp screen. Declaration: void g_put(void *buf,dword x1,dword y1,dword x2,dword y2); Input: buf = memory buffer holding video image data (x1,y1)-(x2,y2) = define rectangular area Output: nothing See also: How to use grafix services g_get
g_put0() [VIDEO.H] Puts a rectangular image to the grafix temp screen except it does not copy color #0 pixels. Declaration: void g_put0(void *buf,dword x1,dword y1,dword x2,dword y2); Input: buf = memory buffer holding video image data (x1,y1)-(x2,y2) = define rectangular area Output: nothing See also: How to use grafix services
g_putb0() [VIDEO.H] Puts a rectangular image to the grafix temp screen except it does not copy color #0 pixels. This uses bit-packed mono color images. This is usually used by QLIB's font services. Declaration: void g_putb0(void *buf,dword x1,dword y1,dword x2,dword y2 ,dword clr); Input: buf = memory buffer holding video image data (x1,y1)-(x2,y2) = define rectangular area clr = color to draw with Output: nothing See also: How to use grafix services
g_putch() [VIDEO.H] Prints a character in the grafix temp screen. Declaration: void g_putch(dword x,dword y,char ch); Input: (x,y) = coordinates to print char ch = character to print Output: nothing See also: How to use grafix services g_printf
g_putpixel() [VIDEO.H] Puts a pixel into the grafix temp screen. Declaration: void g_putpixel(dword x,dword y,dword clr); Input: (x,y) = coordinates of pixel to draw clr = color to draw with Output: nothing See also: How to use grafix services
g_vline() [VIDEO.H] Draws a vertical line. Declaration: void g_vline(dword x,dword y1,dword y2,dword clr); Input: (x,y1) = starting pos. to draw line y2 = ending pos. to draw line clr = color to draw line Output: nothing Notes: o This function was developed before g_line() was created. See also: How to use grafix services g_line g_hline
g_waitvsync() [VIDEO.H] Does not return until the video monitors e-beam is moving vertically to the top of the screen. Declaration: void g_waitvsync(void); Input: nothing Output: nothing Notes: o This should be used before g_setcol() and g_setpal() to avoid snow on the video screen See also: How to use grafix services g_setcol g_setpal
g_window() [VIDEO.H] Changes the grafix view port window. Most grafix functions are clipped to this viewport. Declaration: void g_window(dword x1,dword y1,dword x2,dword y2); Input: (x1,y1)-(x2,y2) = define rectangular area Output: nothing Notes: o Currently the following functions perform clipping: g_line(), g_vline(), g_hline(), g_box, g_boxfill g_putpixel() g_printf(), g_printxy(), g_putch() See also: How to use grafix services
irq_enable() irq_disable() [QLIB.H] irq_enable() will enables a hardware IRQ. irq_disable() will disables a hardware IRQ. Declaration: void irq_enable(int irq); void irq_disable(int irq); Input: irq = IRQ # to enable/disable (0-15) Output: nothing
mouse_init() [VIDEO.H] Detects if a mouse driver is present. Declaration: sbyte mouse_init(void); Input: nothing Output: On success: SUCCESS (0) On error : ERROR (-1) Notes: o You should call this function once before using other mouse related functions. o If this returns ERROR then you must not call other mouse related functions. See also: How to use grafix services
mouse_loadcursor() [VIDEO.H] Loads a mouse cursor and makes it the default mouse pointer. Declaration: void *mouse_loadcursor(char *fn); Input: fn = filename (*.PTR) Output: On success: void* = pointer to mouse cursor buffer On error : void* = NULL (0) Notes: o This PROC uses malloc() to allocate the buffer for the cursor. See also: How to use grafix services mouse_setcursor
mouse_off() [VIDEO.H] Hides the mouse cursor. You must do this before terminating your program. Declaration: void mouse_off(void); Input: nothing Output: nothing Notes: o This PROC is automatically called during video mode switches, if you use g_setmode() or t_setmode(). See also: How to use grafix services g_setmode t_setmode
mouse_on() [VIDEO.H] Shows the mouse. Declaration: void mouse_on(void); Input: nothing Output: nothing See also: How to use grafix services
mouse_setcolor() [VIDEO.H] Changes the color of mono-color mouse cursors. Declaration: void mouse_setcolor(dword clr); Input: clr = new color for mouse pointer Output: nothing Notes: o This takes effect immediately to the mouse if it is shown. o Has no effect to multi-color cursors. o In Text modes this defines the background color that is XORed into the background byte. See also: How to use grafix services
mouse_setcursor() [VIDEO.H] Changes the mouse pointer. Declaration: void mouse_setcursor(void *ptr); Input: ptr = pointer to a mouse cursor loaded with mouse_loadcursor() Output: nothing Notes: o May be called when the mouse is shown. See also: How to use grafix services mouse_loadcursor()
mouse_setspd() [VIDEO.H] Changes the speed of the mouse. Declaration: void mouse_setspd(byte xr,byte yr); Input: xr = X ratio (1-4) yr = Y ratio (1-4) Output: nothing Notes: o A value of 1 is fastest while 4 is slowest. o May be called while mouse is shown. See also: How to use grafix services
mouse_setuser() [VIDEO.H] Defines a function to call whenever the mouse status changes (location or buttons). Declaration: void mouse_setuser(void *proc,struct mouse_user *mouse_info); Input: func = your function to call for any mouse activity *mouse_info = struct of mouse status Output: nothing Notes: o Everytime the mouse status changes the mouse_info struct is changed to the current status of the mouse and then *proc() is called. o Your function will be running in an IRQ handler which has limited stack space and can not call DOS and most QLIB functions. You should simply act apon the values in the mouse_info struct. You may call mouse_...() related functions. (ie: mouse_setcursor()) o mouse_user.x and mouse_user.y represent the mouses current location on screen. In text mode this does NOT represent the cursors char location but instead its pixel location, assuming that the char is 8x8 regardless of what it really is. o mouse_user.but represents the mouses current button status. Each bit represents a button, 1=pressed, 0=not pressed bit 0 = 1st button (left) bit 1 = 2nd button (right) bit 2 = 3rd button (middle) See also: How to use grafix services Example: #include <qlib.h> #include <stdio.h> #include <conio.h> #include <video.h> #include <process.h> //for exit() struct mouse_user mouse_info; void MouseFunc(void) { word x,y,b; //IRQ handler! //The screen is split up into 4 sections, and each has it's own color x=mouse_info.x / 8; //column y=mouse_info.y / 8; //row b=mouse_info.but; //button status if ((x<40> && (y<12)) mouse_setcolor(RED << 4); else if ((x<40> && (y>=12)) mouse_setcolor(BLUE << 4); else if ((x>=40> && (y<12)) mouse_setcolor(GREEN << 4); else mouse_setcolor(CYAN << 4); //draw a number based on button status if (but & 1) ch='1'; //button one pressed in else if (but & 2) ch='2'; //button two pressed in else if (but & 4) ch='3'; //button three pressed in else ch=' '; //no button pressed, print space //print text char directly to screen memset((void *)0xb8000+(y*80*2)+(x*2),ch,1); } void main(void) { if (mouse_init()==ERROR) { printf("Mouse driver not detected!\n"); exit(0); } clrscr(); t_setmode(80,50); //set to 80x50 text mode printf("Mouse Demo Program, press Button 1+2 to quit"); mouse_setuser((void*)&MouseFunc,&mouse_info); mouse_on(); //show mouse cursor while (1) { if (mouse_info.but == (1 | 2)) break; //break if button 1 and 2 set } mouse_off(); //hide mouse cursor t_setmode(80,25); // }
mouse_setwin() [VIDEO.H] Defines a rectangular area the mouse is allowed to stay in. Declaration: void mouse_setwin(dword x1,dword y1,dword x2,dword y2); Input: (x1,y1)-(x2,y2) = defines rectangular area Output: nothing Notes: o Mouse is not allowed to move beyond the area o May be called while mouse is shown o Mouse is moved into area if it is not in the area immediately See also: How to use grafix services
NULLPROC() [QLIB.H] Function that does nothing. Declaration: sbyte NULLPROC(void); Input: nothing Output: NULL (0) Notes: o This function is usually used to replace unused function pointers to prevent system crashes.
pack_open() [QLIB.H] Opens a packed file (*.PAK or *.PAH) so that files within may be accessed thru normal file IO operations (open(), read(), write(), etc.). Declaration: pack_close How to use PACK services
pack_close() [QLIB.H] Closes a pack file that was opened with pack_open(). Declaration: sbyte pack_open(sdword handle); Input: handle = pack file handle returned by pack_open() Output: On success: 0 On error : ERROR (-1) if invalid handle See Also: pack_open How to use PACK services
t_backboxfill() [VIDEO.H] Changes the background color in a filled box in the grafix temp screen. Declaration: void t_backboxfill(dword x1,dword y1,dword x2,dword y2 ,byte clr); Input: (x1,y1)-(x2,y2) = define rectangular area clr = color to draw with (including the blink bit) Output: nothing Notes: o This is usually used to draw a bar on menus and such. See also: How to use grafix services t_boxfill
t_box1() [VIDEO.H] Draws a single lined box in the grafix temp screen. Declaration: void t_box1(dword x1,dword y1,dword x2,dword y2,byte clr); Input: (x1,y1)-(x2,y2) = define box coordinates clr = color to draw (foreground/background info) Output: nothing See also: How to use grafix services t_box2
t_box2() [VIDEO.H] Draws a double lined box in the grafix temp screen. Declaration: void t_box2(dword x1,dword y1,dword x2,dword y2,byte clr); Input: (x1,y1)-(x2,y2) = define box coordinates clr = color to draw (foreground/background info) Output: nothing See also: How to use grafix services t_box1
t_boxfill() [VIDEO.H] Fills in a box area with a character in the grafix temp screen. Declaration: void t_boxfill(dword x1,dword y1,dword x2,dword y2,word _char); Input: (x1,y1)-(x2,y2) = define box coordinates Output: nothing _char = character/color to draw (foreground/background info) (16bits) See also: How to use grafix services t_backboxfill
t_printf() [VIDEO.H] Prints a formatting string into the grafix temp screen. Declaration: void t_printf(dword x,dword y,char *str,...); Input: (x,y) = define starting location to print string str = formatting string ... = args to print in string Output: nothing Notes: o This PROC uses the current color set o This PROC will wrap the text around the window set by window(). See also: How to use grafix services t_printxy
t_printxy() [VIDEO.H] Prints a string into the grafix temp screen. Declaration: void t_printxy(dword x,dword y,char *str,); Input: (x,y) = define starting location to print string str = string Output: nothing Notes: o This PROC uses the current color set o This PROC will wrap the text around the window set by window(). See also: How to use grafix services t_printf
t_restorestate() [VIDEO.H] Restores the complete Text Video state that was previously saved with t_savestate(). Declaration: void t_restorestate(void *state); Input: state = pointer returned by t_savestate(). Output: nothing Notes: o Does not release state buffer with free(). You may do this if you like. See also: How to use grafix services t_savestate
t_savestate() [VIDEO.H] Saves the complete Text Video state, including everything that is currently on screen. Warning : This function is not guarenteed to work in every text video mode possible. Declaration: void t_savestate(void *state); Input: nothing Output: state = pointer to the video state Notes: o Uses malloc() to allocate buffer. See also: How to use grafix services t_restorestate
t_setmode() [VIDEO.H] Changes the video mode into a text mode. Declaration: void t_setmode(byte x,byte y); Input: x = desired number of colomns. y = desired number of rows. Output: On success: SUCCESS (0) On error : ERROR (-1) Notes: o Currently QLIB supports the following text mode: 80 x 25 80 x 43 80 x 50 o The screen is always cleared and filled in with the current set color when switching to the new mode. See also: How to use grafix services
win95_title...() win95_vmtitle...() [QLIB.H] Controls title that is on the DOS BOX. win95_title_set/get() controls the title. win95_vmtitle_set/get() controls the VM title (virtual machine). Declaration: sbyte win95_title_set(const char * name); sbyte win95_title_get(char * name,dword strsiz); sbyte win95_vmtitle_set(const char * name); sbyte win95_vmtitle_get(char * name,dword strsiz); Input: name = buffer to get/set name strsiz = size of string in bytes Output: On success: 0 On error : ERROR (-1) if Win95+ is not present. Notes: o The format of the title on a Win95 Window is: vmtitle - title o You must restore the vmtitle before termination since this effect is permanent to the DOS BOX. See Also: win95_title...
win95_close...() [QLIB.H] Controls Win95 [X] user application close request. Declaration: sbyte win95_close_enable(void); sbyte win95_close_disable(void); sbyte win95_close_query(void); sbyte win95_close_ack(void); sbyte win95_close_cancel(void); Input: nothing Output: On success: 0 On error : ERROR (-1) if Win95+ is not present. Notes: o All of these functions currently do not work at all for unknown reasons. More info will be given when they do work. See Also: win95_title...
NULL [ALLOC.H, MEM.H, STDDEF.H, STDIO.H, STDLIB.H] Null pointer value.

Index of ANSI-C functions [incomplete]

-A-

abort abs assert atexit atexit_t atof atoi atol

-C-

calloc ceil chdir chmod clearerr clock close clrscr

-F-

floor

-M-

malloc

Index of QLIB functions [incomplete]

-D-

dma_alloc... dma_free dma_setup

-E-

ERRORPROC

-G-

g_alloc g_cls g_copy g_copyblk g_copybuf g_get g_getbuf g_getmode g_getpixel g_line g_loadfnt g_setbuf g_setcol g_setfnt g_setfntcolor g_setmode g_setpal g_put g_put0 g_putb0 g_putpixel g_vline g_waitvsync g_window

-M-

mouse_init mouse_loadcursor mouse_off mouse_on mouse_setcolor mouse_setcursor mouse_setspd mouse_setwin

-T-

t_backboxfill t_box1 t_box2 t_boxfill t_printf t_printxy t_restorestate t_savestate t_setmode

-I-

irq_enable/irq_disable

-N-

NULLPROC

-P-

pack_open pack_close

-W-

win95_title... win95_close...

Index of all headers (*.H) [incomplete]

CONIO.H DOS.H OS.H QLIB.H SIGNAL.H STDIO.H STDLIB.H SYS\STAT.H TIME.H VIDEO.H

CONIO.H

Constants, data types, and global variables ------------------------------------------- BLINK COLORS directvideo _NOCURSOR _NORMALCURSOR _SOLIDCURSOR text_info text_modes See Also: List of all Header files COLORS (text mode) |Back-|Fore- Constant |Value|grnd?|grnd? -------------------------------- BLACK | 0 | Yes | Yes BLUE | 1 | Yes | Yes GREEN | 2 | Yes | Yes CYAN | 3 | Yes | Yes RED | 4 | Yes | Yes MAGENTA | 5 | Yes | Yes BROWN | 6 | Yes | Yes LIGHTGRAY | 7 | Yes | Yes DARKGRAY | 8 | No | Yes LIGHTBLUE | 9 | No | Yes LIGHTGREEN | 10 | No | Yes LIGHTCYAN | 11 | No | Yes LIGHTRED | 12 | No | Yes LIGHTMAGENTA | 13 | No | Yes YELLOW | 14 | No | Yes WHITE | 15 | No | Yes --------------------------------- BLINK |128 | No | *** *** To display blinking characters in text mode, add BLINK to the foreground color.

SIGNAL.H

Signal | Meaning | Default Action --------------------------------------------------------------------- SIGABRT | Abnormal termination | = to calling _exit(3) SIGFPE | Bad floating-point operation | = to calling _exit(1) | Arithmetic error caused by | | division by 0, invalid operation, | | etc. | SIGILL | Illegal operation | = to calling _exit(1) SIGINT | Control-C interrupt | = to calling _exit(1) SIGSEGV | Invalid access to storage | = to calling _exit(1) SIGTERM |*Request for program termination | = to calling _exit(1) * - can only be triggered thru raise() SIG_ERR - Returned by signal() on error SIGFPE Type Signals (subcodes) --------------------- These SIGFPE-type signals can occur (or be generated). They correspond to the exceptions that the 8087 family is capable of detecting, as well as the "INTEGER DIVIDE BY ZERO" and "INTERRUPT ON OVERFLOW" exceptions on the main CPU. The declarations for these signals are in FLOAT.H. SIGFPE signal ³ Meaning ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΨΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ FPE_EXPLICITGEN³ User program executed raise(SIGFPE) ³ FPE_INEXACT ³ Precision FPE_INTDIV0 ³ Integer divide by zero FPE_INTOVFLOW ³ INTO executed with OF flag set FPE_INVALID ³ Invalid operation FPE_OVERFLOW ³ Numeric overflow FPE_UNDERFLOW ³ Numeric underflow FPE_ZERODIVIDE ³ Division by zero FPE_NOFPU ³ No Floating Point Unit available (QLIB only) The FPE_INTOVFLOW and FPE_INTDIV0 signals are generated by integer operations, and the others are generated by floating-point operations. SIGSEGV Type Signals (subcodes) ---------------------- These SIGSEGV-type signals can occur: SIGSEGV Signal ³ Meaning ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΨΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ SEGV_EXPLICITGEN ³ User program executed raise(SIGSEGV) ³ SEGV_BOUND ³ Bound constraint exception SEGV_PAGEFAULT ³ Page fault exception (QLIB only) SIGILL Type Signals (subcodes) --------------------- These SIGILL-type signals can occur: SIGSEGV Signal ³ Meaning ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΨΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ ILL_EXPLICITGEN ³ User program executed raise(SIGILL) ³ ILL_EXECUTION ³ Illegal operation attempted

STDIO.H

Constants, data types, and global variables ------------------------------------------- BUFSIZ Default buffer size used by setbuf function.
atexit_t Type of exit function passed to atexit() typedef void (* atexit_t)(void);

DOS.H

Constants, data types, and global variables ------------------------------------------- BYTEREGS and WORDREGS and DWORDREGS and REGS Structures for storing byte and word registers. struct BYTEREGS { byte al, ah; word _1; byte bl, bh; word _2; byte cl, ch; word _3; byte dl, dh; word _4; }; struct WORDREGS { word ax,_1; word bx,_2; word cx,_3; word dx,_4; word si,_5; word di,_6; word cflag,_7; word flags,_8; }; struct DWORDREGS { dword eax, ebx, ecx, edx; dword esi, edi, cflag, flags; }; union REGS { struct DWORDREGS x; struct WORDREGS w; struct BYTEREGS h; };

SYS\STAT.H

Definitions used for file status and directory functions. Name | Meaning -------------------------------- S_IFMT | File type mask S_IFDIR | Directory S_IFIFO | FIFO special S_IFCHR | Character special S_IFBLK | Block special S_IFREG | Regular file S_IREAD | Owner can read S_IWRITE | Owner can write S_IEXEC | Owner can execute

TIME.H

typedef long time_t; typedef long clock_t; #define CLK_TCK #define CLOCKS_PER_SEC Divide return from clock() by these to get seconds that have elapsed since program start.

QLIB.H

Functions --------- dma_alloc... dma_free dma_setup ERRORPROC irq_enable/irq_disable NULLPROC pack_open pack_close win95_title... win95_close... Constants, data types, and global variables ------------------------------------------- The following are new-age integer/float definitions used through out QLIB. byte = unsigned char (8bits) word = unsigned short int (16bits) dword = unsigned long int (32bits) sbyte = signed char (8bits) sword = signed short int (16bits) sdword = signed long int (32bits) Here are some alternative definitions (not used but available in QLIB.H) uint8 = unsigned char (8bits) uint16 = unsigned short int (16bits) uint32 = unsigned long int (32bits) int8 = signed char (8bits) int16 = signed short int (16bits) int32 = signed long int (32bits) sint8 = signed char (8bits) sint16 = signed short int (16bits) sint32 = signed long int (32bits) byte _os_typ; Indicates current OS present (if detectable), see OS.H for types. byte _os_ver_major; byte _os_ver_minor; Version of current OS detected (if detectable). byte _dos_ver_major; byte _dos_ver_minor; Version of DOS present (always detected). word _dosXver; Version of DOS extender in use (if possible). byte _dosXtyp; Type of DOS extender is use. Types detectable are: #define DOSX_PMODEW 0 #define DOSX_DOS4GW 1 #define DOSX_DOS32 2 //Obsolete DOS extender #define DOSX_WDOSX 3 //Currently not detectable #define DOSX_UNKNOWN 0xff word selcode; word seldata; Protected Mode selectors for current running code and data. dword _environ; Linear address (pointer) of environment in memory dword _psp; Linear address (pointer) of PSP (program segment prefix) dword _dta; Linear address (pointer) of DTA (data transfer area) This area by default is set 'outside' of your PSP by QLIB. byte _fpu; Indicates if an 80387 coprocessor or compatible is present. Possible Values: 0 = not present 1 = present char ** _argv; byte _argc; Arguments given to program. QLIB will treat arguments in "quotes" as one argument. To insert a double quote into the argument you must double them up. byte _pmmode; Indicates what type of Protected Mode server is present (if detectable). Constants: name | value | desc. ------------------------------------------------------------ SRV_UNKNOWN | 0xff | server could not be detected SRV_DPMI | 3 | DPMI (DOS Protected Mode Interface) SRV_VCPI | 2 | VCPI (Virtual Control Program Interface) SRV_XMS | 1 | XMS (eXented Memory Specification) SRV_RAW | 0 | RAW (no server present, direct access to Protected Mode) char *_filename; This is the same as _argv[0] which is the EXE filename as run by DOS with full PATH info. word _ds_; //these are loaded when certain INTs are called word _es_; // INT 10h,33h These values are loaded into DS and ES whenever INT 10h or INT 33h go to Real Mode from Protected Mode. When these INTs return _ds_ and _es_ are filled in with what DS and ES were after the INT call. This can be used to communicate with Real Mode easily (such as VBE or the mouse). You can use the _8kbuffer/_8kbufferseg as a Real Mode buffer for data exchange. word _pic_master; word _pic_slave; Indicate where in the INT Table the PIC (master and slave) are using INTs as IRQ handlers. Usually: _pic_master = 0x8 _pic_slave = 0x70 But under Windoze and other system this may change. word _8kbufferseg; dword _8kbuffer; A small 8k buffer allocated by QLIB during startup that exists under the 640k barrier. This memory may be used to communicate with Real Mode services. _8kbuffer = a 32bit linear address (pointer) you may use to access this pointer from Protected Mode _8kbufferseg = a 16bit segment address that you should give to the Real Mode services so it may know where to retieve the data/info. byte _processor; byte _cpu; Indicate processor detected by DPMI host (usually DOS extender). 3=386 4=486 5=586 etc. This is not accurate since I've seen Win95 report 486 on my Pentium. byte _ansi_sys; Indicates if ANSI.SYS is loaded into memory. 0=NO 1=YES byte _lfn; Indicates if long filename support is available from Win95. 0=NO 1=YES If they are then long filename functions may be used. byte _cpuid; Indicates if the CPUID instruction is available. 0=NO 1=YES byte _mmx; Indicates if the MMX instruction set is available. 0=NO 1=YES byte _cpl; Indicates the current privledge level of your running program. 0=high (fast execution) 1,2=medium 3=low (slow execution) byte _debugger; Indicates if a debugger is present. Note that the DOS/4GW DOS extender is considered a debugger since it can not be distinguished between WD.EXE and it will ignores INT 3 which makes it safe to insert them. Usually this variable is used to test if break points (INT 3) may be inserted into the code. byte _qdebug; Indicates if QDebug is present. DMA Constants: name | value | desc. ------------------------------------------------------------ DMA_MODE_READ | 0x44 | DMA Read mode (device to memory) DMA_MODE_WRITE | 0x48 | DMA Write mode (memory to device) DMA_MODE_AUTO | 0x10 | Auto. init. DMA mode (continuous buffer reuse)

VIDEO.H

Functions --------- g_alloc g_cls g_copy g_copyblk g_copybuf g_get g_getbuf g_getmode g_getpixel g_line g_loadfnt g_setbuf g_setcol g_setfnt g_setfntcolor g_setmode g_setpal g_put g_put0 g_putb0 g_putpixel g_vline g_waitvsync g_window mouse_init mouse_loadcursor mouse_off mouse_on mouse_setcolor mouse_setcursor mouse_setspd mouse_setuser mouse_setwin t_backboxfill t_box1 t_box2 t_boxfill t_printf t_printxy t_restorestate t_savestate t_setmode Constants, data types, and global variables ------------------------------------------- Structure for holding mouse info. This structure is filled in by QLIB mouse driver before every call to your PROC set by mouse_setuser(). struct mouse_user { word x; word y; word but; }; dword _v_buffer; Current Grafix temp screen. Set by g_setbuf(). dword _v_linear; Linear address of Video RAM (may not be 0a0000h under VESA 2.0) byte _v_debug; Set this to have QLIB print debug info during g_getmode() and g_setmode(). Grafix Modes returned by g_getmode() when the video mode desired is available. name | value | desc. ------------------------------------------------------------ G_TEXT | 1 | Text mode G_VGA | 2 | Standard VGA Mode (320x200x8bpp) G_VESA | 3 | VESA 1.2 or 2.0 Mode G_MODEX | 4 | ModeX Mode (tweaked VGA) See Also: List of all Header files

OS.H

Constants, data types, and global variables ------------------------------------------- name | value | desc. ------------------------------------------------- OS_DOS | 0 | MS-DOS OS_WIN | 1 | Windows 3.1x OS_WIN32 | 2 | Windows 95/97/98/etc. OS_WINNT | 3 | Windows NT OS_OS2 | 4 | OS/2 OS_DV | 5 | Desqview

How to use grafix services


The basics:

The basic idea behind the QLIB grafix functions is that you create an image to be displayed on the screen and then have it copied to the video RAM with g_copy(). The driver will handle cases like keeping the mouse on the screen (which will not even blink during g_copy()). First you setup the screen using g_getmode() and g_setmode(). Then allocate yourself enough RAM for the Grafix temp screen where you will create images to be displayed. You must tell the video functions where this temp screen is by using g_setbuf(). Then when ever you have an image ready to be displayed simply call g_copy(). Make sure to use t_setmode() to return back to text mode so that the grafix functions can free any buffers used.

The mouse:

To use the mouse in QLIB you first need to detect if a mouse driver is loaded by using mouse_init(). If this call fails you should exit with an error message if the program requires a mouse driver. If you are in grafix mode you must use mouse_loadcursor() to load a mouse cursor. If you are in text mode you should use mouse_setcolor to change the mouse color. That function call also can be used in grafix mode to change the mouse color if the mouse is a mono-colored cursor. Now you are ready to show the mouse by calling mouse_on. When ever you need to hide the mouse cursor simply call mouse_off. In order for your program to determine the location and status of the mouse buttons at any time your program must install a mouse callback PROC. This is done thru mouse_setuser(). After the handler has been installed your PROC will be called everytime the mouse moves or the status of a button changes. When your PROC is called in text mode the (x,y) that is in your mouse_user struct does NOT represent the cursors column/row position. Instead it represent the cursors current pixel poisition assuming that each char is 8x8 (regardless of what it really is).
Your PROC is running in an IRQ handler so it should not call DOS or anything else, simply record the mouse status onto your own stack or whatever you need to do. It is not necessary to hide the mouse while calling g_copy() or g_copybuf() or g_copyblk(). QLIB will copy the image to the screen without making the mouse cursor blink. Now you can play videos without an annoying mouse such as in Windoze.



How to compile/link using QLIB BAT files


There are many BAT files within QLIB to help you compile/link.

These are to compile and link programs to EXE files:

These just compile the programs into OBJ files:



Index of all QLIB Utilities





QLINK Utility

The QLINK utility will allow you to easily use the Watcom Linker to generate your EXEs. QLINK will link together all OBJs and LIBs you specify plus the default Library file(s) and the startup code.

QLINK [options] <exename> [file(s)]

exefile = the EXE name to creat
file(s) = OBJs and LIBs to include into link
options = Run QLINK without any arguments for available options

Notes:
The PMWSETUP utility is a great way to manage memory usage with your EXE files. But if you have to run that each time you compile your project it can become a pain. Fortunately QLINK offers a relief. When linking is performed and if there is a .SET file with the same name as the EXE file to be compiled this SET file will be run as a BAT file which could run the PMWSETUP program or QSETUP or anything else you want. See \test\spawn.set to see what I mean. To compile the spawn test program use "QMAKE SPAWN". This BAT file is run only once just before QLITE is used to compress the EXE (if the /l option is used). Two parameters are given to the SET BAT file, the first is the EXE filename and the second is the DOS extender that is being used which could be any of the following : (pmodew, wdosx, dos4g or qdll. See also \test\ram.set for an example. The order in which QSETUP or PMWSETUP is used in SET files does not matter any longer. Just note that QSETUP can not work on compressed EXEs so that is why SET files are run _before_ QLITE is used.



QMAKE Utility

The QMAKE utility will allow you to easily use the Microsoft MAKE utility to run MAKE files (*.MAK).
QMAKE <makefile>

makefile = Filename of makefile (*.MAK) (do not give .MAK extension)



QLITE Utility

The QLITE utility will allow you to easily use the PMWLITE EXE compress utility to compress your PMODE/W EXEs.
QLITE <exefile>

exefile = Filename to compress (*.EXE) (do not give .EXE extension)

Notes:
The PMWLITE utility destroys all PMWSETUP info in the PMODE/W DOS extender when used, so to compensate for this bug QLITE will Unbind the PMODE/W DOS extender before PMWLITE is used and then Rebind the PMODE/W DOS extender to your EXE file to keep PMWSETUP info in the DOS extender.



QSETUP Utility

The QSETUP utility allows you to control how much memory QLIB will allocate during startup. This Utility should be used along with PMWSETUP.EXE if you are using the PMODE/W DOS extender.

QSETUP [options] <exefile>

exefile = Filename to configure (*.EXE) (do not give .EXE extension)
options = Run QSETUP without any arguments for available options

Notes:
PMWSETUP allows you to configure how much XMS will be allocated during startup but this only affects operation under RAW, XMS and VCPI mode. So under DPMI you will be allowed to allocate as much as possible. Before I created the QSETUP program the QLIB package would do just that. If your application uses spawn...() functions then under DPMI there will be no RAM for the new apps under DPMI even if you use PMWSETUP. So what QSETUP does is configure how much QLIB will allocate at max during startup. But you still must use the PMWSETUP utility a long with QSETUP or else PMODE/W will still allocate all ram under VCPI, XMS or RAW modes.



QBIND Utility

The QBIND utility allows you to add/remove/extract DOS extenders from LE-EXEs.

QBIND [options] <exefile>

exefile = Filename to work with (*.EXE)
options = Run QBIND without any arguments for available options



































-=-