home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource1 / svgacc20 / svgacc20.txt < prev    next >
Encoding:
Text File  |  1994-03-11  |  264.4 KB  |  12,429 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                   REFERENCE MANUAL
  9.  
  10.  
  11.                                      FOR SVGACC
  12.  
  13.  
  14.                                     THE SUPER VGA
  15.  
  16.  
  17.                                   GRAPHICS LIBRARY
  18.  
  19.  
  20.                                     FOR USE WITH
  21.  
  22.  
  23.                                       MICROSOFT
  24.  
  25.  
  26.                                      AND BORLAND
  27.  
  28.  
  29.                                         C/C++
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.           1993-1994 by Zephyr Software - Stephen L. Balkum and Daniel A.
  52.           Sill
  53.  
  54.           All rights reserved.  No part of this book shall be reproduced or
  55.           transmitted by any means, electronic, mechanical, photocopying,
  56.           recording or otherwise, without written permission from Zephyr
  57.           Software - Stephen L. Balkum and Daniel A. Sill.
  58.  
  59.           Although every effort has been made to insure the accuracy of the
  60.           material in this book, Zephyr Software, Stephen L. Balkum and
  61.           Daniel A. Sill assume no responsibility for errors or omissions.
  62.           In addition no liability is assumed for damages resulting from
  63.           the use of the information contained herein.
  64.  
  65.           Printed in the United States of America
  66.  
  67.           Trademarks
  68.  
  69.           The Graphics Interchange Format (c) is the Copyright property of
  70.           CompuServe Incorporated.
  71.           GIF (sm) is a Service Mark property of CompuServe Incorporated.
  72.           Sound Blaster and Sound Blaster Pro are trademarks of Creative
  73.           Labs, Inc.
  74.           All others are trademarks of their respective owners.
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.                                                                          ii
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.                              SOFTWARE LICENSE AGREEMENT
  100.  
  101.                By using this software, you agree to the terms of this
  102.                                      agreement.
  103.  
  104.                No warranties are expressed or implied.  In no event
  105.                shall Zephyr Software, Stephen L. Balkum or Daniel A.
  106.                Sill be held liable for damages resulting from the use
  107.                or misuse of this product, including but not limited to
  108.                implied warranties of fitness for a particular purpose.
  109.  
  110.                The shareware version may be freely distributed as long
  111.                as all files stay together and are not modified in any
  112.                way.  No cost may be charged for the shareware version
  113.                beyond normal and reasonable copying and distribution
  114.                expenses.
  115.  
  116.                No products developed with this software shall be sold
  117.                unless this software has been registered with Zephyr
  118.                Software, Stephen L. Balkum or Daniel A. Sill.
  119.  
  120.                At no time for any reason shall this software be
  121.                reverse engineered, decompiled or disassembled.
  122.  
  123.                This software may not be rented or leased.
  124.  
  125.                This software may be used only on one terminal or one
  126.                computer at any one given moment in time.  This
  127.                software may not be installed on a network of any type.
  128.                Contact Zephyr Software, Stephen L. Balkum or Daniel A.
  129.                Sill for networking options.
  130.  
  131.                United States Government Restricted Rights:
  132.                Use, duplication or disclosure of this software and
  133.                documentation by the U.S. Government is subject to the
  134.                restrictions as set forth in subparagraph (c)(1)(ii) of
  135.                the Rights in Technical Data and Computer Software
  136.                clause at DFARS 252.227-7013.  Contractor/manufacturer
  137.                is Stephen L. Balkum and Daniel A. Sill, P.O. Box 7704,
  138.                Austin, Texas 78713-7704.
  139.  
  140.                The ownership of this software may be transferred as
  141.                long as Zephyr Software, Stephen L. Balkum or Daniel A.
  142.                Sill is notified in writing of the transfer date and
  143.                new owner.  The new owner must agree to this contract.
  144.                The transfer must include all registered updates and
  145.                previously registered versions.  The original owner may
  146.                not retain any copies in any form of the registered
  147.                software or its documents.
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.                                                                         iii
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.           INTRODUCTION
  163.  
  164.           We spent weeks searching the depths of the internet ftp sites for
  165.           a library that would allow the programmer full access to the
  166.           abilities of Super VGA.  We wanted the colors VGA could provide
  167.           and better resolution than EGA could provide.  Professionally
  168.           developed libraries with this ability were definitely out of our
  169.           price range.  After our searches continuously returned nothing,
  170.           we decided to fill the apparent void in the shareware market.
  171.  
  172.           Our searches did give two useful packages:  John Bridges' VGAKIT
  173.           and Finn Thoegersen's VGADOC.  We began with these two works and
  174.           developed a graphics library intended to allow the programmer
  175.           access to the huge world of high resolution programming.
  176.  
  177.           On the surface the task appeared quite simple.  However, it
  178.           quickly became obvious that the routines in this library would be
  179.           required to affect extremely large amounts of data.  Operations
  180.           must be quick to be successful.  Therefore, every effort was made
  181.           to create the fastest code possible - even at the expense of
  182.           size.  For this reason we opted to write code with the 32 bit
  183.           instructions of the 80386 and 80486 chips.  It is our opinion
  184.           that anyone with a hi-res card in a lesser machine may have some
  185.           priorities out of order. All routines are written in assembly and
  186.           use absolutely no floating point values.  Anytime a real number
  187.           was required, fixed point notation was used.  In addition we
  188.           attempted to write the routines such that any reasonable argument
  189.           passed can be interpreted intelligently by the library.
  190.  
  191.           With the numerous Super VGA cards available and no well
  192.           established standard we chose John Bridges' identification and
  193.           bank switching routines as a beginning.  These two routines have
  194.           undergone some modification, but not enough to justify
  195.           copyrighting this portion of the library's code by Zephyr
  196.           Software.  We have no intentions of releasing our changes to
  197.           these routines into the public domain.  From that point onward
  198.           all code is original.  In some instances common algorithms were
  199.           researched and original code written according to that algorithm.
  200.  
  201.           This Super VGA library gives the programmer transparent access to
  202.           twenty different Super VGA cards.  These cards include Acumos,
  203.           Ahead, ATI Technologies, Avance, Chips and Technologies, Cirrus
  204.           Logic, Everex, Genoa, MXIC, NCR, Oak Technologies,
  205.           Paradise/Western Digital, Primus, Realtek, Trident, Tseng Labs,
  206.           Video 7 and the VESA standard.  Please see the WHICHVGA function
  207.           for the specific chipsets.  The programmer only needs to verify
  208.           that the end user's card has been identified, but not which card
  209.           was recognized.  After proper identification, all functions react
  210.           in exactly the same fashion.  The library contains functions to
  211.           draw all of the major primitives.  In addition there are
  212.           functions that modify the screen palette, write text on the
  213.           screen with a choice of fonts and modify the reaction of the
  214.           primitives.  Identification routines include not only the video
  215.           card, but also the amount of video memory, type of processor and
  216.  
  217.  
  218.                                                                           2
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.           installed pointing devices.  Advanced functions provide full
  226.           mouse support (when used with a Microsoft compatible driver) and
  227.           joystick support.  Finally, support for two dimensional and three
  228.           dimensional coordinate systems is provided including rotation,
  229.           translation, scaling and projection.
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.                                                                           3
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.           SUGGESTED METHODS FOR USING THIS LIBRARY
  289.  
  290.           VERIFICATION OF A COMPUTER'S HARDWARE
  291.  
  292.           It is strongly recommended that any program written with this
  293.           library first verifies that the computer is a 80386 or better by
  294.           calling the WHICHCPU function.  Many of the library's functions
  295.           use 386 exclusive code which may cause a computer with a lesser
  296.           processor to crash.  In addition WHICHMOUSE must be called before
  297.           calling any of the mouse functions.  Lastly, it is recommended
  298.           that WHICHJOYSTICK be called before a program uses the joystick
  299.           routines.
  300.  
  301.           It is required that a program call WHICHVGA prior to any function
  302.           that communicates with the video card.  If WHICHVGA returns a
  303.           zero for unknown card type, the program should not call any
  304.           graphics function.  Without proper identification of the video
  305.           card any graphics function will likely cause a system failure.
  306.           It is recommended, although not necessary, that a program call
  307.           WHICHMEM prior to calling any RES function.  Although the video
  308.           card was properly identified, it may not have sufficient onboard
  309.           memory to support the desired resolution.  As a second check the
  310.           RES functions will do nothing if the video card has not been
  311.           identified or if the video card does not support the specified
  312.           resolution for memory or hardware reasons.
  313.  
  314.           THE 256 COLOR PALETTE
  315.  
  316.           The 256 color palette of the Super VGA cards is a six bit
  317.           palette.  Each of the 256 colors of the palette are described by
  318.           three values representing the intensity of the colors red, blue
  319.           and green.  These values can range from 0 to 63.  Anytime a value
  320.           outside of this range is used, the video card simply ignores the
  321.           upper two bits.  Therefore, 64 is the same as 0.  This should be
  322.           taken into consideration when manipulating the palette or when
  323.           importing a palette from an external source such as a GIF image.
  324.  
  325.           USE OF 2-D AND 3-D FUNCTIONS
  326.  
  327.           In the interest of speed, the 2-D and 3-D functions were written
  328.           to best work on multiple points at once.  We refer to these
  329.           functions as object-oriented.  This means that the points
  330.           defining an object (a box, a house, etc.) should be contained
  331.           within one array or part of an array and calls to the functions
  332.           should act on all of the points in the array.  Calls to functions
  333.           have a high speed overhead, therefore, placing more than one
  334.           object in the same array and passing the entire array to the
  335.           functions can be beneficial.  However, these functions will work
  336.           on a single point as well.
  337.  
  338.           A consequence of our object-oriented 2-D and 3-D functions is the
  339.           use of the scaling functions.  When scaling objects, we recommend
  340.           the object be defined about the origin.  D2SCALE and D3SCALE both
  341.           work with respect to the origin.  This eliminates a significant
  342.  
  343.  
  344.                                                                           4
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.           number of translations that would otherwise be required by having
  352.           a definable scale origin.  For example, to draw two boxes, one
  353.           scaled by one-half of the other, each rotated by 45 degrees at
  354.           the center of the screen, the recommended procedure is as
  355.           follows:
  356.  
  357.             define an array BOX containing the 2-D points: (100, 100), (-
  358.                100, 100), (-100, -100), (100, -100), (note: the box is
  359.                centered about the origin.)
  360.             rotate BOX by 45 degrees about (0, 0) and place the output in
  361.                RBOX,
  362.             scale RBOX by 50% (scaling factor would be 128, or 80 hex) and
  363.                place output in SRBOX,
  364.             translate RBOX to the center of the screen - a translation of
  365.                320, 240 in 640x480 resolution - and place output in TRBOX,
  366.             translate SRBOX to the center of the screen - same translation
  367.                as for RBOX - and place output in TSRBOX,
  368.             draw TRBOX and TSRBOX on the screen.
  369.  
  370.           Notice that by defining the box centered about the origin the
  371.           translation values were extremely intuitive.  Also notice that if
  372.           we had scaled the second box after the translation, it would have
  373.           been draw in the upper left quadrant of the screen instead of the
  374.           center.
  375.  
  376.           In mathematics and many sciences it is customary that in a 2-D
  377.           coordinate system the Y axis increases upward and the X axis
  378.           increases to the right.  The computer industry has decided the Y
  379.           axis should increase downward.  The 2-D functions are not
  380.           affected by the choice in coordinate systems.  However, it is
  381.           important to remember that a positive rotation in D2ROTATE
  382.           rotates from the positive X axis to the positive Y axis.
  383.           Therefore, when using mathematical conventions, a positive
  384.           rotation moves counter-clockwise.  On the computer screen a
  385.           positive rotation moves clockwise.
  386.  
  387.           The 3-D coordinate system follows mathematical conventions by
  388.           using a right-handed coordinate system.  The easiest way to
  389.           visualize this coordinate system is by using your right hand.
  390.           Place your index finger and thumb at a right angle to one another
  391.           as if to form an imaginary pistol.  Now place your second finger
  392.           at a right angle to your index finger.  It should be at a right
  393.           angle to your thumb as well.  This represents the three axes.
  394.           The index finger is the X axis, the second finger is the Y axis
  395.           and the thumb is the Z axis.  The easiest way to remember
  396.           rotation directions in this system is cyclically.  A positive
  397.           rotation about the X axis rotates the Y axis into the Z axis.  A
  398.           positive rotation about the Y axis rotates the Z axis into the X
  399.           axis.  A positive rotation about the Z axis rotates the X axis
  400.           into the Y axis.
  401.  
  402.           After doing all necessary 3-D transformations, projection onto
  403.           the 2-D computer screen is required.  Although the computer
  404.           screen's coordinate system does not follow mathematical
  405.  
  406.  
  407.                                                                           5
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.           conventions, the D3PROJECT function automatically takes care of
  415.           all conversions.  The programmer only needs to draw the resulting
  416.           lines on the screen.
  417.  
  418.           THE CONCEPT OF SPRITE GRAPHICS
  419.  
  420.           The key to sprite graphics is the assumption that only a small
  421.           percentage of the pixels in a graphics block are used by the
  422.           animation and the remaining pixels should be treated as
  423.           transparent, revealing the background behind the sprite.  The
  424.           sprite routines in this library only act on non-transparent
  425.           colors, thus, saving time by ignoring a large number of pixels.
  426.           When retrieving the background for a sprite, prior knowledge of
  427.           the sprite itself permits obtaining background only where it is
  428.           necessary.
  429.  
  430.           The following steps outline an example of the recommended
  431.           procedure for using the sprite functions:
  432.  
  433.             1. draw the sprite on the screen - a white stick figure on a
  434.                black background, for example
  435.             2. use BLKGET to place the sprite in an array STICK
  436.             3. use SPRITEGAP to simultaneously retrieve the background into
  437.                BACKSTICK and place STICK on the screen, declaring black as
  438.                the transparent color
  439.             4. use SPRITEPUT to replace the background BACKSTICK in the
  440.                same location as step 3
  441.             5. repeat steps 3 and 4 as many times and in as many locations
  442.                as desired
  443.  
  444.           GLOBAL VARIABLES
  445.  
  446.           Access to several global variables provided to the programmer.
  447.           The most important two variables are MAXX and MAXY.  These two
  448.           values give the current resolution and are set by the RES###
  449.           functions.  They should not be changed directly at any time by
  450.           the programmer.  Doing so may cause erratic results from many of
  451.           the graphics functions in this library.  These variables
  452.           initially contain 0.
  453.  
  454.           Four other variables, VIEWX1, VIEWY1, VIEWX2, VIEWY2, can be
  455.           accessed by the programmer.  They define the current viewport
  456.           used for clipping purposes.  These values, also, should not be
  457.           changed directly by the programmer.  The SETVIEW function should
  458.           be used to change these values as it performs important error
  459.           checking.  The viewport is defined as the whole screen by the
  460.           RES### functions.  If drawing on more or less than the entire
  461.           screen is desired, call SETVIEW as necessary.
  462.  
  463.           EXTENDED MEMORY SUPPORT
  464.  
  465.           With the higher screen resolutions, more memory may be needed for
  466.           data storage.  For this reason extended memory support is
  467.           provided.  Accessing extended memory requires the computer to
  468.  
  469.  
  470.                                                                           6
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.           switch into protected mode.  The process of switching into
  478.           protected mode and returning is handled by the extended memory
  479.           manager, usually HIMEM.SYS.  The switch is relatively slow.
  480.           Therefore, it should be used as fast storage access since it is
  481.           much faster than disk access.
  482.  
  483.           Extended memory access is also limited by the number of available
  484.           handles.  The limit is controlled by a switch on the extended
  485.           memory manager's command line and normally defaults to 32.  Also,
  486.           it is imperative that all allocated extended memory blocks be
  487.           freed before the program terminates.  Unfreed memory blocks will
  488.           be unavailable until the computer is rebooted.
  489.  
  490.           CONVENTIONS USED IN THIS MANUAL
  491.  
  492.           All parameters, other than pointers, passed to and from functions
  493.           and procedures in this graphics library are short (two byte)
  494.           integers  A byte variable type is assumed to be an unsigned
  495.           character.  No floating point values are used.  By not using real
  496.           numbers round-off error can be a concern.  Under most
  497.           circumstances this error will not be a problem and will not be
  498.           noticed.  The use of large numbers in rotations is recommended.
  499.  
  500.           No functions in this library allocate memory for the programmer,
  501.           except, of course, XMSALLOCATE.  It is the programmer's
  502.           responsibility to be sure all pointers reference properly
  503.           allocated memory of the appropriate size.
  504.  
  505.           Whenever a pixel is written on the screen, a mode is required.
  506.           Unless otherwise noted, there are five possible modes:
  507.           NO_ACTION, SET, XOR, OR and AND.  These modes are represented by
  508.           the numbers zero through four respectively.  NO_ACTION is self-
  509.           explanatory.  Technically, SET is the fastest mode.  However, XOR
  510.           maybe the most useful.  XOR'ing a point twice with the same color
  511.           returns the original color.  This can be used to cover and
  512.           uncover graphics.  In addition when a reference to a color index
  513.           is made, only values between and including 0 and 255 are valid.
  514.           Any integer will work, but only the lowest eight bits are
  515.           recognized.
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.                                                                           7
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.           BLKGET
  541.  
  542.             PROTOTYPE
  543.  
  544.             extern int far blkget (int x1, int y1, int x2, int y2,
  545.             RasterBlock far *gfxblk)
  546.  
  547.             INPUT
  548.  
  549.             X1, Y1 - top left corner of block
  550.             x2, y2 - bottom right corner of block
  551.  
  552.             OUTPUT
  553.  
  554.             BLKGET returns 1 if successful, 0 if failed.
  555.             gfxblk - retrieved bitmap
  556.  
  557.             USAGE
  558.  
  559.             BLKGET stores the pixel data contained within the block
  560.             defined by (X1, Y1)-(X2, Y2) in the variable referenced by
  561.             gfxblk.  Memory for gfxblk must be allocated as a RasterBlock
  562.             structure with a data size in bytes equal to
  563.  
  564.                                  [(X2-X1+1)*(Y2-Y1+1)]
  565.  
  566.             plus four bytes for the width and height integers of the
  567.             RasterBlock structure.
  568.  
  569.             Note, however, that gfxblk can be quite large.  If the size of
  570.             gfxblk is insufficient, BLKGET will overwrite any data in
  571.             memory contained beyond gfxblk and may possibly cause the
  572.             system to crash.  BLKGET enforces X2 X1 and Y2Y1.  Also, the
  573.             coordinates must be valid on the screen at the current
  574.             resolution.
  575.  
  576.             SEE ALSO
  577.  
  578.             BLKPUT, BLKRESIZE, BLKROTATE, GETLASTSTRING, SPRITEGAP,
  579.             SPRITEGET, SPRITEPUT
  580.  
  581.             EXAMPLE
  582.  
  583.             /*
  584.              * Places 1/4 of a circle at the center of the screen
  585.              */
  586.             #include <stdlib.h>
  587.             #include <conio.h>
  588.             #include "svgacc.h"
  589.  
  590.             void main(void)
  591.             {
  592.                int vmode;
  593.                int a,b,c,d;
  594.  
  595.  
  596.                                                                           8
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.                RasterBlock *blkdata;
  604.  
  605.                vmode = videomodeget();
  606.                if ( !whichvga() || (whichmem() < 512))
  607.                  exit(1);
  608.                res640();
  609.                drwcircle(1,10,30,30,20);
  610.                fillarea(30,30,10,7);
  611.                a = b = 0;
  612.                c = d = 30;
  613.                blkdata = (RasterBlock *)malloc((c-a+1)*(d-b+1)+4);
  614.                blkget(a,b,c,d,blkdata);
  615.                blkput(1,320,240,blkdata);
  616.                getch();
  617.                videomodeset(vmode);
  618.                exit(0);
  619.             }
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.                                                                           9
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.           BLKPUT
  667.  
  668.             PROTOTYPE
  669.  
  670.             extern void far blkput (PixelMode mode, int x, int y,
  671.             RasterBlock far *gfxblk)
  672.  
  673.             INPUT
  674.  
  675.             mode - pixel write mode
  676.             x, y - location for top left corner of block
  677.             gfxblk - RasterBlock pointer to bitmap
  678.  
  679.             OUTPUT
  680.  
  681.             no value returned
  682.  
  683.             USAGE
  684.  
  685.             BLKPUT places the pixel data contained in the variable
  686.             referenced by gfxblk on the screen.  The top, left corner of
  687.             the block is specified by (X, Y).  Any (X, Y) is acceptable
  688.             and any portion of the block that lies outside of the
  689.             currently defined viewport will not be drawn.
  690.  
  691.             SEE ALSO
  692.  
  693.             BLKGET, BLKRESIZE, BLKROTATE, GETLASTSTRING, SPRITEGAP,
  694.             SPRITEGET, SPRITEPUT, GIFPUT, SETVIEW
  695.  
  696.             EXAMPLE
  697.  
  698.             See BLKGET
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.                                                                          10
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.           BLKRESIZE
  730.  
  731.             PROTOTYPE
  732.  
  733.             extern void far blkresize (unsigned newxsize, unsigned
  734.                newysize, RasterBlock far *sourcegfxblk, RasterBlock far
  735.                *destgfxblk)
  736.  
  737.             INPUT
  738.  
  739.             newxsize, newysize - size of resulting bitmap in destgfxblk
  740.             sourcegfxblk - RasterBlock pointer to source bitmap
  741.  
  742.             OUTPUT
  743.  
  744.             no value returned
  745.             destgfxblk - resized bitmap
  746.  
  747.             USAGE
  748.  
  749.             BLKRESIZE takes the bitmap in sourcegfxblk and scales it up or
  750.             down according the to values passed in newxsize and newysize.
  751.             The resulting bitmap is returned in destgfxblk which should
  752.             already be declared with a size calculated according to the
  753.             equation in BLKGET.  Neither newxsize nor newysize should be
  754.             zero.
  755.  
  756.             SEE ALSO
  757.  
  758.             BLKGET, BLKPUT, BLKROTATE
  759.  
  760.             EXAMPLE
  761.  
  762.             /*
  763.              * Show blkresize
  764.              */
  765.             #include <stdlib.h>
  766.             #include <math.h>
  767.             #include <conio.h>
  768.             #include "svgacc.h"
  769.             #define randnum(size) (rand() % (int)(size))
  770.  
  771.             void main(void)
  772.             {
  773.                int vmode, i, j, colr, x1, y1, x2, y2;
  774.                RasterBlock *gfxblk1, *gfxblk2;
  775.  
  776.                vmode = videomodeget();
  777.                if ( !whichvga() || (whichmem() < 512))
  778.                  exit(1);
  779.                if ( !res640() )
  780.                  exit(1);
  781.                i=20000;
  782.                gfxblk1 = (RasterBlock *)malloc(i);
  783.  
  784.  
  785.                                                                          11
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.                if (!gfxblk1) {
  793.                  restext();
  794.                  printf("ERROR: Allocating memory for gfxblk1: %d
  795.             bytes\n",i);
  796.                  exit(1);
  797.                }
  798.                gfxblk2 = (RasterBlock *)malloc(i);
  799.                if (!gfxblk2) {
  800.                  restext();
  801.                  printf("ERROR: Allocating memory for gfxblk2: %d
  802.             bytes\n",i);
  803.                  exit(1);
  804.                }
  805.                for(i=0;i<=25;i++) {
  806.                  x1 = randnum(50);
  807.                  y1 = randnum(50);
  808.                  x2 = randnum(50);
  809.                  y2 = randnum(50);
  810.                  colr = randnum(16);
  811.                  drwline(1,colr,x1,y1,x2,y2);
  812.                }
  813.                x1 = 0;
  814.                y1 = 0;
  815.                x2 = 50;
  816.                y2 = 50;
  817.                drwbox(1,15,x1,y1,x2,y2);
  818.                blkget(x1,y1,x2,y2,gfxblk1);
  819.                x1 = maxx / 2;
  820.                y1 = maxy / 2;
  821.                blkresize(50,50,gfxblk1,gfxblk2);
  822.                blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  823.             >height)/2,gfxblk2);
  824.                for(i=x2;i<=x2+50;i++) {
  825.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  826.             >height)/2,gfxblk2);
  827.                  blkresize(i,i,gfxblk1,gfxblk2);
  828.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  829.             >height)/2,gfxblk2);
  830.                  sdelay(3);
  831.                }
  832.                for(i=x2+50;i>=x2-50;i--) {
  833.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  834.             >height)/2,gfxblk2);
  835.                  blkresize(i,i,gfxblk1,gfxblk2);
  836.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  837.             >height)/2,gfxblk2);
  838.                  sdelay(3);
  839.                }
  840.                for(i=x2-50;i<=x2+1;i++) {
  841.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  842.             >height)/2,gfxblk2);
  843.                  blkresize(i,i,gfxblk1,gfxblk2);
  844.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  845.             >height)/2,gfxblk2);
  846.  
  847.  
  848.                                                                          12
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.                  sdelay(3);
  856.                }
  857.                getch();
  858.                videomodeset(vmode);
  859.                exit(0);
  860.             }
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.                                                                          13
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.           BLKROTATE
  919.  
  920.             PROTOTYPE
  921.  
  922.             extern int  far blkrotate (int ang, int backfill, RasterBlock
  923.             far *sourcegfxblk, RasterBlock far *destgfxblk)
  924.  
  925.             INPUT
  926.  
  927.             ang - integer degree to rotate source bitmap
  928.             backfill - index to color in current palette to fill blank
  929.             space in destgfxblk
  930.             sourcegfxblk - RasterBlock pointer to source bitmap
  931.  
  932.             OUTPUT
  933.  
  934.             BLKROTATE returns 1 if successful, 0 if unsuccessful.
  935.             destgfxblk - rotated bitmap
  936.  
  937.             USAGE
  938.  
  939.             BLKROTATE takes the bitmap in sourcegfxblk and rotates by the
  940.             number of degrees specified in ang.  The bitmap rotation
  941.             algorithm is a three-pass shear technique modified to make
  942.             efficient use of this library's internal buffers.  Blank space
  943.             around the newly rotated block is filled with the color given
  944.             by backfill.  The resulting bitmap is stored in destgfxblk.
  945.             The size of destgfxblk should be at least as big as given by
  946.             BLKROTATESIZE.
  947.  
  948.             The function will fail if it calculates that the internal
  949.             buffers would be overflowed or if the destination array would
  950.             be larger than 65536 bytes.  BLKROTATESIZE should be called
  951.             first to ensure that buffer integrity is maintained.
  952.  
  953.             SEE ALSO
  954.  
  955.             BLKGET, BLKPUT, BLKRESIZE, BLKROTATESIZE
  956.  
  957.             EXAMPLE
  958.  
  959.             /*
  960.              * Show blkrotate
  961.              */
  962.             #include <stdlib.h>
  963.             #include <math.h>
  964.             #include <conio.h>
  965.             #include "svgacc.h"
  966.  
  967.             void main(void)
  968.             {
  969.                int xinc, yinc, x1, y1, x2, y2, i, j, colr, vmode, cntx,
  970.             cnty, rot;
  971.                RasterBlock *gfxblk, *gfxblk2, *spritebkgnd;
  972.  
  973.  
  974.                                                                          14
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.                vmode = videomodeget();
  983.                if ( !whichvga() || (whichmem() < 512))
  984.                  exit(1);
  985.                if ( !res640() )
  986.                  exit(1);
  987.                xinc = maxx/10;
  988.                yinc = maxy/20;
  989.                x1 = maxx/2-xinc;
  990.                y1 = maxy/2-yinc;
  991.                x2 = maxx/2+xinc;
  992.                y2 = maxy/2+yinc;
  993.                i = (x2-x1+1)*(y2-y1+1)+4;
  994.                gfxblk = (RasterBlock *)malloc(i);
  995.                if (!gfxblk) {
  996.                  restext();
  997.                  printf("ERROR: Allocating memory for gfxblk: %d
  998.             bytes\n",i);
  999.                  exit(1);
  1000.                }
  1001.                colr = 1;
  1002.                for(i=0;i<=maxx/2;i++) {
  1003.                  drwcircle(1,colr,maxx/4+i,maxy/2,maxy/5);
  1004.                  colr+=1;
  1005.                  if(colr>15)
  1006.                     colr = 1;
  1007.                }
  1008.                drwbox(1,0,x1,y1,x2,y2);
  1009.                blkget(x1,y1,x2,y2,gfxblk);
  1010.                cntx = (x2-x1) / 2 + x1;
  1011.                cnty = (y2-y1) / 2 + y1;
  1012.                fillarea(x1+2,y1+2,0,0);
  1013.                i = blkrotatesize(45,gfxblk);
  1014.                if ( !i ) {
  1015.                  restext();
  1016.                  printf("ERROR: rotated sprite will be to large");
  1017.                  exit(1);
  1018.                }
  1019.                spritebkgnd = (RasterBlock *)malloc(i);
  1020.                if (!spritebkgnd) {
  1021.                  restext();
  1022.                  printf("ERROR: Allocating memory for spritebkgnd: %d
  1023.             bytes\n",i);
  1024.                  exit(1);
  1025.                }
  1026.                gfxblk2 = (RasterBlock *)malloc(i);
  1027.                if (!gfxblk2) {
  1028.                  restext();
  1029.                  printf("ERROR: Allocating memory for gfxblk2: %d
  1030.             bytes\n",i);
  1031.                  exit(1);
  1032.                }
  1033.                blkget(x1,y1,x2,y2,spritebkgnd);
  1034.                setview(0,64,maxx,maxy);
  1035.  
  1036.  
  1037.                                                                          15
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.                for(i=0;i<=360;i+=3) {
  1045.                  rot = blkrotate(i,1,gfxblk,gfxblk2);
  1046.                  spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  1047.             (spritebkgnd->height)/2,spritebkgnd);
  1048.                  spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  1049.             >height)/2,gfxblk2,spritebkgnd);
  1050.                  sdelay(3);
  1051.                }
  1052.                spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  1053.             (spritebkgnd->height)/2,spritebkgnd);
  1054.                blkput(SET,x1,y1,(RasterBlock *)gfxblk);
  1055.                videomodeset(vmode);
  1056.                exit(0);
  1057.             }
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.                                                                          16
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.           BLKROTATESIZE
  1108.  
  1109.             PROTOTYPE
  1110.  
  1111.             extern int  far blkrotatesize (int ang, RasterBlock far
  1112.             *sourcegfxblk)
  1113.  
  1114.             INPUT
  1115.  
  1116.             ang - integer degree to rotate source bitmap
  1117.             sourcegfxblk - RasterBlock pointer to source bitmap
  1118.  
  1119.             OUTPUT
  1120.  
  1121.             BLKROTATESIZE returns the number of bytes needed for the
  1122.             destination array if successful, 0 if unsuccessful.
  1123.  
  1124.             USAGE
  1125.  
  1126.             BLKROTATESIZE takes the bitmap in sourcegfxblk and calculates
  1127.             the required size of the output buffer needed when BLKROTATE
  1128.             is called.  It also insures that the internal library buffers
  1129.             are not overflowed.  The function will fail if it calculates
  1130.             that the internal buffers would be overflowed or if the
  1131.             destination buffer would be larger than 65536 bytes.
  1132.             BLKROTATESIZE should be called prior to BLKROTATE to insure
  1133.             that buffer integrity is maintained.
  1134.  
  1135.             SEE ALSO
  1136.  
  1137.             BLKGET, BLKPUT, BLKRESIZE, BLKROTATE
  1138.  
  1139.             EXAMPLE
  1140.  
  1141.             See BLKROTATE
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.                                                                          17
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.           BYTECOPY
  1171.  
  1172.             PROTOTYPE
  1173.  
  1174.             extern void far bytecopy (void far *src, void far *dst, long
  1175.             numbytes)
  1176.  
  1177.             INPUT
  1178.  
  1179.             src - pointer to array to be copied
  1180.             numbytes - number of bytes to copy from src (<65536)
  1181.  
  1182.             OUTPUT
  1183.  
  1184.             no value returned
  1185.             dst - copy of array
  1186.  
  1187.             USAGE
  1188.  
  1189.             BYTECOPY copies the specified number of bytes from src to dst.
  1190.             It assumes that space for dst has been properly allocated.  It
  1191.             is much faster than using a FOR loop or MEMCPY.
  1192.  
  1193.             SEE ALSO
  1194.  
  1195.             PALCOPY
  1196.  
  1197.             EXAMPLE
  1198.  
  1199.             /*
  1200.              * show byte copy
  1201.              */
  1202.             #include <stdlib.h>
  1203.             #include <conio.h>
  1204.             #include "svgacc.h"
  1205.  
  1206.             void main(void)
  1207.             {
  1208.                int i;
  1209.                int test1[10], test2[10];
  1210.  
  1211.                for(i=0;i<10;i++)
  1212.                {
  1213.                  test1[i] = i;
  1214.                }
  1215.                bytecopy(test1,test2,sizeof(test1));
  1216.                printf("ok...we initialized one array with data, copied
  1217.             that\n");
  1218.                printf("array to an a new array...here are the results:\n");
  1219.                printf(" \n");
  1220.                printf("source array         destination array\n");
  1221.                for(i=0;i<10;i++)
  1222.                {
  1223.                  printf(" %d                    %d\n",test1[i],test2[i]);
  1224.  
  1225.  
  1226.                                                                          18
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.                }
  1234.                exit(0);
  1235.             }
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.                                                                          19
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.           D2ROTATE
  1297.  
  1298.             PROTOTYPE
  1299.  
  1300.             extern void far d2rotate (int points, int xorigin, int
  1301.             yorigin, int ang, D2Point far *inary, D2Point far *outary)
  1302.  
  1303.             INPUT
  1304.  
  1305.             numpoints - number of points to be rotated
  1306.             xorigin, yorigin - center of rotation
  1307.             angle - angle of rotation about center
  1308.             inary - D2Point pointer to array containing points to rotate
  1309.  
  1310.             OUTPUT
  1311.  
  1312.             no value returned
  1313.             outary - D2Point array of rotated values
  1314.  
  1315.             USAGE
  1316.  
  1317.             D2ROTATE takes the two dimensional points given in inary and
  1318.             rotates them by the specified angle about xorigin, yorigin.
  1319.             The results are returned in outary which can be the same as
  1320.             inary.  A positive angle causes a clockwise rotation on the
  1321.             screen, from the positive X axis to the positive Y axis.  The
  1322.             function assumes space for outary has been properly allocated.
  1323.  
  1324.             SEE ALSO
  1325.  
  1326.             D2SCALE, D2TRANSLATE
  1327.  
  1328.             EXAMPLE
  1329.  
  1330.             /*
  1331.              * shows d2rotate works
  1332.              */
  1333.  
  1334.             #include <stdlib.h>
  1335.             #include <conio.h>
  1336.             #include "svgacc.h"
  1337.  
  1338.             D2Point tri[3];
  1339.             D2Point trio[3];
  1340.             D2Point tri2[3];
  1341.  
  1342.             void drwtri(void);
  1343.             void ertri(void);
  1344.  
  1345.             void main(void)
  1346.             {
  1347.                int vmode,i;
  1348.  
  1349.                vmode = videomodeget();
  1350.  
  1351.  
  1352.                                                                          20
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.                if (!whichvga())
  1360.                  exit(1);
  1361.                if (whichmem()<512)
  1362.                  exit(1);
  1363.                res640();
  1364.                trio[0].x = 0;
  1365.                trio[0].y = 0;
  1366.                trio[1].x = -80;
  1367.                trio[1].y = 60;
  1368.                trio[2].x = 80;
  1369.                trio[2].y = 60;
  1370.                drwtri();
  1371.                for(i=0;i<=360;i+=2)
  1372.                {
  1373.                  d2rotate(3,0,0,i,trio,tri);
  1374.                  drwtri();
  1375.                  sdelay(2);
  1376.                  ertri();
  1377.                }
  1378.                drwtri();
  1379.                getch();
  1380.                videomodeset(vmode);
  1381.                exit(0);
  1382.             }
  1383.  
  1384.             void drwtri(void)
  1385.             {
  1386.                d2translate(3,320,240,tri,tri2);
  1387.                drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1388.                drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1389.                drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1390.                return;
  1391.             }
  1392.  
  1393.             void ertri(void)
  1394.             {
  1395.                d2translate(3,320,240,tri,tri2);
  1396.                drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1397.                drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1398.                drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1399.                return;
  1400.             }
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.                                                                          21
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.           D2SCALE
  1423.  
  1424.             PROTOTYPE
  1425.  
  1426.             extern void far d2scale (int points, int scalex, int scaley,
  1427.             D2Point far *inary, D2Point far *outary)
  1428.  
  1429.             INPUT
  1430.  
  1431.             numpoints - number of points to scale
  1432.             scalex - scale factor along X axis
  1433.             scaley - scale factor along Y axis
  1434.             inary - D2Point pointer to array containing points to scale
  1435.  
  1436.             OUTPUT
  1437.  
  1438.             no value returned
  1439.             outary - D2Point array of scaled values
  1440.  
  1441.             USAGE
  1442.  
  1443.             D2SCALE multiplies each coordinate in the two dimensional
  1444.             array inary by the corresponding scale factor scalex or
  1445.             scaley.  The results are stored in outary which can be the
  1446.             same as inary.  A scale factor of 256 (100 hex) is considered
  1447.             100 percent and results in no change.  Therefore, 128 (80 hex)
  1448.             reduces values by one half and 512 (200 hex) doubles values.
  1449.             The function assumes space for outary has been properly
  1450.             allocated.
  1451.  
  1452.             SEE ALSO
  1453.  
  1454.             D2ROTATE, D2TRANSLATE
  1455.  
  1456.             EXAMPLE
  1457.  
  1458.             /*
  1459.              * shows d2scale works
  1460.              */
  1461.  
  1462.             #include <stdlib.h>
  1463.             #include <conio.h>
  1464.             #include "svgacc.h"
  1465.  
  1466.             D2Point tri[3];
  1467.             D2Point trio[3];
  1468.             D2Point tri2[3];
  1469.  
  1470.             void drwtri(void);
  1471.             void ertri(void);
  1472.  
  1473.             void main(void)
  1474.             {
  1475.                int vmode,i;
  1476.  
  1477.  
  1478.                                                                          22
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.                vmode = videomodeget();
  1487.                if (!whichvga())
  1488.                  exit(1);
  1489.                if (whichmem()<512)
  1490.                  exit(1);
  1491.                res640();
  1492.                trio[0].x = 0;
  1493.                trio[0].y = 0;
  1494.                trio[1].x = -80;
  1495.                trio[1].y = 60;
  1496.                trio[2].x = 80;
  1497.                trio[2].y = 60;
  1498.                drwtri();
  1499.                for(i=256;i<=512;i+=4)
  1500.                {
  1501.                  d2scale(3,i,i,trio,tri);
  1502.                  drwtri();
  1503.                  sdelay(2);
  1504.                  ertri();
  1505.                }
  1506.                for(i=512;i>=128;i-=4)
  1507.                {
  1508.                  d2scale(3,i,i,trio,tri);
  1509.                  drwtri();
  1510.                  sdelay(2);
  1511.                  ertri();
  1512.                }
  1513.                for(i=128;i<=256;i+=4)
  1514.                {
  1515.                  d2scale(3,i,i,trio,tri);
  1516.                  drwtri();
  1517.                  sdelay(2);
  1518.                  ertri();
  1519.                }
  1520.                drwtri();
  1521.                getch();
  1522.                videomodeset(vmode);
  1523.                exit(0);
  1524.             }
  1525.  
  1526.             void drwtri(void)
  1527.             {
  1528.                d2translate(3,320,240,tri,tri2);
  1529.                drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1530.                drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1531.                drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1532.                return;
  1533.             }
  1534.  
  1535.             void ertri(void)
  1536.             {
  1537.                d2translate(3,320,240,tri,tri2);
  1538.                drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1539.  
  1540.  
  1541.                                                                          23
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.                drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1549.                drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1550.                return;
  1551.             }
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.                                                                          24
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.           D2TRANSLATE
  1612.  
  1613.             PROTOTYPE
  1614.  
  1615.             extern void far d2translate (int points, int xtrans, int
  1616.             ytrans, D2Point far *inary, D2Point far *outary)
  1617.  
  1618.             INPUT
  1619.  
  1620.             numpoints - number of points to be translated
  1621.             xtrans - distance to translate along X axis
  1622.             ytrans - distance to translate along Y axis
  1623.             inary - D2Point pointer to array containing points to
  1624.             translate
  1625.  
  1626.             OUTPUT
  1627.  
  1628.             no value returned
  1629.             outary - D2Point array of translated values
  1630.  
  1631.             USAGE
  1632.  
  1633.             D2TRANSLATE takes the two dimensional points given in inary
  1634.             and translates them by the specified number of pixels along
  1635.             each axis.  The results are returned in outary which can be
  1636.             the same as inary.  The function assumes that space for outary
  1637.             has been properly allocated.
  1638.  
  1639.             SEE ALSO
  1640.  
  1641.             D2ROTATE, D2SCALE
  1642.  
  1643.             EXAMPLE
  1644.  
  1645.             /*
  1646.              * shows d2translate works
  1647.              */
  1648.  
  1649.             #include <stdlib.h>
  1650.             #include <conio.h>
  1651.             #include "svgacc.h"
  1652.  
  1653.             D2Point tri[3];
  1654.             D2Point trio[3];
  1655.             D2Point tri2[3];
  1656.  
  1657.             void drwtri(void);
  1658.             void ertri(void);
  1659.  
  1660.             void main(void)
  1661.             {
  1662.                int vmode,i;
  1663.  
  1664.                vmode = videomodeget();
  1665.  
  1666.  
  1667.                                                                          25
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.                if (!whichvga())
  1675.                  exit(1);
  1676.                if (whichmem()<512)
  1677.                  exit(1);
  1678.                res640();
  1679.                trio[0].x = 0;
  1680.                trio[0].y = 0;
  1681.                trio[1].x = -80;
  1682.                trio[1].y = 60;
  1683.                trio[2].x = 80;
  1684.                trio[2].y = 60;
  1685.                drwtri();
  1686.                for(i=0;i<=100;i+=4)
  1687.                {
  1688.                  d2translate(3,i,i,trio,tri);
  1689.                  drwtri();
  1690.                  sdelay(2);
  1691.                  ertri();
  1692.                }
  1693.                for(i=100;i>=0;i-=4)
  1694.                {
  1695.                  d2translate(3,i,i,trio,tri);
  1696.                  drwtri();
  1697.                  sdelay(2);
  1698.                  ertri();
  1699.                }
  1700.                drwtri();
  1701.                getch();
  1702.                videomodeset(vmode);
  1703.                exit(0);
  1704.             }
  1705.  
  1706.             void drwtri(void)
  1707.             {
  1708.                d2translate(3,320,240,tri,tri2);
  1709.                drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1710.                drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1711.                drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1712.                return;
  1713.             }
  1714.  
  1715.             void ertri(void)
  1716.             {
  1717.                d2translate(3,320,240,tri,tri2);
  1718.                drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1719.                drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1720.                drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1721.                return;
  1722.             }
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.                                                                          26
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.           D3PROJECT
  1738.  
  1739.             PROTOTYPE
  1740.  
  1741.             extern int far d3project (int points, ProjParameters far
  1742.             *params, D3Point far *inary, D2Point far *outary)
  1743.  
  1744.             INPUT
  1745.  
  1746.             numpoints - number of points to be projected
  1747.             params - pointer to ProjParameters structure containing
  1748.             parameters used in projection
  1749.                eyex, eyey, eyez - 3D location of viewer
  1750.                scrd - distance from viewer to projection screen
  1751.                theta - angle from positive 3D X axis to viewing direction
  1752.                phi - angle from positive 3D Z axis to viewing direction
  1753.             inary - D3Point pointer to array containing points to project
  1754.  
  1755.             OUTPUT
  1756.  
  1757.             Returns 1 if successful, 0 if any one point failed.
  1758.             outary - D2Point array of projected values
  1759.  
  1760.             USAGE
  1761.                                 +Z axis
  1762.                                    |                   /\
  1763.                                    |                  /  \
  1764.                                    |            !     \ * \
  1765.                                    |            !......X: /
  1766.                                    |            ! Phi / \/
  1767.                                    |            !    /  :
  1768.                                    |            !   /   :
  1769.                                    |            !  /    :
  1770.                                    |       EyeX ! /ScrD :
  1771.                                    |       EyeY !/      :
  1772.                                    |       EyeZ *- - - -:- - - - -
  1773.                                    |           / `      :
  1774.                                    |          /   `     :
  1775.                                    |         /      `   :
  1776.                                    |        /      ---` :
  1777.                                    |       /___----
  1778.                                    |      /     Theta
  1779.                                    |
  1780.                                    |________________________________+Y axis
  1781.                                   /
  1782.                                  /
  1783.                                 /
  1784.                                /
  1785.                               /
  1786.                              /
  1787.                             /
  1788.                            /
  1789.                           /
  1790.                       +X axis
  1791.  
  1792.  
  1793.                                                                          27
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.             D3PROJECT projects a specified number, numpoints, of three
  1802.             dimensional points starting at inary into two dimensions
  1803.             according to the parameters in params.  The two dimensional
  1804.             points are stored in outary.  The function assumes space for
  1805.             outary has been properly allocated.  The location of the
  1806.             viewer in this three dimensional space is given by eyex, eyey,
  1807.             eyez in the ProjParameters structure.  The direction the
  1808.             viewer is facing is specified with scrd, theta, phi in the
  1809.             ProjParameters structure using spherical coordinates.  A
  1810.             virtual set of axes parallel to the true axes are placed at
  1811.             the viewer's location.  scrd is the distance from the viewer
  1812.             to the center of the projection screen, i.e. the currently
  1813.             defined viewport on the monitor's screen.  Theta is the angle
  1814.             in the virtual X-Y plane from the virtual X axis to the
  1815.             projection screen.  Positive angles rotate clockwise in the X-
  1816.             Y plane.  Lastly, the angle of elevation above or below the
  1817.             virtual X-Y plane is given by phi.  Positive angles direct
  1818.             viewing above the plane; negative below.
  1819.  
  1820.             If a point is projected to a location behind the viewer, i.e.
  1821.             on the side of the viewer opposite the projection screen,
  1822.             D3PROJECT returns a zero indicating one or more failed points.
  1823.             The returned values of the X and Y for failed points will be -
  1824.             32768 to make them easily identified.
  1825.  
  1826.             SEE ALSO
  1827.  
  1828.             D3ROTATE, D3TRANSLATE, D3SCALE, SETVIEW
  1829.  
  1830.             EXAMPLE
  1831.  
  1832.             /* shows d3project works */
  1833.             #include <stdlib.h>
  1834.             #include <conio.h>
  1835.             #include "svgacc.h"
  1836.  
  1837.             D2Point plot[8];
  1838.             void drwcube(void);
  1839.  
  1840.             void main(void)
  1841.             {
  1842.                int vmode,i,dummy;
  1843.                ProjParameters proj;
  1844.                D3Point cube[8] = { { 100,-100, 100},
  1845.                                 { 100,-100,-100},
  1846.                                 { 100, 100,-100},
  1847.                                 { 100, 100, 100},
  1848.                                 {-100,-100, 100},
  1849.                                 {-100,-100,-100},
  1850.                                 {-100, 100,-100},
  1851.                                 {-100, 100, 100}};
  1852.  
  1853.                vmode = videomodeget();
  1854.  
  1855.  
  1856.                                                                          28
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.                if (!whichvga())
  1864.                  exit(1);
  1865.                if (whichmem()<512)
  1866.                  exit(1);
  1867.                res640();
  1868.                proj.eyex = -1040;
  1869.                proj.eyey = -600;
  1870.                proj.eyez = -1200;
  1871.                proj.scrd = 1700;
  1872.                proj.theta = 30;
  1873.                proj.phi = 45;
  1874.                dummy = d3project(8,&proj,cube,plot);
  1875.                drwcube();
  1876.                getch();
  1877.                videomodeset(vmode);
  1878.             }
  1879.  
  1880.             void drwcube(void)
  1881.             {
  1882.                int i;
  1883.  
  1884.                for(i=0;i<=2;i++)
  1885.  
  1886.                drwline(1,10,plot[i].x,plot[i].y,plot[i+1].x,plot[i+1].y);
  1887.                drwline(1,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  1888.                for(i=4;i<=6;i++)
  1889.  
  1890.                drwline(1,10,plot[i].x,plot[i].y,plot[i+1].x,plot[i+1].y);
  1891.                drwline(1,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  1892.                for(i=0;i<=3;i++)
  1893.  
  1894.                drwline(1,10,plot[i].x,plot[i].y,plot[i+4].x,plot[i+4].y);
  1895.                return;
  1896.             }
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.                                                                          29
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.           D3ROTATE
  1927.  
  1928.             PROTOTYPE
  1929.  
  1930.             extern void far d3rotate (int points, int xorigin, int
  1931.                yorigin, int zorigin, int zrang, int yrang, int xrang,
  1932.                D3Point far *inary, D3Point far *outary)
  1933.  
  1934.             INPUT
  1935.  
  1936.             numpoints - number of points to be rotated
  1937.             xorigin, yorigin, zorigin - center of rotation
  1938.             zrang - angle of rotation about the Z axis
  1939.             yrang - angle of rotation about the Y axis
  1940.             xrang - angle of rotation about the X axis
  1941.             inary - D3Point pointer to array containing points to rotate
  1942.  
  1943.             OUTPUT
  1944.  
  1945.             no value returned
  1946.             outary - D3Point array of rotated values
  1947.  
  1948.             USAGE
  1949.  
  1950.             D3ROTATE takes the three dimensional points given in inary and
  1951.             rotates them by the specified angles about xorigin, yorigin,
  1952.             zorigin.  The results are returned in outary which can be the
  1953.             same as inary.  A virtual set of axes are placed at the origin
  1954.             of rotation and rotation takes place about these axes.  A
  1955.             positive angle causes a counter-clockwise rotation from the
  1956.             positive X axis to the positive Y axis.  The function assumes
  1957.             space for outary has been properly allocated.
  1958.  
  1959.             SEE ALSO
  1960.  
  1961.             D3PROJECT, D3SCALE, D3TRANSLATE
  1962.  
  1963.             EXAMPLE
  1964.  
  1965.             /*
  1966.              * shows d3rotate works
  1967.              */
  1968.  
  1969.             #include <stdlib.h>
  1970.             #include <conio.h>
  1971.             #include "svgacc.h"
  1972.  
  1973.             D2Point plot[8];
  1974.  
  1975.             void drwcube(void);
  1976.  
  1977.             void main(void)
  1978.             {
  1979.                int vmode,i,dummy;
  1980.  
  1981.  
  1982.                                                                          30
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.                ProjParameters proj;
  1990.                D3Point rcube[8];
  1991.                D3Point cube[8] = { { 100,-100, 100},
  1992.                                 { 100,-100,-100},
  1993.                                 { 100, 100,-100},
  1994.                                 { 100, 100, 100},
  1995.                                 {-100,-100, 100},
  1996.                                 {-100,-100,-100},
  1997.                                 {-100, 100,-100},
  1998.                                 {-100, 100, 100}};
  1999.  
  2000.                vmode = videomodeget();
  2001.                if (!whichvga() || (whichmem() < 512))
  2002.                  exit(1);
  2003.                res640();
  2004.  
  2005.                proj.eyex = -1040;
  2006.                proj.eyey = -600;
  2007.                proj.eyez = -1200;
  2008.                proj.scrd = 1700;
  2009.                proj.theta = 30;
  2010.                proj.phi = 45;
  2011.  
  2012.                for(i=0;i<=360;i+=2)
  2013.                {
  2014.                  d3rotate(8,0,0,0,i,i,i,cube,rcube);
  2015.                  dummy = d3project(8,&proj,rcube,plot);
  2016.                  drwcube();
  2017.                  sdelay(2);
  2018.                  drwcube();
  2019.                }
  2020.  
  2021.                drwcube();
  2022.  
  2023.                getch();
  2024.  
  2025.                videomodeset(vmode);
  2026.             }
  2027.  
  2028.             void drwcube(void)
  2029.             {
  2030.                int j;
  2031.  
  2032.                for(j=0;j<=2;j++)
  2033.  
  2034.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2035.                drwline(2,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  2036.  
  2037.                for(j=4;j<=6;j++)
  2038.  
  2039.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2040.                drwline(2,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  2041.  
  2042.                for(j=0;j<=3;j++)
  2043.  
  2044.  
  2045.                                                                          31
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.                drwline(2,10,plot[j].x,plot[j].y,plot[j+4].x,plot[j+4].y);
  2054.  
  2055.                return;
  2056.             }
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.                                                                          32
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.           D3SCALE
  2116.  
  2117.             PROTOTYPE
  2118.  
  2119.             extern void far d3scale (int points, int xscale, int yscale,
  2120.                int zscale, D3Point far *inary, D3Point far *outary)
  2121.  
  2122.             INPUT
  2123.  
  2124.             numpoints - number of points to scale
  2125.             xscale - scale factor along X axis
  2126.             yscale - scale factor along Y axis
  2127.             zscale - scale factor along Z axis
  2128.             inary - D3Point pointer to array containing points to scale
  2129.  
  2130.             OUTPUT
  2131.  
  2132.             no value returned
  2133.             outary - D3Point array of scaled values
  2134.  
  2135.             USAGE
  2136.  
  2137.             D3SCALE multiplies each coordinate in the three dimensional
  2138.             array inary by the corresponding scale factor xscale, yscale
  2139.             or zscale.  The results are stored in outary which can be the
  2140.             same as inary.  A scale factor of 256 (100 hex) is considered
  2141.             100 percent and results in no change.  Therefore, 128 (80 hex)
  2142.             reduces values by one half and 512 (200 hex) doubles values.
  2143.             The function assumes space for outary has been properly
  2144.             allocated.
  2145.  
  2146.             SEE ALSO
  2147.  
  2148.             D3PROJECT, D3ROTATE, D3TRANSLATE
  2149.  
  2150.             EXAMPLE
  2151.  
  2152.             /*
  2153.              * shows d3scale works
  2154.              */
  2155.  
  2156.             #include <stdlib.h>
  2157.             #include <conio.h>
  2158.             #include "svgacc.h"
  2159.  
  2160.             D2Point plot[8];
  2161.  
  2162.             void drwcube(void);
  2163.  
  2164.             void main(void)
  2165.             {
  2166.                int vmode,i,dummy;
  2167.                ProjParameters proj;
  2168.                D3Point scube[8];
  2169.  
  2170.  
  2171.                                                                          33
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.                D3Point cube[8] = { { 100,-100, 100},
  2179.                                 { 100,-100,-100},
  2180.                                 { 100, 100,-100},
  2181.                                 { 100, 100, 100},
  2182.                                 {-100,-100, 100},
  2183.                                 {-100,-100,-100},
  2184.                                 {-100, 100,-100},
  2185.                                 {-100, 100, 100}};
  2186.  
  2187.                vmode = videomodeget();
  2188.                if (!whichvga() || (whichmem() < 512))
  2189.                  exit(1);
  2190.                res640();
  2191.  
  2192.                proj.eyex = -1040;
  2193.                proj.eyey = -600;
  2194.                proj.eyez = -1200;
  2195.                proj.scrd = 1700;
  2196.                proj.theta = 30;
  2197.                proj.phi = 45;
  2198.  
  2199.                for(i=256;i>=128;i-=4)
  2200.                {
  2201.                  d3scale(8,i,i,i,cube,scube);
  2202.                  dummy = d3project(8,&proj,scube,plot);
  2203.                  drwcube();
  2204.                  sdelay(2);
  2205.                  drwcube();
  2206.                }
  2207.                for(i=132;i<=256;i+=4)
  2208.                {
  2209.                  d3scale(8,i,i,i,cube,scube);
  2210.                  dummy = d3project(8,&proj,scube,plot);
  2211.                  drwcube();
  2212.                  sdelay(2);
  2213.                  drwcube();
  2214.                }
  2215.                drwcube();
  2216.                getch();
  2217.                videomodeset(vmode);
  2218.             }
  2219.  
  2220.             void drwcube(void)
  2221.             {
  2222.                int j;
  2223.  
  2224.                for(j=0;j<=2;j++)
  2225.  
  2226.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2227.                drwline(2,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  2228.  
  2229.                for(j=4;j<=6;j++)
  2230.  
  2231.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2232.  
  2233.  
  2234.                                                                          34
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.                drwline(2,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  2242.  
  2243.                for(j=0;j<=3;j++)
  2244.  
  2245.                drwline(2,10,plot[j].x,plot[j].y,plot[j+4].x,plot[j+4].y);
  2246.  
  2247.                return;
  2248.             }
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.                                                                          35
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.           D3TRANSLATE
  2305.  
  2306.             PROTOTYPE
  2307.  
  2308.             extern void far d3translate (int points, int xtrans, int
  2309.                ytrans, int ztrans, D3Point far *inary, D3Point far *outary)
  2310.  
  2311.             INPUT
  2312.  
  2313.             numpoints - number of points to translate
  2314.             xtrans - distance to translate along X axis
  2315.             ytrans - distance to translate along Y axis
  2316.             ztrans - distance to translate along Z axis
  2317.             inary - D3Point pointer to array containing points to
  2318.             translate
  2319.  
  2320.             OUTPUT
  2321.  
  2322.             no value returned
  2323.             outary - D3Point array of translated points
  2324.  
  2325.             USAGE
  2326.  
  2327.             D3TRANSLATE takes the three dimensional points given in inary
  2328.             and translates them by the specified number of pixels along
  2329.             each axis.  The results are returned in outary which can be
  2330.             the same as inary.  The function assumes space for outary has
  2331.             been properly allocated.
  2332.  
  2333.             SEE ALSO
  2334.  
  2335.             D3PROJECT, D3ROTATE, D3SCALE
  2336.  
  2337.             EXAMPLE
  2338.  
  2339.             /*
  2340.              * shows d3translate works
  2341.              */
  2342.  
  2343.             #include <stdlib.h>
  2344.             #include <conio.h>
  2345.             #include "svgacc.h"
  2346.  
  2347.             D2Point plot[8];
  2348.  
  2349.             void drwcube(void);
  2350.  
  2351.             void main(void)
  2352.             {
  2353.                int vmode,i,dummy;
  2354.                ProjParameters proj;
  2355.                D3Point tcube[8];
  2356.                D3Point cube[8] = { { 100,-100, 100},
  2357.                                 { 100,-100,-100},
  2358.  
  2359.  
  2360.                                                                          36
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.                                 { 100, 100,-100},
  2368.                                 { 100, 100, 100},
  2369.                                 {-100,-100, 100},
  2370.                                 {-100,-100,-100},
  2371.                                 {-100, 100,-100},
  2372.                                 {-100, 100, 100}};
  2373.  
  2374.                vmode = videomodeget();
  2375.                if (!whichvga() || (whichmem() < 512))
  2376.                  exit(1);
  2377.                res640();
  2378.  
  2379.                proj.eyex = -1040;
  2380.                proj.eyey = -600;
  2381.                proj.eyez = -1200;
  2382.                proj.scrd = 1700;
  2383.                proj.theta = 30;
  2384.                proj.phi = 45;
  2385.  
  2386.                for(i=0;i<=400;i+=8)
  2387.                {
  2388.                  d3translate(8,i,i,i,cube,tcube);
  2389.                  dummy = d3project(8,&proj,tcube,plot);
  2390.                  drwcube();
  2391.                  sdelay(2);
  2392.                  drwcube();
  2393.                }
  2394.                for(i=400;i>=0;i-=8)
  2395.                {
  2396.                  d3translate(8,i,i,i,cube,tcube);
  2397.                  dummy = d3project(8,&proj,tcube,plot);
  2398.                  drwcube();
  2399.                  sdelay(2);
  2400.                  drwcube();
  2401.                }
  2402.                drwcube();
  2403.                getch();
  2404.                videomodeset(vmode);
  2405.             }
  2406.  
  2407.             void drwcube(void)
  2408.             {
  2409.                int j;
  2410.  
  2411.                for(j=0;j<=2;j++)
  2412.  
  2413.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2414.                drwline(2,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  2415.  
  2416.                for(j=4;j<=6;j++)
  2417.  
  2418.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2419.                drwline(2,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  2420.  
  2421.  
  2422.  
  2423.                                                                          37
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.                for(j=0;j<=3;j++)
  2431.  
  2432.                drwline(2,10,plot[j].x,plot[j].y,plot[j+4].x,plot[j+4].y);
  2433.  
  2434.                return;
  2435.             }
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.                                                                          38
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.           DRWBOX
  2494.  
  2495.             PROTOTYPE
  2496.  
  2497.             extern void far drwbox (PixelMode mode, int colr, int x1, int
  2498.             y1, int x2, int y2)
  2499.  
  2500.             INPUT
  2501.  
  2502.             mode - pixel write mode
  2503.             colr - index to color in current palette
  2504.             x1, y1 - location of top left corner
  2505.             x2, y2 - location of bottom right corner
  2506.  
  2507.             OUTPUT
  2508.  
  2509.             no value returned
  2510.  
  2511.             USAGE
  2512.  
  2513.             DRWBOX draws a rectangle with the specified color using mode
  2514.             with opposite vertices defined by (x1, y1) and (x2, y2).  The
  2515.             vertices given do not need to be exactly the top left and
  2516.             bottom right.  They only have to reference opposite vertices
  2517.             of the rectangle.  Any portion of the rectangle that lies
  2518.             outside of the currently defined viewport will not be drawn.
  2519.  
  2520.             SEE ALSO
  2521.  
  2522.             DRWFILLBOX, DRWLINE, SETVIEW
  2523.  
  2524.             EXAMPLE
  2525.  
  2526.             /*
  2527.              * Places a box around the whole screen
  2528.              */
  2529.  
  2530.             #include <stdlib.h>
  2531.             #include <conio.h>
  2532.             #include "svgacc.h"
  2533.  
  2534.             void main(void)
  2535.             {
  2536.                int vmode;
  2537.  
  2538.                vmode = videomodeget();
  2539.                if ( !whichvga() )
  2540.                  exit(1);
  2541.                if ( whichmem() < 512)
  2542.                  exit(1);
  2543.                res640();
  2544.                drwbox (1,10,0,0,639,479);
  2545.                getch();
  2546.                videomodeset(vmode);
  2547.  
  2548.  
  2549.                                                                          39
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.                exit(0);
  2557.             }
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.                                                                          40
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.           DRWCIRCLE
  2620.  
  2621.             PROTOTYPE
  2622.  
  2623.             extern void far drwcircle (PixelMode mode, int colr, int
  2624.             xcenter, int ycenter, int radius)
  2625.  
  2626.             INPUT
  2627.  
  2628.             mode - pixel write mode
  2629.             colr - index to color in current palette
  2630.             xcenter, ycenter - location of center of circle
  2631.             radius - distance from center to edge of circle
  2632.  
  2633.             OUTPUT
  2634.  
  2635.             no value returned
  2636.  
  2637.             USAGE
  2638.  
  2639.             DRWCIRCLE draws a circle of the specified color using mode
  2640.             with the center located at (xcenter, ycenter) and a radius of
  2641.             radius.  All values of xcenter, ycenter and radius are valid.
  2642.             Any portion of the circle that lies outside of the currently
  2643.             defined viewport will not be drawn.
  2644.  
  2645.             SEE ALSO
  2646.  
  2647.             DRWELLIPSE, DRWFILLCIRCLE, SETVIEW
  2648.  
  2649.             EXAMPLE
  2650.  
  2651.             /*
  2652.              * Places a circle at the center of the screen
  2653.              */
  2654.  
  2655.             #include <stdlib.h>
  2656.             #include <conio.h>
  2657.             #include "svgacc.h"
  2658.  
  2659.             void main(void)
  2660.             {
  2661.                int vmode;
  2662.  
  2663.                vmode = videomodeget();
  2664.                if ( !whichvga() )
  2665.                  exit(1);
  2666.                if ( whichmem() < 512)
  2667.                  exit(1);
  2668.                res640();
  2669.                drwcircle (1,10,320,240,200);
  2670.                getch();
  2671.                videomodeset(vmode);
  2672.                exit(0);
  2673.  
  2674.  
  2675.                                                                          41
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.             }
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.                                                                          42
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.           DRWELLIPSE
  2746.  
  2747.             PROTOTYPE
  2748.  
  2749.             extern void far drwellipse (PixelMode mode, int colr, int
  2750.             xcenter, int ycenter, int radiusx, int radiusy)
  2751.  
  2752.             INPUT
  2753.  
  2754.             mode - pixel write mode
  2755.             colr - index to color in current palette
  2756.             xcenter, ycenter - location of center of ellipse
  2757.             radiusx - radius parallel to X axis
  2758.             radiusy - radius parallel to Y axis
  2759.  
  2760.             OUTPUT
  2761.  
  2762.             no value returned
  2763.  
  2764.             USAGE
  2765.  
  2766.             DRWELLIPSE draws an ellipse of the specified color using mode
  2767.             with the center defined by (xcenter, ycenter).  The radius in
  2768.             the horizontal direction is raduisx and the radius in the
  2769.             vertical direction is radiusy.  All values of xcenter,
  2770.             ycenter, radiusx and radiusy are valid.  Any portion of the
  2771.             ellipse that lies outside of the currently defined viewport
  2772.             will not be drawn.
  2773.  
  2774.             SEE ALSO
  2775.  
  2776.             DRWCIRCLE, DRWFILLELLIPSE, SETVIEW
  2777.  
  2778.             EXAMPLE
  2779.  
  2780.             /*
  2781.              * Places an ellipse at the center of the screen
  2782.              */
  2783.  
  2784.             #include <stdlib.h>
  2785.             #include <conio.h>
  2786.             #include "svgacc.h"
  2787.  
  2788.             void main(void)
  2789.             {
  2790.                int vmode;
  2791.  
  2792.                vmode = videomodeget();
  2793.                if ( !whichvga() )
  2794.                  exit(1);
  2795.                if ( whichmem() < 512)
  2796.                  exit(1);
  2797.                res640();
  2798.                drwellipse (1,10,320,240,318,238);
  2799.  
  2800.  
  2801.                                                                          43
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.  
  2808.                getch();
  2809.                videomodeset(vmode);
  2810.                exit(0);
  2811.             }
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.                                                                          44
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.           DRWFILLBOX
  2872.  
  2873.             PROTOTYPE
  2874.  
  2875.             extern void far drwfillbox (PixelMode mode, int colr, int x1,
  2876.             int y1, int x2, int y2)
  2877.  
  2878.             INPUT
  2879.  
  2880.             mode - pixel write mode
  2881.             colr - index to color in current palette
  2882.             x1, y1 - location of top left corner
  2883.             x2, y2 - location of bottom right corner
  2884.  
  2885.             OUTPUT
  2886.  
  2887.             no value returned
  2888.  
  2889.             USAGE
  2890.  
  2891.             DRWFILLBOX draws a solid rectangle with the specified color
  2892.             using mode with opposite vertices defined by (x1, y1) and (x2,
  2893.             y2).  The vertices given do not need to be exactly the top
  2894.             left and bottom right.  They only have to reference opposite
  2895.             vertices of the rectangle.  Any portion of the rectangle that
  2896.             lies outside of the currently defined viewport will not be
  2897.             drawn.
  2898.  
  2899.             SEE ALSO
  2900.  
  2901.             DRWBOX, DRWLINE, SETVIEW
  2902.  
  2903.             EXAMPLE
  2904.  
  2905.             /*
  2906.              * Places a filled box in the center of the screen
  2907.              */
  2908.  
  2909.             #include <stdlib.h>
  2910.             #include <conio.h>
  2911.             #include "svgacc.h"
  2912.  
  2913.             void main(void)
  2914.             {
  2915.                int vmode;
  2916.                vmode = videomodeget();
  2917.                if ( !whichvga() )
  2918.                  exit(1);
  2919.                if ( whichmem() < 512)
  2920.                     exit(1);
  2921.                if ( !res640() )
  2922.                     exit(1);
  2923.                drwfillbox (1,10,270,190,370,290);
  2924.                getch();
  2925.  
  2926.  
  2927.                                                                          45
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.                videomodeset(vmode);
  2935.                exit(0);
  2936.             }
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.                                                                          46
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.           DRWFILLCIRCLE
  2998.  
  2999.             PROTOTYPE
  3000.  
  3001.             extern void far drwfillcircle (PixelMode mode, int colr, int
  3002.             xcenter, int ycenter, int radius)
  3003.  
  3004.             INPUT
  3005.  
  3006.             mode - pixel write mode
  3007.             colr - index to color in current palette
  3008.             xcenter, ycenter - location of center of circle
  3009.             radius - distance from center to edge of circle
  3010.  
  3011.             OUTPUT
  3012.  
  3013.             no value returned
  3014.  
  3015.             USAGE
  3016.  
  3017.             DRWFILLCIRCLE draws a solid circle of the specified color
  3018.             using mode with the center located at (xcenter, ycenter) and a
  3019.             radius of radius.  All values of xcenter, ycenter and radius
  3020.             are valid.  Any portion of the circle that lies outside of the
  3021.             currently defined viewport will not be drawn.
  3022.  
  3023.             SEE ALSO
  3024.  
  3025.             DRWCIRCLE, SETVIEW
  3026.  
  3027.             EXAMPLE
  3028.  
  3029.             /*
  3030.              * Places a filled circle at the center of the screen
  3031.              */
  3032.  
  3033.             #include <stdlib.h>
  3034.             #include <conio.h>
  3035.             #include "svgacc.h"
  3036.  
  3037.             void main(void)
  3038.             {
  3039.                int vmode;
  3040.                vmode = videomodeget();
  3041.                if ( !whichvga() )
  3042.                  exit(1);
  3043.                if ( whichmem() < 512)
  3044.                  exit(1);
  3045.                if ( !res640() )
  3046.                  exit(1);
  3047.                drwfillcircle (1,10,320,240,100);
  3048.                getch();
  3049.                videomodeset(vmode);
  3050.                exit(0);
  3051.  
  3052.  
  3053.                                                                          47
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.             }
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.                                                                          48
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.           DRWFILLELLIPSE
  3124.  
  3125.             PROTOTYPE
  3126.  
  3127.             extern void far drwfillellipse (PixelMode mode, int colr, int
  3128.             xcenter, int ycenter, int radiusx, int radiusy)
  3129.  
  3130.             INPUT
  3131.  
  3132.             mode - pixel write mode
  3133.             colr - index to color in current palette
  3134.             xcenter, ycenter - location of center of ellipse
  3135.             radiusx - radius parallel to X axis
  3136.             radiusy - radius parallel to Y axis
  3137.  
  3138.             OUTPUT
  3139.  
  3140.             no value returned
  3141.  
  3142.             USAGE
  3143.  
  3144.             DRWFILLELLIPSE draws an ellipse of the specified color using
  3145.             mode with the center defined by (xcenter, ycenter).  The
  3146.             radius in the horizontal direction is raduisx and the radius
  3147.             in the vertical direction is radiusy.  All values of xcenter,
  3148.             ycenter, radiusx and radiusy are valid.  Any portion of the
  3149.             ellipse that lies outside of the currently defined viewport
  3150.             will not be drawn.
  3151.  
  3152.             SEE ALSO
  3153.  
  3154.             DRWELLIPSE, SETVIEW
  3155.  
  3156.             EXAMPLE
  3157.  
  3158.             /*
  3159.              * Places a filled ellipse at the center of the screen
  3160.              */
  3161.  
  3162.             #include <stdlib.h>
  3163.             #include <conio.h>
  3164.             #include "svgacc.h"
  3165.  
  3166.             void main(void)
  3167.             {
  3168.                int vmode;
  3169.                vmode = videomodeget();
  3170.                if ( !whichvga() )
  3171.                  exit(1);
  3172.                if ( whichmem() < 512)
  3173.                  exit(1);
  3174.                if ( !res640() )
  3175.                exit(1);
  3176.                drwfillellipse (1,10,320,240,218,138);
  3177.  
  3178.  
  3179.                                                                          49
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.                getch();
  3187.                videomodeset(vmode);
  3188.                exit(0);
  3189.             }
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.                                                                          50
  3243.  
  3244.  
  3245.  
  3246.  
  3247.  
  3248.  
  3249.           DRWLINE
  3250.  
  3251.             PROTOTYPE
  3252.  
  3253.             extern void far drwline (PixelMode mode, int colr, int x1, int
  3254.             y1, int x2, int y2)
  3255.  
  3256.             INPUT
  3257.  
  3258.             mode - pixel write mode
  3259.             colr - index to color in current palette
  3260.             x1, y1 - location of one endpoint of line
  3261.             x2, y2 - location of other endpoint of line
  3262.  
  3263.             OUTPUT
  3264.  
  3265.             no value returned
  3266.  
  3267.             USAGE
  3268.  
  3269.             DRWLINE draws a line of the specified color using mode with
  3270.             endpoints located at (x1, y1) And (x2, y2).  All values of x1,
  3271.             y1, x2 and y2 are valid.  Any portion of the line that lies
  3272.             outside of the currently defined viewport will not be drawn.
  3273.  
  3274.             SEE ALSO
  3275.  
  3276.             DRWBOX, SETVIEW
  3277.  
  3278.             EXAMPLE
  3279.  
  3280.             /*
  3281.              * Draws a line from 0,0 to the center of the screen
  3282.              */
  3283.  
  3284.             #include <stdlib.h>
  3285.             #include <conio.h>
  3286.             #include "svgacc.h"
  3287.  
  3288.             void main(void)
  3289.             {
  3290.                int vmode;
  3291.                vmode = videomodeget();
  3292.                if ( !whichvga() )
  3293.                  exit(1);
  3294.                if ( whichmem() < 512)
  3295.                  exit(1);
  3296.                res640();
  3297.                drwline (1,10,0,0,320,240);
  3298.                getch();
  3299.                videomodeset(vmode);
  3300.                exit(0);
  3301.             }
  3302.  
  3303.  
  3304.  
  3305.                                                                          51
  3306.  
  3307.  
  3308.  
  3309.  
  3310.  
  3311.  
  3312.           DRWPOINT
  3313.  
  3314.             PROTOTYPE
  3315.  
  3316.             extern void far drwpoint (PixelMode mode, int colr, int x, int
  3317.             y)
  3318.  
  3319.             INPUT
  3320.  
  3321.             mode - pixel write mode
  3322.             colr - index to color in current palette
  3323.             x, y - location of pixel to write
  3324.  
  3325.             OUTPUT
  3326.  
  3327.             no value returned
  3328.  
  3329.             USAGE
  3330.  
  3331.             DRWPOINT draws a single point of the specified color using
  3332.             mode at (x, y).  All values of x and y are valid.  If the
  3333.             point (x, y) lies outside of the currently defined viewport,
  3334.             no drawing will take place.
  3335.  
  3336.             SEE ALSO
  3337.  
  3338.             GETPOINT, SETVIEW
  3339.  
  3340.             EXAMPLE
  3341.  
  3342.             /*
  3343.              * Draws a point at the center of the screen
  3344.              */
  3345.  
  3346.             #include <stdlib.h>
  3347.             #include <conio.h>
  3348.             #include "svgacc.h"
  3349.  
  3350.             void main(void)
  3351.             {
  3352.                int vmode;
  3353.  
  3354.                vmode = videomodeget();
  3355.                if ( !whichvga() )
  3356.                  exit(1);
  3357.                if ( whichmem() < 512)
  3358.                  exit(1);
  3359.                res640();
  3360.                drwpoint (1,10,320,240);
  3361.                getch();
  3362.                videomodeset(vmode);
  3363.                exit(0);
  3364.             }
  3365.  
  3366.  
  3367.  
  3368.                                                                          52
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  
  3375.           DRWSTRING
  3376.  
  3377.             PROTOTYPE
  3378.  
  3379.             extern void far drwstring (PixelMode mode, int fcolr, int
  3380.             bcolr, const char far *strng, int x, int y)
  3381.  
  3382.             INPUT
  3383.  
  3384.             mode - pixel write mode
  3385.             fcolr - foreground index to color in current palette
  3386.             bcolr - background index to color in current palette
  3387.             strng - char pointer to string of ASCII characters to be drawn
  3388.             x, y - location of upper, left corner of block
  3389.  
  3390.             OUTPUT
  3391.  
  3392.             no value returned
  3393.  
  3394.             USAGE
  3395.  
  3396.             DRWSTRING takes the null terminated ASCII characters beginning
  3397.             at strng and creates a graphics block similar to the blocks
  3398.             used by blkget and blkput and places this block on the screen
  3399.             at the specified coordinates.  The characters are drawn with
  3400.             color fcolr using the current font and the background is color
  3401.             bcolr.  When mode 0, NO_ACTION, is used, the graphics block is
  3402.             created in memory, retrievable by GETLASTSTRING, but no text
  3403.             is actually drawn on the screen.  (Note: the system font is
  3404.             automatically installed when WHICHVGA is called.)
  3405.  
  3406.             SEE ALSO
  3407.  
  3408.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRINGDN, DRWSTRINGLT,
  3409.             DRWSTRINGRT, GETLASTSTRING
  3410.  
  3411.             EXAMPLE
  3412.  
  3413.             /*
  3414.              * Draws some normal text at the center of the screen
  3415.              */
  3416.             #include <stdlib.h>
  3417.             #include <conio.h>
  3418.             #include "svgacc.h"
  3419.  
  3420.             void main(void)
  3421.             {
  3422.                int vmode;
  3423.                char text[]="hello world";
  3424.  
  3425.                vmode = videomodeget();
  3426.                if ( !whichvga() || (whichmem() < 512))
  3427.                  exit(1);
  3428.                res640();
  3429.  
  3430.  
  3431.                                                                          53
  3432.  
  3433.  
  3434.  
  3435.  
  3436.  
  3437.  
  3438.                drwstring(1,10,0,text,320,240);
  3439.                getch();
  3440.                videomodeset(vmode);
  3441.                exit(0);
  3442.             }
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.  
  3449.  
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.                                                                          54
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.           DRWSTRINGDN
  3502.  
  3503.             PROTOTYPE
  3504.  
  3505.             extern void far drwstringdn (PixelMode mode, int fcolr, int
  3506.             bcolr, const char far *strng, int x, int y)
  3507.  
  3508.             INPUT
  3509.  
  3510.             mode - pixel write mode
  3511.             fcolr - foreground index to color in current palette
  3512.             bcolr - background index to color in current palette
  3513.             strng - char pointer to string of ASCII characters to be drawn
  3514.             x, y - location of lower, right corner of block
  3515.  
  3516.             OUTPUT
  3517.  
  3518.             no value returned
  3519.  
  3520.             USAGE
  3521.  
  3522.             DRWSTRINGDN takes the null terminated ASCII characters
  3523.             beginning at strng and creates a graphics block similar to the
  3524.             blocks used by BLKGET and BLKPUT.  The characters are drawn
  3525.             with color fcolr using the current font and the background is
  3526.             color bcolr.  When mode 0, NO_ACTION, is used, the graphics
  3527.             block is created in memory retrievable by GETLASTSTRING, but
  3528.             no text is actually drawn on the screen.  (Note: the system
  3529.             font is automatically installed when WHICHVGA is called.)  The
  3530.             text is drawn upside down with x, y specifying the lower,
  3531.             right corner.  This corner corresponds to the upper, left
  3532.             corner when the text is oriented upright.
  3533.  
  3534.             SEE ALSO
  3535.  
  3536.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRING, DRWSTRINGLT,
  3537.             DRWSTRINGRT, GETLASTSTRING
  3538.  
  3539.             EXAMPLE
  3540.  
  3541.             /* Draws some text rotated by 180 degrees at the center of the
  3542.             screen */
  3543.             #include <stdlib.h>
  3544.             #include <conio.h>
  3545.             #include "svgacc.h"
  3546.  
  3547.             void main(void)
  3548.             {
  3549.                int vmode;
  3550.                char text[]="hello world";
  3551.  
  3552.                vmode = videomodeget();
  3553.                if ( !whichvga() || (whichmem() < 512))
  3554.                  exit(1);
  3555.  
  3556.  
  3557.                                                                          55
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.                res640();
  3565.                drwstringdn(1,10,0,text,320,240);
  3566.                getch();
  3567.                videomodeset(vmode);
  3568.                exit(0);
  3569.             }
  3570.  
  3571.  
  3572.  
  3573.  
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.                                                                          56
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.           DRWSTRINGLT
  3628.  
  3629.             PROTOTYPE
  3630.  
  3631.             extern void far drwstringlt (PixelMode mode, int fcolr, int
  3632.             bcolr, const char far *strng, int x, int y)
  3633.  
  3634.             INPUT
  3635.  
  3636.             mode - pixel write mode
  3637.             fcolr - foreground index to color in current palette
  3638.             bcolr - background index to color in current palette
  3639.             strng - char pointer to string of ASCII characters to be drawn
  3640.             x, y - location of lower, left corner of block
  3641.  
  3642.             OUTPUT
  3643.  
  3644.             no value returned
  3645.  
  3646.             USAGE
  3647.  
  3648.             DRWSTRINGLT takes the null terminated ASCII characters
  3649.             beginning at strng and creates a graphics block similar to the
  3650.             blocks used by BLKGET and BLKPUT.  The characters are drawn
  3651.             with color fcolr using the current font and the background is
  3652.             color bcolr.  When mode 0, NO_ACTION, is used, the graphics
  3653.             block is created in memory retrievable by GETLASTSTRING, but
  3654.             no text is actually drawn on the screen.  (Note: the system
  3655.             font is automatically installed when WHICHVGA is called.)  The
  3656.             text block is rotated 90 to the left with x, y specifying the
  3657.             lower, left corner.  This corner corresponds to the upper,
  3658.             left corner when the text is oriented upright.
  3659.  
  3660.             SEE ALSO
  3661.  
  3662.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRING, DRWSTRINGDN,
  3663.             DRWSTRINGRT, GETLASTSTRING
  3664.  
  3665.             EXAMPLE
  3666.  
  3667.             /* Draws some text rotated 90 degrees to the left at center of
  3668.             screen */
  3669.             #include <stdlib.h>
  3670.             #include <conio.h>
  3671.             #include "svgacc.h"
  3672.  
  3673.             void main(void)
  3674.             {
  3675.                int vmode;
  3676.                char text[]="hello world";
  3677.  
  3678.                vmode = videomodeget();
  3679.                if ( !whichvga() || (whichmem() < 512))
  3680.                  exit(1);
  3681.  
  3682.  
  3683.                                                                          57
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.                res640();
  3691.                drwstringlt(1,10,0,text,320,240);
  3692.                getch();
  3693.                videomodeset(vmode);
  3694.                exit(0);
  3695.             }
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.                                                                          58
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.           DRWSTRINGRT
  3754.  
  3755.             PROTOTYPE
  3756.  
  3757.             extern void far drwstringrt (PixelMode mode, int fcolr, int
  3758.             bcolr, const char far *strng, int x, int y)
  3759.  
  3760.             INPUT
  3761.  
  3762.             mode - pixel write mode
  3763.             fcolr - foreground index to color in current palette
  3764.             bcolr - background index to color in current palette
  3765.             strng - char pointer to string of ASCII characters to be drawn
  3766.             x, y - location of upper, right corner of block
  3767.  
  3768.             OUTPUT
  3769.  
  3770.             no value returned
  3771.  
  3772.             USAGE
  3773.  
  3774.             DRWSTRINGRT takes the null terminated ASCII characters
  3775.             beginning at strng and creates a graphics block similar to the
  3776.             blocks used by BLKGET and BLKPUT.  The characters are drawn
  3777.             with color fcolr using the current font and the background is
  3778.             color bcolr.  When mode 0, NO_ACTION, is used, the graphics
  3779.             block is created in memory retrievable by GETLASTSTRING, but
  3780.             no text is actually drawn on the screen.  (Note: the system
  3781.             font is automatically installed when WHICHVGA is called.)  The
  3782.             text block is rotated 90 to the right with x, y specifying the
  3783.             upper, right corner.  This corner corresponds to the upper,
  3784.             left corner if the text is oriented upright.
  3785.  
  3786.             SEE ALSO
  3787.  
  3788.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRING, DRWSTRINGDN,
  3789.             DRWSTRINGLT, GETLASTSTRING
  3790.  
  3791.             EXAMPLE
  3792.  
  3793.             /* Draws text rotated 90 degrees to the right at center of
  3794.             screen */
  3795.             #include <stdlib.h>
  3796.             #include <conio.h>
  3797.             #include "svgacc.h"
  3798.  
  3799.             void main(void)
  3800.             {
  3801.                int vmode;
  3802.                char text[]="hello world";
  3803.  
  3804.                vmode = videomodeget();
  3805.                if ( !whichvga() || (whichmem() < 512))
  3806.                  exit(1);
  3807.  
  3808.  
  3809.                                                                          59
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.                res640();
  3817.                drwstringrt(1,10,0,text,320,240);
  3818.                getch();
  3819.                videomodeset(vmode);
  3820.                exit(0);
  3821.             }
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847.  
  3848.  
  3849.  
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.                                                                          60
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.           FILLAREA
  3880.  
  3881.             PROTOTYPE
  3882.  
  3883.             extern void far fillarea (int xseed, int yseed, int
  3884.             bordercolr, int fillcolr)
  3885.  
  3886.             INPUT
  3887.  
  3888.             xseed, yseed - seed location to start fill
  3889.             bordercolr - index to color in current palette at which
  3890.             filling stops
  3891.             fillcolr - index to color in current palette to fill within
  3892.             the border
  3893.  
  3894.             OUTPUT
  3895.  
  3896.             no value returned
  3897.  
  3898.             USAGE
  3899.  
  3900.             FILLAREA fills a region with a new color specified by
  3901.             fillcolr.  The region is defined by any line or curve of the
  3902.             color bordercolr or fillcolr or by the edge of the viewport.
  3903.             All graphics within the region are lost and covered with the
  3904.             fillcolr.  The border is not effected.
  3905.  
  3906.             SEE ALSO
  3907.  
  3908.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLCOLOR,
  3909.             FILLPAGE, FILLSCREEN, FILLVIEW, SETVIEW
  3910.  
  3911.             EXAMPLE
  3912.  
  3913.             /*
  3914.              * fills a box with some color
  3915.              */
  3916.  
  3917.             #include <stdlib.h>
  3918.             #include <conio.h>
  3919.             #include "svgacc.h"
  3920.  
  3921.             void main(void)
  3922.             {
  3923.                int vmode;
  3924.  
  3925.                vmode = videomodeget();
  3926.                if ( !whichvga() )
  3927.                  exit(1);
  3928.                if ( whichmem() < 512)
  3929.                  exit(1);
  3930.                res640();
  3931.                drwbox(1,10,0,0,100,100);
  3932.                fillarea(1,1,10,7);
  3933.  
  3934.  
  3935.                                                                          61
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.                getch();
  3943.                videomodeset(vmode);
  3944.                exit(0);
  3945.             }
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.  
  3988.  
  3989.  
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.                                                                          62
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.           FILLCOLOR
  4006.  
  4007.             PROTOTYPE
  4008.  
  4009.             extern void far fillcolor (int xseed, int yseed, int oldcolr,
  4010.             int newcolr)
  4011.  
  4012.             INPUT
  4013.  
  4014.             xseed, yseed - seed location to start fill
  4015.             oldcolr - index to color in current palette to change
  4016.             newcolr - index to color in current palette to replace oldcolr
  4017.  
  4018.             OUTPUT
  4019.  
  4020.             no value returned
  4021.  
  4022.             USAGE
  4023.  
  4024.             FILLCOLOR replaces every existence of oldcolr with newcolr
  4025.             within a region.  The region is defined as any pixel of
  4026.             oldcolr which has a path of pixels of oldcolr or newcolr with
  4027.             sides touching back to the seed point, (xseed, yseed).
  4028.             Therefore, only pixels of oldcolr are modified and no other
  4029.             information is changed.
  4030.  
  4031.             SEE ALSO
  4032.  
  4033.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA, FILLPAGE,
  4034.             FILLSCREEN, FILLVIEW, SETVIEW
  4035.  
  4036.             EXAMPLE
  4037.  
  4038.             /*
  4039.              * replaces the black color with a new color
  4040.              */
  4041.  
  4042.             #include <stdlib.h>
  4043.             #include <conio.h>
  4044.             #include "svgacc.h"
  4045.  
  4046.             void main(void)
  4047.             {
  4048.                int vmode;
  4049.  
  4050.                vmode = videomodeget();
  4051.                if ( !whichvga() )
  4052.                  exit(1);
  4053.                if ( whichmem() < 512)
  4054.                  exit(1);
  4055.                res640();
  4056.                drwbox(1,10,0,0,100,100);
  4057.                drwbox(1,12,20,20,80,80);
  4058.                fillcolor(1,1,0,7);
  4059.  
  4060.  
  4061.                                                                          63
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.                getch();
  4069.                videomodeset(vmode);
  4070.                exit(0);
  4071.             }
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.                                                                          64
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.  
  4131.           FILLPAGE
  4132.  
  4133.             PROTOTYPE
  4134.  
  4135.             extern void far fillpage (int colr)
  4136.  
  4137.             INPUT
  4138.  
  4139.             colr - index to color in current palette
  4140.  
  4141.             OUTPUT
  4142.  
  4143.             no value is returned
  4144.  
  4145.             USAGE
  4146.  
  4147.             FILLPAGE clears the currently active page with the specified
  4148.             color.  All information on the page is lost.  (Note, a faster
  4149.             method to clear the page is to call any of the RES###
  4150.             functions.  These reset the graphics screen and automatically
  4151.             clear it to color index zero as well as reset the default
  4152.             palette.)
  4153.  
  4154.             SEE ALSO
  4155.  
  4156.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  4157.             FILLCOLOR, FILLSCREEN, FILLVIEW
  4158.  
  4159.             EXAMPLE
  4160.  
  4161.             /*
  4162.              * fill the page with a color
  4163.              */
  4164.  
  4165.             #include <stdlib.h>
  4166.             #include <conio.h>
  4167.             #include "svgacc.h"
  4168.  
  4169.             void main(void)
  4170.             {
  4171.                int vmode;
  4172.  
  4173.                vmode = videomodeget();
  4174.                if ( !whichvga() )
  4175.                  exit(1);
  4176.                if ( whichmem() < 512)
  4177.                  exit(1);
  4178.                res640();
  4179.                fillpage(10);
  4180.                getch();
  4181.                videomodeset(vmode);
  4182.                exit(0);
  4183.             }
  4184.  
  4185.  
  4186.  
  4187.                                                                          65
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.           FILLSCREEN
  4195.  
  4196.             PROTOTYPE
  4197.  
  4198.             extern void far fillscreen (int colr)
  4199.  
  4200.             INPUT
  4201.  
  4202.             colr - index to color in current palette
  4203.  
  4204.             OUTPUT
  4205.  
  4206.             no value is returned
  4207.  
  4208.             USAGE
  4209.  
  4210.             FILLSCREEN clears the entire screen with the specified color.
  4211.             All information on the screen is lost.  (Note, a faster method
  4212.             to clear the screen is to call any of the RES### functions.
  4213.             These reset the graphics screen and automatically clear it to
  4214.             color index zero as well as reset the default palette.)
  4215.  
  4216.             SEE ALSO
  4217.  
  4218.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  4219.             FILLCOLOR, FILLPAGE, FILLVIEW
  4220.  
  4221.             EXAMPLE
  4222.  
  4223.             /*
  4224.              * fill the screen with a color
  4225.              */
  4226.  
  4227.             #include <stdlib.h>
  4228.             #include <conio.h>
  4229.             #include "svgacc.h"
  4230.  
  4231.             void main(void)
  4232.             {
  4233.                int vmode;
  4234.  
  4235.                vmode = videomodeget();
  4236.                if ( !whichvga() )
  4237.                  exit(1);
  4238.                if ( whichmem() < 512)
  4239.                  exit(1);
  4240.                res640();
  4241.                fillscreen(10);
  4242.                getch();
  4243.                videomodeset(vmode);
  4244.                exit(0);
  4245.             }
  4246.  
  4247.  
  4248.  
  4249.  
  4250.                                                                          66
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.           FILLVIEW
  4258.  
  4259.             PROTOTYPE
  4260.  
  4261.             extern void far fillview (int colr)
  4262.  
  4263.             INPUT
  4264.  
  4265.             colr - index to color in current palette
  4266.  
  4267.             OUTPUT
  4268.  
  4269.             no value is returned
  4270.  
  4271.             USAGE
  4272.  
  4273.             FILLVIEW fills the currently defined viewport with the
  4274.             specified color.  All information in the viewport is lost.
  4275.  
  4276.             SEE ALSO
  4277.  
  4278.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  4279.             FILLCOLOR, FILLPAGE, FILLSCREEN, SETVIEW
  4280.  
  4281.             EXAMPLE
  4282.  
  4283.             /*
  4284.              * fill the viewport with a color
  4285.              */
  4286.  
  4287.             #include <stdlib.h>
  4288.             #include <conio.h>
  4289.             #include "svgacc.h"
  4290.  
  4291.             void main(void)
  4292.             {
  4293.                int vmode;
  4294.  
  4295.                vmode = videomodeget();
  4296.                if ( !whichvga() )
  4297.                  exit(1);
  4298.                if ( whichmem() < 512)
  4299.                  exit(1);
  4300.                res640();
  4301.                setview(100,100,539,379);
  4302.                fillview(10);
  4303.                getch();
  4304.                videomodeset(vmode);
  4305.                exit(0);
  4306.             }
  4307.  
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.                                                                          67
  4314.  
  4315.  
  4316.  
  4317.  
  4318.  
  4319.  
  4320.           FONTGETINFO
  4321.  
  4322.             PROTOTYPE
  4323.  
  4324.             extern void far fontgetinfo (int far *wdth, int far *hght)
  4325.  
  4326.             INPUT
  4327.  
  4328.             no input parameters
  4329.  
  4330.             OUTPUT
  4331.  
  4332.             wdth - integer pointer to width in pixels of current font
  4333.             hght - integer pointer to height in pixels of current font
  4334.  
  4335.             USAGE
  4336.  
  4337.             FONTGETINFO returns in wdth and hght the dimensions of the
  4338.             currently loaded font.
  4339.  
  4340.             SEE ALSO
  4341.  
  4342.             FONTSET, FONTSYSTEM
  4343.  
  4344.             EXAMPLE
  4345.  
  4346.             /*
  4347.              * display system font width and height
  4348.              */
  4349.  
  4350.             #include <stdlib.h>
  4351.             #include <conio.h>
  4352.             #include "svgacc.h"
  4353.  
  4354.             void main(void)
  4355.             {
  4356.                int vmode;
  4357.                int fontwidth;
  4358.                int fontheight;
  4359.                char text[50];
  4360.  
  4361.                vmode = videomodeget();
  4362.                if ( !whichvga() )
  4363.                  exit(1);
  4364.                if ( whichmem() < 512)
  4365.                  exit(1);
  4366.                res640();
  4367.                fontgetinfo(&fontwidth,&fontheight);
  4368.                sprintf(text,"the system font width is: %d",fontwidth);
  4369.                drwstring(1,7,0,text,0,0);
  4370.                sprintf(text,"the system font height is: %d",fontheight);
  4371.                drwstring(1,7,0,text,0,20);
  4372.                getch();
  4373.                videomodeset(vmode);
  4374.  
  4375.  
  4376.                                                                          68
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.                exit(0);
  4384.             }
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.  
  4427.  
  4428.  
  4429.  
  4430.  
  4431.  
  4432.  
  4433.  
  4434.  
  4435.  
  4436.  
  4437.  
  4438.  
  4439.                                                                          69
  4440.  
  4441.  
  4442.  
  4443.  
  4444.  
  4445.  
  4446.           FONTSET
  4447.  
  4448.             PROTOTYPE
  4449.  
  4450.             extern void far fontset (Font far *font)
  4451.  
  4452.             INPUT
  4453.  
  4454.             font - pointer to Font structure
  4455.  
  4456.             OUTPUT
  4457.  
  4458.             no value returned
  4459.  
  4460.             USAGE
  4461.  
  4462.             FONTSET loads the current font with the data found at font.
  4463.             The Font structure is 4098 bytes long with the first two bytes
  4464.             being the width and height of the font respectively.
  4465.  
  4466.             SEE ALSO
  4467.  
  4468.             FONTGETINFO, FONTSYSTEM
  4469.  
  4470.             EXAMPLE
  4471.  
  4472.             /*
  4473.              * Load a font from disk and enable it
  4474.              */
  4475.  
  4476.             #include <stdlib.h>
  4477.             #include <conio.h>
  4478.             #include <stdio.h>
  4479.             #include "svgacc.h"
  4480.  
  4481.             Font newfont;
  4482.  
  4483.             void main(void)
  4484.             {
  4485.                int vmode;
  4486.                char text[]="The Dragon Font!";
  4487.                FILE *fontfile;
  4488.                vmode = videomodeget();
  4489.                if ( !whichvga() )
  4490.                  exit(1);
  4491.                if ( whichmem() < 512)
  4492.                  exit(1);
  4493.                if ( !res640() )
  4494.                  exit(1);
  4495.                if( (fontfile = fopen("dragon.fnt","rb")) == NULL )
  4496.                  exit (1);
  4497.                fread(&newfont,4098,1,fontfile);
  4498.                fclose(fontfile);
  4499.                fontset(&newfont);
  4500.  
  4501.  
  4502.                                                                          70
  4503.  
  4504.  
  4505.  
  4506.  
  4507.  
  4508.  
  4509.                drwstring(1,10,0,text,0,0);
  4510.                getch();
  4511.                videomodeset(vmode);
  4512.             }
  4513.  
  4514.  
  4515.  
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.  
  4559.  
  4560.  
  4561.  
  4562.  
  4563.  
  4564.  
  4565.                                                                          71
  4566.  
  4567.  
  4568.  
  4569.  
  4570.  
  4571.  
  4572.           FONTSYSTEM
  4573.  
  4574.             PROTOTYPE
  4575.  
  4576.             extern void far fontsystem (void)
  4577.  
  4578.             INPUT
  4579.  
  4580.             no input parameters
  4581.  
  4582.             OUTPUT
  4583.  
  4584.             no value returned
  4585.  
  4586.             USAGE
  4587.  
  4588.             FONTSYSTEM sets the current font to the standard system font.
  4589.             This font is automatically set when WHICHVGA is called.
  4590.  
  4591.             SEE ALSO
  4592.  
  4593.             WHICHVGA, FONTGETINFO, FONTSET
  4594.  
  4595.             EXAMPLE
  4596.  
  4597.             /* Load font from disk, enable it, and switch back to system
  4598.             font */
  4599.  
  4600.             #include <stdlib.h>
  4601.             #include <conio.h>
  4602.             #include <stdio.h>
  4603.             #include "svgacc.h"
  4604.  
  4605.             Font newfont;
  4606.  
  4607.             void main(void)
  4608.             {
  4609.                int vmode;
  4610.                char text1[]="The Dragon Font!";
  4611.                char text2[]="The System Font!";
  4612.                FILE *fontfile;
  4613.                vmode = videomodeget();
  4614.                if ( !whichvga() || (whichmem() < 512))
  4615.                  exit(1);
  4616.                if ( !res640() )
  4617.                  exit(1);
  4618.                if( (fontfile = fopen("dragon.fnt","rb")) == NULL )
  4619.                  exit(1);
  4620.                fread(&newfont,4098,1,fontfile);
  4621.                fclose(fontfile);
  4622.                fontset(&newfont);
  4623.                drwstring(1,10,0,text1,0,0);
  4624.                fontsystem();
  4625.                drwstring(1,10,0,text2,0,20);
  4626.  
  4627.  
  4628.                                                                          72
  4629.  
  4630.  
  4631.  
  4632.  
  4633.  
  4634.  
  4635.                getch();
  4636.                videomodeset(vmode);
  4637.             }
  4638.  
  4639.  
  4640.  
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.  
  4691.                                                                          73
  4692.  
  4693.  
  4694.  
  4695.  
  4696.  
  4697.  
  4698.           GETARCCOS
  4699.  
  4700.             PROTOTYPE
  4701.  
  4702.             extern long far getarccos (long cosvalue)
  4703.  
  4704.             INPUT
  4705.  
  4706.             cosvalue - number between -1 and +1 scaled up by 13 bits
  4707.             (8192)
  4708.  
  4709.             OUTPUT
  4710.  
  4711.             GETARCCOS returns the arc cosine of cosvalue in degrees.
  4712.  
  4713.             USAGE
  4714.  
  4715.             GETARCCOS returns the arc cosine in degrees for the given
  4716.             value.  The return will be between 0 and 180 degrees.
  4717.             Cosvalue should be between -8192 and +8192 representing the
  4718.             range -1 to +1.  Input values outside this range are invalid
  4719.             and GETARCCOS will return -32768.  This function uses an
  4720.             integer lookup table stored within the library in order to
  4721.             produce the fastest possible results.  No floating point
  4722.             arithmetic is used.  The scale factor of 13 bits (8192) was
  4723.             chosen because this is the number of bits at which every
  4724.             change of one degree gives a change in the value of the sine
  4725.             (or cosine) function.
  4726.  
  4727.             SEE ALSO
  4728.  
  4729.             GETARCSIN, GETARCTAN, GETCOS, GETSIN, GETTAN
  4730.  
  4731.             EXAMPLE
  4732.  
  4733.             /*
  4734.              * show getarccos
  4735.              */
  4736.  
  4737.             #include <stdlib.h>
  4738.             #include <conio.h>
  4739.             #include "svgacc.h"
  4740.  
  4741.             void main(void)
  4742.             {
  4743.                int ang;
  4744.                long valueX8192;
  4745.                float value;
  4746.  
  4747.                for(value=0;value<1;value+=.05)
  4748.                {
  4749.                  valueX8192 = 8192 * value;
  4750.                  ang = getarccos(valueX8192);
  4751.                  printf("arccos of %f = %d degrees\n",value,ang);
  4752.  
  4753.  
  4754.                                                                          74
  4755.  
  4756.  
  4757.  
  4758.  
  4759.  
  4760.  
  4761.                }
  4762.                exit(0);
  4763.             }
  4764.  
  4765.  
  4766.  
  4767.  
  4768.  
  4769.  
  4770.  
  4771.  
  4772.  
  4773.  
  4774.  
  4775.  
  4776.  
  4777.  
  4778.  
  4779.  
  4780.  
  4781.  
  4782.  
  4783.  
  4784.  
  4785.  
  4786.  
  4787.  
  4788.  
  4789.  
  4790.  
  4791.  
  4792.  
  4793.  
  4794.  
  4795.  
  4796.  
  4797.  
  4798.  
  4799.  
  4800.  
  4801.  
  4802.  
  4803.  
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.  
  4810.  
  4811.  
  4812.  
  4813.  
  4814.  
  4815.  
  4816.  
  4817.                                                                          75
  4818.  
  4819.  
  4820.  
  4821.  
  4822.  
  4823.  
  4824.           GETARCSIN
  4825.  
  4826.             PROTOTYPE
  4827.  
  4828.             extern long far getarcsin (long sinvalue)
  4829.  
  4830.             INPUT
  4831.  
  4832.             sinvalue - number between -1 and +1 scaled up by 13 bits
  4833.             (8192)
  4834.  
  4835.             OUTPUT
  4836.  
  4837.             GETARCSIN returns the arc sine of sinvalue in degrees.
  4838.  
  4839.             USAGE
  4840.  
  4841.             GETARCSIN returns the arc sine in degrees for the given value.
  4842.             The return will be between -90 and +90 degrees.  Sinvalue
  4843.             should be between -8192 and +8192 representing the range -1 to
  4844.             +1.  Input values outside this range are invalid and GETARCSIN
  4845.             will return -32768.  This function uses an integer lookup
  4846.             table stored within the library in order to produce the
  4847.             fastest possible results.  No floating point arithmetic is
  4848.             used.  The scale factor of 13 bits (8192) was chosen because
  4849.             this is the number of bits at which every change of one degree
  4850.             gives a change in the value of the sine (or cosine) function.
  4851.  
  4852.             SEE ALSO
  4853.  
  4854.             GETARCCOS, GETARCTAN, GETCOS, GETSIN, GETTAN
  4855.  
  4856.             EXAMPLE
  4857.  
  4858.             /*
  4859.              * show getarcsin
  4860.              */
  4861.  
  4862.             #include <stdlib.h>
  4863.             #include <conio.h>
  4864.             #include "svgacc.h"
  4865.  
  4866.             void main(void)
  4867.             {
  4868.                int ang;
  4869.                long valueX8192;
  4870.                float value;
  4871.  
  4872.                for(value=0;value<1;value+=.05)
  4873.                {
  4874.                  valueX8192 = 8192 * value;
  4875.                  ang = getarcsin(valueX8192);
  4876.                  printf("arcsin of %f = %d degrees\n",value,ang);
  4877.                }
  4878.  
  4879.  
  4880.                                                                          76
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.                exit(0);
  4888.             }
  4889.  
  4890.  
  4891.  
  4892.  
  4893.  
  4894.  
  4895.  
  4896.  
  4897.  
  4898.  
  4899.  
  4900.  
  4901.  
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.                                                                          77
  4944.  
  4945.  
  4946.  
  4947.  
  4948.  
  4949.  
  4950.           GETARCTAN
  4951.  
  4952.             PROTOTYPE
  4953.  
  4954.             extern long far getarctan (long tanvalue)
  4955.  
  4956.             INPUT
  4957.  
  4958.             tanvalue - long integer representing a decimal scaled up by 13
  4959.             bits (8192)
  4960.  
  4961.             OUTPUT
  4962.  
  4963.             GETARCTAN returns the arc tangent of tanvalue in degrees.
  4964.  
  4965.             USAGE
  4966.  
  4967.             GETARCTAN returns the arc tangent in degrees for the given
  4968.             value.  The return will be between -89 and +89 degrees.
  4969.             Tanvalue can be any long integer.  It is interpreted as a
  4970.             decimal scaled up by 8192 (13 bits).  This function uses an
  4971.             integer lookup table stored within the library in order to
  4972.             produce the fastest possible results.  No floating point
  4973.             arithmetic is used.  The scale factor of 13 bits (8192) was
  4974.             chosen because this is the number of bits at which every
  4975.             change of one degree gives a change in the value of the sine
  4976.             (or cosine) function.
  4977.  
  4978.             SEE ALSO
  4979.  
  4980.             GETARCCOS, GETARCSIN, GETCOS, GETSIN, GETTAN
  4981.  
  4982.             EXAMPLE
  4983.  
  4984.             /*
  4985.              * show getarctan
  4986.              */
  4987.  
  4988.             #include <stdlib.h>
  4989.             #include <conio.h>
  4990.             #include "svgacc.h"
  4991.  
  4992.             void main(void)
  4993.             {
  4994.                int tanang;
  4995.                int ang;
  4996.                long valueX8192;
  4997.                float value;
  4998.  
  4999.                for(value=0;value<2;value+=.1)
  5000.                {
  5001.                  valueX8192 = 8192 * value;
  5002.                  ang = getarctan(valueX8192);
  5003.                  printf("arctan of %f = %d degrees\n",value,ang);
  5004.  
  5005.  
  5006.                                                                          78
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.                }
  5014.                exit(0);
  5015.             }
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051.  
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.                                                                          79
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.           GETCOS
  5077.  
  5078.             PROTOTYPE
  5079.  
  5080.             extern long far getcos (long angle)
  5081.  
  5082.             INPUT
  5083.  
  5084.             angle - angle in degrees
  5085.  
  5086.             OUTPUT
  5087.  
  5088.             GETCOS returns the cosine of angle scaled up by 13 bits
  5089.             (8192).
  5090.  
  5091.             USAGE
  5092.  
  5093.             GETCOS returns the cosine of the specified angle.  Angle can
  5094.             be any long value.  The return value has been multiplied by
  5095.             8192.  This function uses an integer lookup table stored
  5096.             within the library in order to produce the fastest possible
  5097.             results.  No floating point arithmetic is used.  The scale
  5098.             factor of 13 bits (8192) was chosen because this is the number
  5099.             of bits at which every change of one degree gives a change in
  5100.             the value of the sine (or cosine) function.
  5101.  
  5102.             SEE ALSO
  5103.  
  5104.             GETARCCOS, GETARCSIN, GETARCTAN, GETSIN, GETTAN
  5105.  
  5106.             EXAMPLE
  5107.  
  5108.             /*
  5109.              * show getcos
  5110.              */
  5111.  
  5112.             #include <stdlib.h>
  5113.             #include <conio.h>
  5114.             #include "svgacc.h"
  5115.  
  5116.             void main(void)
  5117.             {
  5118.                int ang;
  5119.                float value;
  5120.  
  5121.                for(ang=0;ang<90;ang+=5)
  5122.                {
  5123.                  value = (float)getcos(ang) / 8192;
  5124.                  printf("cos of %d degrees = %f\n",ang,value);
  5125.                }
  5126.                exit(0);
  5127.             }
  5128.  
  5129.  
  5130.  
  5131.  
  5132.                                                                          80
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.           GETLASTSTRING
  5140.  
  5141.             PROTOTYPE
  5142.  
  5143.             extern void far getlaststring (RasterBlock far *strnggfxblk)
  5144.  
  5145.             INPUT
  5146.  
  5147.             no input parameters
  5148.  
  5149.             OUTPUT
  5150.  
  5151.             no value returned
  5152.             strnggfxblk - RasterBlock pointer to destination array
  5153.  
  5154.             USAGE
  5155.  
  5156.             GETLASTSTRING returns the text drawn on the screen by the last
  5157.             called DRWSTRING function.  The text is returned in
  5158.             strnggfxblk which may be used with BLKPUT or the sprite
  5159.             functions.  The text in strnggfxblk is oriented in the same
  5160.             manner as the last called DRWSTRING function.  The suggested
  5161.             practice is to call the DRWSTRING function using mode
  5162.             NO_ACTION which does not actually draw text on the screen.
  5163.             GETLASTSTRING should be called immediately after the desired
  5164.             DRWSTRING function to prevent possible loss of data caused by
  5165.             other functions.
  5166.  
  5167.             The number of bytes of raster data needed by strnggfxblk is
  5168.             equal to
  5169.  
  5170.                          (fontwidth*stringlength)*(fontheight)
  5171.  
  5172.             plus four bytes for the width and height integers in the
  5173.             RasterBlock structure.
  5174.  
  5175.             The font's dimensions can be obtained by calling FONTGETINFO
  5176.             and the string's length can be obtained using the STRLEN
  5177.             function.  Note, however, that strnggfxblk can be quite large.
  5178.             If insufficient space is allocated for strnggfxblk,
  5179.             GETLASTSTRING will overwrite any data in memory contained
  5180.             beyond strnggfxblk and may possibly cause the system to crash.
  5181.  
  5182.             SEE ALSO
  5183.  
  5184.             BLKPUT, DRWSTRING, DRWSTRINGDN, DRWSTRINGLT, DRWSTRINGRT,
  5185.             FONTGETINFO
  5186.  
  5187.             EXAMPLE
  5188.  
  5189.             /*
  5190.              * Draws some text using the 'NO-ACTION' mode then
  5191.              * retrieve the raster data as a 'RasterBlock'
  5192.              */
  5193.  
  5194.  
  5195.                                                                          81
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.             #include <stdlib.h>
  5204.             #include <conio.h>
  5205.             #include "svgacc.h"
  5206.  
  5207.             void main(void)
  5208.             {
  5209.                int vmode,fontwidth,fontheight;
  5210.                char text[]="hello world";
  5211.                RasterBlock *blkdata;
  5212.                vmode = videomodeget();
  5213.                if ( !whichvga() || (whichmem() < 512))
  5214.                  exit(1);
  5215.                if ( !res640() )
  5216.                  exit(1);
  5217.                drwstringrt(NO_ACTION,10,0,text,320,240);
  5218.                fontgetinfo(&fontwidth,&fontheight);
  5219.                blkdata = (RasterBlock *)malloc(fontwidth*11*fontheight +
  5220.             4);
  5221.                getlaststring(blkdata);
  5222.                blkput(SET,0,0,blkdata);
  5223.                getch();
  5224.                videomodeset(vmode);
  5225.             }
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  
  5240.  
  5241.  
  5242.  
  5243.  
  5244.  
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.  
  5251.  
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.                                                                          82
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.           GETPOINT
  5266.  
  5267.             PROTOTYPE
  5268.  
  5269.             extern int far getpoint (int x, int y)
  5270.  
  5271.             INPUT
  5272.  
  5273.             x, y - location of pixel to read
  5274.  
  5275.             OUTPUT
  5276.  
  5277.             GETPOINT returns the color index of the pixel at x, y.
  5278.  
  5279.             USAGE
  5280.  
  5281.             GETPOINT returns the value of the pixel at location x, y.
  5282.             This value is a color index into the current palette.
  5283.  
  5284.             SEE ALSO
  5285.  
  5286.             DRWPOINT
  5287.  
  5288.             EXAMPLE
  5289.  
  5290.             /*
  5291.              * draw a point and check that it is there
  5292.              */
  5293.  
  5294.             #include <stdlib.h>
  5295.             #include <conio.h>
  5296.             #include "svgacc.h"
  5297.  
  5298.             void main(void)
  5299.             {
  5300.                int vmode;
  5301.                int pointvalue;
  5302.                char text[50];
  5303.  
  5304.                vmode = videomodeget();
  5305.                if ( !whichvga() )
  5306.                  exit(1);
  5307.                if ( whichmem() < 512)
  5308.                  exit(1);
  5309.                res640();
  5310.                drwpoint(1,10,320,240);
  5311.                pointvalue = getpoint(320,240);
  5312.                sprintf(text,"the point value is: %d",pointvalue);
  5313.                drwstring(1,7,0,text,0,0);
  5314.                getch();
  5315.                videomodeset(vmode);
  5316.                exit(0);
  5317.             }
  5318.  
  5319.  
  5320.  
  5321.                                                                          83
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.           GETSIN
  5329.  
  5330.             PROTOTYPE
  5331.  
  5332.             extern long far getsin (long angle)
  5333.  
  5334.             INPUT
  5335.  
  5336.             angle - angle in degrees
  5337.  
  5338.             OUTPUT
  5339.  
  5340.             GETSIN returns the sine of angle scaled up by 13 bits (8192).
  5341.  
  5342.             USAGE
  5343.  
  5344.             GETSIN returns the sine of the specified angle.  Angle can be
  5345.             any long value.  The return value has been multiplied by 8192.
  5346.             This function uses an integer lookup table stored within the
  5347.             library in order to produce the fastest possible results.  No
  5348.             floating point arithmetic is used.  The scale factor of 13
  5349.             bits (8192) was chosen because this is the number of bits at
  5350.             which every change of one degree gives a change in the value
  5351.             of the sine (or cosine) function.
  5352.  
  5353.             SEE ALSO
  5354.  
  5355.             GETARCCOS, GETARCSIN, GETARCTAN, GETCOS, GETTAN
  5356.  
  5357.             EXAMPLE
  5358.  
  5359.             /*
  5360.              * show getsin
  5361.              */
  5362.  
  5363.             #include <stdlib.h>
  5364.             #include <conio.h>
  5365.             #include "svgacc.h"
  5366.  
  5367.             void main(void)
  5368.             {
  5369.                int sinang, ang;
  5370.                float value;
  5371.  
  5372.                for(ang=0;ang<90;ang+=5)
  5373.                {
  5374.                  value = (float)getsin(ang) / 8192;
  5375.                  printf("sin of %d degrees = %f\n",ang,value);
  5376.                }
  5377.                exit(0);
  5378.             }
  5379.  
  5380.  
  5381.  
  5382.  
  5383.  
  5384.                                                                          84
  5385.  
  5386.  
  5387.  
  5388.  
  5389.  
  5390.  
  5391.           GETTAN
  5392.  
  5393.             PROTOTYPE
  5394.  
  5395.             extern long far gettan (long angle)
  5396.  
  5397.             INPUT
  5398.  
  5399.             angle - angle in degrees
  5400.  
  5401.             OUTPUT
  5402.  
  5403.             GETTAN returns the tangent of angle scaled up by 13 bits
  5404.             (8192)
  5405.  
  5406.             USAGE
  5407.  
  5408.             GETTAN returns the tangent of the specified angle.  Angle can
  5409.             be any long value except +(90+n*180), where n is an integer.
  5410.             The return value has been multiplied by 8192.  If an invalid
  5411.             angle is given, the GETTAN will return &H80000000 (-
  5412.             2147483648).  This function uses an integer lookup table
  5413.             stored within the library in order to produce the fastest
  5414.             possible results.  No floating point arithmetic is used.  The
  5415.             scale factor of 13 bits (8192) was chosen because this is the
  5416.             number of bits at which every change of one degree gives a
  5417.             change in the value of the sine (or cosine) function.
  5418.  
  5419.             SEE ALSO
  5420.  
  5421.             GETARCCOS, GETARCSIN, GETARCTAN, GETCOS, GETSIN
  5422.  
  5423.             EXAMPLE
  5424.  
  5425.             /*
  5426.              * show gettan
  5427.              */
  5428.  
  5429.             #include <stdlib.h>
  5430.             #include <conio.h>
  5431.             #include "svgacc.h"
  5432.  
  5433.             void main(void)
  5434.             {
  5435.                int tanang, ang;
  5436.                float value;
  5437.  
  5438.                for(ang=0;ang<90;ang+=5)
  5439.                {
  5440.                  value = (float)gettan(ang) / 8192;
  5441.                  printf("tan of %d degrees = %f\n",ang,value);
  5442.                }
  5443.                exit(0);
  5444.             }
  5445.  
  5446.  
  5447.                                                                          85
  5448.  
  5449.  
  5450.  
  5451.  
  5452.  
  5453.  
  5454.           GIFGETINFO
  5455.  
  5456.             PROTOTYPE
  5457.  
  5458.             extern int far gifgetinfo (const char far *name, int far
  5459.                *gifxsize, int far *gifysize, int far *numcolors, RGB far
  5460.                *pal)
  5461.  
  5462.             INPUT
  5463.  
  5464.             name - char pointer to the filename of the GIF image to read
  5465.  
  5466.             OUTPUT
  5467.  
  5468.             GIFGETINFO returns 1 if successful, error code otherwise.
  5469.             gifxsize - width in pixels of the image
  5470.             gifysize - height in pixels of the image
  5471.             numcolors - number of colors in the image palette
  5472.             palette - copy of image palette
  5473.  
  5474.             USAGE
  5475.  
  5476.             GIFGETINFO reads name and returns the characteristics of the
  5477.             image.  The dimensions of the image are returned in gifxsize,
  5478.             gifysize.  The number of colors in the image's palette is
  5479.             returned in numcolors and the palette is returned in palette.
  5480.             Although the image's palette may contain less than 256 colors,
  5481.             palette must be 768 bytes in length.  The image's palette will
  5482.             begin with the first color in Palette.
  5483.  
  5484.             For ease of programming the GIF decoder requires that the
  5485.             image be non-interlaced, use only a global color map and be
  5486.             compressed according to GIF87A specifications.
  5487.  
  5488.             If GIFGETINFO determines that Filename is a satisfactory file,
  5489.             the function will return a one.  Otherwise, the function will
  5490.             return one of several error codes as listed below:
  5491.  
  5492.             0 =  does not exist or there is some disk I/O problem
  5493.             -1 = does not have the GIF87A signature
  5494.             -2 = image is interlaced
  5495.             -3 = does not use a global color map
  5496.             -4 = has some general error
  5497.  
  5498.             SEE ALSO
  5499.  
  5500.             GIFMAKE, GIFPUT
  5501.  
  5502.             EXAMPLE
  5503.  
  5504.             /*
  5505.              * show the info on the 'uttower.gif' GIF file
  5506.              */
  5507.  
  5508.  
  5509.  
  5510.                                                                          86
  5511.  
  5512.  
  5513.  
  5514.  
  5515.  
  5516.  
  5517.             #include <stdlib.h>
  5518.             #include <conio.h>
  5519.             #include "svgacc.h"
  5520.  
  5521.             void main(void)
  5522.             {
  5523.                int vmode, xsize, ysize, numcol, ok;
  5524.                int i, darkcolor, britecolor, currcolor;
  5525.                PaletteData gifpal;
  5526.                char buf[80];
  5527.                char fname[] = "uttower.gif";
  5528.  
  5529.                vmode = videomodeget();
  5530.                if ( !whichvga() || (whichmem() < 512))
  5531.                  exit(1);
  5532.  
  5533.                ok = gifgetinfo(fname,&xsize,&ysize,&numcol,gifpal);
  5534.  
  5535.                if (ok == 1) {
  5536.                  if ( !res640() )
  5537.                     exit(1);
  5538.  
  5539.                  /* we have an unknown 8 bit palette and we must cut it
  5540.             down to
  5541.                     6 bits and find the brightest and darkest colors */
  5542.                  darkcolor = 0 + 0 + 0;
  5543.                  britecolor = 63 + 63 + 63;
  5544.                  for(i=0;i<255;i++) {
  5545.                     gifpal[i].r >>= 2;
  5546.                     gifpal[i].g >>= 2;
  5547.                     gifpal[i].b >>= 2;
  5548.                     currcolor = gifpal[i].r + gifpal[i].g + gifpal[i].b;
  5549.                     if (currcolor > darkcolor)
  5550.                       darkcolor = currcolor;
  5551.                     if (currcolor < britecolor)
  5552.                       britecolor = currcolor;
  5553.                  }
  5554.                  palset(gifpal,0,255);
  5555.                  fillscreen(darkcolor);
  5556.                  sprintf(buf,"'%s' is identified as a 'Non-interlaced'
  5557.             type 'GIF87a' GIF image.",fname);
  5558.                  drwstring(1,britecolor,darkcolor,buf,0,0);
  5559.                  sprintf(buf,"Dimensions are: %d pixels wide and %d pixels
  5560.             high.",xsize,ysize);
  5561.                  drwstring(1,britecolor,darkcolor,buf,0,16);
  5562.                  sprintf(buf,"Number of colors: %d.",numcol);
  5563.                  drwstring(1,britecolor,darkcolor,buf,0,32);
  5564.                  gifput(SET,100,100,fname);
  5565.                } else {
  5566.                  printf("error in GIF file, error code: %d\n",ok);
  5567.                }
  5568.                getch();
  5569.                videomodeset(vmode);
  5570.             }
  5571.  
  5572.  
  5573.                                                                          87
  5574.  
  5575.  
  5576.  
  5577.  
  5578.  
  5579.  
  5580.           GIFMAKE
  5581.  
  5582.             PROTOTYPE
  5583.  
  5584.             extern int far gifmake (int x1, int y1, int x2, int y2, const
  5585.             char far *name)
  5586.  
  5587.             INPUT
  5588.  
  5589.             x1, y1 - the location of the top, left corner of the image
  5590.             x2, y2 - the bottom, right corner of the image
  5591.             name - filename to store the GIF image
  5592.  
  5593.             OUTPUT
  5594.  
  5595.             GIFMAKE returns a 1 if successful, 0 if unsuccessful.
  5596.  
  5597.             USAGE
  5598.  
  5599.             GIFMAKE takes the bitmap enclosed in the box defined by (x1,
  5600.             y1) - (x2, y2) and writes a GIF with the filename specified by
  5601.             name.  The resulting file uses the GIF87a compression
  5602.             specifications.  The values x1, y1, x2 and y2 must be valid
  5603.             coordinates on the currently active page.  Name may specify a
  5604.             full path and drive letter, if necessary.
  5605.  
  5606.             SEE ALSO
  5607.  
  5608.             GIFGETINFO, GIFPUT
  5609.  
  5610.             EXAMPLE
  5611.  
  5612.             /*
  5613.              * Make a simple GIF file
  5614.              */
  5615.  
  5616.             #include <stdlib.h>
  5617.             #include <conio.h>
  5618.             #include "svgacc.h"
  5619.             #define randnum(size) (rand() % (int)(size))
  5620.  
  5621.             void main(void)
  5622.             {
  5623.                int vmode,colr,num,i;
  5624.                int x1,y1,x2,y2,er;
  5625.                char text[]="This GIF was made using Zephyr Software's
  5626.             GIFMAKE function!";
  5627.                char fname[]="test.gif";
  5628.  
  5629.                vmode = videomodeget();
  5630.                if ( !whichvga() || (whichmem() < 512))
  5631.                  exit(1);
  5632.                if ( !res640() )
  5633.                  exit(1);
  5634.  
  5635.  
  5636.                                                                          88
  5637.  
  5638.  
  5639.  
  5640.  
  5641.  
  5642.  
  5643.                fillscreen(10);
  5644.                colr = 1;
  5645.                for(i=0;i<200;i++) {
  5646.                  x1 = randnum(maxx);
  5647.                  y1 = randnum(maxy);
  5648.                  x2 = randnum(maxx);
  5649.                  y2 = randnum(maxy);
  5650.                  drwline(1,colr++,x1,y1,x2,y2);
  5651.                  if (colr>15)
  5652.                     colr = 1;
  5653.                }
  5654.                drwbox(SET,15,0,0,maxx,maxy);
  5655.                drwstring(1,15,0,text,60,10);
  5656.                er = gifmake(0,0,maxx,maxy,fname);
  5657.                if (er != 1 ) {
  5658.                  videomodeset(vmode);
  5659.                  exit(1);
  5660.                }
  5661.  
  5662.                videomodeset(vmode);
  5663.                exit(0);
  5664.             } 
  5665.  
  5666.  
  5667.  
  5668.  
  5669.  
  5670.  
  5671.  
  5672.  
  5673.  
  5674.  
  5675.  
  5676.  
  5677.  
  5678.  
  5679.  
  5680.  
  5681.  
  5682.  
  5683.  
  5684.  
  5685.  
  5686.  
  5687.  
  5688.  
  5689.  
  5690.  
  5691.  
  5692.  
  5693.  
  5694.  
  5695.  
  5696.  
  5697.  
  5698.  
  5699.                                                                          89
  5700.  
  5701.  
  5702.  
  5703.  
  5704.  
  5705.  
  5706.           GIFPUT
  5707.  
  5708.             PROTOTYPE
  5709.  
  5710.             extern int far gifput (PixelMode mode, int xloc, int yloc,
  5711.             const char far *name)
  5712.  
  5713.             INPUT
  5714.  
  5715.             mode - pixel write mode
  5716.             xloc, yloc - the location of the top, left corner of the GIF
  5717.             image
  5718.             name - char pointer to filename of the GIF image to read
  5719.  
  5720.             OUTPUT
  5721.  
  5722.             GIFPUT returns 1 if successful, error code otherwise.
  5723.  
  5724.             USAGE
  5725.  
  5726.             GIFPUT reads the GIF image from name and places it on the
  5727.             screen with the top, left corner at xloc, yloc.  The image is
  5728.             automatically clipped to the currently defined viewport.  The
  5729.             image's palette should be previously obtained by using
  5730.             GIFGETINFO.
  5731.  
  5732.             For ease of programming the GIF decoder requires that the
  5733.             image be non-interlaced, use only a global color map and be
  5734.             compressed according to the GIF87A specifications.
  5735.  
  5736.             If GIFPUT encounters no problems, the function will return a
  5737.             one.  Otherwise, the function will return one of several error
  5738.             codes as listed below:
  5739.  
  5740.             0 =  does not exist or there is some disk I/O problem
  5741.             -1 = does not have the GIF87A signature
  5742.             -2 = image is interlaced
  5743.             -3 = does not use a global color map
  5744.             -4 = has some general error
  5745.  
  5746.             SEE ALSO
  5747.  
  5748.             GIFGETINFO, GIFMAKE, SETVIEW
  5749.  
  5750.             EXAMPLE
  5751.  
  5752.             See GIFGETINFO
  5753.  
  5754.  
  5755.  
  5756.  
  5757.  
  5758.  
  5759.  
  5760.  
  5761.  
  5762.                                                                          90
  5763.  
  5764.  
  5765.  
  5766.  
  5767.  
  5768.  
  5769.           JOYSTICKINFO
  5770.  
  5771.             PROTOTYPE
  5772.  
  5773.             extern void far joystickinfo (int far *jax, int far *jay, int
  5774.             far *jabuts, int far *jbx, int far *jby, int far *jbbuts)
  5775.  
  5776.             INPUT
  5777.  
  5778.             no input parameters
  5779.  
  5780.             OUTPUT
  5781.  
  5782.             jax, jay - horizontal and vertical values of joystick A
  5783.             jabuts - button status of joystick A
  5784.             jbx, jby - horizontal and vertical values of joystick B
  5785.             jbbuts - button status of joystick B
  5786.  
  5787.             USAGE
  5788.  
  5789.             JOYSTICKINFO returns the current status of the two joysticks'
  5790.             position and buttons.  The position is returned in jax, jay
  5791.             for joystick A and jbx, jby for joystick B.  The buttons'
  5792.             status is held in jabuts and jbbuts.  For each joystick,
  5793.             button A - usually the fire button - is held in bit zero and
  5794.             button B is in bit one.  Button status is most easily checked
  5795.             with a bitwise AND of jabuts (or jbbuts) and the desired bit.
  5796.  
  5797.             Not all joysticks are constructed with the same components.
  5798.             In addition, joysticks are not linear devices.  The value of a
  5799.             joystick's center will not necessarily be the mean of its
  5800.             extreme values.  Therefore, it is recommended that any program
  5801.             using the joystick for more than just directional control
  5802.             complete a calibration of the joystick prior to usage.  For an
  5803.             example of joystick calibration, see the SVGADEMO.EXE source
  5804.             code.
  5805.  
  5806.             It is recommended, though not required, to call WHICHJOYSTICK,
  5807.             prior to using the joysticks in order to verify the existence
  5808.             of the hardware.
  5809.  
  5810.             SEE ALSO
  5811.  
  5812.             WHICHJOYSTICK
  5813.  
  5814.             EXAMPLE
  5815.  
  5816.             /*
  5817.              * show joysticks port readings
  5818.              */
  5819.  
  5820.             #include <stdlib.h>
  5821.             #include <conio.h>
  5822.             #include "svgacc.h"
  5823.  
  5824.  
  5825.                                                                          91
  5826.  
  5827.  
  5828.  
  5829.  
  5830.  
  5831.  
  5832.  
  5833.             void main(void)
  5834.             {
  5835.                int vmode;
  5836.                int jax, jay, jabuts, jbx, jby, jbbuts;
  5837.  
  5838.                printf("A:  X    Y  btn | B:  X    Y  btn\n  ");
  5839.                while(!kbhit()) {
  5840.                  joystickinfo(&jax,&jay,&jabuts,&jbx,&jby,&jbbuts);
  5841.                  printf("%04d %04d  %1d  |   ",jax,jay,jabuts);
  5842.                  printf("%04d %04d  %1d",jbx,jby,jbbuts);
  5843.                  printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
  5844.                  printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
  5845.                }
  5846.                getch();
  5847.             }
  5848.  
  5849.  
  5850.  
  5851.  
  5852.  
  5853.  
  5854.  
  5855.  
  5856.  
  5857.  
  5858.  
  5859.  
  5860.  
  5861.  
  5862.  
  5863.  
  5864.  
  5865.  
  5866.  
  5867.  
  5868.  
  5869.  
  5870.  
  5871.  
  5872.  
  5873.  
  5874.  
  5875.  
  5876.  
  5877.  
  5878.  
  5879.  
  5880.  
  5881.  
  5882.  
  5883.  
  5884.  
  5885.  
  5886.  
  5887.  
  5888.                                                                          92
  5889.  
  5890.  
  5891.  
  5892.  
  5893.  
  5894.  
  5895.           MOUSEBUTPRESS
  5896.  
  5897.             PROTOTYPE
  5898.  
  5899.             extern void far mousebutpress (int reqbut, int far *xloc, int
  5900.             far *yloc, int far *num, int far *mbuts)
  5901.  
  5902.             INPUT
  5903.  
  5904.             reqbut - button for which information is requested
  5905.  
  5906.             OUTPUT
  5907.  
  5908.             x, y - current location of mouse cursor
  5909.             num - number of times requested button has been pressed since
  5910.             last request
  5911.             mbuts - current status of mouse buttons
  5912.  
  5913.             USAGE
  5914.  
  5915.             MOUSEBUTPRESS returns in Num the number of times a mouse
  5916.             button has been pressed since the last call to MOUSEBUTPRESS.
  5917.             In addition the current status of the mouse cursor and buttons
  5918.             is returned.  The position is returned in X, Y.  The buttons'
  5919.             status is held in mbuts.  The left button is held in bit zero,
  5920.             right button in bit one and center button - for three button
  5921.             mice - in bit two.  Button status is most easily checked with
  5922.             a bitwise AND of mbuts and the desired bit.  The button for
  5923.             which a history is desired is identified by the bits in
  5924.             reqbut.  However, only one bit in reqbut may be set.
  5925.             Therefore, only the values of 1, 2 and 4 are permitted.  If
  5926.             more than one bit in reqbut is set, the function will exit and
  5927.             no information will be returned.
  5928.  
  5929.             SEE ALSO
  5930.  
  5931.             MOUSEBUTRELEASE, MOUSESTATUS
  5932.  
  5933.             EXAMPLE
  5934.  
  5935.             /* enable,show mouse / display left button press history for
  5936.             the last 2
  5937.              * seconds
  5938.              */
  5939.  
  5940.             #include <stdlib.h>
  5941.             #include <conio.h>
  5942.             #include "svgacc.h"
  5943.  
  5944.             void main(void)
  5945.             {
  5946.                int vmode, x, y, n, mbuts;
  5947.                char text[50];
  5948.  
  5949.  
  5950.  
  5951.                                                                          93
  5952.  
  5953.  
  5954.  
  5955.  
  5956.  
  5957.  
  5958.                char textclr[]="
  5959.             ";
  5960.  
  5961.                vmode = videomodeget();
  5962.                if ( !whichvga() )
  5963.                  exit(1);
  5964.                if ( whichmem() < 512)
  5965.                  exit(1);
  5966.                if ( !whichmouse())
  5967.                  exit(1);
  5968.                res640();
  5969.                mousecursordefault();
  5970.                mouseenter();
  5971.                mouseshow();
  5972.                while(!kbhit())
  5973.                {
  5974.                  mousebutpress(1,&x,&y,&n,&mbuts);
  5975.                  sprintf(text,"mouse x loc: %3d, y loc: %3d, number of
  5976.             times: %2d",x,y,n);
  5977.                  mousehide();
  5978.                  drwstring(1,15,8,text,0,0);
  5979.                  mouseshow();
  5980.                  sdelay(80);
  5981.                  mousehide();
  5982.                  drwstring(1,15,8,textclr,0,0);
  5983.                  mouseshow();
  5984.                }
  5985.                mousehide();
  5986.                mouseexit();
  5987.                videomodeset(vmode);
  5988.                exit(0);
  5989.             }
  5990.  
  5991.  
  5992.  
  5993.  
  5994.  
  5995.  
  5996.  
  5997.  
  5998.  
  5999.  
  6000.  
  6001.  
  6002.  
  6003.  
  6004.  
  6005.  
  6006.  
  6007.  
  6008.  
  6009.  
  6010.  
  6011.  
  6012.  
  6013.  
  6014.                                                                          94
  6015.  
  6016.  
  6017.  
  6018.  
  6019.  
  6020.  
  6021.           MOUSEBUTRELEASE
  6022.  
  6023.             PROTOTYPE
  6024.  
  6025.             extern void far mousebutrelease (int reqbut, int far *xloc,
  6026.             int far *yloc, int far *num, int far *mbuts)
  6027.  
  6028.             INPUT
  6029.  
  6030.             reqbut - button for which information is requested
  6031.  
  6032.             OUTPUT
  6033.  
  6034.             x, y - current location of mouse cursor
  6035.             num - number of times requested button has been released since
  6036.             last request
  6037.             mbuts - current status of mouse buttons
  6038.  
  6039.             USAGE
  6040.  
  6041.             MOUSEBUTRELEASE returns in Num the number of times a mouse
  6042.             button has been released since the last call to
  6043.             MOUSEBUTRELEASE.  In addition the current status of the mouse
  6044.             cursor and buttons is returned.  The position is returned in
  6045.             x, y.  The buttons' status is held in mbuts.  The left button
  6046.             is held in bit zero, right button in bit one and center button
  6047.             - for three button mice - in bit two.  Button status is most
  6048.             easily checked with a bitwise AND of mbuts and the desired
  6049.             bit.  The button for which a history is desired is identified
  6050.             by the bits in reqbut.  However, only one bit in reqbut may be
  6051.             set.  Therefore, only the values of 1, 2 and 4 are permitted.
  6052.             If more than one bit in reqbut is set, the function will exit
  6053.             and no information will be returned.
  6054.  
  6055.             SEE ALSO
  6056.  
  6057.             MOUSEBUTPRESS, MOUSESTATUS
  6058.  
  6059.             EXAMPLE
  6060.  
  6061.             /* enable,show mouse / display left button release history for
  6062.             the last
  6063.              * 2 seconds
  6064.              */
  6065.  
  6066.             #include <stdlib.h>
  6067.             #include <conio.h>
  6068.             #include "svgacc.h"
  6069.  
  6070.             void main(void)
  6071.             {
  6072.                int vmode, x, y, n, mbuts;
  6073.                char text[50];
  6074.  
  6075.  
  6076.  
  6077.                                                                          95
  6078.  
  6079.  
  6080.  
  6081.  
  6082.  
  6083.  
  6084.                char textclr[]="
  6085.             ";
  6086.  
  6087.                vmode = videomodeget();
  6088.                if ( !whichvga() )
  6089.                  exit(1);
  6090.                if ( whichmem() < 512)
  6091.                  exit(1);
  6092.                if ( !whichmouse())
  6093.                  exit(1);
  6094.                res640();
  6095.                mousecursordefault();
  6096.                mouseenter();
  6097.                mouseshow();
  6098.                while(!kbhit())
  6099.                {
  6100.                  mousebutrelease(1,&x,&y,&n,&mbuts);
  6101.                  sprintf(text,"mouse x loc: %3d, y loc: %3d, number of
  6102.             times: %2d",x,y,n);
  6103.                  mousehide();
  6104.                  drwstring(1,15,8,text,0,0);
  6105.                  mouseshow();
  6106.                  sdelay(80);
  6107.                  mousehide();
  6108.                  drwstring(1,15,8,textclr,0,0);
  6109.                  mouseshow();
  6110.                }
  6111.                mousehide();
  6112.                mouseexit();
  6113.                videomodeset(vmode);
  6114.                exit(0);
  6115.             }
  6116.  
  6117.  
  6118.  
  6119.  
  6120.  
  6121.  
  6122.  
  6123.  
  6124.  
  6125.  
  6126.  
  6127.  
  6128.  
  6129.  
  6130.  
  6131.  
  6132.  
  6133.  
  6134.  
  6135.  
  6136.  
  6137.  
  6138.  
  6139.  
  6140.                                                                          96
  6141.  
  6142.  
  6143.  
  6144.  
  6145.  
  6146.  
  6147.           MOUSECURSORSET
  6148.  
  6149.             PROTOTYPE
  6150.  
  6151.             extern void far mousecursorset (MouseCursor far *mousecursor)
  6152.  
  6153.             INPUT
  6154.  
  6155.             mousecursor - MouseCursor pointer to mouse cursor data
  6156.  
  6157.             OUTPUT
  6158.  
  6159.             no value returned
  6160.  
  6161.             USAGE
  6162.  
  6163.             MOUSECURSORSET defines the cursor according to the data in the
  6164.             MouseCursor structure.  The hot spot for the cursor is set by
  6165.             mousecursor.hotspotx, mousecursor.hotspoty.  The values for
  6166.             mousecursor.hotspotx and mousecursor.hotspoty must be within
  6167.             the cursor.  Valid mousecursor.hotspotx values are from 0 to
  6168.             15 and mousecursor.hotspoty ranges from 0 to 23.
  6169.  
  6170.             SEE ALSO
  6171.  
  6172.             MOUSECURSORDEFAULT, MOUSEENTER, MOUSESHOW
  6173.  
  6174.             EXAMPLE
  6175.  
  6176.             /*
  6177.              * enable,show mouse, and switch to a different mouse cursor
  6178.              */
  6179.  
  6180.             #include <stdlib.h>
  6181.             #include <conio.h>
  6182.             #include "svgacc.h"
  6183.  
  6184.             void main(void)
  6185.             {
  6186.                int vmode;
  6187.  
  6188.                MouseCursor bigmousecursor = {
  6189.                  1,1,
  6190.  
  6191.                0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,
  6192.                  0,15,15,0,0,255,255,255,255,255,255,255,255,255,255,255,
  6193.                  0,15,15,15,15,0,0,0,255,255,255,255,255,255,255,255,
  6194.                  0,15,15,15,15,15,15,15,0,0,255,255,255,255,255,255,
  6195.                  0,15,15,15,15,15,15,15,15,15,0,0,0,255,255,255,
  6196.                  0,15,15,15,15,15,15,15,15,15,15,15,15,0,0,255,
  6197.                  0,15,15,15,15,15,15,15,15,15,15,15,15,15,0,255,
  6198.                  0,15,15,15,15,15,15,15,15,15,15,15,0,0,255,255,
  6199.                  0,15,15,15,15,15,15,15,15,15,15,0,255,255,255,255,
  6200.                  0,15,15,15,15,15,15,15,15,0,0,255,255,255,255,255,
  6201.  
  6202.  
  6203.                                                                          97
  6204.  
  6205.  
  6206.  
  6207.  
  6208.  
  6209.  
  6210.                  0,15,15,15,15,15,15,15,15,0,255,255,255,255,255,255,
  6211.                  0,15,15,15,15,15,0,15,15,15,0,255,255,255,255,255,
  6212.                  0,15,15,15,15,0,0,15,15,15,0,255,255,255,255,255,
  6213.                  0,15,15,0,0,255,255,0,15,15,15,0,255,255,255,255,
  6214.                  0,15,0,255,255,255,255,0,15,15,15,0,255,255,255,255,
  6215.                  0,0,255,255,255,255,255,255,0,15,15,15,0,255,255,255,
  6216.                  255,255,255,255,255,255,255,255,255,0,15,15,15,0,255,255,
  6217.                  255,255,255,255,255,255,255,255,255,0,15,15,15,0,255,255,
  6218.                  255,255,255,255,255,255,255,255,255,255,0,15,15,15,0,255,
  6219.                  255,255,255,255,255,255,255,255,255,255,255,0,15,15,15,0,
  6220.                  255,255,255,255,255,255,255,255,255,255,255,0,15,15,15,0,
  6221.  
  6222.                255,255,255,255,255,255,255,255,255,255,255,255,0,15,15,0,
  6223.  
  6224.                255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,
  6225.  
  6226.                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  6227.             255
  6228.                };
  6229.  
  6230.                vmode = videomodeget();
  6231.                if ( !whichvga() )
  6232.                  exit(1);
  6233.                if ( whichmem() < 512)
  6234.                  exit(1);
  6235.                if ( !whichmouse())
  6236.                  exit(1);
  6237.                res640();
  6238.                mouseenter();
  6239.                drwstring(1,7,0,"press a key to return to default
  6240.             cursor",0,0);
  6241.                mousecursorset(bigmousecursor);
  6242.                mouseshow();
  6243.                getch();
  6244.                mousecursordefault();
  6245.                drwstring(1,7,0,"press a key to end
  6246.             ",0,0);
  6247.                getch();
  6248.                mousehide();
  6249.                mouseexit();
  6250.                videomodeset(vmode);
  6251.                exit(0);
  6252.             }
  6253.  
  6254.  
  6255.  
  6256.  
  6257.  
  6258.  
  6259.  
  6260.  
  6261.  
  6262.  
  6263.  
  6264.  
  6265.  
  6266.                                                                          98
  6267.  
  6268.  
  6269.  
  6270.  
  6271.  
  6272.  
  6273.           MOUSECURSORDEFAULT
  6274.  
  6275.             PROTOTYPE
  6276.  
  6277.             extern void far mousecursordefault (void)
  6278.  
  6279.             INPUT
  6280.  
  6281.             no input parameters
  6282.  
  6283.             OUTPUT
  6284.  
  6285.             no value returned
  6286.  
  6287.             USAGE
  6288.  
  6289.             MOUSECURSORDEFAULT defines the mouse cursor to be a small
  6290.             arrow with the hot spot in the upper, left corner.  This is
  6291.             the cursor set when MOUSEENTER is called.
  6292.  
  6293.             SEE ALSO
  6294.  
  6295.             MOUSECURSORSET, MOUSEENTER
  6296.  
  6297.             EXAMPLE
  6298.  
  6299.             See MOUSECURSORSET
  6300.  
  6301.  
  6302.  
  6303.  
  6304.  
  6305.  
  6306.  
  6307.  
  6308.  
  6309.  
  6310.  
  6311.  
  6312.  
  6313.  
  6314.  
  6315.  
  6316.  
  6317.  
  6318.  
  6319.  
  6320.  
  6321.  
  6322.  
  6323.  
  6324.  
  6325.  
  6326.  
  6327.  
  6328.  
  6329.                                                                          99
  6330.  
  6331.  
  6332.  
  6333.  
  6334.  
  6335.  
  6336.           MOUSEENTER
  6337.  
  6338.             PROTOTYPE
  6339.  
  6340.             extern void far mouseenter (void)
  6341.  
  6342.             INPUT
  6343.  
  6344.             no input parameters
  6345.  
  6346.             OUTPUT
  6347.  
  6348.             no value returned
  6349.  
  6350.             USAGE
  6351.  
  6352.             MOUSEENTER must be called before any other mouse functions.
  6353.             It initializes all of the mouse abilities including installing
  6354.             the Zephyr mouse display driver.  MOUSEENTER initializes the
  6355.             default mouse cursor, the default sensitivity and sets the
  6356.             range to the current screen resolution.  The mouse cursor
  6357.             location is set to the middle of the screen.
  6358.  
  6359.             SEE ALSO
  6360.  
  6361.             MOUSEEXIT, MOUSEHIDE, MOUSESHOW
  6362.  
  6363.             EXAMPLE
  6364.  
  6365.             /*
  6366.              * enable,show mouse
  6367.              */
  6368.             #include <stdlib.h>
  6369.             #include <conio.h>
  6370.             #include "svgacc.h"
  6371.  
  6372.             void main(void)
  6373.             {
  6374.                int vmode;
  6375.  
  6376.                vmode = videomodeget();
  6377.                if ( !whichvga() )
  6378.                  exit(1);
  6379.                if ( whichmem() < 512)
  6380.                  exit(1);
  6381.                if ( !whichmouse())
  6382.                  exit(1);
  6383.                res640();
  6384.                mouseenter();
  6385.                mouseshow();
  6386.                getch();
  6387.                mousehide();
  6388.                mouseexit();
  6389.                videomodeset(vmode);
  6390.  
  6391.  
  6392.                                                                         100
  6393.  
  6394.  
  6395.  
  6396.  
  6397.  
  6398.  
  6399.                exit(0);
  6400.             }
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406.  
  6407.  
  6408.  
  6409.  
  6410.  
  6411.  
  6412.  
  6413.  
  6414.  
  6415.  
  6416.  
  6417.  
  6418.  
  6419.  
  6420.  
  6421.  
  6422.  
  6423.  
  6424.  
  6425.  
  6426.  
  6427.  
  6428.  
  6429.  
  6430.  
  6431.  
  6432.  
  6433.  
  6434.  
  6435.  
  6436.  
  6437.  
  6438.  
  6439.  
  6440.  
  6441.  
  6442.  
  6443.  
  6444.  
  6445.  
  6446.  
  6447.  
  6448.  
  6449.  
  6450.  
  6451.  
  6452.  
  6453.  
  6454.  
  6455.                                                                         101
  6456.  
  6457.  
  6458.  
  6459.  
  6460.  
  6461.  
  6462.           MOUSEEXIT
  6463.  
  6464.             PROTOTYPE
  6465.  
  6466.             extern void far mouseexit (void)
  6467.  
  6468.             INPUT
  6469.  
  6470.             no input parameters
  6471.  
  6472.             OUTPUT
  6473.  
  6474.             no value returned
  6475.  
  6476.             USAGE
  6477.  
  6478.             MOUSEEXIT properly disables all of the mouse abilities.  This
  6479.             function also removes the Zephyr mouse display driver.  This
  6480.             function should be called prior to exiting any program that
  6481.             previously called MOUSEENTER.
  6482.  
  6483.             SEE ALSO
  6484.  
  6485.             MOUSEENTER, MOUSEHIDE, MOUSESHOW
  6486.  
  6487.             EXAMPLE
  6488.  
  6489.             /*
  6490.              * enable,show mouse, then disable it
  6491.              */
  6492.             #include <stdlib.h>
  6493.             #include <conio.h>
  6494.             #include "svgacc.h"
  6495.  
  6496.             void main(void)
  6497.             {
  6498.                int vmode;
  6499.  
  6500.                vmode = videomodeget();
  6501.                if ( !whichvga() )
  6502.                  exit(1);
  6503.                if ( whichmem() < 512)
  6504.                  exit(1);
  6505.                if ( !whichmouse())
  6506.                  exit(1);
  6507.                res640();
  6508.                mousecursordefault();
  6509.                mouseenter();
  6510.                mouseshow();
  6511.                getch();
  6512.                mousehide();
  6513.                mouseexit();
  6514.                videomodeset(vmode);
  6515.                exit(0);
  6516.  
  6517.  
  6518.                                                                         102
  6519.  
  6520.  
  6521.  
  6522.  
  6523.  
  6524.  
  6525.             }
  6526.  
  6527.  
  6528.  
  6529.  
  6530.  
  6531.  
  6532.  
  6533.  
  6534.  
  6535.  
  6536.  
  6537.  
  6538.  
  6539.  
  6540.  
  6541.  
  6542.  
  6543.  
  6544.  
  6545.  
  6546.  
  6547.  
  6548.  
  6549.  
  6550.  
  6551.  
  6552.  
  6553.  
  6554.  
  6555.  
  6556.  
  6557.  
  6558.  
  6559.  
  6560.  
  6561.  
  6562.  
  6563.  
  6564.  
  6565.  
  6566.  
  6567.  
  6568.  
  6569.  
  6570.  
  6571.  
  6572.  
  6573.  
  6574.  
  6575.  
  6576.  
  6577.  
  6578.  
  6579.  
  6580.  
  6581.                                                                         103
  6582.  
  6583.  
  6584.  
  6585.  
  6586.  
  6587.  
  6588.           MOUSEHIDE
  6589.  
  6590.             PROTOTYPE
  6591.  
  6592.             extern void far mousehide (void)
  6593.  
  6594.             INPUT
  6595.  
  6596.             no input parameters
  6597.  
  6598.             OUTPUT
  6599.  
  6600.             no value returned
  6601.  
  6602.             USAGE
  6603.  
  6604.             MOUSEHIDE turns off the mouse display driver and removes the
  6605.             cursor from the display.  It is recommended to hide the mouse
  6606.             any time something will be drawn in its general vicinity.
  6607.             Note, however, that although the cursor is not visible, all
  6608.             other mouse abilities remain active.
  6609.  
  6610.             SEE ALSO
  6611.  
  6612.             MOUSEENTER, MOUSEEXIT, MOUSESHOW
  6613.  
  6614.             EXAMPLE
  6615.  
  6616.             /*
  6617.              * enable,show mouse,hide mouse
  6618.              */
  6619.             #include <stdlib.h>
  6620.             #include <conio.h>
  6621.             #include "svgacc.h"
  6622.             void main(void)
  6623.             {
  6624.                int vmode;
  6625.  
  6626.                vmode = videomodeget();
  6627.                if ( !whichvga() )
  6628.                  exit(1);
  6629.                if ( whichmem() < 512)
  6630.                  exit(1);
  6631.                if ( !whichmouse())
  6632.                  exit(1);
  6633.                res640();
  6634.                mousecursordefault();
  6635.                mouseenter();
  6636.                mouseshow();
  6637.                getch();
  6638.                mousehide();
  6639.                getch();
  6640.                mouseexit();
  6641.                videomodeset(vmode);
  6642.  
  6643.  
  6644.                                                                         104
  6645.  
  6646.  
  6647.  
  6648.  
  6649.  
  6650.  
  6651.                exit(0);
  6652.             }
  6653.  
  6654.  
  6655.  
  6656.  
  6657.  
  6658.  
  6659.  
  6660.  
  6661.  
  6662.  
  6663.  
  6664.  
  6665.  
  6666.  
  6667.  
  6668.  
  6669.  
  6670.  
  6671.  
  6672.  
  6673.  
  6674.  
  6675.  
  6676.  
  6677.  
  6678.  
  6679.  
  6680.  
  6681.  
  6682.  
  6683.  
  6684.  
  6685.  
  6686.  
  6687.  
  6688.  
  6689.  
  6690.  
  6691.  
  6692.  
  6693.  
  6694.  
  6695.  
  6696.  
  6697.  
  6698.  
  6699.  
  6700.  
  6701.  
  6702.  
  6703.  
  6704.  
  6705.  
  6706.  
  6707.                                                                         105
  6708.  
  6709.  
  6710.  
  6711.  
  6712.  
  6713.  
  6714.           MOUSEINFO
  6715.  
  6716.             PROTOTYPE
  6717.  
  6718.             extern void far mouseinfo (int far *drvmajorver, int far
  6719.             *drvminorver, int far *mousetype, int far *irqnumber)
  6720.  
  6721.             INPUT
  6722.  
  6723.             no input parameters
  6724.  
  6725.             OUTPUT
  6726.  
  6727.             drvmajorver - Microsoft compatible mouse driver major version
  6728.             number
  6729.             drvminorver - Microsoft compatible mouse driver minor version
  6730.             number
  6731.             mousetype - type of mouse installed
  6732.             irqnumber - interrupt used by the mouse
  6733.  
  6734.             USAGE
  6735.  
  6736.             MOUSEINFO returns information about the mouse and its
  6737.             installed driver.  The driver must be Microsoft compatible.
  6738.             This information can be used to determine whether the mouse
  6739.             functions in this library will operate correctly.  For proper
  6740.             operation the driver version number must be greater than 1.00.
  6741.             Irqnumber gives the interrupt number of the mouse.  Mousetype
  6742.             returns information about the type of hardware installed
  6743.             according to the following table:
  6744.  
  6745.             0 =  unknown type
  6746.             1 =  bus mouse
  6747.             2 =  serial mouse
  6748.             3 =  Inport mouse
  6749.             4 =  PS/2 mouse
  6750.             5 =  HP mouse
  6751.  
  6752.             SEE ALSO
  6753.  
  6754.             WHICHMOUSE
  6755.  
  6756.             EXAMPLE
  6757.  
  6758.             /*
  6759.              * id any installed mouse
  6760.              */
  6761.  
  6762.             #include <stdlib.h>
  6763.             #include <conio.h>
  6764.             #include "svgacc.h"
  6765.  
  6766.             void main(void)
  6767.             {
  6768.  
  6769.  
  6770.                                                                         106
  6771.  
  6772.  
  6773.  
  6774.  
  6775.  
  6776.  
  6777.                int mjv, mnv, tp, i, mouse;
  6778.                char buf[100];
  6779.  
  6780.                mouse = whichmouse();
  6781.                if (mouse > 0) {
  6782.                  mouseinfo(&mjv, &mnv, &tp, &i);
  6783.                  switch (tp) {
  6784.                     case 1:
  6785.                       sprintf(buf,"bus mouse");
  6786.                       break;
  6787.                     case 2:
  6788.                       sprintf(buf,"serial mouse");
  6789.                       break;
  6790.                     case 3:
  6791.                       sprintf(buf,"Inport mouse");
  6792.                       break;
  6793.                     case 4:
  6794.                       sprintf(buf,"PS/2 mouse");
  6795.                       break;
  6796.                     case 5:
  6797.                       sprintf(buf,"HP mouse");
  6798.                       break;
  6799.                     default:
  6800.                       sprintf(buf,"unknown type");
  6801.                  }
  6802.                  printf("Microsoft compatible %s detected with %d buttons
  6803.             on IRQ %d.\n", &buf, mouse, i);
  6804.                  printf("Software driver version is %d.%d (Microsoft
  6805.             equivalent version).\n\n", mjv, mnv);
  6806.  
  6807.                } else
  6808.                  printf("No Microsoft compatible mouse detected.\n\n");
  6809.             }
  6810.  
  6811.  
  6812.  
  6813.  
  6814.  
  6815.  
  6816.  
  6817.  
  6818.  
  6819.  
  6820.  
  6821.  
  6822.  
  6823.  
  6824.  
  6825.  
  6826.  
  6827.  
  6828.  
  6829.  
  6830.  
  6831.  
  6832.  
  6833.                                                                         107
  6834.  
  6835.  
  6836.  
  6837.  
  6838.  
  6839.  
  6840.           MOUSELOCSET
  6841.  
  6842.             PROTOTYPE
  6843.  
  6844.             extern void far mouselocset (int xloc, int yloc)
  6845.  
  6846.             INPUT
  6847.  
  6848.             x, y - location on screen
  6849.  
  6850.             OUTPUT
  6851.  
  6852.             no value returned
  6853.  
  6854.             USAGE
  6855.  
  6856.             MOUSELOCSET moves the mouse cursor the location on the screen
  6857.             specified by x, y.  If either x or y is outside of the
  6858.             currently permitted mouse range, it is set to the closest
  6859.             border.  The currently permitted mouse range is the current
  6860.             screen resolution or the last called MOUSERANGESET.
  6861.  
  6862.             SEE ALSO
  6863.  
  6864.             MOUSEENTER, MOUSERANGESET
  6865.  
  6866.             EXAMPLE
  6867.  
  6868.             /*
  6869.              * enable,show mouse then move it to the origin
  6870.              */
  6871.             #include <stdlib.h>
  6872.             #include <conio.h>
  6873.             #include "svgacc.h"
  6874.             void main(void)
  6875.             {
  6876.                int vmode;
  6877.                vmode = videomodeget();
  6878.                if ( !whichvga() )
  6879.                  exit(1);
  6880.                if ( whichmem() < 512)
  6881.                  exit(1);
  6882.                if ( !whichmouse())
  6883.                  exit(1);
  6884.                res640();
  6885.                mousecursordefault();
  6886.                mouseenter();
  6887.                mouseshow();
  6888.                getch();
  6889.                mouselocset(0,0);
  6890.                getch();
  6891.                mousehide();
  6892.                mouseexit();
  6893.                videomodeset(vmode);
  6894.  
  6895.  
  6896.                                                                         108
  6897.  
  6898.  
  6899.  
  6900.  
  6901.  
  6902.  
  6903.                exit(0);
  6904.             }
  6905.  
  6906.  
  6907.  
  6908.  
  6909.  
  6910.  
  6911.  
  6912.  
  6913.  
  6914.  
  6915.  
  6916.  
  6917.  
  6918.  
  6919.  
  6920.  
  6921.  
  6922.  
  6923.  
  6924.  
  6925.  
  6926.  
  6927.  
  6928.  
  6929.  
  6930.  
  6931.  
  6932.  
  6933.  
  6934.  
  6935.  
  6936.  
  6937.  
  6938.  
  6939.  
  6940.  
  6941.  
  6942.  
  6943.  
  6944.  
  6945.  
  6946.  
  6947.  
  6948.  
  6949.  
  6950.  
  6951.  
  6952.  
  6953.  
  6954.  
  6955.  
  6956.  
  6957.  
  6958.  
  6959.                                                                         109
  6960.  
  6961.  
  6962.  
  6963.  
  6964.  
  6965.  
  6966.           MOUSERANGESET
  6967.  
  6968.             PROTOTYPE
  6969.  
  6970.             extern void far mouserangeset (int x1, int y1, int x2, int y2)
  6971.  
  6972.             INPUT
  6973.  
  6974.             x1, y1 - location on screen of top, left corner of range
  6975.             x2, y2 - location on screen of bottom, right corner of range
  6976.  
  6977.             OUTPUT
  6978.  
  6979.             no value returned
  6980.  
  6981.             USAGE
  6982.  
  6983.             MOUSERANGESET defines a permissible range on the screen for
  6984.             mouse movement.  The mouse is automatically positioned in the
  6985.             center of this range.
  6986.  
  6987.             SEE ALSO
  6988.  
  6989.             MOUSELOCSET, MOUSESTATUS
  6990.  
  6991.             EXAMPLE
  6992.  
  6993.             /*
  6994.              * enable,show and set a range for the mouse
  6995.              */
  6996.  
  6997.             #include <stdlib.h>
  6998.             #include <conio.h>
  6999.             #include "svgacc.h"
  7000.  
  7001.             void main(void)
  7002.             {
  7003.                int vmode;
  7004.                vmode = videomodeget();
  7005.                if ( !whichvga() )
  7006.                  exit(1);
  7007.                if ( whichmem() < 512)
  7008.                  exit(1);
  7009.                if ( !whichmouse())
  7010.                  exit(1);
  7011.                if ( !res640() )
  7012.                  exit(1);
  7013.                mouseenter();
  7014.                drwbox(1,10,100,100,539,379);
  7015.                mouserangeset(100,100,539,379);
  7016.                mouseshow();
  7017.                getch();
  7018.                mousehide();
  7019.                mouseexit();
  7020.  
  7021.  
  7022.                                                                         110
  7023.  
  7024.  
  7025.  
  7026.  
  7027.  
  7028.  
  7029.                videomodeset(vmode);
  7030.                exit(0);
  7031.             }
  7032.  
  7033.  
  7034.  
  7035.  
  7036.  
  7037.  
  7038.  
  7039.  
  7040.  
  7041.  
  7042.  
  7043.  
  7044.  
  7045.  
  7046.  
  7047.  
  7048.  
  7049.  
  7050.  
  7051.  
  7052.  
  7053.  
  7054.  
  7055.  
  7056.  
  7057.  
  7058.  
  7059.  
  7060.  
  7061.  
  7062.  
  7063.  
  7064.  
  7065.  
  7066.  
  7067.  
  7068.  
  7069.  
  7070.  
  7071.  
  7072.  
  7073.  
  7074.  
  7075.  
  7076.  
  7077.  
  7078.  
  7079.  
  7080.  
  7081.  
  7082.  
  7083.  
  7084.  
  7085.                                                                         111
  7086.  
  7087.  
  7088.  
  7089.  
  7090.  
  7091.  
  7092.           MOUSERESTORESTATE
  7093.  
  7094.             PROTOTYPE
  7095.  
  7096.             extern void far mouserestorestate (byte far *mousebuf)
  7097.  
  7098.             INPUT
  7099.  
  7100.             mousebuf - byte pointer to buffer holding complete mouse
  7101.             status information
  7102.  
  7103.             OUTPUT
  7104.  
  7105.             no value returned
  7106.  
  7107.             USAGE
  7108.  
  7109.             MOUSERESTORESTATE completely restores a previously saved mouse
  7110.             status as contained in mousebuf.  The mouse status must have
  7111.             been already stored in mousebuf by MOUSESAVESTATE.
  7112.  
  7113.             SEE ALSO
  7114.  
  7115.             MOUSESAVESTATE, MOUSESTORAGESIZE
  7116.  
  7117.             EXAMPLE
  7118.  
  7119.             /*
  7120.              * save the mouse driver state,shell out to DOS, restore the
  7121.             driver state
  7122.              */
  7123.  
  7124.             #include <stdlib.h>
  7125.             #include <conio.h>
  7126.             #include <process.h>
  7127.             #include "svgacc.h"
  7128.  
  7129.             void main(void)
  7130.             {
  7131.                int rt, bufsiz;
  7132.                byte *mousedriverdata;
  7133.                char cmdcom[]="C:\COMMAND.COM";
  7134.                char *args[1];
  7135.  
  7136.                if ( !whichmouse())
  7137.                  exit(1);
  7138.                bufsiz=mousestoragesize();
  7139.                mousedriverdata = (byte *)malloc(bufsiz);
  7140.                mousesavestate(mousedriverdata);
  7141.                printf("* Type Exit To Return To Program *");
  7142.                args[0]=NULL;
  7143.                rt=spawnv(P_WAIT,cmdcom,args);
  7144.                mouserestorestate(mousedriverdata);
  7145.                printf("mouse driver data restored...");
  7146.  
  7147.  
  7148.                                                                         112
  7149.  
  7150.  
  7151.  
  7152.  
  7153.  
  7154.  
  7155.                exit(0);
  7156.             }
  7157.  
  7158.  
  7159.  
  7160.  
  7161.  
  7162.  
  7163.  
  7164.  
  7165.  
  7166.  
  7167.  
  7168.  
  7169.  
  7170.  
  7171.  
  7172.  
  7173.  
  7174.  
  7175.  
  7176.  
  7177.  
  7178.  
  7179.  
  7180.  
  7181.  
  7182.  
  7183.  
  7184.  
  7185.  
  7186.  
  7187.  
  7188.  
  7189.  
  7190.  
  7191.  
  7192.  
  7193.  
  7194.  
  7195.  
  7196.  
  7197.  
  7198.  
  7199.  
  7200.  
  7201.  
  7202.  
  7203.  
  7204.  
  7205.  
  7206.  
  7207.  
  7208.  
  7209.  
  7210.  
  7211.                                                                         113
  7212.  
  7213.  
  7214.  
  7215.  
  7216.  
  7217.  
  7218.           MOUSESAVESTATE
  7219.  
  7220.             PROTOTYPE
  7221.  
  7222.             extern void far mousesavestate (byte far *mousebuf)
  7223.  
  7224.             INPUT
  7225.  
  7226.             no input parameters
  7227.  
  7228.             OUTPUT
  7229.  
  7230.             no value returned
  7231.             mousebuf - buffer holding complete mouse status information
  7232.  
  7233.             USAGE
  7234.  
  7235.             MOUSESAVESTATE saves the complete mouse status in mousebuf.
  7236.             The size of mousebuf in bytes is defined by MOUSESTORAGESIZE
  7237.             which should called first.
  7238.  
  7239.             SEE ALSO
  7240.  
  7241.             MOUSERESTORESTATE, MOUSESTORAGESIZE
  7242.  
  7243.             EXAMPLE
  7244.  
  7245.             See MOUSERESTORESTATE
  7246.  
  7247.  
  7248.  
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.  
  7255.  
  7256.  
  7257.  
  7258.  
  7259.  
  7260.  
  7261.  
  7262.  
  7263.  
  7264.  
  7265.  
  7266.  
  7267.  
  7268.  
  7269.  
  7270.  
  7271.  
  7272.  
  7273.  
  7274.                                                                         114
  7275.  
  7276.  
  7277.  
  7278.  
  7279.  
  7280.  
  7281.           MOUSESENSSET
  7282.  
  7283.             PROTOTYPE
  7284.  
  7285.             extern void far mousesensset (int xsens, int ysens, int
  7286.             dblspdthresh)
  7287.  
  7288.             INPUT
  7289.  
  7290.             xsens = number of mickeys per 8 pixels horizontally (default =
  7291.             8 mickeys per 8 pixels)
  7292.             ysens = number of mickeys per 8 pixels vertically (default =
  7293.             16 mickeys per 8 pixels)
  7294.             dblspdthresh=number of mickeys per second at which speed is
  7295.             doubled (default = 64)
  7296.  
  7297.             OUTPUT
  7298.  
  7299.             no value returned
  7300.  
  7301.             USAGE
  7302.  
  7303.             MOUSESENSSET defines the relationship between mouse movement
  7304.             and cursor movement on the screen.  A mickey is defined as
  7305.             1/200th of an inch.  The ratio between mickeys and pixels is
  7306.             specified by xsens and ysens in the horizontal and vertical
  7307.             directions respectively.  When the mouse movement is faster
  7308.             than DblSpdThresh in mickeys per second, the speed is doubled.
  7309.             The default values are assigned whenever MOUSEENTER or
  7310.             MOUSEEXIT are called.
  7311.  
  7312.             SEE ALSO
  7313.  
  7314.             MOUSEENTER, MOUSEEXIT, MOUSESTATUS
  7315.  
  7316.             EXAMPLE
  7317.  
  7318.             /*
  7319.              * enable,show the mouse and make it very sensitive
  7320.              */
  7321.  
  7322.             #include <stdlib.h>
  7323.             #include <conio.h>
  7324.             #include "svgacc.h"
  7325.             void main(void)
  7326.             {
  7327.                int vmode;
  7328.                vmode = videomodeget();
  7329.                if ( !whichvga() )
  7330.                  exit(1);
  7331.                if ( whichmem() < 512)
  7332.                  exit(1);
  7333.                if ( !whichmouse())
  7334.                  exit(1);
  7335.  
  7336.  
  7337.                                                                         115
  7338.  
  7339.  
  7340.  
  7341.  
  7342.  
  7343.  
  7344.                res640();
  7345.                mousecursordefault();
  7346.                mouseenter();
  7347.                mouseshow();
  7348.                mousesensset(100,100);
  7349.                getch();
  7350.                mousehide();
  7351.                mouseexit();
  7352.                videomodeset(vmode);
  7353.                exit(0);
  7354.             }
  7355.  
  7356.  
  7357.  
  7358.  
  7359.  
  7360.  
  7361.  
  7362.  
  7363.  
  7364.  
  7365.  
  7366.  
  7367.  
  7368.  
  7369.  
  7370.  
  7371.  
  7372.  
  7373.  
  7374.  
  7375.  
  7376.  
  7377.  
  7378.  
  7379.  
  7380.  
  7381.  
  7382.  
  7383.  
  7384.  
  7385.  
  7386.  
  7387.  
  7388.  
  7389.  
  7390.  
  7391.  
  7392.  
  7393.  
  7394.  
  7395.  
  7396.  
  7397.  
  7398.  
  7399.  
  7400.                                                                         116
  7401.  
  7402.  
  7403.  
  7404.  
  7405.  
  7406.  
  7407.           MOUSESHOW
  7408.  
  7409.             PROTOTYPE
  7410.  
  7411.             extern void far mouseshow (void)
  7412.  
  7413.             INPUT
  7414.  
  7415.             no input parameters
  7416.  
  7417.             OUTPUT
  7418.  
  7419.             no value returned
  7420.  
  7421.             USAGE
  7422.  
  7423.             MOUSESHOW enables the mouse display driver and places the
  7424.             cursor on the screen.  The cursor is only updated when the
  7425.             mouse is moved.  Therefore, it is recommended to hide the
  7426.             cursor when drawing on the screen to avoid unexpected results.
  7427.  
  7428.             SEE ALSO
  7429.  
  7430.             MOUSEENTER, MOUSEEXIT, MOUSEHIDE
  7431.  
  7432.             EXAMPLE
  7433.  
  7434.             See MOUSEHIDE
  7435.  
  7436.  
  7437.  
  7438.  
  7439.  
  7440.  
  7441.  
  7442.  
  7443.  
  7444.  
  7445.  
  7446.  
  7447.  
  7448.  
  7449.  
  7450.  
  7451.  
  7452.  
  7453.  
  7454.  
  7455.  
  7456.  
  7457.  
  7458.  
  7459.  
  7460.  
  7461.  
  7462.  
  7463.                                                                         117
  7464.  
  7465.  
  7466.  
  7467.  
  7468.  
  7469.  
  7470.           MOUSESTATUS
  7471.  
  7472.             PROTOTYPE
  7473.  
  7474.             extern void far mousestatus (int far *x, int far *y, int far
  7475.             *mbuts)
  7476.  
  7477.             INPUT
  7478.  
  7479.             no input parameters
  7480.  
  7481.             OUTPUT
  7482.  
  7483.             x, y - mouse position on screen
  7484.             mbuts - status of mouse buttons
  7485.  
  7486.             USAGE
  7487.  
  7488.             MOUSESTATUS returns the current status of the mouse position
  7489.             and buttons.  The position is returned in x, y.  The buttons'
  7490.             status is held in mbuts.  The left button is held in bit zero,
  7491.             right button in bit one and center button - for three button
  7492.             mice - in bit two.  Button status is most easily checked with
  7493.             a bitwise AND of mbuts and the desired bit.
  7494.  
  7495.             SEE ALSO
  7496.  
  7497.             MOUSERANGESET, MOUSESENSSET
  7498.  
  7499.             EXAMPLE
  7500.  
  7501.             /* enable,show mouse & display status */
  7502.             #include <stdlib.h>
  7503.             #include <conio.h>
  7504.             #include "svgacc.h"
  7505.  
  7506.             void main(void)
  7507.             {
  7508.                int vmode, x, y, mbuts;
  7509.                char buf[100];
  7510.  
  7511.                vmode = videomodeget();
  7512.                if ( !whichvga() || (whichmem() < 512))
  7513.                  exit(1);
  7514.                if ( !whichmouse())
  7515.                  exit(1);
  7516.                res640();
  7517.                mouseenter();
  7518.                mouseshow();
  7519.                while(!kbhit()) {
  7520.                  mousestatus(&x,&y,&mbuts);
  7521.                  sprintf(buf,"X= %4d  Y= %4d  LB= %1d  CB= %1d  RB=
  7522.             %1d\0",x,y,(mbuts & 1),(mbuts & 2),(mbuts & 4));
  7523.                  drwstring(1,15,8,buf,10,32);
  7524.  
  7525.  
  7526.                                                                         118
  7527.  
  7528.  
  7529.  
  7530.  
  7531.  
  7532.  
  7533.                }
  7534.                mousehide();
  7535.                mouseexit();
  7536.                videomodeset(vmode);
  7537.             }
  7538.  
  7539.  
  7540.  
  7541.  
  7542.  
  7543.  
  7544.  
  7545.  
  7546.  
  7547.  
  7548.  
  7549.  
  7550.  
  7551.  
  7552.  
  7553.  
  7554.  
  7555.  
  7556.  
  7557.  
  7558.  
  7559.  
  7560.  
  7561.  
  7562.  
  7563.  
  7564.  
  7565.  
  7566.  
  7567.  
  7568.  
  7569.  
  7570.  
  7571.  
  7572.  
  7573.  
  7574.  
  7575.  
  7576.  
  7577.  
  7578.  
  7579.  
  7580.  
  7581.  
  7582.  
  7583.  
  7584.  
  7585.  
  7586.  
  7587.  
  7588.  
  7589.                                                                         119
  7590.  
  7591.  
  7592.  
  7593.  
  7594.  
  7595.  
  7596.           MOUSESTORAGESIZE
  7597.  
  7598.             PROTOTYPE
  7599.  
  7600.             extern int far mousestoragesize (void)
  7601.  
  7602.             INPUT
  7603.  
  7604.             no input parameters
  7605.  
  7606.             OUTPUT
  7607.  
  7608.             MOUSESTORAGESIZE returns the size of buffer in bytes to store
  7609.             complete mouse status
  7610.  
  7611.             USAGE
  7612.  
  7613.             MOUSESTORAGESIZE determines the proper size buffer to hold the
  7614.             complete mouse status information.  This buffer should be
  7615.             allocated before calling MOUSESAVESTATE.
  7616.  
  7617.             SEE ALSO
  7618.  
  7619.             MOUSERESTORESTATE, MOUSESAVESTATE
  7620.  
  7621.             EXAMPLE
  7622.  
  7623.             /*
  7624.              * return the size in bytes need to save the mouse driver
  7625.             status
  7626.              */
  7627.  
  7628.             #include <stdlib.h>
  7629.             #include <conio.h>
  7630.             #include "svgacc.h"
  7631.  
  7632.             void main(void)
  7633.             {
  7634.                int bufsiz;
  7635.                char buf[50];
  7636.  
  7637.                if ( !whichmouse())
  7638.                  exit(1);
  7639.  
  7640.                bufsiz=mousestoragesize();
  7641.                sprintf(buf,"%d bytes are required to save mouse driver
  7642.             status...",bufsiz);
  7643.                printf("%s", &buf);
  7644.                exit(0);
  7645.             }
  7646.  
  7647.  
  7648.  
  7649.  
  7650.  
  7651.  
  7652.                                                                         120
  7653.  
  7654.  
  7655.  
  7656.  
  7657.  
  7658.  
  7659.           OVERSCANSET
  7660.  
  7661.             PROTOTYPE
  7662.  
  7663.             extern void far overscanset (int colr)
  7664.  
  7665.             INPUT
  7666.  
  7667.             colr - index to color in current palette
  7668.  
  7669.             OUTPUT
  7670.  
  7671.             no value returned
  7672.  
  7673.             USAGE
  7674.  
  7675.             OVERSCANSET sets the overscan region to the specified color.
  7676.             The overscan region is the area between the usable pixel area
  7677.             and the region not scanned by the monitor.  Normally, the
  7678.             overscan is color zero which is defined as black the majority
  7679.             of the time.  The overscan color is reset to zero anytime a
  7680.             RES### function is called.
  7681.  
  7682.             Note: OVERSCANSET always works in the 320x200 resolution.  In
  7683.             the higher resolutions on many common SVGA cards this function
  7684.             is ignored.  Instead, the card always assigns the overscan
  7685.             region to color zero.  Therefore, it is recommended to not use
  7686.             OVERSCANSET, but assign color zero as needed.
  7687.  
  7688.             EXAMPLE
  7689.  
  7690.             /*
  7691.              * set the overscan color to green
  7692.              */
  7693.  
  7694.             #include <stdlib.h>
  7695.             #include <conio.h>
  7696.             #include "svgacc.h"
  7697.  
  7698.             void main(void)
  7699.             {
  7700.                int vmode;
  7701.                vmode = videomodeget();
  7702.                if ( !whichvga() )
  7703.                  exit(1);
  7704.                res320();
  7705.                overscanset(10);
  7706.                getch();
  7707.                videomodeset(vmode);
  7708.                exit(0);
  7709.             }
  7710.  
  7711.  
  7712.  
  7713.  
  7714.  
  7715.                                                                         121
  7716.  
  7717.  
  7718.  
  7719.  
  7720.  
  7721.  
  7722.           PAGEACTIVE
  7723.  
  7724.             PROTOTYPE
  7725.  
  7726.             extern int far pageactive (int page)
  7727.  
  7728.             INPUT
  7729.  
  7730.             page - number of page to make active
  7731.  
  7732.             OUTPUT
  7733.  
  7734.             PAGEACTIVE returns a 1 if successful, 0 if unsuccessful.
  7735.  
  7736.             USAGE
  7737.  
  7738.             PAGEACTIVE sets the active page as specified by page.  It
  7739.             works by creating an offset to be added when any bank
  7740.             switching is performed.  This function does not affect the
  7741.             actual display.  A page is defined as the number of 64K blocks
  7742.             necessary to contain the current screen resolution.  For
  7743.             example, 640x480 requires 307,200 bytes which is a little more
  7744.             than 4.5 64K blocks.  One page in this resolution will be 5
  7745.             banks.
  7746.  
  7747.             PAGEACTIVE does not work in 320x200 mode since this mode uses
  7748.             no bank switching.
  7749.  
  7750.             SEE ALSO
  7751.  
  7752.             FILLPAGE, PAGEDISPLAY
  7753.  
  7754.             EXAMPLE
  7755.  
  7756.             /*
  7757.             * Show pageactive (video card needs 1meg to show pages in
  7758.             640x480x256)
  7759.             */
  7760.  
  7761.             #include <stdlib.h>
  7762.             #include <math.h>
  7763.             #include <conio.h>
  7764.             #include "svgacc.h"
  7765.  
  7766.             void main(void)
  7767.             {
  7768.                int vmode,er;
  7769.                char text[]="press a key...";
  7770.                char buf[20];
  7771.                vmode = videomodeget();
  7772.                if ( !whichvga() )
  7773.                  exit(1);
  7774.                if ( whichmem() < 1024)
  7775.                  exit(1);
  7776.  
  7777.  
  7778.                                                                         122
  7779.  
  7780.  
  7781.  
  7782.  
  7783.  
  7784.  
  7785.                if ( !res640() )
  7786.                  exit(1);
  7787.                /* make sure video card supports page flipping */
  7788.                if ( !pagedisplay(0,0,0) ) {
  7789.                  videomodeset(vmode);
  7790.                  exit(1);
  7791.                }
  7792.                er = pageactive(0);
  7793.                fillpage(0);
  7794.                drwstring(1,10,0,text,0,300);
  7795.                sprintf(buf,"Page 0");
  7796.                drwstring(1,10,0,buf,0,0);
  7797.                er = pageactive(1);
  7798.                fillpage(0);
  7799.                drwstring(1,12,0,text,0,300);
  7800.                sprintf(buf,"Page 1");
  7801.                drwstring(1,12,0,buf,0,20);
  7802.                er = pageactive(2);
  7803.                fillpage(0);
  7804.                drwstring(1,13,0,text,0,300);
  7805.                sprintf(buf,"Page 2");
  7806.                drwstring(1,13,0,buf,0,40);
  7807.                er = pageactive(0);
  7808.                er = pagedisplay(0,0,0);
  7809.                getch();
  7810.                er = pagedisplay(0,0,1);
  7811.                getch();
  7812.                er = pagedisplay(0,0,2);
  7813.                getch();
  7814.                videomodeset(vmode);
  7815.                exit(0);
  7816.             }
  7817.  
  7818.  
  7819.  
  7820.  
  7821.  
  7822.  
  7823.  
  7824.  
  7825.  
  7826.  
  7827.  
  7828.  
  7829.  
  7830.  
  7831.  
  7832.  
  7833.  
  7834.  
  7835.  
  7836.  
  7837.  
  7838.  
  7839.  
  7840.  
  7841.                                                                         123
  7842.  
  7843.  
  7844.  
  7845.  
  7846.  
  7847.  
  7848.           PAGEDISPLAY
  7849.  
  7850.             PROTOTYPE
  7851.  
  7852.             extern int far pagedisplay (int x, int y, int page)
  7853.  
  7854.             INPUT
  7855.  
  7856.             x, y - coordinate to place at top, left of display
  7857.             page - number of page to make active
  7858.  
  7859.             OUTPUT
  7860.  
  7861.             PAGEDISPLAY returns a 1 if successful, 0 if unsuccessful.
  7862.  
  7863.             USAGE
  7864.  
  7865.             PAGEDISPLAY tells the video card where in video memory to
  7866.             begin the display.  This display offset is calculated from the
  7867.             specified page, x and y.  This is done by multiplying y times
  7868.             the width of the current resolution, adding x and then adding
  7869.             the appropriate number of 64K blocks for page.  X, y and page
  7870.             must all be positive numbers, but are otherwise not
  7871.             restricted.  The display will wrap if the values are
  7872.             abnormally large.  Wrapping will happen from side to side as
  7873.             well as from top of memory to bottom of memory.
  7874.  
  7875.             PAGEDISPLAY does not work in 320x200 mode since this mode uses
  7876.             no bank switching.  In addition, older models of some SVGA
  7877.             cards operating in native mode do not support paging.  In this
  7878.             library these cards are: Acumos, Ahead version A, Everex and
  7879.             Genoa.  To ensure compatibility, a program should make a call
  7880.             similar to:
  7881.  
  7882.                if ( !pagedisplay(0,0,0) )
  7883.                  printf("PAGING NOT SUPPORTED\n");
  7884.  
  7885.             Note: SVGA cards by ATI Technologies appear to ignore bit 4
  7886.             (counting from 0 to 19) in its linear addressing mode and
  7887.             assume it is zero.  Therefore, bit 4 of the x parameter will
  7888.             be ignored by ATI chipsets.
  7889.  
  7890.             SEE ALSO
  7891.  
  7892.             FILLPAGE, PAGEACTIVE
  7893.  
  7894.             EXAMPLE
  7895.  
  7896.             See PAGEACTIVE
  7897.  
  7898.  
  7899.  
  7900.  
  7901.  
  7902.  
  7903.  
  7904.                                                                         124
  7905.  
  7906.  
  7907.  
  7908.  
  7909.  
  7910.  
  7911.           PALCHGAUTO
  7912.  
  7913.             PROTOTYPE
  7914.  
  7915.             extern void far palchgauto (RGB far *pal, RGB far *newpal, int
  7916.             firstcolr, int lastcolr, int speed)
  7917.  
  7918.             INPUT
  7919.  
  7920.             pal - initial palette
  7921.             newpal - new palette
  7922.             firstcolr - index into palette where change will begin
  7923.             lastcolr - index into palette where change will end
  7924.             speed - speed of change
  7925.  
  7926.             OUTPUT
  7927.  
  7928.             no value returned
  7929.  
  7930.             USAGE
  7931.  
  7932.             PALCHGAUTO smoothly fades the colors between firstcolr and
  7933.             lastcolr from the palette pal to newpal.  The speed of the
  7934.             fade is set by speed which is percentage change between each
  7935.             step of the fade.  Only values between 1 and 128 are valid
  7936.             where 1 represents a one percent change between steps and 128
  7937.             (80 hex) represents fifty percent change between steps.  A
  7938.             speed of 128 would then have only two steps.  A speed outside
  7939.             of the valid range causes the function to immediately return
  7940.             without making any changes.  The time required to accomplish
  7941.             the entire fade is approximately equal to 0.033 seconds times
  7942.             256 divided by speed.  PALCHGAUTO does not modify either pal
  7943.             or newpal.
  7944.  
  7945.             SEE ALSO
  7946.  
  7947.             PALCHGSTEP, PALDIMSTEP, PALIOAUTO
  7948.  
  7949.             EXAMPLE
  7950.  
  7951.             /*
  7952.              * autofade from one palette to another and back again
  7953.              */
  7954.  
  7955.             #include <stdlib.h>
  7956.             #include <conio.h>
  7957.             #include "svgacc.h"
  7958.  
  7959.             void main(void)
  7960.             {
  7961.                int vmode, colr, y, i, index;
  7962.                PaletteData orgpal, newpal;
  7963.  
  7964.                vmode = videomodeget();
  7965.  
  7966.  
  7967.                                                                         125
  7968.  
  7969.  
  7970.  
  7971.  
  7972.  
  7973.  
  7974.                if ( !whichvga() )
  7975.                  exit(1);
  7976.                if ( whichmem() < 512)
  7977.                  exit(1);
  7978.                res640();
  7979.                palget(orgpal,0,255);
  7980.                for (index=0;index<256;index++) {
  7981.                  newpal[index].r = index / 4;
  7982.                  newpal[index].g = index / 4;
  7983.                  newpal[index].b = index / 4;
  7984.                }
  7985.                colr = 0;
  7986.                for (y=0;y<480;y++) {
  7987.                  drwline(1,colr++,0,y,639,y);
  7988.                  if (colr>255)
  7989.                     colr = 0;
  7990.                }
  7991.                palchgauto(orgpal,newpal,0,255,2);
  7992.                palchgauto(newpal,orgpal,0,255,2);
  7993.                getch();
  7994.                videomodeset(vmode);
  7995.                exit(0);
  7996.             }
  7997.  
  7998.  
  7999.  
  8000.  
  8001.  
  8002.  
  8003.  
  8004.  
  8005.  
  8006.  
  8007.  
  8008.  
  8009.  
  8010.  
  8011.  
  8012.  
  8013.  
  8014.  
  8015.  
  8016.  
  8017.  
  8018.  
  8019.  
  8020.  
  8021.  
  8022.  
  8023.  
  8024.  
  8025.  
  8026.  
  8027.  
  8028.  
  8029.  
  8030.                                                                         126
  8031.  
  8032.  
  8033.  
  8034.  
  8035.  
  8036.  
  8037.           PALCHGSTEP
  8038.  
  8039.             PROTOTYPE
  8040.  
  8041.             extern void far palchgstep (RGB far *pal, RGB far *newpal, int
  8042.             firstcolr, int lastcolr, int percent)
  8043.  
  8044.             INPUT
  8045.  
  8046.             pal - initial palette
  8047.             newpal - new palette
  8048.             firstcolr - index into palette where change will begin
  8049.             lastcolr - index into palette where change will end
  8050.             percent - percent step from current palette to new palette
  8051.  
  8052.             OUTPUT
  8053.  
  8054.             no value returned
  8055.  
  8056.             USAGE
  8057.  
  8058.             PALCHGSTEP changes the palette colors between firstcolr and
  8059.             lastcolr by percent from pal to newpal.  This function works
  8060.             very much like PALCHGAUTO except it only takes a single step
  8061.             and returns.  The step taken is a percentage specified by
  8062.             Percent where 256 (100 hex) is a 100 percent change.  The
  8063.             valid range for Percent is 0 to 256.  Values beyond this range
  8064.             cause the function to immediately return without making any
  8065.             changes.  A loop from 4 to 256 by fours using PALCHGSTEP would
  8066.             have similar results as PALCHGAUTO with a speed of 4.  Neither
  8067.             pal, nor newpal are modified.
  8068.  
  8069.             SEE ALSO
  8070.  
  8071.             PALCHGAUTO, PALDIMSTEP, PALIOAUTO
  8072.  
  8073.             EXAMPLE
  8074.  
  8075.             /*
  8076.              * step fade from one palette to another and back again
  8077.              */
  8078.  
  8079.             #include <stdlib.h>
  8080.             #include <conio.h>
  8081.             #include "svgacc.h"
  8082.  
  8083.             void main(void)
  8084.             {
  8085.                int vmode, colr, y, i, index;
  8086.                PaletteData orgpal, newpal;
  8087.  
  8088.                vmode = videomodeget();
  8089.                if ( !whichvga() )
  8090.                  exit(1);
  8091.  
  8092.  
  8093.                                                                         127
  8094.  
  8095.  
  8096.  
  8097.  
  8098.  
  8099.  
  8100.                if ( whichmem() < 512)
  8101.                  exit(1);
  8102.                res640();
  8103.  
  8104.                palget(orgpal,0,255);
  8105.                for (index=0;index<256;index++)
  8106.                {
  8107.                  newpal[index].r = index / 4;
  8108.                  newpal[index].g = index / 4;
  8109.                  newpal[index].b = index / 4;
  8110.                }
  8111.                colr = 0;
  8112.                for (y=0;y<480;y++)
  8113.                {
  8114.                  drwline(1,colr++,0,y,639,y);
  8115.                  if (colr>255)
  8116.                     colr = 0;
  8117.                }
  8118.                for (index=0;index<256;index++)
  8119.                {
  8120.                  palchgstep(orgpal,newpal,0,255,index);
  8121.                }
  8122.                for (index=256;index>=-1;index--)
  8123.                {
  8124.                  palchgstep(orgpal,newpal,0,255,index);
  8125.                }
  8126.                getch();
  8127.                videomodeset(vmode);
  8128.                exit(0);
  8129.             }
  8130.  
  8131.  
  8132.  
  8133.  
  8134.  
  8135.  
  8136.  
  8137.  
  8138.  
  8139.  
  8140.  
  8141.  
  8142.  
  8143.  
  8144.  
  8145.  
  8146.  
  8147.  
  8148.  
  8149.  
  8150.  
  8151.  
  8152.  
  8153.  
  8154.  
  8155.  
  8156.                                                                         128
  8157.  
  8158.  
  8159.  
  8160.  
  8161.  
  8162.  
  8163.           PALCOPY
  8164.  
  8165.             PROTOTYPE
  8166.  
  8167.             extern void far palcopy (RGB far *srcpal, RGB far *destpal,
  8168.             int firstcolr, int lastcolr)
  8169.  
  8170.             INPUT
  8171.  
  8172.             srcpal - source palette
  8173.             firstcolr - index into palette where copy will begin
  8174.             lastcolr - index into palette where copy will end
  8175.  
  8176.             OUTPUT
  8177.  
  8178.             no value returned
  8179.             destpal - copy of srcpal
  8180.  
  8181.             USAGE
  8182.  
  8183.             PALCOPY quickly copies a source palette into a second palette
  8184.             array.  Destpal must be previously allocated.  A portion of a
  8185.             palette may be copied by specifying first and last colors.  If
  8186.             firstcolr is greater than lastcolr, no copy will occur.
  8187.  
  8188.             SEE ALSO
  8189.  
  8190.             BYTECOPY
  8191.  
  8192.             EXAMPLE
  8193.  
  8194.             /*
  8195.              * create a color palette(grayscale) and copy it to a palette
  8196.              * of a different name
  8197.              */
  8198.  
  8199.             #include <stdlib.h>
  8200.             #include <conio.h>
  8201.             #include "svgacc.h"
  8202.  
  8203.             void main(void)
  8204.             {
  8205.                int vmode,colr,y,i,index;
  8206.                PaletteData pal, newpal;
  8207.  
  8208.                vmode = videomodeget();
  8209.                if ( !whichvga() )
  8210.                  exit(1);
  8211.                if ( whichmem() < 512)
  8212.                  exit(1);
  8213.                if ( !res640() )
  8214.                  exit(1);
  8215.                for (index=0;index<256;index++) {
  8216.                  pal[index].r = index / 4;
  8217.  
  8218.  
  8219.                                                                         129
  8220.  
  8221.  
  8222.  
  8223.  
  8224.  
  8225.  
  8226.                  pal[index].g = index / 4;
  8227.                  pal[index].b = index / 4;
  8228.                }
  8229.                colr = 0;
  8230.                palcopy(pal,newpal,0,255);
  8231.                for (y=0;y<480;y++) {
  8232.                  drwline(1,colr++,0,y,639,y);
  8233.                  if (colr>255)
  8234.                     colr = 0;
  8235.                }
  8236.                palset(newpal,0,255);
  8237.                getch();
  8238.                videomodeset(vmode);
  8239.                exit(0);
  8240.             }
  8241.  
  8242.  
  8243.  
  8244.  
  8245.  
  8246.  
  8247.  
  8248.  
  8249.  
  8250.  
  8251.  
  8252.  
  8253.  
  8254.  
  8255.  
  8256.  
  8257.  
  8258.  
  8259.  
  8260.  
  8261.  
  8262.  
  8263.  
  8264.  
  8265.  
  8266.  
  8267.  
  8268.  
  8269.  
  8270.  
  8271.  
  8272.  
  8273.  
  8274.  
  8275.  
  8276.  
  8277.  
  8278.  
  8279.  
  8280.  
  8281.  
  8282.                                                                         130
  8283.  
  8284.  
  8285.  
  8286.  
  8287.  
  8288.  
  8289.           PALDIMSTEP
  8290.  
  8291.             PROTOTYPE
  8292.  
  8293.             extern void far paldimstep (RGB far *pal, int firstcolr, int
  8294.             lastcolr, int percent)
  8295.  
  8296.             INPUT
  8297.  
  8298.             pal - initial palette
  8299.             firstcolr - index into palette where dim will begin
  8300.             lastcolr - index into palette where dim will end
  8301.             percent - percent step from current palette to black
  8302.  
  8303.             OUTPUT
  8304.  
  8305.             no value returned
  8306.  
  8307.             USAGE
  8308.  
  8309.             PALDIMSTEP fades the specified palette to black by the given
  8310.             percentage between firstcolr and lastcolr.  The percentage
  8311.             step from pal to black is specified by percent where 256 (100
  8312.             hex) is full black.  The valid range for Percent is 0 to 256.
  8313.             Values beyond this range cause the function to immediately
  8314.             return without making any changes.  pal is not modified.
  8315.  
  8316.             SEE ALSO
  8317.  
  8318.             PALCHGAUTO, PALCHGSTEP, PALIOAUTO
  8319.  
  8320.             EXAMPLE
  8321.  
  8322.             /*
  8323.              * step dim from a palette to black and back again
  8324.              */
  8325.  
  8326.             #include <stdlib.h>
  8327.             #include <conio.h>
  8328.             #include "svgacc.h"
  8329.  
  8330.             void main(void)
  8331.             {
  8332.                int vmode;
  8333.                int colr;
  8334.                int y;
  8335.                int i;
  8336.                int index;
  8337.                PaletteData orgpal;
  8338.  
  8339.                vmode = videomodeget();
  8340.                if ( !whichvga() )
  8341.                  exit(1);
  8342.                if ( whichmem() < 512)
  8343.  
  8344.  
  8345.                                                                         131
  8346.  
  8347.  
  8348.  
  8349.  
  8350.  
  8351.  
  8352.                  exit(1);
  8353.                res640();
  8354.                palget(orgpal,0,255);
  8355.                colr = 0;
  8356.                for (y=0;y<480;y++)
  8357.                {
  8358.                  drwline(1,colr++,0,y,639,y);
  8359.                  if (colr>255)
  8360.                     colr = 0;
  8361.                }
  8362.                for (index=0;index<256;index++)
  8363.                {
  8364.                  paldimstep(orgpal,0,255,index);
  8365.                }
  8366.                for (index=256;index>=-1;index--)
  8367.                {
  8368.                  paldimstep(orgpal,0,255,index);
  8369.                }
  8370.                getch();
  8371.                videomodeset(vmode);
  8372.                exit(0);
  8373.             }
  8374.  
  8375.  
  8376.  
  8377.  
  8378.  
  8379.  
  8380.  
  8381.  
  8382.  
  8383.  
  8384.  
  8385.  
  8386.  
  8387.  
  8388.  
  8389.  
  8390.  
  8391.  
  8392.  
  8393.  
  8394.  
  8395.  
  8396.  
  8397.  
  8398.  
  8399.  
  8400.  
  8401.  
  8402.  
  8403.  
  8404.  
  8405.  
  8406.  
  8407.  
  8408.                                                                         132
  8409.  
  8410.  
  8411.  
  8412.  
  8413.  
  8414.  
  8415.           PALGET
  8416.  
  8417.             PROTOTYPE
  8418.  
  8419.             extern void far palget (RGB far *pal, int firstcolr, int
  8420.             lastcolr)
  8421.  
  8422.             INPUT
  8423.  
  8424.             firstcolr - index into palette where get will begin
  8425.             lastcolr - index into palette where get will end
  8426.  
  8427.             OUTPUT
  8428.  
  8429.             pal - copy of the current palette in the specified range
  8430.  
  8431.             USAGE
  8432.  
  8433.             PALGET returns in pal the colors from the current palette
  8434.             between firstcolr and lastcolr.  Only colors in the specified
  8435.             range are returned and all others in pal are unchanged.  Pal
  8436.             must be 768 bytes in length despite the number of colors
  8437.             retrieved.
  8438.  
  8439.             SEE ALSO
  8440.  
  8441.             PALROTATE, PALSET
  8442.  
  8443.             EXAMPLE
  8444.  
  8445.             See PALCHGAUTO
  8446.  
  8447.  
  8448.  
  8449.  
  8450.  
  8451.  
  8452.  
  8453.  
  8454.  
  8455.  
  8456.  
  8457.  
  8458.  
  8459.  
  8460.  
  8461.  
  8462.  
  8463.  
  8464.  
  8465.  
  8466.  
  8467.  
  8468.  
  8469.  
  8470.  
  8471.                                                                         133
  8472.  
  8473.  
  8474.  
  8475.  
  8476.  
  8477.  
  8478.           PALIOAUTO
  8479.  
  8480.             PROTOTYPE
  8481.  
  8482.             extern void far palioauto (RGB far *pal, int firstcolr, int
  8483.             lastcolr, int speed)
  8484.  
  8485.             INPUT
  8486.  
  8487.             pal - initial palette
  8488.             firstcolr - index into palette where fade will begin
  8489.             lastcolr - index into palette where fade will end
  8490.             speed - speed of fade
  8491.  
  8492.             OUTPUT
  8493.  
  8494.             no value returned
  8495.  
  8496.             USAGE
  8497.  
  8498.             PALIOAUTO smoothly fades the colors between firstcolr and
  8499.             lastcolr of pal to or from solid black.  The speed of the fade
  8500.             is set by speed which is the percentage change between each
  8501.             step of the fade.  A positive speed corresponds to fading from
  8502.             pal to black and a negative speed fades from black to Pal.
  8503.             Only values between -128 and +128 are valid where  1
  8504.             represents a one percent change between steps and  128 ( 80
  8505.             hex) represents fifty percent change between steps.  A speed
  8506.             of 128 would then have only two steps.  A speed outside of the
  8507.             valid range causes the function to immediately return without
  8508.             making any changes.  The time required to accomplish the
  8509.             entire fade is approximately equal to 0.033 seconds times 256
  8510.             divided by speed.  PALIOAUTO does not modify pal.
  8511.  
  8512.             SEE ALSO
  8513.  
  8514.             PALCHGAUTO, PALCHGSTEP, PALDIMSTEP
  8515.  
  8516.             EXAMPLE
  8517.  
  8518.             /*
  8519.              * autofade a palette to black and back again
  8520.              */
  8521.  
  8522.             #include <stdlib.h>
  8523.             #include <conio.h>
  8524.             #include "svgacc.h"
  8525.  
  8526.             void main(void)
  8527.             {
  8528.                int vmode, colr, y;
  8529.                PaletteData orgpal;
  8530.  
  8531.                vmode = videomodeget();
  8532.  
  8533.  
  8534.                                                                         134
  8535.  
  8536.  
  8537.  
  8538.  
  8539.  
  8540.  
  8541.                if ( !whichvga() )
  8542.                  exit(1);
  8543.                if ( whichmem() < 512)
  8544.                  exit(1);
  8545.                res640();
  8546.                colr = 0;
  8547.                palget(orgpal,0,255);
  8548.                for (y=0;y<480;y++) {
  8549.                  drwline(1,colr++,0,y,639,y);
  8550.                  if (colr>255)
  8551.                     colr = 0;
  8552.                }
  8553.                palioauto(orgpal,0,255,-2);
  8554.                palioauto(orgpal,0,255,2);
  8555.                getch();
  8556.                videomodeset(vmode);
  8557.                exit(0);
  8558.             }
  8559.  
  8560.  
  8561.  
  8562.  
  8563.  
  8564.  
  8565.  
  8566.  
  8567.  
  8568.  
  8569.  
  8570.  
  8571.  
  8572.  
  8573.  
  8574.  
  8575.  
  8576.  
  8577.  
  8578.  
  8579.  
  8580.  
  8581.  
  8582.  
  8583.  
  8584.  
  8585.  
  8586.  
  8587.  
  8588.  
  8589.  
  8590.  
  8591.  
  8592.  
  8593.  
  8594.  
  8595.  
  8596.  
  8597.                                                                         135
  8598.  
  8599.  
  8600.  
  8601.  
  8602.  
  8603.  
  8604.           PALROTATE
  8605.  
  8606.             PROTOTYPE
  8607.  
  8608.             extern void far palrotate (RGB far *pal, int firstcolr, int
  8609.             lastcolr, int shift)
  8610.  
  8611.             INPUT
  8612.  
  8613.             pal - PaletteData pointer to current palette
  8614.             firstcolr - index into palette where shift will begin
  8615.             lastcolr - index into palette where shift will end
  8616.             shift - number of locations to shift colors
  8617.  
  8618.             OUTPUT
  8619.  
  8620.             no value returned
  8621.  
  8622.             USAGE
  8623.  
  8624.             PALROTATE shifts the colors in pal between firstcolr and
  8625.             lastcolr by a given number of locations and sets this new
  8626.             palette.  The number of locations the colors are moved is
  8627.             specified by shift which is between 1 and 256.  Pal is not
  8628.             modified by PALROTATE.
  8629.  
  8630.             SEE ALSO
  8631.  
  8632.             PALGET, PALSET
  8633.  
  8634.             EXAMPLE
  8635.  
  8636.             /*
  8637.              * rotate a few palette entries around
  8638.              */
  8639.  
  8640.             #include <stdlib.h>
  8641.             #include <conio.h>
  8642.             #include "svgacc.h"
  8643.  
  8644.             void main(void)
  8645.             {
  8646.                int vmode, colr, y, i, index;
  8647.                PaletteData orgpal;
  8648.  
  8649.                vmode = videomodeget();
  8650.                if ( !whichvga() )
  8651.                  exit(1);
  8652.                if ( whichmem() < 512)
  8653.                  exit(1);
  8654.                res640();
  8655.                colr = 0;
  8656.                palget(orgpal,0,255);
  8657.                for (y=0;y<480;y++) {
  8658.  
  8659.  
  8660.                                                                         136
  8661.  
  8662.  
  8663.  
  8664.  
  8665.  
  8666.  
  8667.                  drwline(1,colr++,0,y,639,y);
  8668.                  if (colr>255)
  8669.                     colr = 0;
  8670.                }
  8671.                for (i=0;i<200;i++) {
  8672.                  palrotate(orgpal,1,127,1);
  8673.                  palget(orgpal,0,255);
  8674.                }
  8675.                getch();
  8676.                videomodeset(vmode);
  8677.                exit(0);
  8678.             }
  8679.  
  8680.  
  8681.  
  8682.  
  8683.  
  8684.  
  8685.  
  8686.  
  8687.  
  8688.  
  8689.  
  8690.  
  8691.  
  8692.  
  8693.  
  8694.  
  8695.  
  8696.  
  8697.  
  8698.  
  8699.  
  8700.  
  8701.  
  8702.  
  8703.  
  8704.  
  8705.  
  8706.  
  8707.  
  8708.  
  8709.  
  8710.  
  8711.  
  8712.  
  8713.  
  8714.  
  8715.  
  8716.  
  8717.  
  8718.  
  8719.  
  8720.  
  8721.  
  8722.  
  8723.                                                                         137
  8724.  
  8725.  
  8726.  
  8727.  
  8728.  
  8729.  
  8730.           PALSET
  8731.  
  8732.             PROTOTYPE
  8733.  
  8734.             extern void far palset (RGB far *pal, int firstcolr, int
  8735.             lastcolr)
  8736.  
  8737.             INPUT
  8738.  
  8739.             pal - palette to set
  8740.             firstcolr - index into palette where set will begin
  8741.             lastcolr - index into palette where set will end
  8742.  
  8743.             OUTPUT
  8744.  
  8745.             no value returned
  8746.  
  8747.             USAGE
  8748.  
  8749.             PALSET sets the specified range of colors in the current
  8750.             palette with the corresponding range in the palette pal.
  8751.  
  8752.             SEE ALSO
  8753.  
  8754.             PALGET
  8755.  
  8756.             EXAMPLE
  8757.  
  8758.             See PALCOPY
  8759.  
  8760.  
  8761.  
  8762.  
  8763.  
  8764.  
  8765.  
  8766.  
  8767.  
  8768.  
  8769.  
  8770.  
  8771.  
  8772.  
  8773.  
  8774.  
  8775.  
  8776.  
  8777.  
  8778.  
  8779.  
  8780.  
  8781.  
  8782.  
  8783.  
  8784.  
  8785.  
  8786.                                                                         138
  8787.  
  8788.  
  8789.  
  8790.  
  8791.  
  8792.  
  8793.           RES320
  8794.  
  8795.             PROTOTYPE
  8796.  
  8797.             extern int far res320 (void)
  8798.  
  8799.             INPUT
  8800.  
  8801.             no input parameters
  8802.  
  8803.             OUTPUT
  8804.  
  8805.             RES320 always returns a 1.
  8806.  
  8807.             USAGE
  8808.  
  8809.             RES320 sets video mode 0x13 which is the industry standard
  8810.             320x200 graphics mode with 256 colors.  This function can be
  8811.             called without calling WHICHVGA first as this function
  8812.             requires only that a VGA card is present, not a Super VGA
  8813.             card.  If a VGA is not present, the system may crash.
  8814.  
  8815.             SEE ALSO
  8816.  
  8817.             RES640, RES640L, RES800, RES1024, WHICHVGA
  8818.  
  8819.             EXAMPLE
  8820.  
  8821.             /*
  8822.              * set video mode to 320x200x256
  8823.              */
  8824.  
  8825.             #include <stdlib.h>
  8826.             #include <conio.h>
  8827.             #include "svgacc.h"
  8828.  
  8829.             void main(void)
  8830.             {
  8831.                int vmode;
  8832.  
  8833.                vmode = videomodeget();
  8834.                if ( !whichvga() )
  8835.                  exit();
  8836.                res320();
  8837.                drwstring(1,7,0,"this is the 320x200x256 video
  8838.             mode...",0,0);
  8839.                getch();
  8840.                videomodeset(vmode);
  8841.                exit(0);
  8842.             }
  8843.  
  8844.  
  8845.  
  8846.  
  8847.  
  8848.  
  8849.                                                                         139
  8850.  
  8851.  
  8852.  
  8853.  
  8854.  
  8855.  
  8856.           RES640
  8857.  
  8858.             PROTOTYPE
  8859.  
  8860.             extern int far res640 (void)
  8861.  
  8862.             INPUT
  8863.  
  8864.             no input parameters
  8865.  
  8866.             OUTPUT
  8867.  
  8868.             RES640 returns 1 if successful, 0 otherwise.
  8869.  
  8870.             USAGE
  8871.  
  8872.             RES640 sets the video mode to 640x480 graphics mode with 256
  8873.             colors.  This function requires that a Super VGA card with at
  8874.             least 512K of video memory be present.  Also, WHICHVGA must be
  8875.             called first or the function will fail without changing the
  8876.             video mode.  If the video card does not have sufficient
  8877.             memory, RES640 will return without changing the video mode.
  8878.  
  8879.             SEE ALSO
  8880.  
  8881.             RES320, RES640L, RES800, RES1024, WHICHVGA
  8882.  
  8883.             EXAMPLE
  8884.  
  8885.             /*
  8886.              * set video mode to 640x480x256
  8887.              */
  8888.  
  8889.             #include <stdlib.h>
  8890.             #include <conio.h>
  8891.             #include "svgacc.h"
  8892.  
  8893.             void main(void)
  8894.             {
  8895.                int vmode;
  8896.  
  8897.                vmode = videomodeget();
  8898.                if ( !whichvga() )
  8899.                  exit(1);
  8900.                if ( !whichmem() < 512 )
  8901.                  exit(1);
  8902.                res640();
  8903.                drwstring(1,7,0,"this is the 640x480x256 video
  8904.             mode...",0,0);
  8905.                getch();
  8906.                videomodeset(vmode);
  8907.                exit(0);
  8908.             }
  8909.  
  8910.  
  8911.  
  8912.                                                                         140
  8913.  
  8914.  
  8915.  
  8916.  
  8917.  
  8918.  
  8919.           RES640L
  8920.  
  8921.             PROTOTYPE
  8922.  
  8923.             extern int far res640l (void)
  8924.  
  8925.             INPUT
  8926.  
  8927.             no input parameters
  8928.  
  8929.             OUTPUT
  8930.  
  8931.             RES640L returns 1 if successful, 0 otherwise.
  8932.  
  8933.             USAGE
  8934.  
  8935.             RES640L sets the video mode to 640x400 graphics mode with 256
  8936.             colors.  This function requires that a Super VGA card with at
  8937.             least 256K of video memory be present.  Also, WHICHVGA must be
  8938.             called first or the function will fail without changing the
  8939.             video mode.  If the video card does not have sufficient
  8940.             memory, RES640L will return without changing the video mode.
  8941.  
  8942.             Note: The 640x400 is an uncommon resolution.  Many SVGA cards
  8943.             do not support this mode.
  8944.  
  8945.             SEE ALSO
  8946.  
  8947.             RES320, RES640, RES800, RES1024, WHICHVGA
  8948.  
  8949.             EXAMPLE
  8950.  
  8951.             /*
  8952.              * set video mode to 640x400x256
  8953.              */
  8954.  
  8955.             #include <stdlib.h>
  8956.             #include <conio.h>
  8957.             #include "svgacc.h"
  8958.  
  8959.             void main(void)
  8960.             {
  8961.                int vmode;
  8962.  
  8963.                vmode = videomodeget();
  8964.                if ( !whichvga() )
  8965.                  exit(1);
  8966.                res640l();
  8967.                drwstring(1,7,0,"this is the 640x400x256 video
  8968.             mode...",0,0);
  8969.                getch();
  8970.                videomodeset(vmode);
  8971.                exit(0);
  8972.             }
  8973.  
  8974.  
  8975.                                                                         141
  8976.  
  8977.  
  8978.  
  8979.  
  8980.  
  8981.  
  8982.           RES800
  8983.  
  8984.             PROTOTYPE
  8985.  
  8986.             extern int far res800 (void)
  8987.  
  8988.             INPUT
  8989.  
  8990.             no input parameters
  8991.  
  8992.             OUTPUT
  8993.  
  8994.             RES800 returns 1 if successful, 0 otherwise.
  8995.  
  8996.             USAGE
  8997.  
  8998.             RES800 sets the video mode to 800x600 graphics mode with 256
  8999.             colors.  This function requires that a Super VGA card with at
  9000.             least 512K of video memory be present.  Also, WHICHVGA must be
  9001.             called first or the function will fail without changing the
  9002.             video mode.  If the video card does not have sufficient
  9003.             memory, RES800 will return without changing the video mode.
  9004.  
  9005.             SEE ALSO
  9006.  
  9007.             RES320, RES640, RES640L, RES1024, WHICHVGA
  9008.  
  9009.             EXAMPLE
  9010.  
  9011.             /*
  9012.              * set video mode to 800x600x256
  9013.              */
  9014.  
  9015.             #include <stdlib.h>
  9016.             #include <conio.h>
  9017.             #include "svgacc.h"
  9018.  
  9019.             void main(void)
  9020.             {
  9021.                int vmode;
  9022.  
  9023.                vmode = videomodeget();
  9024.                if ( !whichvga() )
  9025.                  exit(1);
  9026.                if ( !whichmem() < 512 )
  9027.                  exit(1);
  9028.                res800();
  9029.                drwstring(1,7,0,"this is the 800x600x256 video
  9030.             mode...",0,0);
  9031.                getch();
  9032.                videomodeset(vmode);
  9033.                exit(0);
  9034.             }
  9035.  
  9036.  
  9037.  
  9038.                                                                         142
  9039.  
  9040.  
  9041.  
  9042.  
  9043.  
  9044.  
  9045.           RES1024
  9046.  
  9047.             PROTOTYPE
  9048.  
  9049.             extern int far res1024 (void)
  9050.  
  9051.             INPUT
  9052.  
  9053.             no input parameters
  9054.  
  9055.             OUTPUT
  9056.  
  9057.             RES1024 returns 1 if successful, 0 otherwise.
  9058.  
  9059.             USAGE
  9060.  
  9061.             RES1024 sets the video mode to 1024x768 graphics mode with 256
  9062.             colors.  This function requires that a Super VGA card with at
  9063.             least 1 Megabyte of video memory be present.  Also, WHICHVGA
  9064.             must be called first or the function will fail without
  9065.             changing the video mode.  If the video card does not have
  9066.             sufficient memory, RES1024 will return without changing the
  9067.             video mode.
  9068.  
  9069.             SEE ALSO
  9070.  
  9071.             RES320, RES640, RES640L, RES800, WHICHVGA
  9072.  
  9073.             EXAMPLE
  9074.  
  9075.             /*
  9076.              * set video mode to 1024x768x256
  9077.              */
  9078.  
  9079.             #include <stdlib.h>
  9080.             #include <conio.h>
  9081.             #include "svgacc.h"
  9082.  
  9083.             void main(void)
  9084.             {
  9085.                int vmode;
  9086.  
  9087.                vmode = videomodeget();
  9088.                if ( !whichvga() )
  9089.                  exit(1);
  9090.                if ( !whichmem() < 1024 )
  9091.                  exit(1);
  9092.                res1024();
  9093.                drwstring(1,7,0,"this is the 1024x768x256 video
  9094.             mode...",0,0);
  9095.                getch();
  9096.                videomodeset(vmode);
  9097.                exit(0);
  9098.             }
  9099.  
  9100.  
  9101.                                                                         143
  9102.  
  9103.  
  9104.  
  9105.  
  9106.  
  9107.  
  9108.           RESTEXT
  9109.  
  9110.             PROTOTYPE
  9111.  
  9112.             extern int far restext (void)
  9113.  
  9114.             INPUT
  9115.  
  9116.             no input parameters
  9117.  
  9118.             OUTPUT
  9119.  
  9120.             RESTEXT always returns a 1.
  9121.  
  9122.             USAGE
  9123.  
  9124.             RESTEXT sets video mode three which is the industry standard
  9125.             80x25 text mode.
  9126.  
  9127.             SEE ALSO
  9128.  
  9129.             VIDEOMODEGET, VIDEOMODESET
  9130.  
  9131.             EXAMPLE
  9132.  
  9133.             /*
  9134.              * set video mode to standard DOS text mode 3
  9135.              */
  9136.  
  9137.             #include <stdlib.h>
  9138.             #include <conio.h>
  9139.             #include "svgacc.h"
  9140.  
  9141.             void main(void)
  9142.             {
  9143.                int vmode;
  9144.  
  9145.                vmode = videomodeget();
  9146.                if ( !restext() )
  9147.                  exit(1);
  9148.                printf("this is the text video mode (DOS video mode 3)...");
  9149.                getch();
  9150.                videomodeset(vmode);
  9151.                exit(0);
  9152.             }
  9153.  
  9154.  
  9155.  
  9156.  
  9157.  
  9158.  
  9159.  
  9160.  
  9161.  
  9162.  
  9163.  
  9164.                                                                         144
  9165.  
  9166.  
  9167.  
  9168.  
  9169.  
  9170.  
  9171.           SCROLLDN
  9172.  
  9173.             PROTOTYPE
  9174.  
  9175.             extern void far scrolldn (int x1, int y1, int x2, int y2, int
  9176.             num, int colr)
  9177.  
  9178.             INPUT
  9179.  
  9180.             x1, y1 - top left corner of block
  9181.             x2, y2 - bottom right corner of block
  9182.             num - number of pixels to shift
  9183.             colr - index to color in current palette
  9184.  
  9185.             OUTPUT
  9186.  
  9187.             no value returned
  9188.  
  9189.             USAGE
  9190.  
  9191.             SCROLLDN shifts the contents of the box described by (x1, y1)
  9192.             - (x2, y2) down by the number of pixels specified by num.  The
  9193.             empty pixels created at the top of the box are filled with
  9194.             colr.  The pixels that are shifted out of the box are lost.
  9195.             SCROLLDN enforces x2 x1 and y2y1.  When placed within a loop,
  9196.             SCROLLDN will create a scrolling effect.
  9197.  
  9198.             SEE ALSO
  9199.  
  9200.             SCROLLLT, SCROLLRT, SCROLLUP
  9201.  
  9202.             EXAMPLE
  9203.  
  9204.             /*
  9205.              * scroll some text down
  9206.              */
  9207.  
  9208.             #include <stdlib.h>
  9209.             #include <conio.h>
  9210.             #include "svgacc.h"
  9211.  
  9212.             void main(void)
  9213.             {
  9214.                int vmode, i;
  9215.  
  9216.                vmode = videomodeget();
  9217.                if ( !whichvga() || (whichmem() < 512))
  9218.                  exit(1);
  9219.                res640();
  9220.                drwbox (1,10,0,0,100,100);
  9221.                drwstring(1,7,0,"text text",20,43);
  9222.                for(i=0;i<40;i++)
  9223.                {
  9224.                  scrolldn(1,1,99,99,1,0);
  9225.  
  9226.  
  9227.                                                                         145
  9228.  
  9229.  
  9230.  
  9231.  
  9232.  
  9233.  
  9234.                  sdelay(2);
  9235.                }
  9236.                getch();
  9237.                videomodeset(vmode);
  9238.             }
  9239.  
  9240.  
  9241.  
  9242.  
  9243.  
  9244.  
  9245.  
  9246.  
  9247.  
  9248.  
  9249.  
  9250.  
  9251.  
  9252.  
  9253.  
  9254.  
  9255.  
  9256.  
  9257.  
  9258.  
  9259.  
  9260.  
  9261.  
  9262.  
  9263.  
  9264.  
  9265.  
  9266.  
  9267.  
  9268.  
  9269.  
  9270.  
  9271.  
  9272.  
  9273.  
  9274.  
  9275.  
  9276.  
  9277.  
  9278.  
  9279.  
  9280.  
  9281.  
  9282.  
  9283.  
  9284.  
  9285.  
  9286.  
  9287.  
  9288.  
  9289.  
  9290.                                                                         146
  9291.  
  9292.  
  9293.  
  9294.  
  9295.  
  9296.  
  9297.           SCROLLLT
  9298.  
  9299.             PROTOTYPE
  9300.  
  9301.             extern void far scrolllt (int x1, int y1, int x2, int y2, int
  9302.             num, int colr)
  9303.  
  9304.             INPUT
  9305.  
  9306.             x1, y1 - top left corner of block
  9307.             x2, y2 - bottom right corner of block
  9308.             num - number of pixels to shift
  9309.             colr - index to color in current palette
  9310.  
  9311.             OUTPUT
  9312.  
  9313.             no value returned
  9314.  
  9315.             USAGE
  9316.  
  9317.             SCROLLLT shifts the contents of the box described by (x1, y1)
  9318.             - (x2, y2) down by the number of pixels specified by num.  The
  9319.             empty pixels created at the right of the box are filled with
  9320.             colr.  The pixels that are shifted out of the box are lost.
  9321.             SCROLLLT enforces x2 x1 and y2y1.  When placed within a loop,
  9322.             SCROLLRT will create a scrolling effect.
  9323.  
  9324.             SEE ALSO
  9325.  
  9326.             SCROLLDN, SCROLLRT, SCROLLUP
  9327.  
  9328.             EXAMPLE
  9329.  
  9330.             /*
  9331.              * scroll some text left
  9332.              */
  9333.  
  9334.             #include <stdlib.h>
  9335.             #include <conio.h>
  9336.             #include "svgacc.h"
  9337.  
  9338.             void main(void)
  9339.             {
  9340.                int vmode, i;
  9341.  
  9342.                vmode = videomodeget();
  9343.                if ( !whichvga() || (whichmem() < 512))
  9344.                  exit(1);
  9345.                res640();
  9346.                drwbox (1,10,0,0,100,100);
  9347.                drwstring(1,7,0,"text text",20,43);
  9348.                for(i=0;i<40;i++)
  9349.                {
  9350.                  scrolllt(1,1,99,99,1,0);
  9351.  
  9352.  
  9353.                                                                         147
  9354.  
  9355.  
  9356.  
  9357.  
  9358.  
  9359.  
  9360.                  sdelay(2);
  9361.                }
  9362.                getch();
  9363.                videomodeset(vmode);
  9364.             }
  9365.  
  9366.  
  9367.  
  9368.  
  9369.  
  9370.  
  9371.  
  9372.  
  9373.  
  9374.  
  9375.  
  9376.  
  9377.  
  9378.  
  9379.  
  9380.  
  9381.  
  9382.  
  9383.  
  9384.  
  9385.  
  9386.  
  9387.  
  9388.  
  9389.  
  9390.  
  9391.  
  9392.  
  9393.  
  9394.  
  9395.  
  9396.  
  9397.  
  9398.  
  9399.  
  9400.  
  9401.  
  9402.  
  9403.  
  9404.  
  9405.  
  9406.  
  9407.  
  9408.  
  9409.  
  9410.  
  9411.  
  9412.  
  9413.  
  9414.  
  9415.  
  9416.                                                                         148
  9417.  
  9418.  
  9419.  
  9420.  
  9421.  
  9422.  
  9423.           SCROLLRT
  9424.  
  9425.             PROTOTYPE
  9426.  
  9427.             extern void far scrollrt (int x1, int y1, int x2, int y2, int
  9428.             num, int colr)
  9429.  
  9430.             INPUT
  9431.  
  9432.             x1, y1 - top left corner of block
  9433.             x2, y2 - bottom right corner of block
  9434.             num - number of pixels to shift
  9435.             colr - index to color in current palette
  9436.  
  9437.             OUTPUT
  9438.  
  9439.             no value returned
  9440.  
  9441.             USAGE
  9442.  
  9443.             SCROLLRT shifts the contents of the box described by (x1, y1)
  9444.             - (x2, y2) down by the number of pixels specified by num.  The
  9445.             empty pixels created at the left of the box are filled with
  9446.             colr.  The pixels that are shifted out of the box are lost.
  9447.             SCROLLRT enforces x2 x1 and y2y1.  When placed within a loop,
  9448.             SCROLLRT will create a scrolling effect.
  9449.  
  9450.             SEE ALSO
  9451.  
  9452.             SCROLLDN, SCROLLLT, SCROLLUP
  9453.  
  9454.             EXAMPLE
  9455.  
  9456.             /*
  9457.              * scroll some text right
  9458.              */
  9459.  
  9460.             #include <stdlib.h>
  9461.             #include <conio.h>
  9462.             #include "svgacc.h"
  9463.  
  9464.             void main(void)
  9465.             {
  9466.                int vmode, i;
  9467.  
  9468.                vmode = videomodeget();
  9469.                if ( !whichvga() || (whichmem() < 512))
  9470.                  exit(1);
  9471.                res640();
  9472.                drwbox (1,10,0,0,100,100);
  9473.                drwstring(1,7,0,"text text",20,43);
  9474.                for(i=0;i<40;i++)
  9475.                {
  9476.                  scrollrt(1,1,99,99,1,0);
  9477.  
  9478.  
  9479.                                                                         149
  9480.  
  9481.  
  9482.  
  9483.  
  9484.  
  9485.  
  9486.                  sdelay(2);
  9487.                }
  9488.                getch();
  9489.                videomodeset(vmode);
  9490.             }
  9491.  
  9492.  
  9493.  
  9494.  
  9495.  
  9496.  
  9497.  
  9498.  
  9499.  
  9500.  
  9501.  
  9502.  
  9503.  
  9504.  
  9505.  
  9506.  
  9507.  
  9508.  
  9509.  
  9510.  
  9511.  
  9512.  
  9513.  
  9514.  
  9515.  
  9516.  
  9517.  
  9518.  
  9519.  
  9520.  
  9521.  
  9522.  
  9523.  
  9524.  
  9525.  
  9526.  
  9527.  
  9528.  
  9529.  
  9530.  
  9531.  
  9532.  
  9533.  
  9534.  
  9535.  
  9536.  
  9537.  
  9538.  
  9539.  
  9540.  
  9541.  
  9542.                                                                         150
  9543.  
  9544.  
  9545.  
  9546.  
  9547.  
  9548.  
  9549.           SCROLLUP
  9550.  
  9551.             PROTOTYPE
  9552.  
  9553.             extern void far scrollup (int x1, int y1, int x2, int y2, int
  9554.             num, int colr)
  9555.  
  9556.             INPUT
  9557.  
  9558.             x1, y1 - top left corner of block
  9559.             x2, y2 - bottom right corner of block
  9560.             num - number of pixels to shift
  9561.             colr - index to color in current palette
  9562.  
  9563.             OUTPUT
  9564.  
  9565.             no value returned
  9566.  
  9567.             USAGE
  9568.  
  9569.             SCROLLUP shifts the contents of the box described by (x1, y1)
  9570.             - (x2, y2) down by the number of pixels specified by num.  The
  9571.             empty pixels created at the bottom of the box are filled with
  9572.             colr.  The pixels that are shifted out of the box are lost.
  9573.             SCROLLUP enforces x2 x1 and y2y1.  When placed within a loop,
  9574.             SCROLLUP will create a scrolling effect.
  9575.  
  9576.             SEE ALSO
  9577.  
  9578.             SCROLLDN, SCROLLLT, SCROLLRT
  9579.  
  9580.             EXAMPLE
  9581.  
  9582.             /*
  9583.              * scroll some text up
  9584.              */
  9585.  
  9586.             #include <stdlib.h>
  9587.             #include <conio.h>
  9588.             #include "svgacc.h"
  9589.  
  9590.             void main(void)
  9591.             {
  9592.                int vmode, i;
  9593.  
  9594.                vmode = videomodeget();
  9595.                if ( !whichvga() || (whichmem() < 512))
  9596.                  exit(1);
  9597.                res640();
  9598.                drwbox (1,10,0,0,100,100);
  9599.                drwstring(1,7,0,"text text",20,43);
  9600.                for(i=0;i<40;i++)
  9601.                {
  9602.                  scrollup(1,1,99,99,1,0);
  9603.  
  9604.  
  9605.                                                                         151
  9606.  
  9607.  
  9608.  
  9609.  
  9610.  
  9611.  
  9612.                  sdelay(2);
  9613.                }
  9614.                getch();
  9615.                videomodeset(vmode);
  9616.             }
  9617.  
  9618.  
  9619.  
  9620.  
  9621.  
  9622.  
  9623.  
  9624.  
  9625.  
  9626.  
  9627.  
  9628.  
  9629.  
  9630.  
  9631.  
  9632.  
  9633.  
  9634.  
  9635.  
  9636.  
  9637.  
  9638.  
  9639.  
  9640.  
  9641.  
  9642.  
  9643.  
  9644.  
  9645.  
  9646.  
  9647.  
  9648.  
  9649.  
  9650.  
  9651.  
  9652.  
  9653.  
  9654.  
  9655.  
  9656.  
  9657.  
  9658.  
  9659.  
  9660.  
  9661.  
  9662.  
  9663.  
  9664.  
  9665.  
  9666.  
  9667.  
  9668.                                                                         152
  9669.  
  9670.  
  9671.  
  9672.  
  9673.  
  9674.  
  9675.           SDELAY
  9676.  
  9677.             PROTOTYPE
  9678.  
  9679.             extern void far sdelay (int count)
  9680.  
  9681.             INPUT
  9682.  
  9683.             count - number of vertical syncs to wait
  9684.  
  9685.             OUTPUT
  9686.  
  9687.             no value returned
  9688.  
  9689.             USAGE
  9690.  
  9691.             SDELAY pauses execution of the program for a period of time
  9692.             specified by count.  This delay remains approximately constant
  9693.             on all machines by using the vertical sync timer of the VGA
  9694.             graphics card which is about 60 - 70 Hz.
  9695.  
  9696.             EXAMPLE
  9697.  
  9698.             /*
  9699.              * make a delay of about 3 seconds long
  9700.              */
  9701.  
  9702.             #include <stdlib.h>
  9703.             #include <conio.h>
  9704.             #include <time.h>
  9705.             #include "svgacc.h"
  9706.  
  9707.             void main(void)
  9708.             {
  9709.                time_t starttime;
  9710.                time_t endtime;
  9711.                printf("ok...stating delay...should be about 3 seconds...");
  9712.                time( &starttime);
  9713.                sdelay(195);
  9714.                time( &endtime);
  9715.                printf("total time was: %d seconds...", endtime-starttime);
  9716.                exit(0);
  9717.             }
  9718.  
  9719.  
  9720.  
  9721.  
  9722.  
  9723.  
  9724.  
  9725.  
  9726.  
  9727.  
  9728.  
  9729.  
  9730.  
  9731.                                                                         153
  9732.  
  9733.  
  9734.  
  9735.  
  9736.  
  9737.  
  9738.           SETCARD
  9739.  
  9740.             PROTOTYPE
  9741.  
  9742.             extern void far setcard (VGAChipset chip, int mem)
  9743.  
  9744.             INPUT
  9745.  
  9746.             chip - code for SVGA chip type
  9747.             mem - amount of video memory installed
  9748.  
  9749.             OUTPUT
  9750.  
  9751.             no value returned
  9752.  
  9753.             USAGE
  9754.  
  9755.             WARNING:  USING SETCARD IMPROPERLY MAY CAUSE A SYSTEM FAILURE
  9756.             OR DAMAGE.
  9757.             SETCARD sets the card type and installed video memory.  It can
  9758.             be used instead of the WHICHVGA function.  However, specifying
  9759.             an incorrect chip type or installed video memory may cause
  9760.             unpredictable results not excluding damage to the SVGA card
  9761.             and/or monitor.  Extreme caution is advised when using this
  9762.             function.  It is recommended that this function only be used
  9763.             when it is suspected that the identification process in
  9764.             WHICHVGA failed.  Be absolutely certain that the chip type
  9765.             specified is the actual chip type installed in the computer.
  9766.             Mem should be a value of 256, 512 or 1024 representing the
  9767.             kilobytes of video memory installed.  Use the following table
  9768.             to identify chip types:
  9769.  
  9770.           1  Acumos AVGA2/3 SuperVGA
  9771.           2  ATI Technologies 18/28/38/68800 SuperVGA
  9772.           3  Ahead V5000 ver A SuperVGA
  9773.           4  Ahead V5000 ver B SuperVGA
  9774.           5  Chips and Technologies 82C45x SuperVGA
  9775.           6  Cirrus Logic CL-GD 5xx, 6xx, 28xx, 54xx, 62xx SuperVGA
  9776.           7  Everex Micro Enhancer Ev236/6xx SuperVGA
  9777.           8  Genoa 61/62/63/64/6600 SuperVGA
  9778.           9  NCR 77C21/22/22E/22E+ SuperVGA
  9779.           10 Oak Technologies OTI-037C/067/077/087 SuperVGA
  9780.           11 Paradise/Western Digital PVGA1A, WD90C00/1x/2x/3x SuperVGA
  9781.           12 Realtek RT3106 SuperVGA
  9782.           13 Trident 8800CS, 8900B/C/CL/CX, 90x0 SuperVGA
  9783.           14 Tseng Labs ET3000-AX/BX/BP SuperVGA
  9784.           15 Tseng Labs ET4000/W32/W32I SuperVGA
  9785.           16 VESA compatible SuperVGA
  9786.           17 Video 7 HT-208/16 SuperVGA
  9787.           18 Avance Logic AL2101 SuperVGA
  9788.           19 MXIC MX68000/10 SuperVGA
  9789.           20 Primus P2000 SuperVGA
  9790.  
  9791.  
  9792.  
  9793.  
  9794.                                                                         154
  9795.  
  9796.  
  9797.  
  9798.  
  9799.  
  9800.  
  9801.             SEE ALSO
  9802.  
  9803.             WHICHVGA
  9804.  
  9805.             EXAMPLE
  9806.  
  9807.             /*
  9808.             !WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNI
  9809.             NG!  */
  9810.             /*                                                        */
  9811.             /* USE THE "SETCARD" FUNCTION CAREFULLY. IT WORKS AROUND
  9812.             "WHICHVGA".  */
  9813.             /* IMPROPER USE (I.E. SETTING THE CARD ID AND MEMORY TO
  9814.             SOMETHING    */
  9815.             /* THAT IS NOT VALID) MIGHT DAMAGE YOUR VIDEO CARD/VIDEO
  9816.             MONITOR OR   */
  9817.             /* CAUSE UNPREDICTABLE RESULTS. IT IS PROVIDED AS A METHOD TO
  9818.             FIND */
  9819.             /* FAULTS IN THE VIDEO CARD/CHIP ID PROCESS.
  9820.                */
  9821.             /*                                                        */
  9822.             /*
  9823.             !WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNI
  9824.             NG!  */
  9825.  
  9826.  
  9827.  
  9828.  
  9829.  
  9830.  
  9831.  
  9832.  
  9833.  
  9834.  
  9835.  
  9836.  
  9837.  
  9838.  
  9839.  
  9840.  
  9841.  
  9842.  
  9843.  
  9844.  
  9845.  
  9846.  
  9847.  
  9848.  
  9849.  
  9850.  
  9851.  
  9852.  
  9853.  
  9854.  
  9855.  
  9856.  
  9857.                                                                         155
  9858.  
  9859.  
  9860.  
  9861.  
  9862.  
  9863.  
  9864.           SETVIEW
  9865.  
  9866.             PROTOTYPE
  9867.  
  9868.             extern void far setview (int x1, int y1, int x2, int y2)
  9869.  
  9870.             INPUT
  9871.  
  9872.             x1, y1 - top, left corner of view port
  9873.             x2, y2 - bottom, right corner of view port
  9874.  
  9875.             OUTPUT
  9876.  
  9877.             no value returned
  9878.  
  9879.             USAGE
  9880.  
  9881.             SETVIEW defines a viewport for clipping output on the screen.
  9882.             Nothing can be drawn outside of the currently defined
  9883.             viewport.  The RES### functions set the viewport to the full
  9884.             screen.  The restrictions on X1, Y1, X2 and Y2 are as follows:
  9885.  
  9886.             0   X1 < X2  (screen width)
  9887.             0   Y1 < Y2  (32767, effectively unbounded)
  9888.  
  9889.             SEE ALSO
  9890.  
  9891.             RES320, RES640, RES640L, RES800, RES1024
  9892.  
  9893.             EXAMPLE
  9894.  
  9895.             /*
  9896.              * draws a lines clipped to a view port
  9897.              */
  9898.  
  9899.             #include <stdlib.h>
  9900.             #include <conio.h>
  9901.             #include "svgacc.h"
  9902.             #define randnum(size) (rand() % (int)(size))
  9903.  
  9904.             void main(void)
  9905.             {
  9906.                int vmode, i, x1, y1, x2, y2;
  9907.  
  9908.                vmode = videomodeget();
  9909.                if ( !whichvga() || (whichmem() < 512))
  9910.                  exit(1);
  9911.                res640();
  9912.                drwbox(1,15,101,101,538,378);
  9913.                setview(101,101,538,378);
  9914.                for(i=0;i<300;i++) {
  9915.                  x1 = randnum(640);
  9916.                  y1 = randnum(480);
  9917.                  x2 = randnum(640);
  9918.  
  9919.  
  9920.                                                                         156
  9921.  
  9922.  
  9923.  
  9924.  
  9925.  
  9926.  
  9927.                  y2 = randnum(480);
  9928.                  drwline(1,10,x1,y1,x2,y2);
  9929.                }
  9930.                getch();
  9931.                videomodeset(vmode);
  9932.                exit(0);
  9933.             }
  9934.  
  9935.  
  9936.  
  9937.  
  9938.  
  9939.  
  9940.  
  9941.  
  9942.  
  9943.  
  9944.  
  9945.  
  9946.  
  9947.  
  9948.  
  9949.  
  9950.  
  9951.  
  9952.  
  9953.  
  9954.  
  9955.  
  9956.  
  9957.  
  9958.  
  9959.  
  9960.  
  9961.  
  9962.  
  9963.  
  9964.  
  9965.  
  9966.  
  9967.  
  9968.  
  9969.  
  9970.  
  9971.  
  9972.  
  9973.  
  9974.  
  9975.  
  9976.  
  9977.  
  9978.  
  9979.  
  9980.  
  9981.  
  9982.  
  9983.                                                                         157
  9984.  
  9985.  
  9986.  
  9987.  
  9988.  
  9989.  
  9990.           SPRITECOLLDETECT
  9991.  
  9992.             PROTOTYPE
  9993.  
  9994.             extern int far spritecolldetect (int transcolr, int x1, int
  9995.             y1, int x2, int y2, RasterBlock far *sprite1, RasterBlock far
  9996.             *sprite2)
  9997.  
  9998.             INPUT
  9999.  
  10000.             transcolr - index to color in current palette
  10001.             x1, y1 - location of top, left corner of sprite number 1
  10002.             x2, y2 - location of top, left corner of sprite number 2
  10003.             sprite1 - sprite number 1
  10004.             sprite2 - sprite number 2
  10005.  
  10006.             OUTPUT
  10007.  
  10008.             SPRITECOLLDETECT returns the collision status of the two
  10009.             sprites.
  10010.  
  10011.             USAGE
  10012.  
  10013.             SPRITECOLLDETECT is used in sprite graphics or animation to
  10014.             report the collision status between two sprites.  Sprite1
  10015.             contains the first sprite which should have been previously
  10016.             defined by BLKGET or similar function.  Sprite2, likewise,
  10017.             contains the second sprite.  The top, left corner of the first
  10018.             and second sprites' locations are specified by x1, y1 and x2,
  10019.             y2, respectively.
  10020.  
  10021.             SPRITECOLLDETECT will return a zero if the sprites are not
  10022.             colliding and the blocks are not overlapping.  The return will
  10023.             be one if the blocks overlap, but the sprites are not
  10024.             colliding.  A return value of two indicates that the sprites
  10025.             have at least one overlapping pixel and are, therefore,
  10026.             colliding.
  10027.  
  10028.             SEE ALSO
  10029.  
  10030.             BLKGET, BLKPUT, GETLASTSTRING, SPRITEGAP, SPRITEGET, SPRITEPUT
  10031.  
  10032.             EXAMPLE
  10033.  
  10034.             /*
  10035.              * shows how spritecolldetect works
  10036.              */
  10037.  
  10038.             #include <stdlib.h>
  10039.             #include <conio.h>
  10040.             #include "svgacc.h"
  10041.  
  10042.             void main(void)
  10043.             {
  10044.  
  10045.  
  10046.                                                                         158
  10047.  
  10048.  
  10049.  
  10050.  
  10051.  
  10052.  
  10053.                int vmode, ret, i, x1, y1, x2, y2;
  10054.                char text[70];
  10055.  
  10056.                RasterBlock *sprite1data, *sprite2data;
  10057.  
  10058.                vmode = videomodeget();
  10059.                if ( !whichvga() )
  10060.                  exit(1);
  10061.                res320();
  10062.                x1 = 0;
  10063.                y1 = 0;
  10064.                x2 = 48;
  10065.                y2 = 48;
  10066.                drwline(1,8,x1,y1,x2,y1);
  10067.                drwline(1,8,x2,y1,x2,y2);
  10068.                drwline(1,8,x2,y2,x1,y2);
  10069.                drwline(1,8,x1,y2,x1,y1);
  10070.                fillarea(x1+1,y1+1,8,8);
  10071.                drwellipse(1,10,((x2-x1)/2+x1),((y2-y1)/2+y1),(x2-x1)/2,(y2-
  10072.             y1)/2);
  10073.                sprite1data = (RasterBlock *)malloc((x2-x1+1)*(y2-y1+1)+4);
  10074.                blkget(x1,y1,x2,y2,sprite1data);
  10075.                blkput(2,x1,y1,sprite1data);
  10076.                x1 = 0;
  10077.                y1 = 0;
  10078.                x2 = 24;
  10079.                y2 = 24;
  10080.                drwline(1,8,x1,y1,x2,y1);
  10081.                drwline(1,8,x2,y1,x2,y2);
  10082.                drwline(1,8,x2,y2,x1,y2);
  10083.                drwline(1,8,x1,y2,x1,y1);
  10084.                fillarea(x1+1,y1+1,8,8);
  10085.                drwline(1,10,x1,y1,x2,y2);
  10086.                drwline(1,10,x2,y1,x1,y2);
  10087.                sprite2data = (RasterBlock *)malloc((x2-x1+1)*(y2-y1+1)+4);
  10088.                blkget(x1,y1,x2,y2,sprite2data);
  10089.                blkput(2,x1,y1,sprite2data);
  10090.                x1=90;
  10091.                y1=90;
  10092.                blkput(2,x1,y1,sprite1data);
  10093.                for(i=30;i<150;i++)
  10094.                {
  10095.                  blkput(2,i,i,sprite2data);
  10096.                  ret =
  10097.             spritecolldetect(8,x1,y1,i,i,sprite1data,sprite2data);
  10098.                  sprintf(text,"the return value is: %d",ret);
  10099.                  drwstring(1,7,0,text,0,0);
  10100.                  getch();
  10101.                  blkput(2,i,i,sprite2data);
  10102.                }
  10103.                videomodeset(vmode);
  10104.                exit(0);
  10105.             }
  10106.  
  10107.  
  10108.  
  10109.                                                                         159
  10110.  
  10111.  
  10112.  
  10113.  
  10114.  
  10115.  
  10116.           SPRITEGAP
  10117.  
  10118.             PROTOTYPE
  10119.  
  10120.             extern void far spritegap (int transcolr, int x, int y,
  10121.             RasterBlock far *sprite, RasterBlock far *spritebkgnd)
  10122.  
  10123.             INPUT
  10124.  
  10125.             transcolr - index to color in current palette
  10126.             x, y - top, left corner of block
  10127.             sprite- the sprite to place on screen
  10128.  
  10129.             OUTPUT
  10130.  
  10131.             no value returned
  10132.             spritebkgnd - sprite background
  10133.  
  10134.             USAGE
  10135.  
  10136.             SPRITEGAP ("Sprite-Get-And-Put") is used in sprite graphics or
  10137.             animation to retrieve a sprite's background and then display
  10138.             the sprite.  Sprite contains the sprite which should have been
  10139.             previously defined by BLKGET or similar function such as
  10140.             GETLASTSTRING.  Transcolr is the transparent colr assumed in
  10141.             sprite.  Spritebkgnd, a pointer to a RasterBlock structure the
  10142.             same size as the sprite, will receive the sprite's background.
  10143.             The top, left corner of the sprite's location is specified by
  10144.             x, y.
  10145.  
  10146.             SEE ALSO
  10147.  
  10148.             BLKGET, BLKPUT, GETLASTSTRING, SPRITECOLLDETECT, SPRITEGET,
  10149.             SPRITEPUT
  10150.  
  10151.             EXAMPLE
  10152.  
  10153.             /*
  10154.              * Show spritegap
  10155.              */
  10156.  
  10157.             #include <stdlib.h>
  10158.             #include <math.h>
  10159.             #include <conio.h>
  10160.             #include "svgacc.h"
  10161.  
  10162.             void main(void)
  10163.             {
  10164.                int vmode;
  10165.                int i, j, colr, xinc, yinc, x1, y1, x2, y2, cnt, cntx, cnty,
  10166.             rot;
  10167.                RasterBlock *gfxblk, *gfxblk2, *spritebkgnd;
  10168.  
  10169.                vmode = videomodeget();
  10170.  
  10171.  
  10172.                                                                         160
  10173.  
  10174.  
  10175.  
  10176.  
  10177.  
  10178.  
  10179.                if ( !whichvga() )
  10180.                  exit(1);
  10181.                if ( whichmem() < 512)
  10182.                  exit(1);
  10183.                if ( !res640() )
  10184.                  exit(1);
  10185.                xinc = maxx/20;
  10186.                yinc = maxy/20;
  10187.                x1 = maxx/2-xinc;
  10188.                y1 = maxy/2-yinc;
  10189.                x2 = maxx/2+xinc;
  10190.                y2 = maxy/2+yinc;
  10191.                i = (x2-x1+1)*(y2-y1+1)+4;
  10192.                gfxblk = (RasterBlock *)malloc(i);
  10193.                if (!gfxblk) {
  10194.                  restext();
  10195.                  printf("ERROR: Allocating memory for gfxblk: %d
  10196.             bytes\n",i);
  10197.                  exit(1);
  10198.                }
  10199.                colr = 1;
  10200.                for(i=0;i<=maxx/2;i++) {
  10201.                  drwcircle(1,colr,maxx/4+i,maxy/2,maxy/5);
  10202.                  colr+=1;
  10203.                  if(colr>15)
  10204.                     colr = 1;
  10205.                }
  10206.                drwbox(1,0,x1,y1,x2,y2);
  10207.                blkget(x1,y1,x2,y2,gfxblk);
  10208.                cntx = (x2-x1) / 2 + x1;
  10209.                cnty = (y2-y1) / 2 + y1;
  10210.                fillarea(x1+2,y1+2,0,0);
  10211.                i = blkrotatesize(45,gfxblk);
  10212.                spritebkgnd = (RasterBlock *)malloc(i);
  10213.                if (!spritebkgnd) {
  10214.                  restext();
  10215.                  printf("ERROR: Allocating memory for spritebkgnd: %d
  10216.             bytes\n",i);
  10217.                  exit(1);
  10218.                }
  10219.                gfxblk2 = (RasterBlock *)malloc(i);
  10220.                if (!gfxblk2) {
  10221.                  restext();
  10222.                  printf("ERROR: Allocating memory for gfxblk2: %d
  10223.             bytes\n",i);
  10224.                  exit(1);
  10225.                }
  10226.                blkget(x1,y1,x2,y2,spritebkgnd);
  10227.                setview(0,64,maxx,maxy);
  10228.                for(i=0;i<=360;i+=3) {
  10229.                  rot = blkrotate(i,1,gfxblk,gfxblk2);
  10230.                  spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  10231.             (spritebkgnd->height)/2,spritebkgnd);
  10232.  
  10233.  
  10234.  
  10235.                                                                         161
  10236.  
  10237.  
  10238.  
  10239.  
  10240.  
  10241.  
  10242.                  spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  10243.             >height)/2,gfxblk2,spritebkgnd);
  10244.                  sdelay(3);
  10245.                }
  10246.                spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  10247.             (spritebkgnd->height)/2,spritebkgnd);
  10248.                blkput(SET,x1,y1,(RasterBlock *)gfxblk);
  10249.                getch();
  10250.                videomodeset(vmode);
  10251.                exit(0);
  10252.             }
  10253.  
  10254.  
  10255.  
  10256.  
  10257.  
  10258.  
  10259.  
  10260.  
  10261.  
  10262.  
  10263.  
  10264.  
  10265.  
  10266.  
  10267.  
  10268.  
  10269.  
  10270.  
  10271.  
  10272.  
  10273.  
  10274.  
  10275.  
  10276.  
  10277.  
  10278.  
  10279.  
  10280.  
  10281.  
  10282.  
  10283.  
  10284.  
  10285.  
  10286.  
  10287.  
  10288.  
  10289.  
  10290.  
  10291.  
  10292.  
  10293.  
  10294.  
  10295.  
  10296.  
  10297.  
  10298.                                                                         162
  10299.  
  10300.  
  10301.  
  10302.  
  10303.  
  10304.  
  10305.           SPRITEGET
  10306.  
  10307.             PROTOTYPE
  10308.  
  10309.             extern void far spriteget (int transcolr, int x, int y,
  10310.             RasterBlock far *sprite, RasterBlock far *spritebkgnd)
  10311.  
  10312.             INPUT
  10313.  
  10314.             transcolr - index to color in current palette
  10315.             x, y - top, left corner of block
  10316.             sprite - sprite to use as pattern
  10317.  
  10318.             OUTPUT
  10319.  
  10320.             no value returned
  10321.             spritebkgnd - sprite background
  10322.  
  10323.             USAGE
  10324.  
  10325.             SPRITEGET is used in sprite graphics or animation to retrieve
  10326.             the background for a sprite, normally just before using
  10327.             SPRITEPUT.  Sprite contains the sprite which should have been
  10328.             previously defined by BLKGET or similar function.  Transcolr
  10329.             is the transparent color assumed in the sprite.  Spritebkgnd,
  10330.             a pointer to a RasterBlock structure the same size as the
  10331.             sprite, will receive the sprite's background.  The top, left
  10332.             corner of the sprite's location is specified by x, y.
  10333.  
  10334.             SEE ALSO
  10335.  
  10336.             BLKGET, BLKPUT, GETLASTSTRING, SPRITECOLLDETECT, SPRITEGAP,
  10337.             SPRITEPUT
  10338.  
  10339.             EXAMPLE
  10340.  
  10341.             /*
  10342.              * Show spriteget
  10343.              */
  10344.  
  10345.             #include <stdlib.h>
  10346.             #include <math.h>
  10347.             #include <conio.h>
  10348.             #include "svgacc.h"
  10349.  
  10350.             void main(void)
  10351.             {
  10352.                int vmode, i, j, colr, xinc, yinc, x1, y1, x2, y2, cntx,
  10353.             cnty, rot;
  10354.                RasterBlock *gfxblk, *gfxblk2, *spritebkgnd;
  10355.                vmode = videomodeget();
  10356.                if ( !whichvga() )
  10357.                  exit(1);
  10358.                if ( whichmem() < 512)
  10359.  
  10360.  
  10361.                                                                         163
  10362.  
  10363.  
  10364.  
  10365.  
  10366.  
  10367.  
  10368.                  exit(1);
  10369.                if ( !res640() )
  10370.                  exit(1);
  10371.                xinc = maxx/20;
  10372.                yinc = maxy/20;
  10373.                x1 = maxx/2-xinc;
  10374.                y1 = maxy/2-yinc;
  10375.                x2 = maxx/2+xinc;
  10376.                y2 = maxy/2+yinc;
  10377.                i = (x2-x1+1)*(y2-y1+1)+4;
  10378.                gfxblk = (RasterBlock *)malloc(i);
  10379.                if (!gfxblk) {
  10380.                  restext();
  10381.                  printf("ERROR: Allocating memory for gfxblk: %d
  10382.             bytes\n",i);
  10383.                  exit(1);
  10384.                }
  10385.                colr = 1;
  10386.                for(i=0;i<=maxx/2;i++) {
  10387.                  drwcircle(1,colr,maxx/4+i,maxy/2,maxy/5);
  10388.                  colr+=1;
  10389.                  if(colr>15)
  10390.                     colr = 1;
  10391.                }
  10392.                drwbox(1,0,x1,y1,x2,y2);
  10393.                blkget(x1,y1,x2,y2,gfxblk);
  10394.                cntx = (x2-x1) / 2 + x1;
  10395.                cnty = (y2-y1) / 2 + y1;
  10396.                fillarea(x1+2,y1+2,0,0);
  10397.                i = blkrotatesize(45,gfxblk);
  10398.                spritebkgnd = (RasterBlock *)malloc(i);
  10399.                if (!spritebkgnd) {
  10400.                  restext();
  10401.                  printf("ERROR: Allocating memory for spritebkgnd: %d
  10402.             bytes\n",i);
  10403.                  exit(1);
  10404.                }
  10405.                gfxblk2 = (RasterBlock *)malloc(i);
  10406.                if (!gfxblk2) {
  10407.                  restext();
  10408.                  printf("ERROR: Allocating memory for gfxblk2: %d
  10409.             bytes\n",i);
  10410.                  exit(1);
  10411.                }
  10412.                blkget(x1,y1,x2,y2,spritebkgnd);
  10413.                setview(0,64,maxx,maxy);
  10414.                for(i=0;i<=360;i+=3) {
  10415.                  rot = blkrotate(i,1,gfxblk,gfxblk2);
  10416.                  spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  10417.             (spritebkgnd->height)/2,spritebkgnd);
  10418.                  spriteget(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  10419.             >height)/2,gfxblk2,spritebkgnd);
  10420.                  spriteput(SET,1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  10421.             >height)/2,gfxblk2);
  10422.  
  10423.  
  10424.                                                                         164
  10425.  
  10426.  
  10427.  
  10428.  
  10429.  
  10430.  
  10431.                  sdelay(3);
  10432.                }
  10433.                spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  10434.             (spritebkgnd->height)/2,spritebkgnd);
  10435.                blkput(SET,x1,y1,(RasterBlock *)gfxblk);
  10436.                getch();
  10437.                videomodeset(vmode);
  10438.                exit(0);
  10439.             }
  10440.  
  10441.  
  10442.  
  10443.  
  10444.  
  10445.  
  10446.  
  10447.  
  10448.  
  10449.  
  10450.  
  10451.  
  10452.  
  10453.  
  10454.  
  10455.  
  10456.  
  10457.  
  10458.  
  10459.  
  10460.  
  10461.  
  10462.  
  10463.  
  10464.  
  10465.  
  10466.  
  10467.  
  10468.  
  10469.  
  10470.  
  10471.  
  10472.  
  10473.  
  10474.  
  10475.  
  10476.  
  10477.  
  10478.  
  10479.  
  10480.  
  10481.  
  10482.  
  10483.  
  10484.  
  10485.  
  10486.  
  10487.                                                                         165
  10488.  
  10489.  
  10490.  
  10491.  
  10492.  
  10493.  
  10494.           SPRITEPUT
  10495.  
  10496.             PROTOTYPE
  10497.  
  10498.             extern void far spriteput (PixelMode mode, int transcolr, int
  10499.             x, int y, RasterBlock far *sprite)
  10500.  
  10501.             INPUT
  10502.  
  10503.             mode - pixel write mode
  10504.             transcolr - index to color in current palette
  10505.             x, y - top, left corner of block
  10506.             sprite- sprite to place on screen
  10507.  
  10508.             OUTPUT
  10509.  
  10510.             no value returned
  10511.  
  10512.             USAGE
  10513.  
  10514.             SPRITEPUT is used in sprite graphics or animation to display a
  10515.             sprite or, more commonly, its background.  Sprite contains the
  10516.             sprite which should have been previously defined by BLKGET,
  10517.             SPRITEGAP or SPRITEGET.  Transcolr is the transparent color
  10518.             assumed in sprite.  The top, left corner of the sprite's
  10519.             location is specified by x, y.
  10520.  
  10521.             SEE ALSO
  10522.  
  10523.             BLKGET, BLKPUT, GETLASTSTRING, SPRITECOLLDETECT, SPRITEGAP,
  10524.             SPRITEGET
  10525.  
  10526.             EXAMPLE
  10527.  
  10528.             See SPRITEGET
  10529.  
  10530.  
  10531.  
  10532.  
  10533.  
  10534.  
  10535.  
  10536.  
  10537.  
  10538.  
  10539.  
  10540.  
  10541.  
  10542.  
  10543.  
  10544.  
  10545.  
  10546.  
  10547.  
  10548.  
  10549.  
  10550.                                                                         166
  10551.  
  10552.  
  10553.  
  10554.  
  10555.  
  10556.  
  10557.           VIDEOMODEGET
  10558.  
  10559.             PROTOTYPE
  10560.  
  10561.             extern int far videomodeget (void)
  10562.  
  10563.             INPUT
  10564.  
  10565.             no input parameters
  10566.  
  10567.             OUTPUT
  10568.  
  10569.             the current video mode
  10570.  
  10571.             USAGE
  10572.  
  10573.             VIDEOMODEGET returns the current video mode.  This function is
  10574.             best used to retrieve the video mode being used when a program
  10575.             begins.  When the program ends, this video mode can then be
  10576.             restored using VIDEOMODESET.
  10577.  
  10578.             SEE ALSO
  10579.  
  10580.             RES320, RES640, RES640L, RES800, RES1024, RESTEXT,
  10581.             VIDEOMODESET
  10582.  
  10583.             EXAMPLE
  10584.  
  10585.             /*
  10586.              * save the current video mode, enable 640x480x256, and reset
  10587.             the video mode
  10588.              */
  10589.  
  10590.             #include <stdlib.h>
  10591.             #include <conio.h>
  10592.             #include "svgacc.h"
  10593.  
  10594.             void main(void)
  10595.             {
  10596.                int vmode;
  10597.  
  10598.                vmode = videomodeget();
  10599.                if ( !whichvga() )
  10600.                  exit(1);
  10601.                if ( whichmem() < 512)
  10602.                  exit(1);
  10603.                res640();
  10604.                videomodeset(vmode);
  10605.                printf("we are back!");
  10606.                getch();
  10607.                exit(0);
  10608.             }
  10609.  
  10610.  
  10611.  
  10612.  
  10613.                                                                         167
  10614.  
  10615.  
  10616.  
  10617.  
  10618.  
  10619.  
  10620.           VIDEOMODESET
  10621.  
  10622.             PROTOTYPE
  10623.  
  10624.             extern void far videomodeset (int videomode)
  10625.  
  10626.             INPUT
  10627.  
  10628.             mode - number of video mode
  10629.  
  10630.             OUTPUT
  10631.  
  10632.             no value returned
  10633.  
  10634.             USAGE
  10635.  
  10636.             VIDEOMODESET sets the video mode specified by mode.  This
  10637.             function is best used at the end of a program to restore the
  10638.             video mode to the mode in use when the program began.  The
  10639.             program should retrieve the video mode at the beginning by
  10640.             using VIDEOMODEGET.
  10641.  
  10642.             SEE ALSO
  10643.  
  10644.             RES320, RES640, RES640L, RES800, RES1024, RESTEXT,
  10645.             VIDEOMODEGET
  10646.  
  10647.             EXAMPLE
  10648.  
  10649.             See VIDEMODEGET
  10650.  
  10651.  
  10652.  
  10653.  
  10654.  
  10655.  
  10656.  
  10657.  
  10658.  
  10659.  
  10660.  
  10661.  
  10662.  
  10663.  
  10664.  
  10665.  
  10666.  
  10667.  
  10668.  
  10669.  
  10670.  
  10671.  
  10672.  
  10673.  
  10674.  
  10675.  
  10676.                                                                         168
  10677.  
  10678.  
  10679.  
  10680.  
  10681.  
  10682.  
  10683.           VIDEOOFF
  10684.  
  10685.             PROTOTYPE
  10686.  
  10687.             extern void far videooff (void)
  10688.  
  10689.             INPUT
  10690.  
  10691.             no input parameters
  10692.  
  10693.             OUTPUT
  10694.  
  10695.             no value returned
  10696.  
  10697.             USAGE
  10698.  
  10699.             VIDEOOFF turns the output display off.  Graphics may still be
  10700.             drawn to the screen.  However, the computer's monitor will
  10701.             display nothing and appear black.  This function can be used
  10702.             to hide graphics being drawn by initially using VIDEOOFF and
  10703.             then later calling VIDEOON.
  10704.  
  10705.             SEE ALSO
  10706.  
  10707.             VIDEOON
  10708.  
  10709.             EXAMPLE
  10710.  
  10711.             /*
  10712.              * disable the video for about 3 seconds, then enable it
  10713.              */
  10714.  
  10715.             #include <stdlib.h>
  10716.             #include <conio.h>
  10717.             #include "svgacc.h"
  10718.  
  10719.             void main(void)
  10720.             {
  10721.                int vmode;
  10722.  
  10723.                printf("press a key to disable video for 3 seconds...");
  10724.                getch();
  10725.                videooff();
  10726.                sdelay(195);
  10727.                videoon();
  10728.                videomodeset(vmode);
  10729.                printf("we are back!");
  10730.                getch();
  10731.                exit(0);
  10732.             }
  10733.  
  10734.  
  10735.  
  10736.  
  10737.  
  10738.  
  10739.                                                                         169
  10740.  
  10741.  
  10742.  
  10743.  
  10744.  
  10745.  
  10746.           VIDEOON
  10747.  
  10748.             PROTOTYPE
  10749.  
  10750.             extern void far videoon (void)
  10751.  
  10752.             INPUT
  10753.  
  10754.             no input parameters
  10755.  
  10756.             OUTPUT
  10757.  
  10758.             no value returned
  10759.  
  10760.             USAGE
  10761.  
  10762.             VIDEOON turns the display on.  All graphics that were drawn
  10763.             while the display was off are now visible.  This function can
  10764.             be used to hide graphics being drawn by initially using
  10765.             VIDEOOFF and then later calling VIDEOON.
  10766.  
  10767.             SEE ALSO
  10768.  
  10769.             VIDEOOFF
  10770.  
  10771.             EXAMPLE
  10772.  
  10773.             See VIDEOOFF
  10774.  
  10775.  
  10776.  
  10777.  
  10778.  
  10779.  
  10780.  
  10781.  
  10782.  
  10783.  
  10784.  
  10785.  
  10786.  
  10787.  
  10788.  
  10789.  
  10790.  
  10791.  
  10792.  
  10793.  
  10794.  
  10795.  
  10796.  
  10797.  
  10798.  
  10799.  
  10800.  
  10801.  
  10802.                                                                         170
  10803.  
  10804.  
  10805.  
  10806.  
  10807.  
  10808.  
  10809.           WHICHCPU
  10810.  
  10811.             PROTOTYPE
  10812.  
  10813.             extern int far whichcpu (void)
  10814.  
  10815.             INPUT
  10816.  
  10817.             no input parameters
  10818.  
  10819.             OUTPUT
  10820.  
  10821.             processor type
  10822.  
  10823.             USAGE
  10824.  
  10825.             WHICHCPU returns the computer's processor type as 86, 286, 386
  10826.             or 486.  This function should be called by any program using
  10827.             this library's routines to insure that the computer is at
  10828.             least 386 compatible or better.
  10829.  
  10830.             SEE ALSO
  10831.  
  10832.             WHICHJOYSTICK, WHICHMOUSE, WHICHVGA
  10833.  
  10834.             EXAMPLE
  10835.  
  10836.             /*
  10837.              * id the microprocessor
  10838.              */
  10839.  
  10840.             #include <stdlib.h>
  10841.             #include <conio.h>
  10842.             #include "svgacc.h"
  10843.  
  10844.             void main(void)
  10845.             {
  10846.                int vmode;
  10847.                int cpu;
  10848.  
  10849.                cpu = whichcpu();
  10850.                printf("Microprocessor is identified as an 80%d.\n", cpu);
  10851.                getch();
  10852.                exit(0);
  10853.             }
  10854.  
  10855.  
  10856.  
  10857.  
  10858.  
  10859.  
  10860.  
  10861.  
  10862.  
  10863.  
  10864.  
  10865.                                                                         171
  10866.  
  10867.  
  10868.  
  10869.  
  10870.  
  10871.  
  10872.           WHICHJOYSTICK
  10873.  
  10874.             PROTOTYPE
  10875.  
  10876.             extern int far whichjoystick (void)
  10877.  
  10878.             INPUT
  10879.  
  10880.             no input parameters
  10881.  
  10882.             OUTPUT
  10883.  
  10884.             available joystick support
  10885.  
  10886.             USAGE
  10887.  
  10888.             WHICHJOYSTICK returns the joystick support available on the
  10889.             computer.  This function should be called prior to use of the
  10890.             joysticks to verify that joysticks are available.  If the
  10891.             function returns a -1, there is no joystick port present or no
  10892.             BIOS support for a joystick.  Joystick A is bit 1 and B is bit
  10893.             2.  Therefore, a return value of 1 means joystick A is
  10894.             available, a value of 2 means B is available and a value of 3
  10895.             means both are available.  If no bits are set, there are no
  10896.             joysticks present.
  10897.  
  10898.             SEE ALSO
  10899.  
  10900.             JOYSTICKINFO, WHICHCPU, WHICHMOUSE, WHICHVGA
  10901.  
  10902.             EXAMPLE
  10903.  
  10904.             /* id any joysticks */
  10905.             #include <stdlib.h>
  10906.             #include "svgacc.h"
  10907.  
  10908.             void main(void)
  10909.             {
  10910.                int vmode, joystick;
  10911.  
  10912.                joystick = whichjoystick();
  10913.                switch (joystick) {
  10914.                  case -1:
  10915.                     printf("No joystick port detected or no joystick BIOS
  10916.             support present.\n\n");
  10917.                     break;
  10918.                  case 0:
  10919.                     printf("No joystick detected\n\n");
  10920.                     break;
  10921.                  case 1:
  10922.                     printf("Joystick A is present and available.\n\n");
  10923.                     break;
  10924.                  case 2:
  10925.                     printf("Joystick B is present and available.\n\n");
  10926.  
  10927.  
  10928.                                                                         172
  10929.  
  10930.  
  10931.  
  10932.  
  10933.  
  10934.  
  10935.                     break;
  10936.                  case 3:
  10937.                     printf("Both Joystick A and Joystick B are
  10938.             present.\n\n");
  10939.                     break;
  10940.                }
  10941.             }
  10942.  
  10943.  
  10944.  
  10945.  
  10946.  
  10947.  
  10948.  
  10949.  
  10950.  
  10951.  
  10952.  
  10953.  
  10954.  
  10955.  
  10956.  
  10957.  
  10958.  
  10959.  
  10960.  
  10961.  
  10962.  
  10963.  
  10964.  
  10965.  
  10966.  
  10967.  
  10968.  
  10969.  
  10970.  
  10971.  
  10972.  
  10973.  
  10974.  
  10975.  
  10976.  
  10977.  
  10978.  
  10979.  
  10980.  
  10981.  
  10982.  
  10983.  
  10984.  
  10985.  
  10986.  
  10987.  
  10988.  
  10989.  
  10990.  
  10991.                                                                         173
  10992.  
  10993.  
  10994.  
  10995.  
  10996.  
  10997.  
  10998.           WHICHMEM
  10999.  
  11000.             PROTOTYPE
  11001.  
  11002.             extern int far whichmem (void)
  11003.  
  11004.             INPUT
  11005.  
  11006.             no input parameters
  11007.  
  11008.             OUTPUT
  11009.  
  11010.             installed video memory in kilobytes
  11011.  
  11012.             USAGE
  11013.  
  11014.             WHICHMEM returns the amount of installed video memory as
  11015.             previously determined by WHICHVGA.  WHICHVGA should be called
  11016.             prior to WHICHMEM.  This function should be called prior to
  11017.             any of the RES### functions to verify that there is enough
  11018.             memory to support the desired resolution.  If SETCARD was used
  11019.             to set the video card and memory, WHICHMEM will return the
  11020.             amount of memory as defined by SETCARD.
  11021.  
  11022.             SEE ALSO
  11023.  
  11024.             RES320, RES640, RES640L, RES800, RES1024, SETCARD, WHICHVGA
  11025.  
  11026.             EXAMPLE
  11027.  
  11028.             /*
  11029.              * id the video memory
  11030.              */
  11031.  
  11032.             #include <stdlib.h>
  11033.             #include <conio.h>
  11034.             #include "svgacc.h"
  11035.  
  11036.             void main(void)
  11037.             {
  11038.                int vmode, vga, mem;
  11039.  
  11040.                vga = whichvga();
  11041.                mem = whichmem();
  11042.                printf("Installed video memory is %d k.\n", mem);
  11043.                getch();
  11044.                exit(0);
  11045.             }
  11046.  
  11047.  
  11048.  
  11049.  
  11050.  
  11051.  
  11052.  
  11053.  
  11054.                                                                         174
  11055.  
  11056.  
  11057.  
  11058.  
  11059.  
  11060.  
  11061.           WHICHMOUSE
  11062.  
  11063.             PROTOTYPE
  11064.  
  11065.             extern int far whichmouse (void)
  11066.  
  11067.             INPUT
  11068.  
  11069.             no input parameters
  11070.  
  11071.             OUTPUT
  11072.  
  11073.             number of buttons on mouse
  11074.  
  11075.             USAGE
  11076.  
  11077.             WHICHMOUSE returns a value indicating whether a Microsoft
  11078.             compatible mouse is available.  If the function returns a 0,
  11079.             no mouse is available.  A non zero value indicates a mouse and
  11080.             Microsoft compatible driver are installed and gives the number
  11081.             of buttons (2 or 3) available.
  11082.  
  11083.             SEE ALSO
  11084.  
  11085.             MOUSEINFO, WHICHCPU, WHICHJOYSTICK, WHICHVGA
  11086.  
  11087.             EXAMPLE
  11088.  
  11089.             See MOUSEINFO
  11090.  
  11091.  
  11092.  
  11093.  
  11094.  
  11095.  
  11096.  
  11097.  
  11098.  
  11099.  
  11100.  
  11101.  
  11102.  
  11103.  
  11104.  
  11105.  
  11106.  
  11107.  
  11108.  
  11109.  
  11110.  
  11111.  
  11112.  
  11113.  
  11114.  
  11115.  
  11116.  
  11117.                                                                         175
  11118.  
  11119.  
  11120.  
  11121.  
  11122.  
  11123.  
  11124.           WHICHVGA
  11125.  
  11126.             PROTOTYPE
  11127.  
  11128.             extern VGAChipset far whichvga (void)
  11129.  
  11130.             INPUT
  11131.  
  11132.             no input parameters
  11133.  
  11134.             OUTPUT
  11135.  
  11136.             WHICHVGA returns a code identifying the video card.
  11137.  
  11138.             USAGE
  11139.  
  11140.             WHICHVGA identifies the video card installed and the amount of
  11141.             video memory.  In addition this function sets up the default
  11142.             font and mouse cursor.  This function must be called before
  11143.             any other graphics function.  The code returned identifies the
  11144.             video card according to the following table:
  11145.  
  11146.           1  Acumos AVGA2/3 SuperVGA
  11147.           2  ATI Technologies 18/28/38/68800 SuperVGA
  11148.           3  Ahead V5000 ver A SuperVGA
  11149.           4  Ahead V5000 ver B SuperVGA
  11150.           5  Chips and Technologies 82C45x SuperVGA
  11151.           6  Cirrus Logic CL-GD 5xx, 6xx, 28xx, 54xx, 62xx SuperVGA
  11152.           7  Everex Micro Enhancer Ev236/6xx SuperVGA
  11153.           8  Genoa 61/62/63/64/6600 SuperVGA
  11154.           9  NCR 77C21/22/22E/22E+ SuperVGA
  11155.           10 Oak Technologies OTI-037C/067/077/087 SuperVGA
  11156.           11 Paradise/Western Digital PVGA1A, WD90C00/1x/2x/3x SuperVGA
  11157.           12 Realtek RT3106 SuperVGA
  11158.           13 Trident 8800CS, 8900B/C/CL/CX, 90x0 SuperVGA
  11159.           14 Tseng Labs ET3000-AX/BX/BP SuperVGA
  11160.           15 Tseng Labs ET4000/W32/W32I SuperVGA
  11161.           16 VESA compatible SuperVGA
  11162.           17 Video 7 HT-208/16 SuperVGA
  11163.           18 Avance Logic AL2101 SuperVGA
  11164.           19 MXIC MX68000/10 SuperVGA
  11165.           20 Primus P2000 SuperVGA
  11166.  
  11167.             Any value returned not found on this table represents an
  11168.             unidentified video card.
  11169.  
  11170.             No graphics functions should be called unless the video card
  11171.             is properly identified.
  11172.  
  11173.             SEE ALSO
  11174.  
  11175.             SETCARD, WHICHCPU, WHICHJOYSTICK, WHICHMOUSE, WHICHMEM
  11176.  
  11177.             EXAMPLE
  11178.  
  11179.  
  11180.                                                                         176
  11181.  
  11182.  
  11183.  
  11184.  
  11185.  
  11186.  
  11187.  
  11188.             /*
  11189.              * id the svga
  11190.              */
  11191.  
  11192.             #include <stdlib.h>
  11193.             #include <conio.h>
  11194.             #include "svgacc.h"
  11195.  
  11196.             void main(void)
  11197.             {
  11198.  
  11199.             char buf[40];
  11200.  
  11201.             switch(whichvga()) {
  11202.                case ACUMOS:
  11203.                  sprintf(buf,"Acumos AVGA2/3 SuperVGA");
  11204.                  break;
  11205.                case ATI:
  11206.                  sprintf(buf,"ATI Technologies 18/28/38/68800 SuperVGA");
  11207.                  break;
  11208.                case AHEADA:
  11209.                  sprintf(buf,"Ahead V5000 Ver A SuperVGA");
  11210.                  break;
  11211.                case AHEADB:
  11212.                  sprintf(buf,"Ahead V5000 Ver B SuperVGA");
  11213.                  break;
  11214.                case CHIPSTECH:
  11215.                  sprintf(buf,"Chips and Technologies 82C450/1/2/3/5/6/7
  11216.           SuperVGA");
  11217.                  break;
  11218.                case CIRRUS:
  11219.                  sprintf(buf,"Cirrus Logic CL-GD 5xx,6xx,28xx,54xx,62xx
  11220.           SuperVGA");
  11221.                  break;
  11222.                case EVEREX:
  11223.                  sprintf(buf,"Everex EV236/6xx Micro Enhancer SuperVGA");
  11224.                  break;
  11225.                case GENOA:
  11226.                  sprintf(buf,"Genoa 61/62/63/64/6600 SuperVGA");
  11227.                  break;
  11228.                case NCR:
  11229.                  sprintf(buf,"NCR 77C21/22/22E/22E+ SuperVGA");
  11230.                  break;
  11231.                case OAKTECH:
  11232.                  sprintf(buf,"Oak Technologies OTI-037/67/77/87C
  11233.           SuperVGA");
  11234.                  break;
  11235.                case PARADISE:
  11236.                  sprintf(buf,"Paradise/Western Digital
  11237.           PVGA1A,WD90C00/1x/2x/3x SuperVGA");
  11238.                  break;
  11239.                case REALTEK:
  11240.                  sprintf(buf,"Realtek RT3106 SuperVGA");
  11241.  
  11242.  
  11243.                                                                         177
  11244.  
  11245.  
  11246.  
  11247.  
  11248.  
  11249.  
  11250.                  break;
  11251.                case TRIDENT:
  11252.                  sprintf(buf,"Trident 8800CS,8900B/C/CL/CX,90x0
  11253.           SuperVGA");
  11254.                  break;
  11255.                case TSENG3:
  11256.                  sprintf(buf,"Tseng Labs ET3000-AX/BX/BP SuperVGA");
  11257.                  break;
  11258.                case TSENG4:
  11259.                  sprintf(buf,"Tseng Labs ET4000/W32/W32I SuperVGA");
  11260.                  break;
  11261.                case VESA:
  11262.                  sprintf(buf,"VESA compatible SuperVGA");
  11263.                  break;
  11264.                case VIDEO7:
  11265.                  sprintf(buf,"Video 7 HT-208/16 SuperVGA");
  11266.                  break;
  11267.                case AVANCE:
  11268.                  sprintf(buf,"Avance Logic AL2101 SuperVGA");
  11269.                  break;
  11270.                case MXIC:
  11271.                  sprintf(buf,"MXIC MX68000/10 SuperVGA");
  11272.                  break;
  11273.                case PRIMUS:
  11274.                  sprintf(buf,"Primus P2000 SuperVGA");
  11275.                  break;
  11276.                default:
  11277.                  printf("Sorry, unable to identify video card or it is not
  11278.           a SuperVGA video adapter.\n");
  11279.                  exit(0);
  11280.             }
  11281.             printf("Video card/chip is identified as %s.\n",&buf);
  11282.             exit(0);
  11283.           }
  11284.  
  11285.  
  11286.  
  11287.  
  11288.  
  11289.  
  11290.  
  11291.  
  11292.  
  11293.  
  11294.  
  11295.  
  11296.  
  11297.  
  11298.  
  11299.  
  11300.  
  11301.  
  11302.  
  11303.  
  11304.  
  11305.  
  11306.                                                                         178
  11307.  
  11308.  
  11309.  
  11310.  
  11311.  
  11312.  
  11313.           WHICHXMS
  11314.  
  11315.             PROTOTYPE
  11316.  
  11317.             extern int far whichxms (unsigned int far *xmskbytesavail,
  11318.             unsigned int far *xmshandlesavail)
  11319.  
  11320.             INPUT
  11321.  
  11322.             no input parameters
  11323.  
  11324.             OUTPUT
  11325.  
  11326.             WHICHXMS returns a 1 if extended memory support is detected, 0
  11327.             otherwise.
  11328.             xmskbytesavail - number of free kilobytes in extended memory
  11329.             xmshandlesavail - number of available free handles
  11330.  
  11331.             USAGE
  11332.  
  11333.             WHICHXMS detects the existence of extended memory support and
  11334.             sets up the library function calls.  This function must be
  11335.             called before any other extended memory functions.  WHICHXMS
  11336.             also returns the number of free kilobytes of extended memory
  11337.             and the number of available handles.  The number of available
  11338.             handles is limited, normally to 32.  This limit can be
  11339.             modified by changing the extended memory driver (Microsoft's
  11340.             HIMEM.SYS is the most common) command line in the CONFIG.SYS
  11341.             file.
  11342.  
  11343.             SEE ALSO
  11344.  
  11345.             XMSALLOCATE, XMSCOPY, XMSERROR, XMSFREE, XMSGET, XMSPUT
  11346.  
  11347.             EXAMPLE
  11348.  
  11349.             /*
  11350.              * show what xms memory is available
  11351.              */
  11352.  
  11353.             #include <stdlib.h>
  11354.             #include <conio.h>
  11355.             #include "svgacc.h"
  11356.  
  11357.             void main(void)
  11358.             {
  11359.                int er, mem, handles;
  11360.  
  11361.                if ( whichxms(&mem,&handles) ) {
  11362.                  printf("an active xms memory manager was found!\n");
  11363.                  printf("a total of %d kb of xms memory
  11364.             available...\n",mem);
  11365.                  printf("a total of %d xms memory handles
  11366.             available...\n",handles);
  11367.  
  11368.  
  11369.                                                                         179
  11370.  
  11371.  
  11372.  
  11373.  
  11374.  
  11375.  
  11376.                  printf(" \n");
  11377.                  if ((mem < 1) || (handles < 1)) {
  11378.                     printf("sorry...there is either no free xms or\n");
  11379.                     printf("no free handles\n");
  11380.                     printf(" \n");
  11381.                     printf("xms support not available...\n");
  11382.                     exit(1);
  11383.                  }
  11384.                  else {
  11385.                  printf(" \n");
  11386.                  printf("xms support is ready and available!\n");
  11387.                  exit(1);
  11388.                  }
  11389.                }
  11390.                else {
  11391.                  printf("sorry...no active xms memory manager
  11392.             found...\n");
  11393.                  printf("make sure you have an xms memory manager\n");
  11394.                  printf("(such as HIMEM.SYS) loaded\n");
  11395.                  printf(" \n");
  11396.                  printf("xms support not available...\n");
  11397.                  exit(1);
  11398.                }
  11399.  
  11400.                exit(0);
  11401.             }
  11402.  
  11403.  
  11404.  
  11405.  
  11406.  
  11407.  
  11408.  
  11409.  
  11410.  
  11411.  
  11412.  
  11413.  
  11414.  
  11415.  
  11416.  
  11417.  
  11418.  
  11419.  
  11420.  
  11421.  
  11422.  
  11423.  
  11424.  
  11425.  
  11426.  
  11427.  
  11428.  
  11429.  
  11430.  
  11431.  
  11432.                                                                         180
  11433.  
  11434.  
  11435.  
  11436.  
  11437.  
  11438.  
  11439.           XMSALLOCATE
  11440.  
  11441.             PROTOTYPE
  11442.  
  11443.             extern int far xmsallocate (unsigned int reqkbytes)
  11444.  
  11445.             INPUT
  11446.  
  11447.             reqkbytes - requested number of kilobytes of extended memory
  11448.  
  11449.             OUTPUT
  11450.  
  11451.             XMSALLOCATE returns the assigned memory handle if the
  11452.             allocation is successful, 0 otherwise.
  11453.  
  11454.             USAGE
  11455.  
  11456.             XMSALLOCATE attempts to allocate the requested number of
  11457.             kilobytes in extended memory.  If successful, the function
  11458.             returns the handle of the new memory block.  If the function
  11459.             returns zero, then the allocation was unsuccessful; check
  11460.             XMSERROR for error codes.
  11461.  
  11462.             All allocated blocks must be freed using XMSFREE before a
  11463.             program terminates or the memory is lost until the machine is
  11464.             rebooted.  Simply exiting a program will not free allocated
  11465.             extended memory blocks.
  11466.  
  11467.             SEE ALSO
  11468.  
  11469.             WHICHXMS, XMSCOPY, XMSERROR, XMSFREE, XMSGET, XMSPUT
  11470.  
  11471.             EXAMPLE
  11472.  
  11473.             See XMSCOPY
  11474.  
  11475.  
  11476.  
  11477.  
  11478.  
  11479.  
  11480.  
  11481.  
  11482.  
  11483.  
  11484.  
  11485.  
  11486.  
  11487.  
  11488.  
  11489.  
  11490.  
  11491.  
  11492.  
  11493.  
  11494.  
  11495.                                                                         181
  11496.  
  11497.  
  11498.  
  11499.  
  11500.  
  11501.  
  11502.           XMSCOPY
  11503.  
  11504.             PROTOTYPE
  11505.  
  11506.             extern int far xmscopy (int xmssrchandle, long srcoffset, int
  11507.             xmsdesthandle, long destoffset, unsigned long count)
  11508.  
  11509.             INPUT
  11510.  
  11511.             xmssrchandle - handle of source extended memory block
  11512.             srcoffset - number of bytes from beginning of source memory
  11513.             block
  11514.             xmsdesthandle - handle of destination extended memory block
  11515.             destoffset - number of bytes from beginning of destination
  11516.             memory block
  11517.             count - number of bytes to copy from source to destination
  11518.             (must be even)
  11519.  
  11520.             OUTPUT
  11521.  
  11522.             XMSCOPY returns a 1 if copy was successful, 0 otherwise.
  11523.  
  11524.             USAGE
  11525.  
  11526.             XMSCOPY copies the number of bytes specified in count from the
  11527.             source extended memory block to the destination extended
  11528.             memory block.  Count must be an even number.  The copy may
  11529.             begin and/or end offset from the beginning of the source and
  11530.             destination blocks by passing non zero values in srcoffset
  11531.             and/or destoffset.  The copy will occur faster if both offsets
  11532.             are divisible by four.  If the copy was unsuccessful, check
  11533.             XMSERROR for error codes.
  11534.  
  11535.             SEE ALSO
  11536.  
  11537.             WHICHXMS, XMSALLOCATE, XMSERROR, XMSFREE, XMSGET, XMSPUT
  11538.  
  11539.             EXAMPLE
  11540.  
  11541.             /*
  11542.              * show xms functions: this will copy one array into one
  11543.              * xms block, copy that xms block to a second xms block,
  11544.              * and then copy that second xms block to another array
  11545.              */
  11546.  
  11547.             #include <stdlib.h>
  11548.             #include <conio.h>
  11549.             #include "svgacc.h"
  11550.  
  11551.             void main(void)
  11552.             {
  11553.                int i, handle1, handle2, er, mem, handles;
  11554.                int test1[10], test2[10];
  11555.  
  11556.  
  11557.  
  11558.                                                                         182
  11559.  
  11560.  
  11561.  
  11562.  
  11563.  
  11564.  
  11565.                /* make sure xms is ready and available */
  11566.                if ( whichxms(&mem,&handles) ) {
  11567.                  if ((mem < 1) || (handles < 1)) {
  11568.                     printf("sorry...there is either no free xms or\n");
  11569.                     printf("no free handles\n");
  11570.                     exit(1);
  11571.                  }
  11572.                }
  11573.                else {
  11574.                  printf("sorry...no active xms memory manager
  11575.             found...\n");
  11576.                  printf("make sure you have an xms memory manager\n");
  11577.                  printf("(such as HIMEM.SYS) loaded\n");
  11578.                  exit(1);
  11579.                }
  11580.  
  11581.                /* generate some data */
  11582.                for(i=0;i<10;i++)
  11583.                {
  11584.                  test1[i] = i;
  11585.                }
  11586.  
  11587.                /* allocate the first xms block */
  11588.                handle1 = xmsallocate(1);
  11589.                if ( !handle1 ) {
  11590.                  printf("opps there is some error...unable to allocate
  11591.             xms...\n");
  11592.                  printf("error # %d\n",xmserror());
  11593.                  er = xmsfree(handle1);
  11594.                  exit(1);
  11595.                }
  11596.  
  11597.                /* allocate the second xms block */
  11598.                handle2 = xmsallocate(1);
  11599.                if ( !handle2 ) {
  11600.                  printf("opps there is some error...unable to allocate
  11601.             xms...\n");
  11602.                  printf("error # %d\n",xmserror());
  11603.                  er = xmsfree(handle1);
  11604.                  er = xmsfree(handle2);
  11605.                  exit(1);
  11606.                }
  11607.  
  11608.                /* copy our source array into first xms block */
  11609.                er = xmsput (test1, handle1, 0, sizeof(test1));
  11610.                if ( !er ) {
  11611.                  printf("opps there is some error...see error code
  11612.             list...\n");
  11613.                  printf("error # %d\n",xmserror());
  11614.                  er = xmsfree(handle1);
  11615.                  er = xmsfree(handle2);
  11616.                  exit(1);
  11617.                }
  11618.  
  11619.  
  11620.  
  11621.                                                                         183
  11622.  
  11623.  
  11624.  
  11625.  
  11626.  
  11627.  
  11628.                /* copy first xms block into second xms block */
  11629.                er = xmscopy (handle1, 0, handle2, 0, sizeof(test1));
  11630.                if ( !er ) {
  11631.                  printf("opps there is some error...see error code
  11632.             list...\n");
  11633.                  printf("error # %d\n",xmserror());
  11634.                  er = xmsfree(handle1);
  11635.                  er = xmsfree(handle2);
  11636.                  exit(1);
  11637.                }
  11638.  
  11639.                /* copy second xms block to out destination array */
  11640.                er = xmsget (handle2, 0, test2, sizeof(test1));
  11641.                if ( !er ) {
  11642.                  printf("opps there is some error...see error code
  11643.             list...\n");
  11644.                  printf("error # %d\n",xmserror());
  11645.                  er = xmsfree(handle1);
  11646.                  er = xmsfree(handle2);
  11647.                  exit(1);
  11648.                }
  11649.  
  11650.                /* free up all the xms memory we have allocated */
  11651.                er = xmsfree(handle1);
  11652.                er = xmsfree(handle2);
  11653.  
  11654.                /* show the results */
  11655.                printf("ok...we initialized one array with data, copied
  11656.             that\n");
  11657.                printf("array to an xms block, copied that xms block to
  11658.             a\n");
  11659.                printf("second xms block, and finally copied the second
  11660.             xms\n");
  11661.                printf("block into a new array...here are the results:\n");
  11662.                printf(" \n");
  11663.                printf("source array         destination array\n");
  11664.                for(i=0;i<10;i++)
  11665.                {
  11666.                printf(" %d                    %d\n",test1[i],test2[i]);
  11667.                }
  11668.                exit(0);
  11669.             }
  11670.  
  11671.  
  11672.  
  11673.  
  11674.  
  11675.  
  11676.  
  11677.  
  11678.  
  11679.  
  11680.  
  11681.  
  11682.  
  11683.  
  11684.                                                                         184
  11685.  
  11686.  
  11687.  
  11688.  
  11689.  
  11690.  
  11691.           XMSERROR
  11692.  
  11693.             PROTOTYPE
  11694.  
  11695.             extern int far xmserror (void)
  11696.  
  11697.             INPUT
  11698.  
  11699.             no input parameters
  11700.  
  11701.             OUTPUT
  11702.  
  11703.             XMSERROR returns the error code from the most recent XMS
  11704.             function call.
  11705.  
  11706.             USAGE
  11707.  
  11708.             XMSERROR returns the error code from the most recent XMS
  11709.             function call.  Each XMS function resets the error code to
  11710.             zero.  Therefore, if there has been an error, the error code
  11711.             should be checked immediately.  The error code will be one of
  11712.             the following:
  11713.  
  11714.             0    no error
  11715.             1    WHICHXMS has not been called
  11716.             2    number of bytes to copy is zero
  11717.             3    number of bytes to copy is odd
  11718.             4    offset into XMS block is zero
  11719.             128  Function not implemented
  11720.             129  VDISK device driver was detected
  11721.             142  General driver error
  11722.             143  Unrecoverable driver error
  11723.             146  DX is less than /HMAMIN= parameter
  11724.             160  All extended memory is allocated
  11725.             161  XMM handles are exhausted
  11726.             162  Handle is invalid
  11727.             163  Source handle is invalid
  11728.             164  Source offset is invalid
  11729.             165  Destination handle is invalid
  11730.             166  Destination offset is invalid
  11731.             167  Length is invalid
  11732.             168  Overlap in move request is invalid
  11733.             169  Parity error detected
  11734.             171  Block locked
  11735.  
  11736.             SEE ALSO
  11737.  
  11738.             WHICHXMS, XMSALLOCATE, XMSCOPY, XMSFREE, XMSGET, XMSPUT
  11739.  
  11740.             EXAMPLE
  11741.  
  11742.             See XMSCOPY
  11743.  
  11744.  
  11745.  
  11746.  
  11747.                                                                         185
  11748.  
  11749.  
  11750.  
  11751.  
  11752.  
  11753.  
  11754.           XMSFREE
  11755.  
  11756.             PROTOTYPE
  11757.  
  11758.             extern int far xmsfree (int xmshandle)
  11759.  
  11760.             INPUT
  11761.  
  11762.             xmshandle - handle of extended memory block to free
  11763.  
  11764.             OUTPUT
  11765.  
  11766.             XMSFREE returns 1 if extended memory block was deallocated, 0
  11767.             otherwise.
  11768.  
  11769.             USAGE
  11770.  
  11771.             XMSFREE deallocates the specified extended memory block.  All
  11772.             allocated blocks must be freed before a program terminates or
  11773.             the memory is lost until the machine is rebooted.  Simply
  11774.             exiting a program will not free allocated extended memory
  11775.             blocks.  If the function was unsuccessful, check XMSERROR for
  11776.             error codes.
  11777.  
  11778.             SEE ALSO
  11779.  
  11780.             WHICHXMS, XMSALLOCATE, XMSCOPY, XMSERROR, XMSGET, XMSPUT
  11781.  
  11782.             EXAMPLE
  11783.  
  11784.             See XMSCOPY
  11785.  
  11786.  
  11787.  
  11788.  
  11789.  
  11790.  
  11791.  
  11792.  
  11793.  
  11794.  
  11795.  
  11796.  
  11797.  
  11798.  
  11799.  
  11800.  
  11801.  
  11802.  
  11803.  
  11804.  
  11805.  
  11806.  
  11807.  
  11808.  
  11809.  
  11810.                                                                         186
  11811.  
  11812.  
  11813.  
  11814.  
  11815.  
  11816.  
  11817.           XMSGET
  11818.  
  11819.             PROTOTYPE
  11820.  
  11821.             extern int far xmsget (int xmshandle, long offset, void far
  11822.             *destmem, unsigned long count)
  11823.  
  11824.             INPUT
  11825.  
  11826.             xmshandle - handle of source extended memory block
  11827.             offset - number of bytes from beginning of source memory block
  11828.             count - number of bytes to copy from extended memory to
  11829.             conventional memory (must be even)
  11830.  
  11831.             OUTPUT
  11832.  
  11833.             XMSGET returns 1 if the copy was successful, 0 otherwise.
  11834.             destmem - copy of data in conventional memory
  11835.  
  11836.             USAGE
  11837.  
  11838.             XMSGET retrieves data from extended memory and places it in
  11839.             conventional memory.  The number of bytes copied must be an
  11840.             even number and cannot be larger than 65536.  The copy may
  11841.             begin off the beginning of the source extended memory block by
  11842.             specifying an non zero offset.  If the function was
  11843.             unsuccessful, check XMSERROR for error codes.
  11844.  
  11845.             SEE ALSO
  11846.  
  11847.             WHICHXMS, XMSALLOCATE, XMSCOPY, XMSERROR, XMSFREE, XMSPUT
  11848.  
  11849.             EXAMPLE
  11850.  
  11851.             See XMSCOPY
  11852.  
  11853.  
  11854.  
  11855.  
  11856.  
  11857.  
  11858.  
  11859.  
  11860.  
  11861.  
  11862.  
  11863.  
  11864.  
  11865.  
  11866.  
  11867.  
  11868.  
  11869.  
  11870.  
  11871.  
  11872.  
  11873.                                                                         187
  11874.  
  11875.  
  11876.  
  11877.  
  11878.  
  11879.  
  11880.           XMSPUT
  11881.  
  11882.             PROTOTYPE
  11883.  
  11884.             extern int far xmsput (void far *sourcemem, int xmshandle,
  11885.             long offset, unsigned long count)
  11886.  
  11887.             INPUT
  11888.  
  11889.             sourcemem - source data in conventional memory
  11890.             xmshandle - handle of destination extended memory block
  11891.             offset - number of bytes from beginning of destination memory
  11892.             block
  11893.             count - number of bytes to copy from conventional memory to
  11894.             extended memory (must be even)
  11895.  
  11896.             OUTPUT
  11897.  
  11898.             XMSPUT returns 1 if the copy was successful, 0 otherwise.
  11899.  
  11900.             USAGE
  11901.  
  11902.             XMSPUT copies data from conventional memory to extended
  11903.             memory.  The number of bytes copied must be an even number and
  11904.             cannot be larger than 65536.  The destination may begin off
  11905.             the beginning of the extended memory block by specifying an
  11906.             non zero offset.  If the function was unsuccessful, check
  11907.             XMSERROR for error codes.
  11908.  
  11909.             SEE ALSO
  11910.  
  11911.             WHICHXMS, XMSALLOCATE, XMSCOPY, XMSERROR, XMSFREE, XMSGET
  11912.  
  11913.             EXAMPLE
  11914.  
  11915.             See XMSCOPY
  11916.  
  11917.  
  11918.  
  11919.  
  11920.  
  11921.  
  11922.  
  11923.  
  11924.  
  11925.  
  11926.  
  11927.  
  11928.  
  11929.  
  11930.  
  11931.  
  11932.  
  11933.  
  11934.  
  11935.  
  11936.                                                                         188
  11937.  
  11938.  
  11939.  
  11940.  
  11941.  
  11942.  
  11943.           APPENDIX A.  SVGACC.H
  11944.  
  11945.           This is the header file containing function prototypes and
  11946.           structure definitions for SVGACC.LIB.  This file should be
  11947.           included in every program module that uses this library.  To
  11948.           properly include the header file, place the following line at the
  11949.           top of the every code module:
  11950.  
  11951.                                  #include "svgacc.h"
  11952.  
  11953.           Without these prototypes and definitions, the C/C++ compiler will
  11954.           be unable to compile any code module using the commands found in
  11955.           this library.
  11956.  
  11957.             /* SVGA Graphics Library Include File for MS C and QuickC
  11958.              * Copyright 1994 by Stephen L. Balkum and Daniel A. Sill
  11959.              * Zephyr Software P.O. Box 7704, Austin, Texas  78713-7704
  11960.              */
  11961.  
  11962.             #ifndef SVGACC_H
  11963.             #define SVGACC_H
  11964.  
  11965.             typedef unsigned char byte;
  11966.  
  11967.             typedef struct {
  11968.                char r;
  11969.                char g;
  11970.                char b;
  11971.             } RGB;
  11972.  
  11973.             typedef RGB PaletteData[256];
  11974.  
  11975.             typedef struct {
  11976.                byte hotspotx;
  11977.                byte hotspoty;
  11978.                byte data[384];
  11979.             } MouseCursor;
  11980.  
  11981.             typedef struct {
  11982.                byte width;
  11983.                byte height;
  11984.                byte data[4096];
  11985.             } Font;
  11986.  
  11987.             typedef enum {
  11988.                NO_ACTION = 0,
  11989.                SET,
  11990.                XOR,
  11991.                OR,
  11992.                AND
  11993.             } PixelMode;
  11994.  
  11995.             typedef enum {
  11996.                UNKNOWN = 0,
  11997.  
  11998.  
  11999.                                                                         189
  12000.  
  12001.  
  12002.  
  12003.  
  12004.  
  12005.  
  12006.                ACUMOS,
  12007.                ATI,
  12008.                AHEADA,
  12009.                AHEADB,
  12010.                CHIPSTECH,
  12011.                CIRRUS,
  12012.                EVEREX,
  12013.                GENOA,
  12014.                NCR,
  12015.                OAKTECH,
  12016.                PARADISE,
  12017.                REALTEK,
  12018.                TRIDENT,
  12019.                TSENG3,
  12020.                TSENG4,
  12021.                VESA,
  12022.                VIDEO7,
  12023.                AVANCE,
  12024.                MXIC,
  12025.                PRIMUS
  12026.             } VGAChipset;
  12027.  
  12028.             typedef struct {
  12029.                unsigned int width;
  12030.                unsigned int height;
  12031.                byte data[];
  12032.             } RasterBlock;
  12033.  
  12034.             typedef struct {
  12035.                int x;
  12036.                int y;
  12037.             } D2Point;
  12038.  
  12039.             typedef struct {
  12040.                int x;
  12041.                int y;
  12042.                int z;
  12043.             } D3Point;
  12044.  
  12045.             typedef struct {
  12046.                int eyex;
  12047.                int eyey;
  12048.                int eyez;
  12049.                int scrd;
  12050.                int theta;
  12051.                int phi;
  12052.             } ProjParameters;
  12053.  
  12054.             #ifdef __cplusplus
  12055.             extern "C" {
  12056.             #endif
  12057.  
  12058.             /* Global variables */
  12059.             extern const int far maxx;
  12060.  
  12061.  
  12062.                                                                         190
  12063.  
  12064.  
  12065.  
  12066.  
  12067.  
  12068.  
  12069.             extern const int far maxy;
  12070.             extern const int far viewx1;
  12071.             extern const int far viewy1;
  12072.             extern const int far viewx2;
  12073.             extern const int far viewy2;
  12074.  
  12075.             /* 'BLocK' methods to manipulate RasterBlocks on and off the
  12076.                screen */
  12077.  
  12078.             extern int   far blkget (int x1, int y1, int x2, int y2,
  12079.                RasterBlock far *gfxblk);
  12080.             extern void  far blkput (PixelMode mode, int x, int y,
  12081.                RasterBlock far *gfxblk);
  12082.             extern void  far blkresize (unsigned newxsize, unsigned
  12083.                newysize, RasterBlock far *sourcegfxblk, RasterBlock far
  12084.                *destgfxblk);
  12085.             extern int   far blkrotate (int ang, int backfill, RasterBlock
  12086.                far *sourcegfxblk, RasterBlock far *destgfxblk);
  12087.             extern int   far blkrotatesize (int ang, RasterBlock far
  12088.                *sourcegfxblk);
  12089.  
  12090.             /* 'BYTECOPY' method for fast memory copy */
  12091.  
  12092.             extern void far bytecopy (void far *src, void far *dst,
  12093.                unsigned long numbytes);
  12094.  
  12095.             /* '2D' methods to transform D2Points */
  12096.  
  12097.             extern void  far d2rotate (int points, int xorigin, int
  12098.                yorigin, int ang, D2Point far *inary, D2Point far *outary);
  12099.             extern void  far d2scale (int points, int xscale, int yscale,
  12100.                D2Point far *inary, D2Point far *outary);
  12101.             extern void  far d2translate (int points, int xtrans, int
  12102.                ytrans, D2Point far *inary, D2Point far *outary);
  12103.  
  12104.             /* '3D' methods to transform D3Points */
  12105.  
  12106.             extern int   far d3project (int points, ProjParameters far
  12107.                *params, D3Point far *inary, D2Point far *outary);
  12108.             extern void  far d3rotate (int points, int xorigin, int
  12109.                yorigin, int zorigin, int zrang, int yrang, int xrang,
  12110.                D3Point far *inary, D3Point far *outary);
  12111.             extern void  far d3scale (int points, int xscale, int yscale,
  12112.                int zscale, D3Point far *inary, D3Point far *outary);
  12113.             extern void  far d3translate (int points, int xtrans, int
  12114.                ytrans, int ztrans, D3Point far *inary, D3Point far
  12115.                *outary);
  12116.  
  12117.             /* 'DRaW' methods for placing text and graphics primitives on
  12118.                screen */
  12119.  
  12120.             extern void  far drwbox (PixelMode mode, int colr, int x1, int
  12121.                y1, int x2, int y2);
  12122.  
  12123.  
  12124.  
  12125.                                                                         191
  12126.  
  12127.  
  12128.  
  12129.  
  12130.  
  12131.  
  12132.             extern void  far drwcircle (PixelMode mode, int colr, int
  12133.                centerx, int centery, int radius);
  12134.             extern void  far drwellipse (PixelMode mode, int colr, int
  12135.                centerx, int centery, int radiusx, int radiusy);
  12136.             extern void  far drwfillbox (PixelMode mode, int colr, int x1,
  12137.                int y1, int x2, int y2);
  12138.             extern void  far drwfillcircle (PixelMode mode, int colr, int
  12139.                centerx, int centery, int radius);
  12140.             extern void  far drwfillellipse (PixelMode mode, int colr, int
  12141.                centerx, int centery, int radiusx, int radiusy);
  12142.             extern void  far drwline (PixelMode mode, int colr, int x1, int
  12143.                y1, int x2, int y2);
  12144.             extern void  far drwpoint (PixelMode mode, int colr, int x, int
  12145.                y);
  12146.             extern void  far drwstring (PixelMode mode, int fcolr, int
  12147.                bcolr, const char far *strng, int x, int y);
  12148.             extern void  far drwstringdn (PixelMode mode, int fcolr, int
  12149.                bcolr, const char far *strng, int x, int y);
  12150.             extern void  far drwstringlt (PixelMode mode, int fcolr, int
  12151.                bcolr, const char far *strng, int x, int y);
  12152.             extern void  far drwstringrt (PixelMode mode, int fcolr, int
  12153.                bcolr, const char far *strng, int x, int y);
  12154.  
  12155.             /* 'FILL' methods for filling various regions on screen with a
  12156.                color */
  12157.  
  12158.             extern void  far fillarea (int xseed, int yseed, int
  12159.                bordercolr, int fillcolr);
  12160.             extern void  far fillcolor (int xseed, int yseed, int oldcolr,
  12161.                int newcolr);
  12162.             extern void  far fillpage (int colr);
  12163.             extern void  far fillscreen (int colr);
  12164.             extern void  far fillview (int colr);
  12165.  
  12166.             /* 'FONT' methods for setting the current font */
  12167.  
  12168.             extern void  far fontgetinfo (int far *wdth, int far *hght);
  12169.             extern void  far fontset (Font far *font);
  12170.             extern void  far fontsystem (void);
  12171.  
  12172.             /* 'GET' methods to return information held by library */
  12173.  
  12174.             extern void  far getlaststring (RasterBlock far *strnggfxblk);
  12175.             extern long  far getarccos (long cosvalue);
  12176.             extern long  far getarcsin (long sinvalue);
  12177.             extern long  far getarctan (long tanvalue);
  12178.             extern long  far getcos (long angle);
  12179.             extern int   far getpoint (int x, int y);
  12180.             extern long  far getsin (long angle);
  12181.             extern long  far gettan (long angle);
  12182.  
  12183.             /* 'GIF' methods to read / write GIF files and place images on
  12184.                screen */
  12185.  
  12186.  
  12187.  
  12188.                                                                         192
  12189.  
  12190.  
  12191.  
  12192.  
  12193.  
  12194.  
  12195.             extern int   far gifgetinfo (const char far *name, int far
  12196.                *gifxsize, int far *gifysize, int far *numcolors, RGB far
  12197.                *pal);
  12198.             extern int   far gifmake (int x1, int y1, int x2, int y2, const
  12199.                char far *name);
  12200.             extern int   far gifput (PixelMode mode, int xloc, int yloc,
  12201.                const char far *name);
  12202.  
  12203.             /* 'JOYSTICK' method to read joysticks' status */
  12204.  
  12205.             extern void  far joystickinfo (int far *jax, int far *jay, int
  12206.                far *jabuts, int far *jbx, int far *jby, int far *jbbuts);
  12207.  
  12208.             /* 'MOUSE' methods to interact with mouse driver */
  12209.  
  12210.             extern void  far mousebutpress (int reqbut, int far *xloc, int
  12211.                far *yloc, int far *num, int far *mbuts);
  12212.             extern void  far mousebutrelease (int reqbut, int far *xloc,
  12213.                int far *yloc, int far *num, int far *mbuts);
  12214.             extern void  far mousecursordefault (void);
  12215.             extern void  far mousecursorset (MouseCursor far *mousecursor);
  12216.             extern void  far mouseenter (void);
  12217.             extern void  far mouseexit (void);
  12218.             extern void  far mousehide (void);
  12219.             extern void  far mouseinfo (int far *drvmajorver, int far
  12220.                *drvminorver, int far *mousetype, int far *irqnumber);
  12221.             extern void  far mouselocset (int xloc, int yloc);
  12222.             extern void  far mouserangeset (int x1, int y1, int x2, int
  12223.                y2);
  12224.             extern void  far mouserestorestate (byte far *mousebuf);
  12225.             extern void  far mousesavestate (byte far *mousebuf);
  12226.             extern void  far mousesensset (int xsens, int ysens, int
  12227.                dblspdthresh);
  12228.             extern void  far mouseshow (void);
  12229.             extern void  far mousestatus (int far *x, int far *y, int far
  12230.                *mbuts);
  12231.             extern int   far mousestoragesize (void);
  12232.  
  12233.             extern void  far overscanset (int colr);
  12234.  
  12235.             /* 'PAGE' methods to control paging abilities */
  12236.             extern int   far pageactive (int page);
  12237.             extern int   far pagedisplay (int x, int y, int page);
  12238.  
  12239.             /* 'PALette' methods to manipulate and activate palettes */
  12240.             extern void  far palchgauto (RGB far *pal, RGB far *newpal, int
  12241.                firstcolr, int lastcolr, int speed);
  12242.             extern void  far palchgstep (RGB far *pal, RGB far *newpal, int
  12243.                firstcolr, int lastcolr, int percent);
  12244.             extern void  far palcopy (RGB far *srcpal, RGB far *destpal,
  12245.                int firstcolr, int lastcolr);
  12246.             extern void  far paldimstep (RGB far *pal, int firstcolr, int
  12247.                lastcolr, int percent);
  12248.  
  12249.  
  12250.  
  12251.                                                                         193
  12252.  
  12253.  
  12254.  
  12255.  
  12256.  
  12257.  
  12258.             extern void  far palget (RGB far *pal, int firstcolr, int
  12259.                lastcolr);
  12260.             extern void  far palioauto (RGB far *pal, int firstcolr, int
  12261.                lastcolr, int speed);
  12262.             extern void  far palrotate (RGB far *pal, int firstcolr, int
  12263.                lastcolr, int shift);
  12264.             extern void  far palset (RGB far *pal, int firstcolr, int
  12265.                lastcolr);
  12266.  
  12267.             /* 'RESolution' methods to set various video modes */
  12268.  
  12269.             extern int   far res320 (void);
  12270.             extern int   far res640 (void);
  12271.             extern int   far res640l (void);
  12272.             extern int   far res800 (void);
  12273.             extern int   far res1024 (void);
  12274.             extern int   far restext (void);
  12275.  
  12276.             /* 'SCROLL' methods for scrolling various sections of the
  12277.                screen */
  12278.  
  12279.             extern void  far scrolldn (int x1, int y1, int x2, int y2, int
  12280.                num, int colr);
  12281.             extern void  far scrolllt (int x1, int y1, int x2, int y2, int
  12282.                num, int colr);
  12283.             extern void  far scrollrt (int x1, int y1, int x2, int y2, int
  12284.                num, int colr);
  12285.             extern void  far scrollup (int x1, int y1, int x2, int y2, int
  12286.                num, int colr);
  12287.  
  12288.             /* 'Sync' delay method */
  12289.  
  12290.             extern void  far sdelay (int count);
  12291.  
  12292.             /* 'SET' methods to adjust library internal variables */
  12293.  
  12294.             extern void  far setcard (VGAChipset chip, int mem);
  12295.             extern void  far setview (int x1, int y1, int x2, int y2);
  12296.  
  12297.             /* 'SPRITE' methods for manipulating sprites on and off screen
  12298.                */
  12299.  
  12300.             extern int   far spritecolldetect (int transcolr, int x1, int
  12301.                y1, int x2, int y2, RasterBlock far *sprite1, RasterBlock
  12302.                far *sprite2);
  12303.             extern void  far spritegap (int transcolr, int x, int y,
  12304.                RasterBlock far *sprite, RasterBlock far *spritebkgnd);
  12305.             extern void  far spriteget (int transcolr, int x, int y,
  12306.                RasterBlock far *sprite, RasterBlock far *spritebkgnd);
  12307.             extern void  far spriteput (PixelMode mode, int transcolr, int
  12308.                x, int y, RasterBlock far *sprite);
  12309.  
  12310.             /* 'VIDEO' methods to interact with video mode and display */
  12311.  
  12312.  
  12313.  
  12314.                                                                         194
  12315.  
  12316.  
  12317.  
  12318.  
  12319.  
  12320.  
  12321.             extern int   far videomodeget (void);
  12322.             extern void  far videomodeset (int videomode);
  12323.             extern void  far videooff (void);
  12324.             extern void  far videoon (void);
  12325.  
  12326.             /* 'Identification' methods to discover WHICH hardware is
  12327.                available */
  12328.  
  12329.             extern int   far whichcpu (void);
  12330.             extern int   far whichjoystick (void);
  12331.             extern int   far whichmem (void);
  12332.             extern int   far whichmouse (void);
  12333.             extern VGAChipset far whichvga (void);
  12334.             extern int   far whichxms (unsigned int far *xmskbytesavail,
  12335.                unsigned int far *xmshandlesavail);
  12336.  
  12337.             /* 'XMS' methods to store and retrieve extended memory */
  12338.  
  12339.             extern int   far xmsallocate (unsigned int reqkbytes);
  12340.             extern int   far xmscopy (int xmssrchandle, long srcoffset, int
  12341.                xmsdesthandle, long destoffset, unsigned long count);
  12342.             extern int   far xmserror (void);
  12343.             extern int   far xmsfree (int xmshandle);
  12344.             extern int   far xmsget (int xmshandle, long offset, void far
  12345.                *destmem, unsigned long count);
  12346.             extern int   far xmsput (void far *sourcemem, int xmshandle,
  12347.                long offset, unsigned long count);
  12348.  
  12349.             #ifdef __cplusplus
  12350.             }
  12351.             #endif
  12352.  
  12353.             #endif
  12354.             /* SVGACC_H */
  12355.  
  12356.  
  12357.  
  12358.  
  12359.  
  12360.  
  12361.  
  12362.  
  12363.  
  12364.  
  12365.  
  12366.  
  12367.  
  12368.  
  12369.  
  12370.  
  12371.  
  12372.  
  12373.  
  12374.  
  12375.  
  12376.  
  12377.                                                                         195
  12378.  
  12379.  
  12380.  
  12381.  
  12382.  
  12383.  
  12384.           APPENDIX B.  JOYSTICK PORTS AND Y-CABLES
  12385.  
  12386.           SCHEMATIC WIRING DIAGRAM FOR A STANDARD JOYSTICK PORT
  12387.  
  12388.                                     DB15 male
  12389.                                     connector
  12390.                    Joystick B            ___       Joystick A
  12391.                                       __/   |
  12392.                                      /    o | 1 -------------------+
  12393.              +------------------  9 | o     |     ___Button A      |
  12394.              |     Button A___      |     o | 2 --o o-+            |
  12395.              |           +-o o-- 10 | o     |         |    X Axis  |
  12396.              |  X Axis   |          |     o | 3 -------------+     |
  12397.              |     +------------ 11 | o     |         |      |     |
  12398.              |     |     |          |     o | 4 ------+      |     |
  12399.              +--/\/\/\   +------ 12 | o     |         |    /\/\/\--+
  12400.              |           |          |     o | 5       |            |
  12401.              |     +------------ 13 | o     |         |            |
  12402.              |     |     | ___      |     o | 6 -------------+     |
  12403.              |     |     +-o o-- 14 | o     |     ___ |      |     |
  12404.              |     |    Button B    |     o | 7 --o o-+      |     |
  12405.              |     |             15 | o     |   Button B   /\/\/\--+
  12406.              +--/\/\/\               \__  o | 8            Y Axis
  12407.                Y Axis                   \___|
  12408.  
  12409.           Notes:
  12410.  
  12411.           1)This diagram comes with NO warranties expressed or implied.
  12412.             It is provided for information only.  In no event shall
  12413.             Stephen L. Balkum, Daniel A. Sill or Zephyr Software be held
  12414.             liable for damages resulting from use, misuse, or inability to
  12415.             use this information.
  12416.  
  12417.           2)The x and y axis potentiometers have a typical range of 0 to
  12418.             100k ohms.  Buttons are normally open and close when pressed.
  12419.  
  12420.           3)This diagram is correct for joystick ports that conform to the
  12421.             standard set forth by IBM. Some specialty joystick cards
  12422.             provide separate A and B joystick connectors.  For these
  12423.             cards, both connectors are wired to pins 1 through 8 as shown
  12424.             in the diagram.
  12425.  
  12426.           4)Many 'Super I/O' boards (2H/2F/2S/1P/1G) equipped with a
  12427.             joystick port will support only one joystick.  On these cards,
  12428.             pins 9 through 15 are not used.
  12429.  
  12430.           5)Commercially available joysticks are wired to use pins 1
  12431.             through 8 and, therefore, will always be 'Joystick A' if
  12432.             plugged directly into a dual joystick port connector.
  12433.  
  12434.           6)Many sound cards provide joystick ports; however, their
  12435.             connector wiring does not always conform to the standard shown
  12436.             above.  Some of these connectors may be used for other
  12437.  
  12438.  
  12439.  
  12440.                                                                         196
  12441.  
  12442.  
  12443.  
  12444.  
  12445.  
  12446.  
  12447.             purposes such as a MIDI port.  See the documentation that
  12448.             comes with the sound card.
  12449.  
  12450.           7)If there is more than one joystick port on a computer
  12451.             configured to operate the same joystick, only ONE port should
  12452.             be enabled at any given time for proper operation.  Disable
  12453.             all but one joystick port.  For example, if the computer has
  12454.             both a Super I/O card and a sound card, the joystick port on
  12455.             the Super I/O card should be disabled since the sound card's
  12456.             port probably supports two joysticks and the I/O card supports
  12457.             only one.
  12458.  
  12459.  
  12460.  
  12461.  
  12462.  
  12463.  
  12464.  
  12465.  
  12466.  
  12467.  
  12468.  
  12469.  
  12470.  
  12471.  
  12472.  
  12473.  
  12474.  
  12475.  
  12476.  
  12477.  
  12478.  
  12479.  
  12480.  
  12481.  
  12482.  
  12483.  
  12484.  
  12485.  
  12486.  
  12487.  
  12488.  
  12489.  
  12490.  
  12491.  
  12492.  
  12493.  
  12494.  
  12495.  
  12496.  
  12497.  
  12498.  
  12499.  
  12500.  
  12501.  
  12502.  
  12503.                                                                         197
  12504.  
  12505.  
  12506.  
  12507.  
  12508.  
  12509.  
  12510.           SCHEMATIC WIRING DIAGRAM FOR A JOYSTICK Y-CABLE
  12511.                                               ___
  12512.                          DB15 male         __/   |
  12513.                        connector to       /    o | 1 --------+
  12514.                        Joystick Port   9 | o     |           |
  12515.                         on computer      |     o | 2 --------|-+
  12516.                             +-------- 10 | o     |           | |
  12517.                             |            |     o | 3 --------|-|-+
  12518.                             | +------ 11 | o     |           | | |
  12519.                             | |          |     o | 4 --------|-|-|-+
  12520.                             | |       12 | o     |           | | | |
  12521.                             | |          |     o | 5         | | | |
  12522.                             | | +---- 13 | o     |           | | | |
  12523.                             | | |        |     o | 6 --------|-|-|-|-+
  12524.                             | | | +-- 14 | o     |           | | | | |
  12525.                             | | | |      |     o | 7 --------|-|-|-|-|-+
  12526.                             | | | |   15 | o     |           | | | | | |
  12527.                             | | | |       \__  o | 8         | | | | | |
  12528.                             | | | |          \___|           | | | | | |
  12529.                             | | | |                          | | | | | |
  12530.                             | | | |                          | | | | | |
  12531.                             | | | |  +-----------------------+ | | | | |
  12532.                             | | | |  |                       | | | | | |
  12533.                             | | | |  | +---------------------|-|-|-+ | |
  12534.                             | | | |  | |                     | | | | | |
  12535.                             | | | |  | |                     | | | | | |
  12536.            DB15 female      | | | |  | |     DB15 female     | | | | | |
  12537.            connector to     | | | |  | |     connector to    | | | | | |
  12538.             Joystick B      | | | |  | |      Joystick A     | | | | | |
  12539.                   ___       | | | |  | |            ___      | | | | | |
  12540.                __/   |      | | | |  | |         __/   |     | | | | | |
  12541.               /    o | 1 ---|-|-|-|--+ |        /    o | 1 --+ | | | | |
  12542.            9 | o     |      | | | |    |     9 | o     |       | | | | |
  12543.              |     o | 2 ---+ | | |    |       |     o | 2 ----+ | | | |
  12544.           10 | o     |        | | |    |    10 | o     |         | | | |
  12545.              |     o | 3 -----+ | |    |       |     o | 3 ------+ | | |
  12546.           11 | o     |          | |    |    11 | o     |           | | |
  12547.              |     o | 4 -------|-|----+       |     o | 4 --------+ | |
  12548.           12 | o     |          | |         12 | o     |             | |
  12549.              |     o | 5        | |            |     o | 5           | |
  12550.           13 | o     |          | |         13 | o     |             | |
  12551.              |     o | 6 -------+ |            |     o | 6 ----------+ |
  12552.           14 | o     |            |         14 | o     |               |
  12553.              |     o | 7 ---------+            |     o | 7 ------------+
  12554.           15 | o     |                      15 | o     |
  12555.               \__  o | 8                        \__  o | 8
  12556.                  \___|                             \___|
  12557.  
  12558.           Notes:
  12559.  
  12560.           1)This diagram comes with NO warranties expressed or implied.
  12561.             It is provided for information only.  In no event shall
  12562.             Stephen L. Balkum, Daniel A. Sill or Zephyr Software be held
  12563.  
  12564.  
  12565.  
  12566.                                                                         198
  12567.  
  12568.  
  12569.  
  12570.  
  12571.  
  12572.  
  12573.             liable for damages resulting from use, misuse, or inability to
  12574.             use this information.
  12575.  
  12576.           2)This cable has worked with a standard joystick port connector,
  12577.             a Sound Blaster port connector, and a Sound Blaster Pro
  12578.             joystick port connector.
  12579.  
  12580.  
  12581.  
  12582.  
  12583.  
  12584.  
  12585.  
  12586.  
  12587.  
  12588.  
  12589.  
  12590.  
  12591.  
  12592.  
  12593.  
  12594.  
  12595.  
  12596.  
  12597.  
  12598.  
  12599.  
  12600.  
  12601.  
  12602.  
  12603.  
  12604.  
  12605.  
  12606.  
  12607.  
  12608.  
  12609.  
  12610.  
  12611.  
  12612.  
  12613.  
  12614.  
  12615.  
  12616.  
  12617.  
  12618.  
  12619.  
  12620.  
  12621.  
  12622.  
  12623.  
  12624.  
  12625.  
  12626.  
  12627.  
  12628.  
  12629.                                                                         199
  12630.