home *** CD-ROM | disk | FTP | other *** search
- MIKE'S GAME GRAPHICS ROUTINES
- -----------------------------
- Copyright (c) 1992 Michael Cantelmi
-
-
- Before I start, I want you to know this is my first shareware upload and
- I've never written documentation for anything before, so I apologize for any
- errors or inconsistancies you might find, and thanks for trying my routines.
-
-
- For years I've searched high and low for a package of routines that would
- allow me to program my own arcade games and never found one. The problem was
- that the few I did find either didn,t have the right combinations of
- routines or they were just to slow. Well I finally got fed up and started to
- learn assembly and these routines are the result.
- These routines should allow anyone with a knowledge of C to create there
- own arcade, adventure or roleplaying games. Yep, you read it right, I said
- ARCADE. These routines are FAST.
- These routines were written for an 80286 or higher computer with VGA
- (320x200x256) color and a Microsoft C compiler or 100% compatible.They will
- allow you to use virtual screens of any size and of any number(within your
- computer's memory limit of course). You will also be able to control the mouse,
- joystick and EMS memory, and the sprite routines don't require a bit mask while
- giving you the ability to make any color trasparent, not just the color 0. You
- can also load PCX files in 320x200x256 format.
-
-
- Shareware
- ---------
-
- Yes these routines are shareware. I'm only asking $15.00 for them. I've
- spent many long hours on this code and none of the routines have been disabled,
- you hold in your possession the entire working package so please register.
- Registered users will receive information on further updates and how to
- obtain them. Updates will most likely include support for SVGA and Mode x.
- You can send your check in US funds drawn on a US bank to:
-
- Mike Cantelmi
- 229 Maujer Street
- Brooklyn, NY 11206
-
-
- Lisence
- -------
-
- Registered users can market programs that use these routines without
- paying any royalties to me. You may not ,however, sell the routines by
- themselves. You may distribute these routines for nonprofit or you may charge a
- fee for distribution on disk provided it does not exceed $5.00, and all
- libraries, documentation and affiliated files are included and unaltered.
- These routines are provided as is. I cannot be liable for any damage caused
- directly or indirectly by the use or misuse of these routines.
-
-
- ------------
-
- Before using the block manipulation routines (eg. _spritev,_putv,_getv) you
- must allocate memory for them using _amem().
- NOTE-If you want to copy a sprite or virtual screen to the visual screen
- create a integer variable and assign the value a000h(40960 decimal), this
- is the memory address of video memory. (eg. mainscreen=40960;)
- I included a couple of demos with commented source code. They should be
- helpfull in demostrating the use of the routines. If you have any questions
- and you're a registered user, I will be more than happy to answer them.
- Just drop me some E-mail (74270,1664) or send me a letter with a SASE.
- Whether you're registered or not, I'll welcome any comments, complaints or
- suggestions.
-
- About Memory
- ------------
-
- Before I explain the individual routines, I think a word about how they use
- memory is in order. For those of you who know how DOS uses memory, you're in
- luck, these routines use memory in 64k blocks just like DOS.
- Here's how it works, if you don't know much about memory handling just keep
- in mind that a buffer can only be as large as 64k (or a screen 320x200 max).
- It's possible for you to allocate a block as large as 640k and then manage it
- in blocks of 64k by adjusting the segment address (the value returned by
- _amem()), but unfortunatly that's beyond the scope of these docs.
- If you already know some assembly and the memory addressing techniques of
- DOS and the 80x86 chips, you'll find that these routines provide the
- versatility to produce some fantastic animation. If not, don't worry, you'll
- still be able to produce commercial quality games.
- If you're interested in learning to use these routines to their fullest
- potential you will need an intermediate knowledge of assemble, DOS and the VGA.
-
- About Expanded Memory
- ---------------------
-
- You must have an expanded memory driver installed before using the EMS
- routines.
- First you need to know that the EMS driver will set aside a 64k block of
- memory called the page frame. This page frame is divided into four 16k byte
- blocks numbered 0-3 to which expanded memory will be moved in and out of.
- For example: lets say you have 512k expanded memory. This memory is divided
- into 32 16k blocks of virtual memory. If you want to access this memory you
- must tell the EMS manager how many blocks you wish to use. Lets say you want
- 10 blocks of EMS memory, first call _eallocmem. The EMS manager will allocate
- 10 blocks for you labled 0-9 and it will give you a handle. This handle is like
- a file name that identifies the 10 blocks you requested. You may have more
- than one handle at a time to identify different blocks of memory.
- To move these virtual blocks in and out of expanded memory you must first
- ask the EMS manager what address in memory it has placed the page frame buffer
- into. You do this by calling _epageframe. You can then use the graphics
- routines on the page frame as you would on a buffer created with _amem().
- You must then tell the EMS manager which virtual blocks you want to move
- into the page frame with _emapmem. From now on you just use _emapmem to move
- the 10 blocks you allocated in and out of the page frame whenever you need
- them. Remember that the page frame is 64k bytes but each ems page is 16k bytes.
- To access page 2 in the page frame, add 16384 decimal(4000 hex) to the value
- returned by _epageframe. Add 32768 dec(8000 hex) and 49152 dec(c000 hex) for
- page 3 and 4 respectively.
-
-
- The Routines
- ------------
-
- Remember to have your Expanded Memory manger installed for the EMS routines
- and your Microsoft compatible mouse driver installed for the mouse routines.
-
-
- int _amem (int block)-
- Allocates memory. Returns integer pointer to segment allocated.
- block=# of blocks to locate.(Each block is 16 bytes long).
- For instance, to allocate memory for a whole screen, which is 64000
- bytes long, you would use [screen=_amem(4000);].
-
- void _damem (int block)-
- Deallocates memory.
-
- void _showpointer (void)-
- Shows the mouse pointer.
-
- void _hidepointer (void)-
- Hides the mouse pointer.
-
- int _getbuttondown (void)-
- Returns button down status.
- 1=left button down.
- 2=right button down.
- 4=center button down.
-
- int _initmouse (void)-
- Initializes mouse and clears all mouse buffers. Returns a 0 if a
- mouse is not available.
-
- int _xmouse (void)-
- Returns x position of mouse.
-
- int _ymouse (void)-
- Returns y position of mouse.
-
- int _stickx (void)-
- Returns joystick x value.
-
- int _sticky (void)-
- Returns joystick y value.
-
- int _button1 (void)-
- Returns joystick button #1 status.
- 1=pressed
- 0=not pressed
-
- int _button2 (void)-
- Returns joystick button #2 status.
- 1=pressed
- 0=not pressed
-
- void _delay (int tm)-
- Sets a delay in integral multiples of 976ms.
- tm=0 to 65535.
-
- void _clsv (int scrn,int size, char color)-
- Clears a screen or part of screen.
- scrn=pointer to screen.
- size=size of screen in bytes. (eg. 320x200 is 64000 bytes)
- color=0-255.
-
- void _setpoint (int x,int y,char color,int scrn,int sxs)-
- Sets a point on the screen.
- x,y=location of point.
- color=0-255.
- scrn=pointer to screen.
- sxs=width of screen in pixels.
-
- void _getpoint (intx,int y,int scrn,int sxs)-
- Gets color value of a point on the screen.
- x,y=location of point.
- scrn=pointer to screen.
- sxs=width of screen in pixels.
-
- void _LoadPCX (char filename[],int smem)-
- Loads a 320x200x256 PCX file to screen or buffer.
- filename[]=filename of PCX file.
- smem=pointer to screen or buffer.
-
- void _putv (int x,int y,int xs,int ys,int pic,int screen,int sxs)-
- Puts picture buffer to the screen or another buffer 2 bytes at a
- time.
- x,y=location to put pic.
- xs,ys=horizontal and vertical size of pic. xs must be an even #.(eg.
- xs=30 or xs=32, not xs=31)
- pic=buffer or picture to put on screen.
- screen=pointer to screen or buffer to put pic on.
- sxs=width of screen or buffer.
-
- void _getv (int x,int y,int xs,int ys,int pic,int screen,int sxs)-
- Gets a picture from screen or buffer 2 bytes at a time.
- x,y=location to get from.
- xs,ys=x and y size of pic. xs must be an even #.
- pic=buffer to store pic in.
- screen=pointer to screen or buffer to get pic from.
- sxs=width of screen or buffer to get from.
-
- void _spritev (int x,int y,int xs,int ys,int pic,int screen,int sxs,
- char COLOR)-
- Same as _putv except pixels with color value of COLOR are
- transparent.
-
- void _sprite2 (int x,int y,int xs,int ys,int pic,int screen,int sxs,
- char color)-
- Same as _spritev except its faster. It copies 2 bytes at a time.
- xs must be an even #.
-
- void _screencopy (int screen1,int screen2,int numwords)-
- Copies part or all of one screen or buffer to another.
- screen1=pointer to screen or buffer to copy from.
- screen2=pointer to screen or buffer to copy to.
- numwords=size of screen in WORDS(# of bytes/2). eg. 320x200 screen is
- 64000 bytes, numwords would equal 64000/2 which is 32000.
-
- int _epageframe (void)-
- Returns the address of the page frame used by the EMS manager.
- The page frame is the 64k block that the EMS manager maps the EMS
- memory in and out of. The address is the beginning of this block.
- The 64k block is divided further into four 16kbyte pages numbered 0-3.
-
- int _etotalmem (void)-
- Returns the total number of EMS pages.
- Each page is 16k bytes long.
-
- int _eunusedmem (void)-
- Returns the number of available EMS pages.
-
- int _eallocmem (int pages)-
- Assigns the requested number of EMS pages to an EMM handle.
- Returns the EMM handle assigned to the requested pages.
-
- void _emapmem (char mainpage,int emspage,int emmhandle)-
- Maps requested EMS page to requested page in the page frame.
- mainpage=page frame to map EMS page to. There are 4 pages 0-3.
- emspage=EMS page to map into page frame. This value ranges from
- 0 to the requested number of pages -1.
- emmhandle=The EMM handle returned from _eallocmem.
-
- void _edallocmem (int emmhandle)-
- Deallocates EMM handle and pages assigned to it.
-
- void _settick(int count)
- Sets the tick counter.
- count=the value the tick counter should start at. 0-65535.
-
- int _gettick(void)
- Returns the tick counter value.
- Every tick occurs 18.2 times per second regardless of the speed of
- the computer.
-
-
-
-