home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / gamegraf / games.doc < prev    next >
Encoding:
Text File  |  1992-08-06  |  11.8 KB  |  270 lines

  1.                         MIKE'S GAME GRAPHICS ROUTINES
  2.                         -----------------------------
  3.                       Copyright (c) 1992 Michael Cantelmi
  4.  
  5.  
  6.    Before I start, I want you to know this is my first shareware upload and
  7. I've never written documentation for anything before, so I apologize for any
  8. errors or inconsistancies you might find, and thanks for trying my routines.
  9.  
  10.  
  11.    For years I've searched high and low for a package of routines that would
  12. allow me to program my own arcade games and never found one. The problem was
  13. that the few I did find either didn,t have the right combinations of
  14. routines or they were just to slow. Well I finally got fed up and started to
  15. learn assembly and these routines are the result.
  16.    These routines should allow anyone with a knowledge of C to create there
  17. own arcade, adventure or roleplaying games. Yep, you read it right, I said
  18. ARCADE. These routines are FAST.
  19.    These routines were written for an 80286 or higher computer with VGA 
  20. (320x200x256) color and a Microsoft C compiler or 100% compatible.They will 
  21. allow you to use virtual screens of any size and of any number(within your 
  22. computer's memory limit of course). You will also be able to control the mouse, 
  23. joystick and EMS memory, and the sprite routines don't require a bit mask while 
  24. giving you the ability to make any color trasparent, not just the color 0. You 
  25. can also load PCX files in 320x200x256 format.
  26.  
  27.  
  28.                                 Shareware
  29.                                 ---------
  30.  
  31.    Yes these routines are shareware. I'm only asking $15.00 for them. I've
  32. spent many long hours on this code and none of the routines have been disabled,
  33. you hold in your possession the entire working package so please register.
  34. Registered users will receive information on further updates and how to
  35. obtain them. Updates will most likely include support for SVGA and Mode x.
  36.    You can send your check in US funds drawn on a US bank to:
  37.  
  38.                                 Mike Cantelmi
  39.                                 229 Maujer Street
  40.                                 Brooklyn, NY  11206
  41.  
  42.  
  43.                                 Lisence
  44.                                 -------
  45.  
  46.    Registered users can market programs that use these routines without
  47. paying any royalties to me. You may not ,however, sell the routines by
  48. themselves. You may distribute these routines for nonprofit or you may charge a
  49. fee for distribution on disk provided it does not exceed $5.00, and all
  50. libraries, documentation and affiliated files are included and unaltered.
  51.    These routines are provided as is. I cannot be liable for any damage caused
  52. directly or indirectly by the use or misuse of these routines.
  53.  
  54.                                 
  55.                                 ------------
  56.  
  57. Before using the block manipulation routines (eg. _spritev,_putv,_getv) you
  58. must allocate memory for them using _amem().
  59.    NOTE-If you want to copy a sprite or virtual screen to the visual screen
  60. create a integer variable and assign the value a000h(40960 decimal), this 
  61. is the memory address of video memory. (eg. mainscreen=40960;)
  62.    I included a couple of demos with commented source code. They should be
  63. helpfull in demostrating the use of the routines. If you have any questions
  64. and you're a registered user, I will be more than happy to answer them.
  65. Just drop me some E-mail (74270,1664) or send me a letter with a SASE.
  66.    Whether you're registered or not, I'll welcome any comments, complaints or
  67. suggestions.
  68.  
  69.                                 About Memory
  70.                                 ------------
  71.  
  72.    Before I explain the individual routines, I think a word about how they use
  73. memory is in order. For those of you who know how DOS uses memory, you're in
  74. luck, these routines use memory in 64k blocks just like DOS.
  75.    Here's how it works, if you don't know much about memory handling just keep
  76. in mind that a buffer can only be as large as 64k (or a screen 320x200 max).
  77. It's possible for you to allocate a block as large as 640k and then manage it
  78. in blocks of 64k by adjusting the segment address (the value returned by 
  79. _amem()), but unfortunatly that's beyond the scope of these docs.
  80.    If you already know some assembly and the memory addressing techniques of
  81. DOS and the 80x86 chips, you'll find that these routines provide the
  82. versatility to produce some fantastic animation. If not, don't worry, you'll
  83. still be able to produce commercial quality games.
  84.    If you're interested in learning to use these routines to their fullest
  85. potential you will need an intermediate knowledge of assemble, DOS and the VGA.
  86.  
  87.                            About Expanded Memory
  88.                            ---------------------
  89.  
  90.    You must have an expanded memory driver installed before using the EMS
  91. routines.
  92.    First you need to know that the EMS driver will set aside a 64k block of
  93. memory called the page frame. This page frame is divided into four 16k byte
  94. blocks numbered 0-3 to which expanded memory will be moved in and out of.
  95.    For example: lets say you have 512k expanded memory. This memory is divided
  96. into 32 16k blocks of virtual memory. If you want to access this memory you
  97. must tell the EMS manager how many blocks you wish to use. Lets say you want
  98. 10 blocks of EMS memory, first call _eallocmem. The EMS manager will allocate
  99. 10 blocks for you labled 0-9 and it will give you a handle. This handle is like
  100. a file name that identifies the 10 blocks you requested. You may have more 
  101. than one handle at a time to identify different blocks of memory.
  102.    To move these virtual blocks in and out of expanded memory you must first
  103. ask the EMS manager what address in memory it has placed the page frame buffer
  104. into. You do this by calling _epageframe. You can then use the graphics 
  105. routines on the page frame as you would on a buffer created with _amem().
  106.    You must then tell the EMS manager which virtual blocks you want to move
  107. into the page frame with _emapmem. From now on you just use _emapmem to move
  108. the 10 blocks you allocated in and out of the page frame whenever you need
  109. them. Remember that the page frame is 64k bytes but each ems page is 16k bytes.
  110. To access page 2 in the page frame, add 16384 decimal(4000 hex) to the value
  111. returned by _epageframe. Add 32768 dec(8000 hex) and 49152 dec(c000 hex) for
  112. page 3 and 4 respectively.
  113.  
  114.                                 
  115.                                 The Routines
  116.                                 ------------
  117.  
  118.    Remember to have your Expanded Memory manger installed for the EMS routines
  119. and your Microsoft compatible mouse driver installed for the mouse routines.
  120.  
  121.  
  122. int _amem (int block)-
  123.         Allocates memory. Returns integer pointer to segment allocated.
  124.         block=# of blocks to locate.(Each block is 16 bytes long).
  125.         For instance, to allocate memory for a whole screen, which is 64000
  126.         bytes long, you would use [screen=_amem(4000);].
  127.         
  128. void _damem (int block)-
  129.         Deallocates memory.
  130.  
  131. void _showpointer (void)-
  132.         Shows the mouse pointer.
  133.  
  134. void _hidepointer (void)-
  135.         Hides the mouse pointer.
  136.  
  137. int _getbuttondown (void)-
  138.         Returns button down status.
  139.         1=left button down.
  140.         2=right button down.
  141.         4=center button down.
  142.  
  143. int _initmouse (void)-
  144.         Initializes mouse and clears all mouse buffers. Returns a 0 if a
  145.         mouse is not available.
  146.  
  147. int _xmouse (void)-
  148.         Returns x position of mouse.
  149.  
  150. int _ymouse (void)-
  151.         Returns y position of mouse.
  152.  
  153. int _stickx (void)-
  154.         Returns joystick x value.
  155.  
  156. int _sticky (void)-
  157.         Returns joystick y value.
  158.  
  159. int _button1 (void)-
  160.         Returns joystick button #1 status.
  161.         1=pressed
  162.         0=not pressed
  163.  
  164. int _button2 (void)-
  165.         Returns joystick button #2 status.
  166.         1=pressed
  167.         0=not pressed
  168.  
  169. void _delay (int tm)-
  170.         Sets a delay in integral multiples of 976ms. 
  171.         tm=0 to 65535.
  172.  
  173. void _clsv (int scrn,int size, char color)-
  174.         Clears a screen or part of screen.
  175.         scrn=pointer to screen.
  176.         size=size of screen in bytes. (eg. 320x200 is 64000 bytes)
  177.         color=0-255.
  178.  
  179. void _setpoint (int x,int y,char color,int scrn,int sxs)-
  180.         Sets a point on the screen.
  181.         x,y=location of point.
  182.         color=0-255.
  183.         scrn=pointer to screen.
  184.         sxs=width of screen in pixels.
  185.  
  186. void _getpoint (intx,int y,int scrn,int sxs)-
  187.         Gets color value of a point on the screen.
  188.         x,y=location of point.
  189.         scrn=pointer to screen.
  190.         sxs=width of screen in pixels.
  191.  
  192. void _LoadPCX (char filename[],int smem)-
  193.         Loads a 320x200x256 PCX file to screen or buffer.
  194.         filename[]=filename of PCX file.
  195.         smem=pointer to screen or buffer.
  196.  
  197. void _putv (int x,int y,int xs,int ys,int pic,int screen,int sxs)-
  198.         Puts picture buffer to the screen or another buffer 2 bytes at a
  199.         time.
  200.         x,y=location to put pic.
  201.         xs,ys=horizontal and vertical size of pic. xs must be an even #.(eg.
  202.               xs=30 or xs=32, not xs=31)
  203.         pic=buffer or picture to put on screen.
  204.         screen=pointer to screen or buffer to put pic on.
  205.         sxs=width of screen or buffer.
  206.  
  207. void _getv (int x,int y,int xs,int ys,int pic,int screen,int sxs)-
  208.         Gets a picture from screen or buffer 2 bytes at a time.
  209.         x,y=location to get from.
  210.         xs,ys=x and y size of pic. xs must be an even #.
  211.         pic=buffer to store pic in.
  212.         screen=pointer to screen or buffer to get pic from.
  213.         sxs=width of screen or buffer to get from.
  214.  
  215. void _spritev (int x,int y,int xs,int ys,int pic,int screen,int sxs,
  216.                 char COLOR)-
  217.         Same as _putv except pixels with color value of COLOR are 
  218.         transparent.
  219.  
  220. void _sprite2 (int x,int y,int xs,int ys,int pic,int screen,int sxs,
  221.                 char color)-
  222.         Same as _spritev except its faster. It copies 2 bytes at a time.
  223.         xs must be an even #.
  224.  
  225. void _screencopy (int screen1,int screen2,int numwords)-
  226.         Copies part or all of one screen or buffer to another.
  227.         screen1=pointer to screen or buffer to copy from.
  228.         screen2=pointer to screen or buffer to copy to.
  229.         numwords=size of screen in WORDS(# of bytes/2). eg. 320x200 screen is
  230.         64000 bytes, numwords would equal 64000/2 which is 32000.
  231.  
  232. int _epageframe (void)-
  233.         Returns the address of the page frame used by the EMS manager.
  234.         The page frame is the 64k block that the EMS manager maps the EMS
  235.         memory in and out of. The address is the beginning of this block.
  236.         The 64k block is divided further into four 16kbyte pages numbered 0-3.
  237.  
  238. int _etotalmem (void)-
  239.         Returns the total number of EMS pages.
  240.         Each page is 16k bytes long.
  241.  
  242. int _eunusedmem (void)-
  243.         Returns the number of available EMS pages.
  244.  
  245. int _eallocmem (int pages)-
  246.         Assigns the requested number of EMS pages to an EMM handle.
  247.         Returns the EMM handle assigned to the requested pages.
  248.  
  249. void _emapmem (char mainpage,int emspage,int emmhandle)-
  250.         Maps requested EMS page to requested page in the page frame.
  251.         mainpage=page frame to map EMS page to. There are 4 pages 0-3.
  252.         emspage=EMS page to map into page frame. This value ranges from
  253.                 0 to the requested number of pages -1.
  254.         emmhandle=The EMM handle returned from _eallocmem.
  255.  
  256. void _edallocmem (int emmhandle)-
  257.         Deallocates EMM handle and pages assigned to it.
  258.  
  259. void _settick(int count)
  260.         Sets the tick counter.
  261.         count=the value the tick counter should start at. 0-65535.
  262.  
  263. int _gettick(void)
  264.         Returns the tick counter value.
  265.         Every tick occurs 18.2 times per second regardless of the speed of
  266.         the computer.
  267.  
  268.  
  269.  
  270.