home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 325_02 / function.doc < prev    next >
Text File  |  1990-03-28  |  50KB  |  1,891 lines

  1.  
  2.         /*    Functions    */
  3.  
  4. OpenGraph
  5. ---------
  6.  
  7.     Include    : grph.h
  8.     Declaration : int far pascal OpenGraph(Byte Mode,Byte Erase)
  9.     Parameters    : Mode = Bios mode no. to set
  10.             Erase = 0 video buffer is cleared
  11.                 1 video buffer is not cleared
  12.     Return    : Mode no. if successful.
  13.     Usage    :
  14.  
  15.     OpenGraph(0x12,0);
  16.  
  17.     This will set Video adapter in mode hex 12, and erase the video buffer.
  18.  
  19.     Description : sets the system in Graphics mode, Video buffer is cleared
  20.     if Erase = 0, and not cleared when Erase = 1.
  21.  
  22.     Mode is mapped to BIOS mode no. according to following scheme, which can
  23.     be modified in GRPH.H
  24.  
  25.     Mode    Resolutions and colors             BIOS Mode No
  26.  
  27.       0        640x350x16                0x10
  28.       1        640x480x16                0x12
  29.       2        320x200x256             0x13
  30.       3        640x400x256             0x5c
  31.       4        640x480x256             0x5d
  32.       5        800x600x16                0x5b
  33.       6        1024x768x16             0x5f
  34.  
  35.     Mode Nos. 4 and 6 require 512k video memory.
  36.  
  37.     This function also sets up a no. of graphics state defaults.
  38.  
  39.     Sets up Graphics controller in the requested mode.
  40.     Sets current viewport to whole screen, specifically, viewport boundaries
  41.     will be (0,0) and (XRes,YRes).
  42.     sets up world co-ordinates same as viewport co-ordinates, i. e.
  43.     one-to-one mapping between viewport and world co-ordinates.
  44.     clipping is enabled, drawing color is 7, fillpattern is Solid-fill
  45.     (Fp[19] in PATTERN.H), all drawing styles also solid.
  46.     Binary font from file 'v8x8.fnt', and stroked font from file 'sdflt.fnt',
  47.     these files should be in the current directory.
  48.  
  49.  
  50. CloseGraph
  51. ----------
  52.  
  53.     Include    : grph.h
  54.     Declaration : void far pascal CloseGraph(void)
  55.     Usage    :
  56.  
  57.     CloseGraph();
  58.  
  59.     This call will, normally, return to text mode.
  60.  
  61.     Description : Resets to Previous mode when OpenGraph was called with
  62.     Erase = 0, (Modes are not stacked !)
  63.  
  64.  
  65. SetFillPattern
  66. --------------
  67.  
  68.     Include    : grph.h
  69.     Declaration : void far pascal SetFillPattern(Byte Color,Byte XIndex,
  70.                    Byte YIndex,void  far *Pattern)
  71.     Parameters    : Color = culor value of fill, either 0 to 255 or 0 to 15
  72.               depending upon mode
  73.           XIndex = 0-7, Start index from left within Pattern matrix
  74.           YIndex = 0-7, start index from top within pattern matrix
  75.           Pattern = 8 bytes Pattern array
  76.     Usage    :
  77.  
  78.     SetFillPattern(8,0,0,Fp[0]);
  79.  
  80.     Will set fill color to 8 (grey), Indexes are zero, and fill pattern
  81.     to be used is 1st. pattern of the standard patterns Fp defined in
  82.     PATTERN.H.
  83.  
  84.     Description :
  85.  
  86.     This call is used to set either standard or user defined fill patterns,
  87.     fill color, and fill pattern indices, so subsequent calls to area
  88.     fill routines will use these parameters.
  89.  
  90.  
  91. GetFillPattern
  92. --------------
  93.  
  94.     Include    : grph.h
  95.     Declaration : void far pascal GetFillPattern(void *Color,void *XIndex,
  96.                   void *YIndex, void far *Pattern)
  97.     Parameters    : Color = Address of Byte variable, will contain color value
  98.           XIndex, YIndex = Addresses of integers
  99.           Pattern = Address of 8 byte array to return fill pattern
  100.     Usage    : GetFillPattern(&clr, &ix, &iy, pattern);
  101.  
  102.     this will return fill pattern parameters in the respective variables
  103.  
  104.     Description : Returns Fill Parameters
  105.  
  106.  
  107. SetViewPort
  108. -----------
  109.  
  110.     Include    : grph.h
  111.     Declaration : void far pascal SetViewPort(struct VP vp1)
  112.     Parameters    : structure VP type variable vp1 containing corner co-ordinates
  113.           of the viewport
  114.     Usage    :
  115.  
  116.     struct  VP    vp1;
  117.  
  118.     vp1.x1 = 10;
  119.     vp1.y1 = 10;
  120.     vp1.x2 = 120;
  121.     vp1.y2 = 140;
  122.  
  123.     SetViewPort(VP);
  124.  
  125.     This will set up a view port with upper left corner at (10,10) and
  126.     lower right corner at (120,140), in device co-ordinates.
  127.  
  128.     Description :
  129.  
  130.     Sets viewport boundaries, with upper left x , upper left y, lower right x,
  131.     lower right y device co-ordinates given by x1,y1,x2,y2 of structure VP.
  132.     With clipping enabled, all drawings can be clipped to this viewport
  133.     boundary. However, absolute co-ordinates (10,10) will not be translated
  134.     to (0,0) in the above given example. This can be achieved by a small
  135.     inteface routine of your own, so can the 'Normalised Device Co-ordinates"
  136.     be implemented by a small translation routine.
  137.  
  138.     At mode set, by OpenGraph procedure, default viewport is entire screen and
  139.     clipping is enabled.
  140.  
  141.  
  142. GetViewPort
  143. -----------
  144.  
  145.     Include    : grph.h
  146.     Declaration : void far pascal GetViewPort(struct VP *vp1)
  147.     Parameters    : Address of a variable of type structure VP
  148.     Usage    : GetViewPort(&vp1);
  149.  
  150.     Returns current viewport co-ordinates in vp1.
  151.  
  152.     Description : x1, y1, x2, y2 of structure VP type variable vp1 will
  153.     contain co-ordinates of upper left corner and lower right corner of
  154.     the current active v. p.
  155.  
  156.  
  157. SetXLen
  158. -------
  159.  
  160.     Include    : grph.h
  161.     Declaration : void far pascal SetXLen(Word Length)
  162.     Parameters    : Word type Length containing no of bytes.
  163.     Usage    :
  164.  
  165.     SetXLen(100);
  166.  
  167.     will set video buffer length to 100 bytes.
  168.  
  169.     Description : Re-dimensions video buffer with length as Length Bytes,
  170.     and height as 64*1024/Length bytes, only applicable in modes 0x10 and 0x12.
  171.  
  172.     This is like having a drawing area larger than what is displayed on
  173.     screen at a time, function SScroll() can be used to scroll display
  174.     horizontally or vertically so that portions of video buffer become
  175.     visible.
  176.  
  177.  
  178. ImageSize
  179. ---------
  180.  
  181.     Include    : grph.h
  182.     Declaration : #define ImageSize(int x1,int y1,int x2,int y2) \
  183.                  ((abs(x2-x1)+1)*(abs(y2-y1)+1)+5)
  184.     Parameters    : x1,y1 = upper left corner of the image
  185.           x2,y2 = lower right corner of the image
  186.     Usage    :
  187.  
  188.     int     isize;
  189.  
  190.     isize = ImageSize(10,10,120,140);
  191.  
  192.     will calculate no of bytes required to store an image (rectangular),
  193.     with upper left corner at device co-ordinates (10,10) and lower right
  194.     corner at device co-ordinates (120,140)
  195.  
  196.     Description : Calculates No of bytes required to store Bit image bounded
  197.     by rectangular region x1,y1,x2,y2, so that memory can be allocated for a
  198.     buffer of that size for subsequent bit-block moves.
  199.  
  200.  
  201. GetImage
  202. --------
  203.  
  204.     Include    : grph.h
  205.     Declaration : void far pascal GetImage(int Ulx ,int Uly,int Lrx,int Lry,\
  206.                  void far *Buffer)
  207.     Parameters    : Ulx, Uly = co-ordinates of upper left corner
  208.           Lrx, Lry = co-ordinates of lower right corner
  209.           Buffer   = Address of buffer to store Image
  210.     Usage    :
  211.  
  212.     void    far *pB;
  213.  
  214.     pB = (void far *)malloc(ImageSize(10,10,120,140));
  215.  
  216.     GetImage(10,10,120,140,pB);
  217.  
  218.     will calculate size of the image and store it in buffer, the image
  219.     bounded by upper left corner at (10,10) and lower right corner at
  220.     (120,140).
  221.  
  222.     Description : Returns Bit-Image bounded by rectangular region Ulx,Uly and
  223.     Lrx, Lry in Buffer, for subsequent Bit block moves
  224.  
  225.  
  226. PutImage
  227. --------
  228.  
  229.     Include    : grph.h
  230.     Declaration : void far pascal PutImage(int Ulx,int Uly,void  far *Buffer)
  231.     Parameters    : Ulx, Uly = co-ordinates of left corner of position
  232.           where to store image.
  233.           Buffer = Address of buffer containig bit image, previously
  234.           obtained by a call to GetImage, or read from file by a
  235.           call to LoadImage.
  236.     Usage    :
  237.  
  238.     GetImage(10,10,110,110,pB);     /* assume pB is allocated */
  239.  
  240.     for (i=10; i<530; i++)
  241.     PutImage(i,220,pB);
  242.  
  243.     will put image on screen from pB from x-co-ordinate 10 to 520 and y = 220,
  244.     if left vertical edge of the image is same as background, then this will
  245.     have an effect of sliding the image from left to right.
  246.  
  247.     Description : Displays Bit Image stored in Buffer, obtained by a call to
  248.     GetImage, at (Ulx,Uly) as upper left corner
  249.  
  250.  
  251. CopyImage
  252. ---------
  253.  
  254.     Include    : grph.h
  255.     Declaration : void far pascal CopyImage(int Ulx,int Uly,int Lrx,int Lry,\
  256.                int x,int y)
  257.     Parameters    : Ulx, Uly = upper left corner co-ordinates
  258.           Lrx, Lry = Lower right corner co-ordinates
  259.           x,y       = upper left corner do-ordinates of the destination
  260.     Usage    :
  261.  
  262.     CopyImage(8,10,63,60,64,61);
  263.  
  264.     will copy rectangular block bounded by (8,10) and (63,60) to (64,61).
  265.  
  266.     Description : Copies within video buffer rectangular region bounded by
  267.     (Ulx,Uly) and (Lrx,Lry) to location x,y. x,y can not be within the
  268.     source region. In 16 colour modes, only byte-aligned extents are allowed.
  269.     i.e. Ulx and x must be mod 8, and Lrx must be mod 7. In 256 colour modes,
  270.     these can be any valid values.
  271.  
  272.  
  273. SaveImage
  274. ---------
  275.  
  276.     Include    : grph.h
  277.     Declaration : void far pascal SaveImage(void *FileName,void far *Buffer,\
  278.                         Word Size)
  279.     Parameters    : FileName = character string containig valid DOS file name
  280.           Buffer   = Address of buffer containing bit image to store
  281.           Size       = size of buffer in no. of bytes
  282.     Usage    :
  283.  
  284.     isize = ImageSize(10,10,110,110);
  285.     pB = (void far *)malloc(isize);
  286.     GetImage(10,10,110,110,pB);
  287.     SaveImage("image1.dat",pB,isize);
  288.  
  289.     will save the bit image bounded by (10,10) and (110,110) in file
  290.     "image1.dat"
  291.  
  292.     Description : Save Bit image in a file given by FileName, Buffer contains
  293.     Bit Image of size Size bytes
  294.  
  295.  
  296. LoadImage
  297. ---------
  298.  
  299.     Include    : grph.h
  300.     Declaration : void far pascal LoadImage(void *FileName,\
  301.                         void far *Buffer,Word Size)
  302.     Parameters    : FileName = character string containig name of file
  303.           Buffer   = address of memory to store image in
  304.           Size       = size of Image to load from file = size of buffer
  305.     Usage    :
  306.  
  307.     pB = (void    far*)malloc(isize);
  308.     LoadImage("image1.dat',pB,isize);
  309.  
  310.     will load image from file "image1.dat" into buffer pB of isize bytes.
  311.  
  312.     Description : Loads a Bit image from a file previously saved by a call
  313.     to SaveImage.
  314.  
  315.  
  316. WindScrollUp
  317. ------------
  318.  
  319.     Include    : grph.h
  320.     Declaration : void far pascal WindScrollUp(int x1,int y1,\
  321.                            int x2,int y2, int N);
  322.     Parameters    : x1,y1 = co-ordinates of upper left corner of the
  323.                 window to scroll
  324.           x2,y2 = co-ordinates of lower right corner
  325.           N    = No. of scan lines to scroll
  326.     Usage    :
  327.  
  328.     WindScrollUp(8,10,114,110,1);
  329.  
  330.     will scroll window bounded by (8,10) and (114,110) 1 scan line up.
  331.  
  332.     Description : Scrolls window bounded by (x1,y1) and (x2,y2) by N scan
  333.     lines up. The bottom N scan lines are not modified and will be same as
  334.     before, you must fill them up with whatever color or drawing. In 16
  335.     colour modes, window must be byte-aligned.
  336.  
  337.  
  338. WindScrollDown
  339. --------------
  340.  
  341.     This function is very similar to WindScrollUp described above, except
  342.     that N scan lines are scrolled down.
  343.  
  344.  
  345. WindScrollLeft
  346. --------------
  347.  
  348.     Similar to WindScrollUp, but Image is scrolled left, so N vertical
  349.     lines on right are left as before. In 16 colour modes, N must be a
  350.     multiple of 8.
  351.  
  352.  
  353. WindScrollRight
  354. ---------------
  355.  
  356.     Similar procedure to WindScrollLeft, now we are talking about scrolling
  357.     window right.
  358.  
  359.  
  360. PolyLineD
  361. ---------
  362.  
  363.     Include    : grph.h
  364.     Declaration : int far pascal PolyLineD(Word N,int far *X,int far *Y);
  365.     Parameters    : N = No. of points in X,Y below
  366.           X = array of N integers containing x co-ordinates
  367.           Y = array of N integers containing y co-ordinates
  368.     Return    : 0 if N<1, otherwise N
  369.     Usage    :
  370.  
  371.     int     x[6],y[6];
  372.  
  373.     x[0] = 10; y[0] = 10;
  374.     x[1] = 100; y[1] = 10;
  375.     x[2] = 100; y[2] = 100;
  376.     x[3] = 50;    y[3] = 150;
  377.     x[4] = 10;    y[4] = 100;
  378.     x[5] = 10;    y[5] = 10;
  379.  
  380.     PolyLineD(6,x,y);
  381.  
  382.     will draw a closed polygon with 5 sides, note that last vertex = first
  383.     vertex to close the polygon.
  384.  
  385.     Description :
  386.  
  387.     Draws connected lines between N points given in arrays X and Y, in
  388.     device co-ordinates, if N < 1 then nothing is done and a 0 is returned,
  389.     if N=1, a single pixel is set given by first co-ordinate in X and Y,
  390.     otherwise N-1 line segments are drawn. to close polygon, last co-ordinate
  391.     must equal first co-ordinate.
  392.  
  393.     Current settings of LineStyle, drawing color, drawing mode and clipping
  394.     is used.
  395.  
  396.  
  397. Rectangl
  398. --------
  399.  
  400.     Include    : grph.h
  401.     Declaration : void far pascal Rectangl(int Ulx,int Uly,int Lrx,int Lry);
  402.     Parameters    : Ulx,Uly = upper left corner co-ordinates,
  403.           Lrx,Lry = Lower right cotner co-ordinates.
  404.     Usage    :
  405.  
  406.     int     i;
  407.     SetDraw(3);       /* set XOR drawing mode */
  408.     PxlClr = 15;        /* drawing color = white */
  409.     LineStyle = 15;        /* solid line style      */
  410.     SetClipOff();
  411.  
  412.     for (i=0; i<101; i++)
  413.     {
  414.         Rectangl(i+10,10,i+110,110);    /* draw rectangle   */
  415.         Rectangl(i+10,10,i+110,110);       /* Erase rectangle  */
  416.     }
  417.  
  418.     draws a sliding rectangle from bounds (10,10), (110,110) to
  419.     (110,10), (210,110).
  420.  
  421.     Description : Draws a rectangle with upperleft corner as Ulx,Uly and
  422.     lower-right corner as Lrx,Lry, given in device co-ordinates,
  423.     in current settings.
  424.  
  425.  
  426. EllipseD
  427. --------
  428.  
  429.     Include    : grph.h
  430.     Declaration : void far pascal EllipseD(int cx,int cy,int a,int b);
  431.     Parameters    : x,y = co-ordinates of the center
  432.           a   = axis 1 (major axis along x)
  433.           b   = axis 2 (minor axis along y)
  434.     Usage    :
  435.  
  436.     int     i;
  437.     SetClipOff();
  438.     SetDraw(3);
  439.  
  440.     for (i=0; i<401; i++)
  441.     {
  442.         EllipseD(0,0,i,i);
  443.         EllipseD(0,0,i,i);
  444.     }
  445.  
  446.     draws an exploding circle from origin
  447.  
  448.     Description : Draws Ellipse in device co-ordinates (Bresenham algorithm)
  449.     with center at cx,cy, and X and Y-axes as a and b, in current settings.
  450.  
  451.  
  452. FillPolyD
  453. ---------
  454.  
  455.     Include    : grph.h
  456.     Declaration : int far pascal FillPolyD(Word N, int far *X,int far *Y);
  457.     Parameters    : N = no of vertices in polygon
  458.           X,Y = integer arrays containing x and y co-ordinates of
  459.             polygon vertices
  460.     Usage    :
  461.  
  462.     int     x[5],y[5];
  463.  
  464.     x[0] = 10; y[0] = 10;
  465.     x[1] = 100; y[1] = 10;
  466.     x[2] = 100; y[2] = 100;
  467.     x[3] = 50;    y[3] = 150;
  468.     x[4] = 10;    y[4] = 100;
  469.  
  470.     SetFillPattern(14,0,0,Fp[0]);    /* fill settings */
  471.  
  472.     FillPolyD(5,x,y);
  473.  
  474.     fills the same polygon as drawn in example of PolyLineD, in current
  475.     Fill settings, note that polygon is automatcally taken as closed by
  476.     taking last vertice same as first, hence only 5 vertices are given in
  477.     first parameter.
  478.  
  479.     Description : Fills a closed polygon in current Fill pattern parameters,
  480.     consisting of N points in arrays X and Y, Polygon is automatcally closed.
  481.  
  482.  
  483. FillArea
  484. --------
  485.  
  486.     Include    : grph.h
  487.     Declaration : void far pascal FillArea(int SeedX,int SeedY,int Color);
  488.     Parameters    : SeedX,SeedY = co-ordinates of a point in the region
  489.           Color = Boundary color of the region
  490.     Usage    :
  491.  
  492.     PxlClr = 15;
  493.     EllipseD(0,0,10,20);        /* draw small ellipse */
  494.     EllipseD(0,0,30,40);        /* draw large ellipse */
  495.     SetFillPattern(14,0,0,Fp[1]);    /* set Fill parameters */
  496.     FillArea(20,0,PxlClr);        /* fill region between Ellipses */
  497.  
  498.     fills the area between two ellipses in the current settings.
  499.  
  500.     Description : Fills a closed area bounded by Color Pixels in current
  501.     fill settings. SeedX and SeedY are co-ordinates of a point in the
  502.     bounded region, any pixels of same boundary color lying within region
  503.     will be left as hole.
  504.  
  505.  
  506. FillRectangle
  507. -------------
  508.  
  509.     Include    : grph.h
  510.     Declaration : void far pascal FillRectangle(int x1,int y1,int x2,int y2);
  511.     Parameters    : x1,y1 = co-ordinates of the upper left corner
  512.           x2,y2 = co-ordinates of the lower right corner
  513.     Usage    :
  514.  
  515.     SetFillPattern(13,0,0,Fp[2]);        /* set fill parameters  */
  516.     FillRectangle(10,10,110,110);        /* fill the rectangle   */
  517.  
  518.     Description : Fills a rectangle in current fill pattern, results in much
  519.     faster fill.
  520.  
  521.  
  522. FillAgain
  523. ---------
  524.  
  525.     Include    : grph.h
  526.     Declaration : void far pascal FillAgain(void);
  527.     Parameters    : none
  528.     Usage    :
  529.  
  530.     SetDraw(3);           /* set XOR mode */
  531.     FillAgain();        /* last fill be erased ! */
  532.  
  533.     if called immidiatey after FillArea(), it will erase last fill.
  534.  
  535.     Description : fills the same area as last call to FillArea, but without
  536.     calculating area parameters, results in much faster fill.
  537.  
  538.  
  539. SetPalette
  540. ----------
  541.  
  542.     Include    : grph.h
  543.     Declaration : void far pascal SetPalette(int PaletteNo,int ColorNo);
  544.     Parameters    : PaletteNo = 0 to 15
  545.           ColorNo   = 0 to 255
  546.     Usage    :
  547.  
  548.     SetPalette(0,100);
  549.  
  550.     Sets the (hardware) palette given by PaletteNo to value given by ColorNo,
  551.     no range checking done on  PaletteNo
  552.  
  553.     Description : Sets a given palette to contain given colour value, colour
  554.     value is address of colour register in VGA.
  555.  
  556.  
  557. GetPalette
  558. ----------
  559.  
  560.     Include    : grph.h
  561.     Declaration : Byte      far pascal GetPalette(int PaletteNo);
  562.     Parameters    : PaletteNo = 0 to 15
  563.     Return    : Color no.
  564.     Usage    :
  565.  
  566.     Byte    Color = GetPalette(0);
  567.  
  568.     will return color value of palette 0.
  569.  
  570.     Description : returns  value of (hardware) palette given by PaletteNo
  571.  
  572.  
  573. SetPalettes
  574. -----------
  575.  
  576.     Include    : grph.h
  577.     Declaration : void      far pascal SetPalettes(void  far *Buffer);
  578.     Parameters    : Buffer = address of 17 byte buffer containg colour
  579.           values to set
  580.     Usage    :
  581.  
  582.     int     i;
  583.     Byte    aB[17];
  584.  
  585.     for (int i=0; i<17; i++)
  586.     aB[i] = i;
  587.     SetPalettes(aB);
  588.  
  589.     will set pallettes and over scan to their corresponding values as
  590.     color values
  591.  
  592.     Description : Sets all 16 palettes and overscan to values fiven in
  593.     array Buffer
  594.  
  595.  
  596. GetPalettes
  597. -----------
  598.  
  599.     Include    : grph.h
  600.     Declaration : void      far pascal GetPalettes(void  far *Buffer);
  601.     Parameters    : Buffer = address of 17 byte buffer in which color values
  602.           will be returned
  603.     Usage    :
  604.  
  605.     Byte    aB[17];
  606.     GetPalettes(aB);
  607.  
  608.     will return color values of all 16 palettes and over scan color in aB.
  609.  
  610.     Description : Returns colour values of all palettes and over-scan in Buffer
  611.  
  612.  
  613. SetClrReg
  614. ---------
  615.  
  616.     Include    : grph.h
  617.     Declaration : void      far pascal SetClrReg(StructRGB  far *Buffer,int N);
  618.     Parameters    : Buffer = Address of structure StructRGB type
  619.           N     = 0 to 255, colour register no.
  620.     Usage    :
  621.  
  622.     StructRGB    rgb;
  623.  
  624.     rgb.Red = 10;
  625.     rgb.Blue = 15;
  626.     rgb.Green = 20;
  627.  
  628.     SetClrReg(&rgb, 100);
  629.  
  630.     sets colour register no. 100 to values specified in struct rgb.
  631.  
  632.     Description :
  633.  
  634.     Sets up color register no.N (between 0 and 255)  to RGB value given in
  635.     Buffer, of type StructRGB, which is 3 byte structure each specifying
  636.     Red, Green and Blue colour values, only lower 6 bits of each Red, green
  637.     and blue are significant.
  638.  
  639.  
  640. GetClrReg
  641. ---------
  642.  
  643.     Include    : grph.h
  644.     Declaration : void      far pascal GetClrReg(void  far *Buffer,int N);
  645.     Parameters    : Buffer = address of a structure of type StructRGB
  646.           N     = 0 to 255, colour register no.
  647.     Usage    :
  648.  
  649.     StructRGB        rgb;
  650.     GetClrReg(&rgb,100);
  651.  
  652.     will return colour values of register no. 100
  653.  
  654.     Description :
  655.  
  656.     Returns RGB values of colour register no N in Buffer, red, green and
  657.     blue components are returned in Red, Green and Blue fields of the
  658.     structure. Only lower 6 bits are significant
  659.  
  660.  
  661. SetRGBDAC
  662. ---------
  663.  
  664.     Include    : grph.h
  665.     Declaration : void far pascal SetRGBDAC(int StartReg,int N,void  far *Bffr);
  666.     Parameters    : StartReg = 0,255 the DAC register no. to start from
  667.           N       = No. of registers to update
  668.           Bffr       = array of N elements of type StructRGB
  669.     Usage    :
  670.  
  671.     StructRGB        Bffr[2];
  672.  
  673.     Bffr[0].Red = 5;    Bffr[0].Green = 10; Bffr[0].Blue = 15;
  674.     Bffr[1].Red = 25;    Bffr[1].Green = 30; Bffr[1].Blue = 35;
  675.  
  676.     SetRGBDAC(0,2,Bffr);
  677.  
  678.     will update two DAC registers 0 and 1 with values in Bffr;
  679.  
  680.     Description : Sets a No of color registers N, starting with StartReg,
  681.     to RGB values given by Red,Green and Blue components of Bffr.
  682.  
  683.  
  684. GetRGBDAC
  685. ---------
  686.  
  687.     Include    : grph.h
  688.     Declaration : void far pascal GetRGBDAC(int StartReg,int N,void far *Bffr);
  689.     Parameters    : StartReg = 0,255, Register No. to start
  690.           N       = no. of registers to get values of
  691.           Bffr       = array of N elements of type StructRGB
  692.     Usage    :
  693.  
  694.     StructRGB        Bffr[256];
  695.  
  696.     GetRGBDAC(0,256,Bffr);
  697.  
  698.     will return values of all 256 color registers.
  699.  
  700.     Description :
  701.  
  702.     Returns RGB values of a no of consecutive N registers, starting with
  703.     StartReg into array of N elements of type StructRGB. Each element of the
  704.     array will contain Red, Green and Blue components in the fields of
  705.     respective names.
  706.  
  707.  
  708. GreyScale
  709. ---------
  710.  
  711.     Include    : grph.h
  712.     Declaration : void far pascal GreyScale(int StartReg,int N);
  713.     Parameters    : StartReg = 0-255, register no. to start
  714.           N       = No. of registers to enable grey-scaling
  715.     Usage    :
  716.  
  717.     GreyScale(0,256);
  718.  
  719.     will enable grey scaling on all 256 colour registers
  720.  
  721.     Description :
  722.  
  723.     Enables Grey-Scaling on a no of Registers N with   starting register
  724.     specified by StartReg, immidiate effect will be seen on the screen,
  725.     To disable, call to mode set function is necessary i. e. call
  726.     OpenGraph with Erase=1, and set up all other grpaphics state variables
  727.     same as before if required.
  728.  
  729.  
  730. ClearScreen
  731. -----------
  732.  
  733.     Include    : grph.h
  734.     Declaration : void      far pascal ClearScreen(void);
  735.     Usage    :
  736.  
  737.     ClearScreen();
  738.  
  739.     Description : Clears the entire video buffer, all bits are set to 0.
  740.  
  741.  
  742. SetOrigin
  743. ---------
  744.  
  745.     Include    : grph.h
  746.     Declaration : void      far pascal SetOrigin(int x,int y);
  747.     Parameters    : x,y = co-ordinates where origin is required
  748.     Usage    :
  749.  
  750.     SetOrigin(XRes+1,YRes+1);
  751.  
  752.     will set upper left corner of the scrren with reference to line YRes+1,
  753.     coloumn XRes+1 in the video buffer, this is like switching to video page 1
  754.     in mode hex 10.
  755.  
  756.     Description : sets video buffer origin so that device co-ordinates x,y
  757.     are at upper left corner of the screen, Immidiate effect will be seen
  758.     on screen, this can be used to switch video pages.
  759.  
  760.  
  761. SplitScreen
  762. -----------
  763.  
  764.     Include    : grph.h
  765.     Declaration : void      far pascal SplitScreen(int Row);
  766.     Parameters    : Row = line at which to split screen
  767.     Usage    :
  768.  
  769.     int     i;
  770.  
  771.     for (i=0; i<151; i++)
  772.     SplitScreen(i);
  773.  
  774.     will split 150 times from row 1 to row 150 continuously, so will have
  775.     effect of image appearing from top and moving down.
  776.  
  777.     Description : Splits the screen at given line no.
  778.  
  779.  
  780. SScroll
  781. -------
  782.  
  783.     Include    : grph.h
  784.     Declaration : void      far pascal SScroll(int No,int Direction);
  785.     Parameters    : No = no of scan line to scroll by
  786.           Direction = 0 for left
  787.                   1 for right
  788.                   2 for up
  789.                   3 for down
  790.     Usage    :
  791.  
  792.     SScroll(XMax-XRes, 0);
  793.     SScroll(YMax-YRes, 2);
  794.     SScroll(XMax-XRes, 1);
  795.     SScroll(YMax-YRes, 3);
  796.  
  797.     will display contents of entire video buffer by scrolling first left,
  798.     then up, then right, and down, all by maximum scan lines possible.
  799.  
  800.     Description : Smooth scrolls by No lines in left,right,up or down Direction
  801.     so that different portions of video buffer are visible.
  802.  
  803.  
  804. SetGC
  805. -----
  806.  
  807.     Include    : grph.h
  808.     Declaration : void      far pascal SetGC(void);
  809.     Usage    :
  810.  
  811.     ReSerGC();
  812.     printf("This text should be displayed correctly");
  813.     SetGc();
  814.  
  815.     first sets graphics board to BIOS deafult parameters, so thar text will
  816.     be displayed properly, then by a call to SetGC(), graphics output to
  817.     video can be resumed.
  818.  
  819.     Description : Sets up Graphics board for current mode, to be called after
  820.     any video buffer output by other functions not in this library.
  821.  
  822.  
  823. ReSetGC
  824. -------
  825.     Include    : grph.h
  826.     Declaration : void      far pascal ReSetGC(void);
  827.     Usage    :
  828.  
  829.     see example above for SetGC();
  830.  
  831.     Description : Sets up Graphic board in BIOS default mode, to be called
  832.     before invoking any video output function not in this library.
  833.  
  834.  
  835. SetVdOn
  836. -------
  837.  
  838.     Include    : grph.h
  839.     Declaration : int far pascal SetVdOn(void);
  840.     Return    : not used
  841.     Usage    :
  842.  
  843.     SetVdOn();
  844.  
  845.     will resume display on monitor.
  846.  
  847.     Description : Sets the video monitor on, ie display resumes
  848.  
  849.  
  850. SetVdOff
  851. --------
  852.  
  853.     Include    : grph.h
  854.     Declaration : int      far pascal SetVdOff(void);
  855.     Return    : not used
  856.     Usage    :
  857.  
  858.     SetVdOff();
  859.  
  860.     display on monitor will stop, also monitor will be blank
  861.  
  862.     Description : sets off monitor so nothing will be visible, but output
  863.     to video buffer can continue, so when SetVdOn() is called, current
  864.     contents of video buffer will be displayed
  865.  
  866.  
  867. GetPixel
  868. --------
  869.  
  870.     Include    : grph.h
  871.     Declaration : Byte      far pascal GetPixel(int x,int y);
  872.     Parameters    : x,y = device do-ordinates of the point
  873.     Return value: Colour value at x,y
  874.     Usage    :
  875.  
  876.     Byte    c;
  877.  
  878.     PxlClr = 15;
  879.     SetPixel(100,100);
  880.     if ((c=GetPixel(100,100)) != PxlClr)
  881.     printf ("Error !!!");
  882.  
  883.     will set pixel value 15 at point (100,100), and test by calling
  884.     GetPixel.
  885.  
  886.     Description : returns pixel color value at device co-ordinates x,y
  887.  
  888.  
  889. SetPixel
  890. --------
  891.  
  892.     Include    : grph.h
  893.     Declaration : void      far pascal SetPixel(int x,int y);
  894.     Parameters    : x,y = device co-ordinates of the point
  895.     Usage    :
  896.  
  897.     see example above
  898.  
  899.     Description : Sets the Pixel value to current drawing color given by
  900.     global variable PxlClr at device co-ordinates x,y
  901.  
  902.  
  903. LineD
  904. -----
  905.  
  906.     Include    : grph.h
  907.     Declaration : void      far pascal LineD(int x1,int y1,int x2,int y2);
  908.     Parameters    : x1,y1 = device co-ordinates of end point 1
  909.           x2,y2 = device co-ordinates of other end point
  910.     Usage    :
  911.  
  912.     int     i;
  913.  
  914.     for (i=0; i<=XRes; i++)
  915.     LineD((XRes>>1,YRes>>1,i,0);
  916.  
  917.     will draw a no. of lines emanating from center of the screen and ending
  918.     at top most row.
  919.  
  920.     Description : Draws a line in device co-ordinates between (x1,y1) (x2,y2)
  921.     in the color given by global variable PxlClr, and in current settings.
  922.  
  923.  
  924. SetClipOn
  925. ---------
  926.  
  927.     Include    : grph.h
  928.     Declaration : #define SetClipOn() ClipTrue=1
  929.     Usage    :
  930.  
  931.     SetClipOn();
  932.  
  933.     will enable clipping, so all subsequent video outputs will be clipped
  934.     to current or changing viewport boundaries, until it is disabled by
  935.     function call SetClipOff().
  936.  
  937.     Description : Sets clipping active to current active viewport boundaries,
  938.     all drawings will be clipped
  939.  
  940.  
  941. SetClipOff
  942. ----------
  943.  
  944.     Include    : grph.h
  945.     Declaration : #define SetClipOff() ClipTrue=0
  946.     Usage    :
  947.  
  948.     SetClipOff();
  949.  
  950.     re-sets clipping, so output beyond video buffer boundaries will
  951.     wrap around, which may not be desirable.
  952.  
  953.     Description : Re-sets clipping, so no clliping will be done on any
  954.     of the drawings
  955.  
  956.  
  957. GetClip
  958. -------
  959.  
  960.     Include    : grph.h
  961.     Declaration : #define GetClip(c) c=ClipTrue
  962.     Return value: current clipping status 0 = no-clipping, 1 = enabled.
  963.     Usage    :
  964.  
  965.     Byte    c;
  966.  
  967.     GetClip(c);
  968.     if (c == 0)
  969.     SetClipOn();
  970.  
  971.     will enable clipping if it is already not enabled.
  972.  
  973.     Description : returns the status of the current clipping ,
  974.     0= dis-abled, 1 = enabled
  975.  
  976.  
  977. SetDraw
  978. -------
  979.  
  980.     Include    : grph.h
  981.     Declaration : #define SetDraw(Mode) (WrtMd=Mode<<3);SetGc
  982.     Parameters    : Mode = 0,1,2 or 3
  983.     Usage    :
  984.  
  985.     SetDraw(3);
  986.  
  987.     will set subsequent video buffer update mode to 3 = XOR.
  988.  
  989.     Description : Sets up drawing mode as one of the following
  990.     0 = replace
  991.     1 = and
  992.     2 = or
  993.     3 = xor
  994.  
  995.     All subsequent drawing of any kind will follow this logic
  996.  
  997.  
  998. GetDraw
  999. -------
  1000.  
  1001.     Include    : grph.h
  1002.     Declaration : #define GetDraw(d) (d=WrtMd>>3)
  1003.     Usage    :
  1004.  
  1005.     Byte    m;
  1006.     GetDraw(m);
  1007.  
  1008.     will return current drawing mode in m.
  1009.  
  1010.     Description : returns current logical drawing mode between 0 and 3
  1011.  
  1012.  
  1013. SetLineStyle
  1014. ------------
  1015.  
  1016.     Include    : grph.h
  1017.     Declaration : void far pascal SetLineStyle(Byte Styl);
  1018.     Parameters    : Styl = 8 bit value specifying line-style bit pattern
  1019.     Usage    :
  1020.  
  1021.     SetLineStyle(15);
  1022.  
  1023.     will set style to dashed lines.
  1024.  
  1025.     Description : Sets the line drawing pattern given in Styl byte
  1026.  
  1027.  
  1028. GetLineStyle
  1029. ------------
  1030.  
  1031.     Include    : grph.h
  1032.     Declaration : #define GetLineStyle(Styl)   Styl=LineStyle
  1033.     Parameters    : Styl = Byte value to receive current line style bit-pattern
  1034.     Usage    :
  1035.  
  1036.     GetLineStyle(l);
  1037.  
  1038.     will return current line style in l.
  1039.  
  1040.     Description : Returns line drawing pattern given in Styl byte
  1041.  
  1042.  
  1043. SetEllipseStyle
  1044. ---------------
  1045.  
  1046.     Include    : grph.h
  1047.     Declaration : SetEllipseStyle(Styl)     EllpsStyle=Styl
  1048.     Parameters    : Style = 8 bit pattern for style
  1049.     Usage    :
  1050.  
  1051.     SetEllipseStyle(0xAA);
  1052.  
  1053.     will set dots style
  1054.  
  1055.     Description : Sets the Ellipse drawing pattern given in Styl byte
  1056.  
  1057.  
  1058. GetEllipseStyle
  1059. ---------------
  1060.  
  1061.     Include    : grph.h
  1062.     Declaration : #define GetEllipseStyle(Styl)     Styl=EllpsStyle
  1063.     Parameters    : Styl = return value for bit-pattern byte
  1064.     Usage    :
  1065.  
  1066.     Byte    s;
  1067.  
  1068.     GetEllipseStyle(s);
  1069.  
  1070.     will return current ellipse drawing bit-pattern in s
  1071.  
  1072.     Description : Returns current ellipse drawing pattern in Styl byte
  1073.  
  1074.  
  1075. SFntStClr
  1076. ---------
  1077.  
  1078.     Include    : font.h
  1079.     Declaration : void      far pascal SFntStClr(Byte c);
  1080.     Parameters    : colour value for stroked font
  1081.     Usage    :
  1082.  
  1083.     SFntStClr(14);
  1084.  
  1085.     will draw all subsequent stroked font characters in bright yellow (14)
  1086.  
  1087.     Description : sets drawing color for stroked fonts
  1088.  
  1089.  
  1090. SFntStSz
  1091. --------
  1092.  
  1093.     Include    : font.h
  1094.     Declaration : void      far pascal SFntStSz(float w,float h);
  1095.     Parameters    : w = width of characters
  1096.           h = height of characters
  1097.     Usage    :
  1098.  
  1099.     SFntStSz(2.0f,3.0f);
  1100.  
  1101.     will set horizontal width of character to 2, and vertical height to 3
  1102.  
  1103.     Description : sets horizontal w and vertical h sizes for stroked fonts
  1104.  
  1105.  
  1106. SFntStOrntn
  1107. -----------
  1108.  
  1109.     Include    : font.h
  1110.     Declaration : void      far pascal SFntStOrntn(float a);
  1111.     Parameters    : a = angle of rotation +ve is anticlock wise and
  1112.             0 is along x-direction (0=default)
  1113.     Usage    :
  1114.  
  1115.     SFntStOrntn(45.0f);
  1116.  
  1117.     will output stroked font text at 45.0 degrees from +ve x-axis
  1118.  
  1119.     Description : sets the orientation of stroked fonts drawing
  1120.     given by angle a
  1121.  
  1122.  
  1123. SFntStLctn
  1124. ----------
  1125.  
  1126.     Include    : font.h
  1127.     Declaration : void      far pascal SFntStLctn(float x,float y);
  1128.     Parameters    : x,y = world co-ordinates of point where next storked
  1129.             font text will be displayed
  1130.     Usage    :
  1131.  
  1132.     SFntStLctn(1005.0f,2050.0f);
  1133.  
  1134.     will set start co-ordinates of text display
  1135.  
  1136.     Description : sets the positions given by world co-ordinates for
  1137.     stroked fonts
  1138.  
  1139.  
  1140. SFntStDrctn
  1141. -----------
  1142.  
  1143.     Include    : font.h
  1144.     Declaration : void      far pascal SFntStDrctn(enum SFntDrctnTp drctn);
  1145.     Parameters    : drctn = left,right,up or down
  1146.     Usage    :
  1147.  
  1148.     SFntStDrctn(up);
  1149.  
  1150.     will display subsequent text going up
  1151.  
  1152.     Description : sets stroked font direction right, left up or down
  1153.  
  1154.  
  1155. SFntYRflct
  1156. ----------
  1157.  
  1158.     Include    : grph.h
  1159.     Declaration : void      far pascal SFntYRflct(void);
  1160.     Usage    :
  1161.  
  1162.     SFntYRflct();
  1163.  
  1164.     will draw characters reflected about y-axis
  1165.  
  1166.     Description : Each character is reflected about Y axis before drawing
  1167.  
  1168.  
  1169. SFntLd
  1170. ------
  1171.  
  1172.     Include    : grph.h
  1173.     Declaration : int      far pascal SFntLd(void *filename);
  1174.     Parameters    : filename = text string containing valid DOS file name
  1175.                  of font
  1176.     Return Value: 0 = successful, 2=can not open file, 1 = file error
  1177.     Usage    :
  1178.  
  1179.     SFntLd("sdflt.fnt");
  1180.  
  1181.     loads font characters from file "sdflt.fnt'
  1182.  
  1183.     Description : loads the font file and makes that font active
  1184.  
  1185.  
  1186. SFntInit
  1187. --------
  1188.  
  1189.     Include    : font.h
  1190.     Declaration : int     far pascal SFntInit(void *filename);
  1191.     Parameters    : filename = characters strin containt valid DOS file name
  1192.                  of font
  1193.     Return value: 0 = 0.k., 1=file read error, 2=file open error
  1194.     Usage    :
  1195.  
  1196.     SFntInit("sdflt.fnt");
  1197.  
  1198.     loads font from "sdflt.fnt", and sets default font settings
  1199.  
  1200.     Description : Initilises stroked font parameters, loads font
  1201.     from given file name and makes it active
  1202.  
  1203.  
  1204. SFntDsply
  1205. ---------
  1206.  
  1207.     Include    : font.h
  1208.     Declaration : void      far pascal SFntDsply(void *s);
  1209.     Parameters    : s = character string to display
  1210.     Usage    :
  1211.  
  1212.     SFntDsply("Test of Display string routine");
  1213.  
  1214.     Description :     displays string s in stroked fonts
  1215.  
  1216.  
  1217. BFntInit
  1218. --------
  1219.  
  1220.     Include    : font.h
  1221.     Declaration : int  far pascal BFntInit(void *filename, int Points);
  1222.     Parameters    : filename = string of DOS file name of Font
  1223.           Points = height of character in pixel, i. e 8 or 16
  1224.     Return Value: 0 = o.k., 1=file read error, 2= file open error
  1225.     Usage    :
  1226.  
  1227.     BFntInit("v8x8.fnt",8);
  1228.  
  1229.     loads font from "v8x8.fnt" file, character height is 8 pixels;
  1230.  
  1231.  
  1232.     Description : initializes bit-mapped font parameters and loads font from
  1233.     given file name of Points size and makes it active
  1234.  
  1235.  
  1236. BFntStLctn
  1237. ----------
  1238.  
  1239.     Include    : font.h
  1240.     Declaration : void      far pascal BFntStLctn(int x,int y);
  1241.     Parameters    : x,y = device co-ordinates to output characters
  1242.     Usage    :
  1243.  
  1244.     BFntStLctn(10,20);
  1245.  
  1246.     following this call, character will be displayed at (10,20)
  1247.  
  1248.     Description  : sets the position of bit-mapped character given by device
  1249.     co-ordinates (x,y)
  1250.  
  1251.  
  1252. BFntStSz
  1253. --------
  1254.  
  1255.     Include    : font.h
  1256.     Declaration : void      far pascal BFntStSz(int w,int h);
  1257.     Parameters    : w = width of characters, actual width in pixels will be 8 * w
  1258.           h = height, actual will be Points * h
  1259.     Usage    :
  1260.  
  1261.     BFntStSz(2,4);
  1262.  
  1263.     will display characters twice wide and four times high than normal
  1264.  
  1265.  
  1266.     Description : sets up logical size of bit-mapped fonts
  1267.  
  1268.  
  1269. BFntLd
  1270. ------
  1271.  
  1272.     Include    : font.h
  1273.     Declaration : int      far pascal BFntLd(void *filename,int charsize);
  1274.     Parameters    : filename = character string, must be valid DOS file name
  1275.           charsize = height of a character in pixel in font
  1276.  
  1277.     Return Value: 0 = o.k., 1 = file error, 2 = can not open file
  1278.     Usage    :
  1279.  
  1280.     int     i;
  1281.     if ((i=BFntLd("v8x16.fnt",16)) != 0)
  1282.     printf (" Can't read font from file");
  1283.  
  1284.     loads 16 point font from v8x16, displays error if any
  1285.  
  1286.     Description : loads the font from a file, vertical height in pixels is
  1287.     given by charsize parameter
  1288.  
  1289.  
  1290. BFntDsply
  1291. ---------
  1292.  
  1293.     Include    : font.h
  1294.     Declaration : void      far pascal BFntDsply(void *s1);
  1295.     Parameters    : s1 = character string to display
  1296.     Usage    :
  1297.  
  1298.     BFntStLctn(10,20);
  1299.     BFntDsply("displaying at (10,20)");
  1300.  
  1301.     Description : displays string s1 in bit-mapped font
  1302.  
  1303.  
  1304. BFntStOrntn
  1305. -----------
  1306.  
  1307.     Include    : font.h
  1308.     Declaration : void      far pascal BFntStOrntn(int a);
  1309.     Parameters    : a = angle of rotation, will be always taken mod 90
  1310.     Usage    :
  1311.  
  1312.     BFntStOrntn(90);
  1313.     BFntStOrntn(90);
  1314.  
  1315.     first call will set text going up, second call will cascade and set
  1316.     text output to horizontal, but from right to left
  1317.  
  1318.     Description : sets up  bit-mapped font rotation in multiple of 90 degrees
  1319.     only, applicable only when a 8 by 8 font is active
  1320.  
  1321.  
  1322. BFntStClr
  1323. ---------
  1324.  
  1325.     Include    : font.h
  1326.     Declaration : #define     BFntStClr(c)    BFntFClr=c
  1327.     Parameters    : c = colour value to set for text display
  1328.     Usage    :
  1329.  
  1330.     BFntStClr(14);
  1331.     BFntStLctn(10,20);
  1332.     BFntStOrntn(100);
  1333.  
  1334.     BFntDsply("This must be in Yellow startin from (10,20) and going up");
  1335.  
  1336.     Description : sets up bit-mapped font text drawing colour
  1337.  
  1338.  
  1339. MapWorld
  1340. --------
  1341.  
  1342.     Include    : ops2d.h
  1343.     Declaration : void far pascal MapWorld(float x,float y,float x1,float y1);
  1344.     Parameters    : x,y = world co-ordinates of lower left corner
  1345.           x1,y1 = world co-ordinates of upper right corner
  1346.     Usage    :
  1347.  
  1348.     Struct    VP  vp1;
  1349.  
  1350.     vp1.x1 = 10, vp1.y1 = 10;
  1351.     vp1.x2 = 310; vp1.y2 = 310;
  1352.  
  1353.     SetViewPort(vp1);
  1354.     MapWorld(-1000.0f,-1000.0f,500.0f, 400.0f);
  1355.  
  1356.     sets up a view port and maps a world co-ordinate systems on to it
  1357.  
  1358.     Description : sets up world co-ordinates system, mapped to current
  1359.     viewport co-ordinates. x,y are co-ordinates of lower-left corner and
  1360.     x1,y1 are co-ordinates of upper right corner
  1361.  
  1362.  
  1363. WtoDX
  1364. -----
  1365.  
  1366.     Include    : ops2d.h
  1367.     Declaration : #define WtoDX(xw) (int)(stvwx*(xw-Wrldxy[0])+Wrldxy[4])
  1368.     Parameters    : xw = world x co-ordinate (float), which will be
  1369.                converted to corresponding device co-ordinate
  1370.     Usage    :
  1371.  
  1372.     int     p = WtoDX(100.0f);
  1373.  
  1374.     converts world x co-ordinate 100.0f into device x co-ordinate in p
  1375.  
  1376.     Description : returns device x co-ordinate corresponing to world
  1377.     xw co-ordinate
  1378.  
  1379.  
  1380. WtoDY
  1381. -----
  1382.  
  1383.     Include    : ops2d.h
  1384.     Declaration : #define WtoDY(yw) (int)(stvwy*(yw-Wrldxy[1])+Wrldxy[5])
  1385.     Parameters    : yw = world y co-ordinate to convert into device y ordinate
  1386.     Usage    :
  1387.  
  1388.     int     y = WtoDY(2500.0f);
  1389.  
  1390.     will convert 2500.0f into device y ordinate in y
  1391.  
  1392.     Description : returns device y co-ordinate corresponding to world
  1393.     yw ordinate
  1394.  
  1395.  
  1396. LWtoDX
  1397. ------
  1398.  
  1399.     Include    : ops2d.h
  1400.     Declaration : #define LWtoDX(xl) abs((int) (stvwx * xl))
  1401.     Parameters    : xl = length in x direction measured in world co-ordinates
  1402.     Usage    :
  1403.  
  1404.     int     dxl = LWtoDX(25.0f);
  1405.  
  1406.     converts into dxl length in device co-ordinates
  1407.  
  1408.     Description : returns the length in x-direction in device co-ordinates
  1409.     corresponding to length xl in world co-ordinates
  1410.  
  1411.  
  1412. LWtoDY
  1413. ------
  1414.  
  1415.     Include    : ops2d.h
  1416.     Declaration : #define LWtoDY(yl) abs((int) (stvwy * yl))
  1417.     Parameters    : yl = length in y direction in world co-ordinates
  1418.     Usage    :
  1419.  
  1420.     int     dyl = LWtoDY(350.0f);
  1421.  
  1422.     converts length into device co-ordinate system length
  1423.  
  1424.     Description : returns the length in y-direction in device co-ordinates
  1425.     corresponding to length yl in world co-ordinates
  1426.  
  1427.  
  1428. Line
  1429. ----
  1430.  
  1431.     Include    : ops2d.h
  1432.     Declaration : #define Line(x1,y1,x2,y2) LineD(WtoDX(x1),WtoDY(y1),\
  1433.                           WtoDX(x2),WtoDY(y2))
  1434.     Parameters    : x1,y1 = end point 1
  1435.           x2,y2 = other end point
  1436.  
  1437.     Usage    :
  1438.  
  1439.     Line(25.00f,25.00f,340.0f,2500.0f);
  1440.  
  1441.     will draw a line between two end points in current settings
  1442.  
  1443.     Description : draws a line in world co-ordinates connecting points
  1444.     (x1,y1) and (x2,y2)
  1445.  
  1446.  
  1447. Ellipse
  1448. -------
  1449.  
  1450.     Include    : ops2d.h
  1451.     Declaration : #define Ellipse(xc,yc,a,b) EllipseD(WtoDX(xc),WtoDY(yc),\
  1452.                               LWtoDX(a),LWtoDY(b))
  1453.     Parameters    : xc,yc = point of the ellipse center
  1454.           a,b = axes of ellipse in x,y direction respectively
  1455.     Usage    :
  1456.  
  1457.     Ellipse(0.0f,0.0f,150.0f,240.0f);
  1458.  
  1459.     will draw ellipse with center at (0.0f,0.0f), x-axis of 150.0f, and
  1460.     y-axis of 240.0f
  1461.  
  1462.     Description : draws an ellipse (bresenham's algorithm) whose center
  1463.     is at xc,yc and x-axis and y-axis given by a and b, all in world
  1464.     system
  1465.  
  1466.  
  1467. Arc
  1468. ---
  1469.  
  1470.     Include    : ops2d.h
  1471.     Declaration : Word    far pascal Arc(float xc, float yc, float a, float b,\
  1472.                 float t1,float t2, float *x, float *y,Word N)
  1473.     Parameters    : xc,yc = center of ellipse of arc
  1474.           a,b    = major and minor axes of ellipse
  1475.           t1,t2 = start and end angles of sweep of arc, +ve is
  1476.           anticlock wise
  1477.           x,y    = array of N elements to return arc points, will
  1478.               return N points, N-1 line segments
  1479.           N    = No. of points in the arc sweep
  1480.     Return Value: No of arc points generated
  1481.           0 -> if t1=t2 or N<2 , i.e. no arc points
  1482.           2 -> If a=0.0f or b=0.0f,
  1483.           N -> otherwise
  1484.     Usage    :
  1485.  
  1486.     float    x[50],y[50];
  1487.     Word    i;
  1488.  
  1489.     i = Arc(0.0f,0.0f,100.0f,50.0f,45.0f,135.0f,x,y,50);
  1490.  
  1491.     will return 50 points (49 line segments) in arrays x,y, of the arc of
  1492.     an ellipse whose center is at (0.0f,0.0f), axes are 100.0f in x-direction
  1493.     and 50.0f in y-direction, and arc sweeps from angle 45.0 dgrees to 135.00
  1494.     degrees, requiring 50 points while actual no. of points generated will
  1495.     be in i.
  1496.  
  1497.     Description : returns a no. of points of an arc segment of an ellipse.
  1498.     Ellipse center is at (xc,yc), axes a and b, the arc starts from angle t1
  1499.     and ends at angle t2, t1 and t2 will be taken modulus 360 degrees, to
  1500.     draw complete ellipse t1=0, t2=359.99
  1501.  
  1502.  
  1503. PolyLine
  1504. --------
  1505.  
  1506.     Include    : ops2d.h
  1507.     Declaration : int far pascal PolyLine(Word N,float far *x,float far *y)
  1508.     Parameters    : N = No. of points in x and y below
  1509.           x,y = arrays of N floats, each is a polygon vertex
  1510.     Return Value: 0 -> if N < 1, N -> Otherwise
  1511.     Usage    :
  1512.  
  1513.     float    x[5],y[5];
  1514.  
  1515.     x[0] = 10; y[0]= 10;
  1516.     x[1] = 100; y[1] = 10;
  1517.     x[2] = 100; y[2] = 100;
  1518.     x[3] = 10; y[3] = 100;
  1519.     x[4] = 10; y[4] = 10;
  1520.  
  1521.     PolyLine(5,x,y);
  1522.  
  1523.     will draw a four sided closed polygon, in particular a rectangle.
  1524.  
  1525.     Description : draws (N-1) connected line segments whose points in world
  1526.     co-ordinates are given in arrays x and y, if a single point is given,
  1527.     then pixel value is set at (x[0],y[0]). Current settings are used. To
  1528.     close polygon, last point must given as equal to first point.
  1529.  
  1530.  
  1531. FillPoly
  1532. --------
  1533.  
  1534.     Include    : grph.h
  1535.     Declaration : void far pascal FillPoly(Word N, float far *x,float far *y);
  1536.     Parameters    : N = No. of points in the polygon
  1537.           x,y = arrays of floats of polygon vertices
  1538.  
  1539.     Usage    :
  1540.  
  1541.     FillPoly(10,x,y);
  1542.  
  1543.     will fill polygon of 10 vertices whose co-ordinates are in arrays x,y
  1544.  
  1545.     Description : fills a closed polygon of N points given in arrays
  1546.     x and y, in world co-ordinates, current settings will be used. Also
  1547.     note that polygon will be automatically taken as closed, hence
  1548.     it is not necessary to specify last point equal to first point.
  1549.  
  1550.  
  1551. MkIdnt2D
  1552. --------
  1553.  
  1554.     Include    : ops2d.h
  1555.     Declaration : void      far pascal MkIdnt2D(float *m);
  1556.     Parameters    : m = array of floats of 9 elements, a 2D matrix.
  1557.     Usage    :
  1558.  
  1559.     float    m[9];
  1560.     MkIdnt2D(m);
  1561.  
  1562.     will return a 2D identity matrix in m.
  1563.  
  1564.     Description : converts a 3x3 array into an identity matrix.
  1565.  
  1566.  
  1567. PolyCntr2D
  1568. ----------
  1569.  
  1570.     Include    : ops2d.h
  1571.     Declaration : void far pascal PolyCntr2D(Word N,float *x,float *y,\
  1572.                          float *xc,float *yc);
  1573.     Parameters    : N = No of points in arrays x,y
  1574.           x,y = arrays of floats
  1575.           xc,yc = co-ordinates of center point
  1576.     Usage    :
  1577.  
  1578.     float    xc,yc;
  1579.     float    x[100],y[100];
  1580.  
  1581.     PolyCntr2D(100,x,y,&xc,&yc);
  1582.  
  1583.     will return center of gravity of 100 points in x,y; in xc,yc
  1584.  
  1585.     Description : returns the average (Bary-Center) of N points given in
  1586.     arrays x,y; in xc,yc
  1587.  
  1588.  
  1589. TrnsfrmPnts2D
  1590. -------------
  1591.  
  1592.     Include    : ops2d.h
  1593.     Declaration : void far pascal TrnsfrmPnts2D(Word N,float *x,\
  1594.                         float *y,float *m);
  1595.     Parameters    : N = no. of Points to Transform
  1596.           x,y = arrays of floats of at least N points
  1597.           m = 3x3 transformation matrix
  1598.     Usage    :
  1599.  
  1600.     float    m[9];
  1601.  
  1602.     Trnslt2D(100.0f,50.0f,m);
  1603.     TrnsfrmPnts2D(10,x,y,m);
  1604.  
  1605.     will transform 10 points in x,y by matrix m, a translation of 100.0f
  1606.     in x direction and 50.0f in y direction is applied.
  1607.  
  1608.     Description : applies transformation matrix m to N point in arrays x,y
  1609.  
  1610.  
  1611. Scale2D
  1612. -------
  1613.  
  1614.     Include    : ops2d.h
  1615.     Declaration : void far pascal Scale2D(float a,float b,float xc,\
  1616.                       float yc,float *m);
  1617.     Parameters    : a = scaling factor in x direction
  1618.           b = scaling factor in y direction
  1619.           xc,yc = point about which scaling is to be applied
  1620.           m = 3x3 matrix.
  1621.     Usage    :
  1622.  
  1623.     float    m[9];
  1624.     Scale2D(2.0f,1.5f,0.0f,0.0f,m);
  1625.  
  1626.     will generate matrix m, which when applied to a 2d object will make the
  1627.     object twice in size in horizontal direction and 1.5 times in vertical
  1628.     direction, about origin.
  1629.  
  1630.     Description : returns scaling matrix in m, scaling center at xc,yc and
  1631.     scaling factors a in x direction and b in y direction
  1632.  
  1633.  
  1634. Rotate2D
  1635. --------
  1636.  
  1637.     Include    : grph.h
  1638.     Declaration : void far pascal Rotate2D(float t,float xc,float yc,float *m);
  1639.     Parameters    : t = angle of rotation, anti-clock wise is +ve
  1640.           xc,yc = co-ordinates of a point about which rotation
  1641.           is to be applied
  1642.           m = a 3x3 return matrix
  1643.     Usage    :
  1644.  
  1645.     float    m[9];
  1646.     Rotate2D(45.0f,0.0f,0.0f,m);
  1647.  
  1648.     will return rotation matrix of 45 degrees about origin.
  1649.  
  1650.     Description : returns rotation  by angle t about a point xc,yc, in m
  1651.  
  1652.  
  1653. Trnslt2D
  1654. --------
  1655.  
  1656.     Include    : ops2d.h
  1657.     Declaration : void far pascal Trnslt2D(float x,float y,float *m);
  1658.     Parameters    : x = translation factor in x-direction
  1659.           y = translation factor in y-direction
  1660.           m = 3x3 matrix
  1661.     Usage    :
  1662.  
  1663.     float    m[9];
  1664.     Trnslt2D(40.0f,60.0f,m);
  1665.  
  1666.     will return a translation matrix of 40 in x and 60 in y directions
  1667.  
  1668.     Description : returns translation matrix m, x and y are displacements
  1669.     factors.
  1670.  
  1671.  
  1672. CmbnTrnsfrm2D
  1673. -------------
  1674.  
  1675.     Include    : grph.h
  1676.     Declaration : void far pascal CmbnTrnsfrm2D(float *m1, float *m2);
  1677.     Parameters    : m1 = 3x3 matrix to combine, this will be un-changed
  1678.           m2 = 3x3 matrix to combine into, will be product of m1 & m2;
  1679.     Usage    :
  1680.  
  1681.     float    m1[9],m2[9];
  1682.  
  1683.     MkIdnt2D(m2);
  1684.     Trnslt2D(100.0f,200.0f,m1);
  1685.     CmbnTrnsfrm2D(m1,m2);
  1686.     Scale2D(2.0f,4.0f,0.0f,0.0f,m1);
  1687.     CmbnTrnsfrm2D(m1,m2);
  1688.  
  1689.     will result in m2 containg a transformation which is a combination
  1690.     of translation and scaling, order of combination is significant, and
  1691.     may produce different result if applied in different order.
  1692.  
  1693.     Description : transformation matrices m1 and m2 are combined to form
  1694.     single transformation matrix in m2
  1695.  
  1696.  
  1697. XRflct2D
  1698. --------
  1699.  
  1700.     Include    : ops2d.h
  1701.     Declaration : void      far pascal XRflct2D(float *m);
  1702.     Parameters    : m = 3x3 matrix for reflection about x-axis
  1703.     Usage    :
  1704.  
  1705.     float    m[9];
  1706.     XRflct2D(m);
  1707.  
  1708.     will return in m, reflection about x-axis matrix
  1709.  
  1710.     Description : returns reflection about x-axis, in matrix m
  1711.  
  1712.  
  1713. YRflct2D
  1714. --------
  1715.  
  1716.     Include    : ops2d.h
  1717.     Declaration : void    far pascal YRflct2D(float *m);
  1718.     Parameters    : m = 3x3 matrix for reflection about y-axis
  1719.     Usage    :
  1720.  
  1721.     float    m[9];
  1722.     YRflct2D(m);
  1723.  
  1724.     will retun in m, reflection about y-axis, in matrix m
  1725.  
  1726.     Description : returns reflection about y-axis in matrix m
  1727.  
  1728.  
  1729. XShr2D
  1730. ------
  1731.  
  1732.     Include    : ops2d.h
  1733.     Declaration : void far pascal XShr2D(float a, float *m);
  1734.     Parameters    : a = shearing factor
  1735.           m = 3x3 result matrix
  1736.     Usage    :
  1737.  
  1738.     float    m[9];
  1739.     XShr2D(1.5f,m);
  1740.  
  1741.     will return in m, shearin matrix of factor 1.5, about x-axis
  1742.  
  1743.     Description : returns shearing about x-axis, matrix m
  1744.  
  1745.  
  1746. YShr2D
  1747. ------
  1748.  
  1749.     Include    : ops2d.h
  1750.     Declaration : void far pascal YShr2D(float b, float *m);
  1751.     Parameters    : b = shearing factor
  1752.           m = 3x3 result matrix
  1753.     Usage    :
  1754.  
  1755.     float    m[9];
  1756.     YShr2D(2.0f,m);
  1757.  
  1758.     will return in m, shearing matrix of factor 2.0f about y-axis
  1759.  
  1760.     Description : returns shearing about y-axis, matrix m
  1761.  
  1762.  
  1763. PlayNote
  1764. --------
  1765.  
  1766.     Include    : sound.h
  1767.     Declaration : void far pascal PlayNote(unsigned f,unsigned d);
  1768.     Parameters    : f = frequency of sound
  1769.           d = duration for this frequency f
  1770.     Usage    :
  1771.  
  1772.     PlayNote(500,10);
  1773.  
  1774.     will turn on speaker with frequency 500 for a duration of 10 units
  1775.  
  1776.     Description : turns on the speaker for duration d, with frequency f
  1777.  
  1778.  
  1779.  
  1780.         /*     Global Variables    */
  1781.  
  1782.  
  1783. extern    Byte    WrtMd;
  1784.     Current logical drawing mode, 0 = REPLACE, 1=AND, 2=OR, 3=XOR
  1785.  
  1786. extern    Byte    ClipTrue;
  1787.     variable to enable or disable clipping 0 = disable, 1= enable
  1788.  
  1789. extern    Byte    PxlClr;
  1790.     current drawing color, all video buffer updates done in this color
  1791.     except area fills
  1792.  
  1793. extern    Byte    LineStyle;
  1794.     line style bit pattern
  1795.  
  1796. extern    Byte    EllpsStyle;
  1797.     ellipse style bit pattern
  1798.  
  1799. extern    Byte    FllPttrn[8];
  1800.     8 byte array of fill pattern
  1801.  
  1802. extern    Byte    FllClr;
  1803.     color value for fills
  1804.  
  1805. extern    Byte    FllPttrnIndxX;
  1806.     starting x index within fill pattern
  1807.  
  1808. extern    Byte    FllPttrnIndxY;
  1809.     starting y index within fill pattern
  1810.  
  1811. extern    int    XMax;
  1812.     length of video buffer in x-direction in bytes, for the current mode
  1813.  
  1814. extern    int    YMax;
  1815.     length in y-direction
  1816.  
  1817. extern    int    XRes;
  1818.     resolution in x-direction for the active video mode
  1819.  
  1820.  
  1821. extern    int    YRes;
  1822.     resolution in y direction
  1823.  
  1824. extern    int    XOrgn;
  1825.     x co-ordinate of screen origin
  1826.  
  1827. extern    int    YOrgn;
  1828.     y co-ordinate of screen origin
  1829.  
  1830. extern    int    XLen;
  1831.     no. of bytes per line in vedio buffer for current mode
  1832.  
  1833. extern float  stvwx,stvwy;
  1834.     viewport device co-ordinates to world co-ordinates mapping factors
  1835.  
  1836.  
  1837. extern float  Wrldxy[8];
  1838.     world co-ordinates in first 4 varables
  1839.  
  1840. extern    Byte    _ZMode;
  1841.     equals 0 for 16 colour modes,  1 for 256 colour modes
  1842.  
  1843. #define Max_Points    400
  1844.     buffer size for polygon fill routines
  1845.  
  1846. #define Max_Fill_Buffer 2500
  1847.     buffer size for area fill routine
  1848.  
  1849. struct    VP
  1850. {
  1851.     int x1;
  1852.     int y1;
  1853.     int x2;
  1854.     int y2;
  1855. };
  1856.  
  1857.     Structure type for defining viewports
  1858.  
  1859. struct    RGBstruct
  1860. {
  1861.     Byte    Red;
  1862.     Byte    Green;
  1863.     Byte    Blue;
  1864. };
  1865.  
  1866.     Structure type for defining RGB colour DAC update variables
  1867.  
  1868. enum    SFntDrctnTp {left,right,up,down};
  1869.     direction type for text output
  1870.  
  1871. extern    Byte    BFntHSz;
  1872.     bit mapped-font logical horizontal size
  1873.  
  1874. extern    Byte    BFntVSz;
  1875.     bit mapped font logical vertical size
  1876.  
  1877. extern    Byte    BFntFClr;
  1878.     bit-mapped font drawing colour
  1879.  
  1880. extern    Word    BFntHght;
  1881.     height of one character in pixels
  1882.  
  1883. extern    Word    BFntWdth;
  1884.     width of one character in pixels
  1885.  
  1886. extern    float    SFntHght;
  1887.     stroked-font height in pixels
  1888.  
  1889. extern    float    SFntWdth;
  1890.     width of stroked fonts in pixels
  1891.