home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / TGE129D / TGESETUP.C < prev    next >
C/C++ Source or Header  |  1993-08-28  |  65KB  |  1,331 lines

  1. /*****************************************************************************
  2. *       The Graphics Engine version 1.29ßD                                   *
  3. *                                                                            *
  4. *       The Graphics Engine code and documentation are Copyright (c) 1993    *
  5. *       by Matthew Hildebrand.                                               *
  6. *                                                                            *
  7. *       Unauthorised usage or modification of any or all of The Graphics     *
  8. *       Engine is strictly prohibited.                                       *
  9. *****************************************************************************/
  10.  
  11. #include <alloc.h>
  12. #include <dos.h>
  13. #include <mem.h>
  14. #include <stdio.h>
  15. #include "tge.h"
  16.  
  17.  
  18. /* Guess what... this file must be compiled with the large or huge model. */
  19. #if !defined(__LARGE__) && !defined(__HUGE__) && !defined(M_I86LM)
  20.   #error This module must be compiled with the large or huge model.
  21. #endif
  22.  
  23. /* This copyright notice may not be removed and must remain intact */
  24. static char copyright[] = "The Graphics Engine 1.29ßD -- Copyright (c) 1993 by Matthew Hildebrand";
  25.  
  26. /* #define macros needed only for TGE.C */
  27. #define INADDR        (TGEsys->inAddr)
  28. #define OUTADDR        (TGEsys->outAddr)
  29. #define SCRADDR        (TGEsys->scrAddr)
  30. #define INSCREENWIDE    (TGEsys->inScreenWide)
  31. #define OUTSCREENWIDE    (TGEsys->outScreenWide)
  32. #define SCREEN        1
  33. #define MEMORY        2
  34.  
  35.  
  36.  
  37. /******
  38. ******* Function prototypes and global data
  39. ******/
  40.  
  41. extern void far TGE_deInitGraphics(void);
  42. extern void far TGE_setPaletteReg(unsigned palReg, unsigned char red, unsigned char blue, unsigned char green);
  43. extern void far TGE_getPaletteReg(unsigned palReg, unsigned char *red, unsigned char *blue, unsigned char *green);
  44. extern void far TGE_setBlockPalette(unsigned firstReg, unsigned numRegs, void far *data);
  45. extern void far TGE_getBlockPalette(unsigned firstReg, unsigned numRegs, void far *data);
  46. extern unsigned far TGE_colourCloseTo(unsigned char red, unsigned char green, unsigned    char blue);
  47. extern unsigned far TGE_colourCloseToX(unsigned char red, unsigned char green, unsigned    char blue, unsigned colourExclude);
  48. extern unsigned long far TGE_imageSize(int ulx, int uly, int lrx, int lry);
  49. extern unsigned long far TGE_imageSizeDim(unsigned wide, unsigned deep);
  50. extern void huge TGE_getImage(int ulx, int uly, int lrx, int lry, void far *image);
  51. extern void far TGE_getLine(int lineNum, int xOff, int lineLen, void far *buf);
  52. extern unsigned far TGE_getPixel_scr(int x, int y);
  53. extern unsigned far TGE_getPixel_mem(int x, int y);
  54. extern void huge TGE_putImage(int x, int y, void far *image);
  55. extern void huge TGE_putImageInv(int x, int y, void far *image);
  56. extern void far TGE_putLine(int lineNum, int xOff, int lineLen, void far *buf);
  57. extern void far TGE_putLineInv(int lineNum, int xOff, int lineLen, void far *buf);
  58. extern void far TGE_putPixel_scr_copy(int x, int y, unsigned colour);
  59. extern void far TGE_putPixel_scr_and (int x, int y, unsigned colour);
  60. extern void far TGE_putPixel_scr_not (int x, int y, unsigned colour);
  61. extern void far TGE_putPixel_scr_or  (int x, int y, unsigned colour);
  62. extern void far TGE_putPixel_scr_xor (int x, int y, unsigned colour);
  63. extern void far TGE_putPixel_mem_copy(int x, int y, unsigned colour);
  64. extern void far TGE_putPixel_mem_and (int x, int y, unsigned colour);
  65. extern void far TGE_putPixel_mem_not (int x, int y, unsigned colour);
  66. extern void far TGE_putPixel_mem_or  (int x, int y, unsigned colour);
  67. extern void far TGE_putPixel_mem_xor (int x, int y, unsigned colour);
  68. extern void far TGE_line(int x1, int y1, int x2, int y2, unsigned colour);
  69. extern void far TGE_horizLine(int y, int x1, int x2, unsigned colour);
  70. extern void far TGE_vertLine(int x, int y1, int y2, unsigned colour);
  71. extern void far TGE_drawRect(int ulx, int uly, int lrx, int lry, unsigned colour);
  72. extern void far TGE_filledRect(int ulx, int uly, int lrx, int lry, unsigned colour);
  73. extern void far TGE_clearGraphics(unsigned colour);
  74. extern void far TGE_ellipse(int xc, int yc, int wide, int deep, unsigned colour);
  75. extern void far TGE_filledEllipse(int xc, int yc, int wide, int deep, unsigned colour);
  76. extern void far TGE_circle(int x, int y, int radius, unsigned colour);
  77. extern void far TGE_filledCircle(int x, int y, int radius, unsigned colour);
  78. extern void far TGE_fillRegion(int x, int y, unsigned colour);
  79. static void* near forceOffset(void far *p);
  80. static void near setupInfo(struct GraphDrv far *grDrv);
  81. extern void near setInputFunctions(int memOrScreen);
  82. extern void near setOutputFunctions(int memOrScreen, int writeMode);
  83.  
  84. static int curOutputMode = TGE_COPY_PUT;
  85. static int curOutputDest = SCREEN;
  86. static void far *drvAddr = NULL;
  87. struct GraphDrv far *TGEsys = NULL;
  88.  
  89.  
  90. /*****
  91. ****** Routines to load a graphics driver from disk.
  92. *****/
  93.  
  94. /***
  95. **** Main loader function.
  96. ***/
  97. int TGE_loadGraphDriver(char *filename)
  98. {
  99.   struct GraphDrv far *grDrv = NULL;
  100.   FILE *inFile;
  101.   long fileLen;
  102.   char signature[4];
  103.  
  104.  
  105.   /* Outsmart smart linkers; force copyright string to be in EXE file */
  106.   copyright[0] = 'T';                /* dummy write */
  107.  
  108.  
  109.   /* Open the input file */
  110.   if ((inFile=fopen(filename,"rb")) == NULL)    /* open the file */
  111.     return (TGE_OPEN_ERR);
  112.  
  113.  
  114.   /* Get file size */
  115.   fseek(inFile, 0, SEEK_END);            /* seek to end of file */
  116.   fileLen = ftell(inFile);            /* get current position */
  117.   rewind(inFile);                /* seek to start of file */
  118.  
  119.  
  120.   /* Parse the file header */
  121.   if (!fread(signature, 1, 4, inFile))        /* read signature string */
  122.   {
  123.     fclose(inFile);
  124.     return (TGE_FORMAT_ERR);
  125.   }
  126.  
  127.   if (memcmp(signature, "TGE3", 4))           /* check signature string */
  128.   {
  129.     fclose(inFile);
  130.     return (TGE_FORMAT_ERR);
  131.   }
  132.  
  133.  
  134.   /* Allocate memory for the driver */
  135.   fileLen -= 4;                    /* remove signature size */
  136.   if (((void*)drvAddr=farmalloc(fileLen+15L)) == NULL)    /* grab some RAM */
  137.   {
  138.     fclose(inFile);
  139.     return (TGE_ALLOC_ERR);
  140.   }
  141.  
  142.   (void*)grDrv = forceOffset(drvAddr);        /* force to XXXX:0004 */
  143.  
  144.  
  145.   /* Read in the body of the driver */
  146.   if (fread(grDrv, 1, (unsigned)fileLen, inFile) != (unsigned)fileLen)
  147.   {
  148.     fclose(inFile);
  149.     farfree(drvAddr);
  150.     return (TGE_FILE_ERR);
  151.   }
  152.  
  153.  
  154.   /* Everything is loaded properly; now set up for program use */
  155.   TGEsys = grDrv;                /* set global variable */
  156.   setupInfo(grDrv);                /* setup function pointers */
  157.   fclose(inFile);                /* close input file */
  158.  
  159.   return (TGE_SUCCESS);                /* return success code */
  160. }
  161.  
  162.  
  163. /***
  164. **** Force a pointer to the form XXXX:0004.
  165. ***/
  166. static void* near forceOffset(void far *p)
  167. {
  168.   void huge *temp = (void huge*)p;
  169.  
  170.   if (FP_OFF(temp) == 4)
  171.     return ((void far*)temp);
  172.   else if (FP_OFF(temp) > 4)
  173.     return (MK_FP(FP_SEG(temp)+1, 4));
  174.   else
  175.     return (MK_FP(FP_SEG(temp), 4));
  176. }
  177.  
  178.  
  179. /***
  180. **** Set up function pointers once a driver has been loaded.
  181. ***/
  182. static void near setupInfo(struct GraphDrv far *grDrv)
  183. {
  184.   register unsigned seg = FP_SEG(grDrv);
  185.  
  186.   /* initGraphics must always be present */
  187.   (void*)grDrv->_initGraphics = MK_FP(seg, FP_OFF(grDrv->_initGraphics));
  188.  
  189.  
  190.   /* Set up non-I/O functions */
  191.   if (FP_OFF(grDrv->_deInitGraphics))        /* deInitGraphics */
  192.     (void*)grDrv->_deInitGraphics = MK_FP(seg, FP_OFF(grDrv->_deInitGraphics));
  193.   else
  194.     grDrv->_deInitGraphics = TGE_deInitGraphics;
  195.  
  196.   if (FP_OFF(grDrv->_setPaletteReg))        /* setPaletteReg */
  197.     (void*)grDrv->_setPaletteReg = MK_FP(seg, FP_OFF(grDrv->_setPaletteReg));
  198.   else
  199.     grDrv->_setPaletteReg = TGE_setPaletteReg;
  200.  
  201.   if (FP_OFF(grDrv->_getPaletteReg))        /* getPaletteReg */
  202.     (void*)grDrv->_getPaletteReg = MK_FP(seg, FP_OFF(grDrv->_getPaletteReg));
  203.   else
  204.     grDrv->_getPaletteReg = TGE_getPaletteReg;
  205.  
  206.   if (FP_OFF(grDrv->_setBlockPalette))        /* setBlockPalette */
  207.     (void*)grDrv->_setBlockPalette = MK_FP(seg, FP_OFF(grDrv->_setBlockPalette));
  208.   else
  209.     grDrv->_setBlockPalette = TGE_setBlockPalette;
  210.  
  211.   if (FP_OFF(grDrv->_getBlockPalette))        /* getBlockPalette */
  212.     (void*)grDrv->_getBlockPalette = MK_FP(seg, FP_OFF(grDrv->_getBlockPalette));
  213.   else
  214.     grDrv->_getBlockPalette = TGE_getBlockPalette;
  215.  
  216.   if (FP_OFF(grDrv->_colourCloseTo))        /* colourCloseTo */
  217.     (void*)grDrv->_colourCloseTo = MK_FP(seg, FP_OFF(grDrv->_colourCloseTo));
  218.   else
  219.     grDrv->_colourCloseTo = TGE_colourCloseTo;
  220.  
  221.   if (FP_OFF(grDrv->_colourCloseToX))        /* colourCloseToX */
  222.     (void*)grDrv->_colourCloseToX = MK_FP(seg, FP_OFF(grDrv->_colourCloseToX));
  223.   else
  224.     grDrv->_colourCloseToX = TGE_colourCloseToX;
  225.  
  226.   if (FP_OFF(grDrv->_imageSize))        /* imageSize */
  227.     (void*)grDrv->_imageSize = MK_FP(seg, FP_OFF(grDrv->_imageSize));
  228.   else
  229.     grDrv->_imageSize = TGE_imageSize;
  230.  
  231.   if (FP_OFF(grDrv->_imageSizeDim))        /* imageSizeDim */
  232.     (void*)grDrv->_imageSizeDim = MK_FP(seg, FP_OFF(grDrv->_imageSizeDim));
  233.   else
  234.     grDrv->_imageSizeDim = TGE_imageSizeDim;
  235.  
  236.  
  237.   /* Set up input functions */
  238.   if (FP_OFF(grDrv->_getImage_scr))        /* getImage_scr */
  239.     (void*)grDrv->_getImage_scr = MK_FP(seg, FP_OFF(grDrv->_getImage_scr));
  240.   else
  241.     grDrv->_getImage_scr = TGE_getImage;
  242.  
  243.   if (FP_OFF(grDrv->_getImage_mem))        /* getImage_mem */
  244.     (void*)grDrv->_getImage_mem = MK_FP(seg, FP_OFF(grDrv->_getImage_mem));
  245.   else
  246.     grDrv->_getImage_mem = TGE_getImage;
  247.  
  248.   if (FP_OFF(grDrv->_getLine_scr))        /* getLine_scr */
  249.     (void*)grDrv->_getLine_scr = MK_FP(seg, FP_OFF(grDrv->_getLine_scr));
  250.   else
  251.     grDrv->_getLine_scr = TGE_getLine;
  252.  
  253.   if (FP_OFF(grDrv->_getLine_mem))        /* getLine_mem */
  254.     (void*)grDrv->_getLine_mem = MK_FP(seg, FP_OFF(grDrv->_getLine_mem));
  255.   else
  256.     grDrv->_getLine_mem = TGE_getLine;
  257.  
  258.   if (FP_OFF(grDrv->_getPixel_scr))        /* getPixel_scr */
  259.     (void*)grDrv->_getPixel_scr = MK_FP(seg, FP_OFF(grDrv->_getPixel_scr));
  260.   else
  261.     grDrv->_getPixel_scr = TGE_getPixel_scr;
  262.  
  263.   if (FP_OFF(grDrv->_getPixel_mem))        /* getPixel_mem */
  264.     (void*)grDrv->_getPixel_mem = MK_FP(seg, FP_OFF(grDrv->_getPixel_mem));
  265.   else
  266.     grDrv->_getPixel_mem = TGE_getPixel_mem;
  267.  
  268.  
  269.   /* Set up output functions */
  270.   if (FP_OFF(grDrv->_putImage_scr_copy))    /* putImage_scr_copy */
  271.     (void*)grDrv->_putImage_scr_copy = MK_FP(seg, FP_OFF(grDrv->_putImage_scr_copy));
  272.   else
  273.     grDrv->_putImage_scr_copy = TGE_putImage;
  274.   if (FP_OFF(grDrv->_putImage_scr_and))        /* putImage_scr_and */
  275.     (void*)grDrv->_putImage_scr_and = MK_FP(seg, FP_OFF(grDrv->_putImage_scr_and));
  276.   else
  277.     grDrv->_putImage_scr_and = TGE_putImage;
  278.   if (FP_OFF(grDrv->_putImage_scr_not))        /* putImage_scr_not */
  279.     (void*)grDrv->_putImage_scr_not = MK_FP(seg, FP_OFF(grDrv->_putImage_scr_not));
  280.   else
  281.     grDrv->_putImage_scr_not = TGE_putImage;
  282.   if (FP_OFF(grDrv->_putImage_scr_or))        /* putImage_scr_or */
  283.     (void*)grDrv->_putImage_scr_or = MK_FP(seg, FP_OFF(grDrv->_putImage_scr_or));
  284.   else
  285.     grDrv->_putImage_scr_or = TGE_putImage;
  286.   if (FP_OFF(grDrv->_putImage_scr_xor))        /* putImage_scr_xor */
  287.     (void*)grDrv->_putImage_scr_xor = MK_FP(seg, FP_OFF(grDrv->_putImage_scr_xor));
  288.   else
  289.     grDrv->_putImage_scr_xor = TGE_putImage;
  290.   if (FP_OFF(grDrv->_putImage_mem_copy))    /* putImage_mem_copy */
  291.     (void*)grDrv->_putImage_mem_copy = MK_FP(seg, FP_OFF(grDrv->_putImage_mem_copy));
  292.   else
  293.     grDrv->_putImage_mem_copy = TGE_putImage;
  294.   if (FP_OFF(grDrv->_putImage_mem_and))        /* putImage_mem_and */
  295.     (void*)grDrv->_putImage_mem_and = MK_FP(seg, FP_OFF(grDrv->_putImage_mem_and));
  296.   else
  297.     grDrv->_putImage_mem_and = TGE_putImage;
  298.   if (FP_OFF(grDrv->_putImage_mem_not))        /* putImage_mem_not */
  299.     (void*)grDrv->_putImage_mem_not = MK_FP(seg, FP_OFF(grDrv->_putImage_mem_not));
  300.   else
  301.     grDrv->_putImage_mem_not = TGE_putImage;
  302.   if (FP_OFF(grDrv->_putImage_mem_or))        /* putImage_mem_or */
  303.     (void*)grDrv->_putImage_mem_or = MK_FP(seg, FP_OFF(grDrv->_putImage_mem_or));
  304.   else
  305.     grDrv->_putImage_mem_or = TGE_putImage;
  306.   if (FP_OFF(grDrv->_putImage_mem_xor))        /* putImage_mem_xor */
  307.     (void*)grDrv->_putImage_mem_xor = MK_FP(seg, FP_OFF(grDrv->_putImage_mem_xor));
  308.   else
  309.     grDrv->_putImage_mem_xor = TGE_putImage;
  310.  
  311.   if (FP_OFF(grDrv->_putImageInv_scr_copy))    /* putImageInv_scr_copy */
  312.     (void*)grDrv->_putImageInv_scr_copy = MK_FP(seg, FP_OFF(grDrv->_putImageInv_scr_copy));
  313.   else
  314.     grDrv->_putImageInv_scr_copy = TGE_putImageInv;
  315.   if (FP_OFF(grDrv->_putImageInv_scr_and))    /* putImageInv_scr_and */
  316.     (void*)grDrv->_putImageInv_scr_and = MK_FP(seg, FP_OFF(grDrv->_putImageInv_scr_and));
  317.   else
  318.     grDrv->_putImageInv_scr_and = TGE_putImageInv;
  319.   if (FP_OFF(grDrv->_putImageInv_scr_not))    /* putImageInv_scr_not */
  320.     (void*)grDrv->_putImageInv_scr_not = MK_FP(seg, FP_OFF(grDrv->_putImageInv_scr_not));
  321.   else
  322.     grDrv->_putImageInv_scr_not = TGE_putImageInv;
  323.   if (FP_OFF(grDrv->_putImageInv_scr_or))    /* putImageInv_scr_or */
  324.     (void*)grDrv->_putImageInv_scr_or = MK_FP(seg, FP_OFF(grDrv->_putImageInv_scr_or));
  325.   else
  326.     grDrv->_putImageInv_scr_or = TGE_putImageInv;
  327.   if (FP_OFF(grDrv->_putImageInv_scr_xor))    /* putImageInv_scr_xor */
  328.     (void*)grDrv->_putImageInv_scr_xor = MK_FP(seg, FP_OFF(grDrv->_putImageInv_scr_xor));
  329.   else
  330.     grDrv->_putImageInv_scr_xor = TGE_putImageInv;
  331.   if (FP_OFF(grDrv->_putImageInv_mem_copy))    /* putImageInv_mem_copy */
  332.     (void*)grDrv->_putImageInv_mem_copy = MK_FP(seg, FP_OFF(grDrv->_putImageInv_mem_copy));
  333.   else
  334.     grDrv->_putImageInv_mem_copy = TGE_putImageInv;
  335.   if (FP_OFF(grDrv->_putImageInv_mem_and))    /* putImageInv_mem_and */
  336.     (void*)grDrv->_putImageInv_mem_and = MK_FP(seg, FP_OFF(grDrv->_putImageInv_mem_and));
  337.   else
  338.     grDrv->_putImageInv_mem_and = TGE_putImageInv;
  339.   if (FP_OFF(grDrv->_putImageInv_mem_not))    /* putImageInv_mem_not */
  340.     (void*)grDrv->_putImageInv_mem_not = MK_FP(seg, FP_OFF(grDrv->_putImageInv_mem_not));
  341.   else
  342.     grDrv->_putImageInv_mem_not = TGE_putImageInv;
  343.   if (FP_OFF(grDrv->_putImageInv_mem_or))    /* putImageInv_mem_or */
  344.     (void*)grDrv->_putImageInv_mem_or = MK_FP(seg, FP_OFF(grDrv->_putImageInv_mem_or));
  345.   else
  346.     grDrv->_putImageInv_mem_or = TGE_putImageInv;
  347.   if (FP_OFF(grDrv->_putImageInv_mem_xor))    /* putImageInv_mem_xor */
  348.     (void*)grDrv->_putImageInv_mem_xor = MK_FP(seg, FP_OFF(grDrv->_putImageInv_mem_xor));
  349.   else
  350.     grDrv->_putImageInv_mem_xor = TGE_putImageInv;
  351.  
  352.   if (FP_OFF(grDrv->_putLine_scr_copy))        /* putLine_scr_copy */
  353.     (void*)grDrv->_putLine_scr_copy = MK_FP(seg, FP_OFF(grDrv->_putLine_scr_copy));
  354.   else
  355.     grDrv->_putLine_scr_copy = TGE_putLine;
  356.   if (FP_OFF(grDrv->_putLine_scr_and))        /* putLine_scr_and */
  357.     (void*)grDrv->_putLine_scr_and = MK_FP(seg, FP_OFF(grDrv->_putLine_scr_and));
  358.   else
  359.     grDrv->_putLine_scr_and = TGE_putLine;
  360.   if (FP_OFF(grDrv->_putLine_scr_not))        /* putLine_scr_not */
  361.     (void*)grDrv->_putLine_scr_not = MK_FP(seg, FP_OFF(grDrv->_putLine_scr_not));
  362.   else
  363.     grDrv->_putLine_scr_not = TGE_putLine;
  364.   if (FP_OFF(grDrv->_putLine_scr_or))        /* putLine_scr_or */
  365.     (void*)grDrv->_putLine_scr_or = MK_FP(seg, FP_OFF(grDrv->_putLine_scr_or));
  366.   else
  367.     grDrv->_putLine_scr_or = TGE_putLine;
  368.   if (FP_OFF(grDrv->_putLine_scr_xor))        /* putLine_scr_xor */
  369.     (void*)grDrv->_putLine_scr_xor = MK_FP(seg, FP_OFF(grDrv->_putLine_scr_xor));
  370.   else
  371.     grDrv->_putLine_scr_xor = TGE_putLine;
  372.   if (FP_OFF(grDrv->_putLine_mem_copy))        /* putLine_mem_copy */
  373.     (void*)grDrv->_putLine_mem_copy = MK_FP(seg, FP_OFF(grDrv->_putLine_mem_copy));
  374.   else
  375.     grDrv->_putLine_mem_copy = TGE_putLine;
  376.   if (FP_OFF(grDrv->_putLine_mem_and))        /* putLine_mem_and */
  377.     (void*)grDrv->_putLine_mem_and = MK_FP(seg, FP_OFF(grDrv->_putLine_mem_and));
  378.   else
  379.     grDrv->_putLine_mem_and = TGE_putLine;
  380.   if (FP_OFF(grDrv->_putLine_mem_not))        /* putLine_mem_not */
  381.     (void*)grDrv->_putLine_mem_not = MK_FP(seg, FP_OFF(grDrv->_putLine_mem_not));
  382.   else
  383.     grDrv->_putLine_mem_not = TGE_putLine;
  384.   if (FP_OFF(grDrv->_putLine_mem_or))        /* putLine_mem_or */
  385.     (void*)grDrv->_putLine_mem_or = MK_FP(seg, FP_OFF(grDrv->_putLine_mem_or));
  386.   else
  387.     grDrv->_putLine_mem_or = TGE_putLine;
  388.   if (FP_OFF(grDrv->_putLine_mem_xor))        /* putLine_mem_xor */
  389.     (void*)grDrv->_putLine_mem_xor = MK_FP(seg, FP_OFF(grDrv->_putLine_mem_xor));
  390.   else
  391.     grDrv->_putLine_mem_xor = TGE_putLine;
  392.  
  393.   if (FP_OFF(grDrv->_putLineInv_scr_copy))    /* putLineInv_scr_copy */
  394.     (void*)grDrv->_putLineInv_scr_copy = MK_FP(seg, FP_OFF(grDrv->_putLineInv_scr_copy));
  395.   else
  396.     grDrv->_putLineInv_scr_copy = TGE_putLineInv;
  397.   if (FP_OFF(grDrv->_putLineInv_scr_and))    /* putLineInv_scr_and */
  398.     (void*)grDrv->_putLineInv_scr_and = MK_FP(seg, FP_OFF(grDrv->_putLineInv_scr_and));
  399.   else
  400.     grDrv->_putLineInv_scr_and = TGE_putLineInv;
  401.   if (FP_OFF(grDrv->_putLineInv_scr_not))    /* putLineInv_scr_not */
  402.     (void*)grDrv->_putLineInv_scr_not = MK_FP(seg, FP_OFF(grDrv->_putLineInv_scr_not));
  403.   else
  404.     grDrv->_putLineInv_scr_not = TGE_putLineInv;
  405.   if (FP_OFF(grDrv->_putLineInv_scr_or))    /* putLineInv_scr_or */
  406.     (void*)grDrv->_putLineInv_scr_or = MK_FP(seg, FP_OFF(grDrv->_putLineInv_scr_or));
  407.   else
  408.     grDrv->_putLineInv_scr_or = TGE_putLineInv;
  409.   if (FP_OFF(grDrv->_putLineInv_scr_xor))    /* putLineInv_scr_xor */
  410.     (void*)grDrv->_putLineInv_scr_xor = MK_FP(seg, FP_OFF(grDrv->_putLineInv_scr_xor));
  411.   else
  412.     grDrv->_putLineInv_scr_xor = TGE_putLineInv;
  413.   if (FP_OFF(grDrv->_putLineInv_mem_copy))    /* putLineInv_mem_copy */
  414.     (void*)grDrv->_putLineInv_mem_copy = MK_FP(seg, FP_OFF(grDrv->_putLineInv_mem_copy));
  415.   else
  416.     grDrv->_putLineInv_mem_copy = TGE_putLineInv;
  417.   if (FP_OFF(grDrv->_putLineInv_mem_and))    /* putLineInv_mem_and */
  418.     (void*)grDrv->_putLineInv_mem_and = MK_FP(seg, FP_OFF(grDrv->_putLineInv_mem_and));
  419.   else
  420.     grDrv->_putLineInv_mem_and = TGE_putLineInv;
  421.   if (FP_OFF(grDrv->_putLineInv_mem_not))    /* putLineInv_mem_not */
  422.     (void*)grDrv->_putLineInv_mem_not = MK_FP(seg, FP_OFF(grDrv->_putLineInv_mem_not));
  423.   else
  424.     grDrv->_putLineInv_mem_not = TGE_putLineInv;
  425.   if (FP_OFF(grDrv->_putLineInv_mem_or))    /* putLineInv_mem_or */
  426.     (void*)grDrv->_putLineInv_mem_or = MK_FP(seg, FP_OFF(grDrv->_putLineInv_mem_or));
  427.   else
  428.     grDrv->_putLineInv_mem_or = TGE_putLineInv;
  429.   if (FP_OFF(grDrv->_putLineInv_mem_xor))    /* putLineInv_mem_xor */
  430.     (void*)grDrv->_putLineInv_mem_xor = MK_FP(seg, FP_OFF(grDrv->_putLineInv_mem_xor));
  431.   else
  432.     grDrv->_putLineInv_mem_xor = TGE_putLineInv;
  433.  
  434.   if (FP_OFF(grDrv->_putPixel_scr_copy))    /* putPixel_scr_copy */
  435.     (void*)grDrv->_putPixel_scr_copy = MK_FP(seg, FP_OFF(grDrv->_putPixel_scr_copy));
  436.   else
  437.     grDrv->_putPixel_scr_copy = TGE_putPixel_scr_copy;
  438.   if (FP_OFF(grDrv->_putPixel_scr_and))        /* putPixel_scr_and */
  439.     (void*)grDrv->_putPixel_scr_and = MK_FP(seg, FP_OFF(grDrv->_putPixel_scr_and));
  440.   else
  441.     grDrv->_putPixel_scr_and = TGE_putPixel_scr_and;
  442.   if (FP_OFF(grDrv->_putPixel_scr_not))        /* putPixel_scr_not */
  443.     (void*)grDrv->_putPixel_scr_not = MK_FP(seg, FP_OFF(grDrv->_putPixel_scr_not));
  444.   else
  445.     grDrv->_putPixel_scr_not = TGE_putPixel_scr_not;
  446.   if (FP_OFF(grDrv->_putPixel_scr_or))        /* putPixel_scr_or */
  447.     (void*)grDrv->_putPixel_scr_or = MK_FP(seg, FP_OFF(grDrv->_putPixel_scr_or));
  448.   else
  449.     grDrv->_putPixel_scr_or = TGE_putPixel_scr_or;
  450.   if (FP_OFF(grDrv->_putPixel_scr_xor))        /* putPixel_scr_xor */
  451.     (void*)grDrv->_putPixel_scr_xor = MK_FP(seg, FP_OFF(grDrv->_putPixel_scr_xor));
  452.   else
  453.     grDrv->_putPixel_scr_xor = TGE_putPixel_scr_xor;
  454.   if (FP_OFF(grDrv->_putPixel_mem_copy))    /* putPixel_mem_copy */
  455.     (void*)grDrv->_putPixel_mem_copy = MK_FP(seg, FP_OFF(grDrv->_putPixel_mem_copy));
  456.   else
  457.     grDrv->_putPixel_mem_copy = TGE_putPixel_mem_copy;
  458.   if (FP_OFF(grDrv->_putPixel_mem_and))        /* putPixel_mem_and */
  459.     (void*)grDrv->_putPixel_mem_and = MK_FP(seg, FP_OFF(grDrv->_putPixel_mem_and));
  460.   else
  461.     grDrv->_putPixel_mem_and = TGE_putPixel_mem_and;
  462.   if (FP_OFF(grDrv->_putPixel_mem_not))        /* putPixel_mem_not */
  463.     (void*)grDrv->_putPixel_mem_not = MK_FP(seg, FP_OFF(grDrv->_putPixel_mem_not));
  464.   else
  465.     grDrv->_putPixel_mem_not = TGE_putPixel_mem_not;
  466.   if (FP_OFF(grDrv->_putPixel_mem_or))        /* putPixel_mem_or */
  467.     (void*)grDrv->_putPixel_mem_or = MK_FP(seg, FP_OFF(grDrv->_putPixel_mem_or));
  468.   else
  469.     grDrv->_putPixel_mem_or = TGE_putPixel_mem_or;
  470.   if (FP_OFF(grDrv->_putPixel_mem_xor))        /* putPixel_mem_xor */
  471.     (void*)grDrv->_putPixel_mem_xor = MK_FP(seg, FP_OFF(grDrv->_putPixel_mem_xor));
  472.   else
  473.     grDrv->_putPixel_mem_xor = TGE_putPixel_mem_xor;
  474.  
  475.   if (FP_OFF(grDrv->_line_scr_copy))        /* line_scr_copy */
  476.     (void*)grDrv->_line_scr_copy = MK_FP(seg, FP_OFF(grDrv->_line_scr_copy));
  477.   else
  478.     grDrv->_line_scr_copy = TGE_line;
  479.   if (FP_OFF(grDrv->_line_scr_and))        /* line_scr_and */
  480.     (void*)grDrv->_line_scr_and = MK_FP(seg, FP_OFF(grDrv->_line_scr_and));
  481.   else
  482.     grDrv->_line_scr_and = TGE_line;
  483.   if (FP_OFF(grDrv->_line_scr_not))        /* line_scr_not */
  484.     (void*)grDrv->_line_scr_not = MK_FP(seg, FP_OFF(grDrv->_line_scr_not));
  485.   else
  486.     grDrv->_line_scr_not = TGE_line;
  487.   if (FP_OFF(grDrv->_line_scr_or))        /* line_scr_or */
  488.     (void*)grDrv->_line_scr_or = MK_FP(seg, FP_OFF(grDrv->_line_scr_or));
  489.   else
  490.     grDrv->_line_scr_or = TGE_line;
  491.   if (FP_OFF(grDrv->_line_scr_xor))        /* line_scr_xor */
  492.     (void*)grDrv->_line_scr_xor = MK_FP(seg, FP_OFF(grDrv->_line_scr_xor));
  493.   else
  494.     grDrv->_line_scr_xor = TGE_line;
  495.   if (FP_OFF(grDrv->_line_mem_copy))        /* line_mem_copy */
  496.     (void*)grDrv->_line_mem_copy = MK_FP(seg, FP_OFF(grDrv->_line_mem_copy));
  497.   else
  498.     grDrv->_line_mem_copy = TGE_line;
  499.   if (FP_OFF(grDrv->_line_mem_and))        /* line_mem_and */
  500.     (void*)grDrv->_line_mem_and = MK_FP(seg, FP_OFF(grDrv->_line_mem_and));
  501.   else
  502.     grDrv->_line_mem_and = TGE_line;
  503.   if (FP_OFF(grDrv->_line_mem_not))        /* line_mem_not */
  504.     (void*)grDrv->_line_mem_not = MK_FP(seg, FP_OFF(grDrv->_line_mem_not));
  505.   else
  506.     grDrv->_line_mem_not = TGE_line;
  507.   if (FP_OFF(grDrv->_line_mem_or))        /* line_mem_or */
  508.     (void*)grDrv->_line_mem_or = MK_FP(seg, FP_OFF(grDrv->_line_mem_or));
  509.   else
  510.     grDrv->_line_mem_or = TGE_line;
  511.   if (FP_OFF(grDrv->_line_mem_xor))        /* line_mem_xor */
  512.     (void*)grDrv->_line_mem_xor = MK_FP(seg, FP_OFF(grDrv->_line_mem_xor));
  513.   else
  514.     grDrv->_line_mem_xor = TGE_line;
  515.  
  516.   if (FP_OFF(grDrv->_horizLine_scr_copy))    /* horizLine_scr_copy */
  517.     (void*)grDrv->_horizLine_scr_copy = MK_FP(seg, FP_OFF(grDrv->_horizLine_scr_copy));
  518.   else
  519.     grDrv->_horizLine_scr_copy = TGE_horizLine;
  520.   if (FP_OFF(grDrv->_horizLine_scr_and))    /* horizLine_scr_and */
  521.     (void*)grDrv->_horizLine_scr_and = MK_FP(seg, FP_OFF(grDrv->_horizLine_scr_and));
  522.   else
  523.     grDrv->_horizLine_scr_and = TGE_horizLine;
  524.   if (FP_OFF(grDrv->_horizLine_scr_not))    /* horizLine_scr_not */
  525.     (void*)grDrv->_horizLine_scr_not = MK_FP(seg, FP_OFF(grDrv->_horizLine_scr_not));
  526.   else
  527.     grDrv->_horizLine_scr_not = TGE_horizLine;
  528.   if (FP_OFF(grDrv->_horizLine_scr_or))        /* horizLine_scr_or */
  529.     (void*)grDrv->_horizLine_scr_or = MK_FP(seg, FP_OFF(grDrv->_horizLine_scr_or));
  530.   else
  531.     grDrv->_horizLine_scr_or = TGE_horizLine;
  532.   if (FP_OFF(grDrv->_horizLine_scr_xor))    /* horizLine_scr_xor */
  533.     (void*)grDrv->_horizLine_scr_xor = MK_FP(seg, FP_OFF(grDrv->_horizLine_scr_xor));
  534.   else
  535.     grDrv->_horizLine_scr_xor = TGE_horizLine;
  536.   if (FP_OFF(grDrv->_horizLine_mem_copy))    /* horizLine_mem_copy */
  537.     (void*)grDrv->_horizLine_mem_copy = MK_FP(seg, FP_OFF(grDrv->_horizLine_mem_copy));
  538.   else
  539.     grDrv->_horizLine_mem_copy = TGE_horizLine;
  540.   if (FP_OFF(grDrv->_horizLine_mem_and))    /* horizLine_mem_and */
  541.     (void*)grDrv->_horizLine_mem_and = MK_FP(seg, FP_OFF(grDrv->_horizLine_mem_and));
  542.   else
  543.     grDrv->_horizLine_mem_and = TGE_horizLine;
  544.   if (FP_OFF(grDrv->_horizLine_mem_not))    /* horizLine_mem_not */
  545.     (void*)grDrv->_horizLine_mem_not = MK_FP(seg, FP_OFF(grDrv->_horizLine_mem_not));
  546.   else
  547.     grDrv->_horizLine_mem_not = TGE_horizLine;
  548.   if (FP_OFF(grDrv->_horizLine_mem_or))        /* horizLine_mem_or */
  549.     (void*)grDrv->_horizLine_mem_or = MK_FP(seg, FP_OFF(grDrv->_horizLine_mem_or));
  550.   else
  551.     grDrv->_horizLine_mem_or = TGE_horizLine;
  552.   if (FP_OFF(grDrv->_horizLine_mem_xor))    /* horizLine_mem_xor */
  553.     (void*)grDrv->_horizLine_mem_xor = MK_FP(seg, FP_OFF(grDrv->_horizLine_mem_xor));
  554.   else
  555.     grDrv->_horizLine_mem_xor = TGE_horizLine;
  556.  
  557.   if (FP_OFF(grDrv->_vertLine_scr_copy))    /* vertLine_scr_copy */
  558.     (void*)grDrv->_vertLine_scr_copy = MK_FP(seg, FP_OFF(grDrv->_vertLine_scr_copy));
  559.   else
  560.     grDrv->_vertLine_scr_copy = TGE_vertLine;
  561.   if (FP_OFF(grDrv->_vertLine_scr_and))        /* vertLine_scr_and */
  562.     (void*)grDrv->_vertLine_scr_and = MK_FP(seg, FP_OFF(grDrv->_vertLine_scr_and));
  563.   else
  564.     grDrv->_vertLine_scr_and = TGE_vertLine;
  565.   if (FP_OFF(grDrv->_vertLine_scr_not))        /* vertLine_scr_not */
  566.     (void*)grDrv->_vertLine_scr_not = MK_FP(seg, FP_OFF(grDrv->_vertLine_scr_not));
  567.   else
  568.     grDrv->_vertLine_scr_not = TGE_vertLine;
  569.   if (FP_OFF(grDrv->_vertLine_scr_or))        /* vertLine_scr_or */
  570.     (void*)grDrv->_vertLine_scr_or = MK_FP(seg, FP_OFF(grDrv->_vertLine_scr_or));
  571.   else
  572.     grDrv->_vertLine_scr_or = TGE_vertLine;
  573.   if (FP_OFF(grDrv->_vertLine_scr_xor))        /* vertLine_scr_xor */
  574.     (void*)grDrv->_vertLine_scr_xor = MK_FP(seg, FP_OFF(grDrv->_vertLine_scr_xor));
  575.   else
  576.     grDrv->_vertLine_scr_xor = TGE_vertLine;
  577.   if (FP_OFF(grDrv->_vertLine_mem_copy))    /* vertLine_mem_copy */
  578.     (void*)grDrv->_vertLine_mem_copy = MK_FP(seg, FP_OFF(grDrv->_vertLine_mem_copy));
  579.   else
  580.     grDrv->_vertLine_mem_copy = TGE_vertLine;
  581.   if (FP_OFF(grDrv->_vertLine_mem_and))        /* vertLine_mem_and */
  582.     (void*)grDrv->_vertLine_mem_and = MK_FP(seg, FP_OFF(grDrv->_vertLine_mem_and));
  583.   else
  584.     grDrv->_vertLine_mem_and = TGE_vertLine;
  585.   if (FP_OFF(grDrv->_vertLine_mem_not))        /* vertLine_mem_not */
  586.     (void*)grDrv->_vertLine_mem_not = MK_FP(seg, FP_OFF(grDrv->_vertLine_mem_not));
  587.   else
  588.     grDrv->_vertLine_mem_not = TGE_vertLine;
  589.   if (FP_OFF(grDrv->_vertLine_mem_or))        /* vertLine_mem_or */
  590.     (void*)grDrv->_vertLine_mem_or = MK_FP(seg, FP_OFF(grDrv->_vertLine_mem_or));
  591.   else
  592.     grDrv->_vertLine_mem_or = TGE_vertLine;
  593.   if (FP_OFF(grDrv->_vertLine_mem_xor))        /* vertLine_mem_xor */
  594.     (void*)grDrv->_vertLine_mem_xor = MK_FP(seg, FP_OFF(grDrv->_vertLine_mem_xor));
  595.   else
  596.     grDrv->_vertLine_mem_xor = TGE_vertLine;
  597.  
  598.   if (FP_OFF(grDrv->_drawRect_scr_copy))    /* drawRect_scr_copy */
  599.     (void*)grDrv->_drawRect_scr_copy = MK_FP(seg, FP_OFF(grDrv->_drawRect_scr_copy));
  600.   else
  601.     grDrv->_drawRect_scr_copy = TGE_drawRect;
  602.   if (FP_OFF(grDrv->_drawRect_scr_and))        /* drawRect_scr_and */
  603.     (void*)grDrv->_drawRect_scr_and = MK_FP(seg, FP_OFF(grDrv->_drawRect_scr_and));
  604.   else
  605.     grDrv->_drawRect_scr_and = TGE_drawRect;
  606.   if (FP_OFF(grDrv->_drawRect_scr_not))        /* drawRect_scr_not */
  607.     (void*)grDrv->_drawRect_scr_not = MK_FP(seg, FP_OFF(grDrv->_drawRect_scr_not));
  608.   else
  609.     grDrv->_drawRect_scr_not = TGE_drawRect;
  610.   if (FP_OFF(grDrv->_drawRect_scr_or))        /* drawRect_scr_or */
  611.     (void*)grDrv->_drawRect_scr_or = MK_FP(seg, FP_OFF(grDrv->_drawRect_scr_or));
  612.   else
  613.     grDrv->_drawRect_scr_or = TGE_drawRect;
  614.   if (FP_OFF(grDrv->_drawRect_scr_xor))        /* drawRect_scr_xor */
  615.     (void*)grDrv->_drawRect_scr_xor = MK_FP(seg, FP_OFF(grDrv->_drawRect_scr_xor));
  616.   else
  617.     grDrv->_drawRect_scr_xor = TGE_drawRect;
  618.   if (FP_OFF(grDrv->_drawRect_mem_copy))    /* drawRect_mem_copy */
  619.     (void*)grDrv->_drawRect_mem_copy = MK_FP(seg, FP_OFF(grDrv->_drawRect_mem_copy));
  620.   else
  621.     grDrv->_drawRect_mem_copy = TGE_drawRect;
  622.   if (FP_OFF(grDrv->_drawRect_mem_and))        /* drawRect_mem_and */
  623.     (void*)grDrv->_drawRect_mem_and = MK_FP(seg, FP_OFF(grDrv->_drawRect_mem_and));
  624.   else
  625.     grDrv->_drawRect_mem_and = TGE_drawRect;
  626.   if (FP_OFF(grDrv->_drawRect_mem_not))        /* drawRect_mem_not */
  627.     (void*)grDrv->_drawRect_mem_not = MK_FP(seg, FP_OFF(grDrv->_drawRect_mem_not));
  628.   else
  629.     grDrv->_drawRect_mem_not = TGE_drawRect;
  630.   if (FP_OFF(grDrv->_drawRect_mem_or))        /* drawRect_mem_or */
  631.     (void*)grDrv->_drawRect_mem_or = MK_FP(seg, FP_OFF(grDrv->_drawRect_mem_or));
  632.   else
  633.     grDrv->_drawRect_mem_or = TGE_drawRect;
  634.   if (FP_OFF(grDrv->_drawRect_mem_xor))        /* drawRect_mem_xor */
  635.     (void*)grDrv->_drawRect_mem_xor = MK_FP(seg, FP_OFF(grDrv->_drawRect_mem_xor));
  636.   else
  637.     grDrv->_drawRect_mem_xor = TGE_drawRect;
  638.  
  639.   if (FP_OFF(grDrv->_filledRect_scr_copy))    /* filledRect_scr_copy */
  640.     (void*)grDrv->_filledRect_scr_copy = MK_FP(seg, FP_OFF(grDrv->_filledRect_scr_copy));
  641.   else
  642.     grDrv->_filledRect_scr_copy = TGE_filledRect;
  643.   if (FP_OFF(grDrv->_filledRect_scr_and))    /* filledRect_scr_and */
  644.     (void*)grDrv->_filledRect_scr_and = MK_FP(seg, FP_OFF(grDrv->_filledRect_scr_and));
  645.   else
  646.     grDrv->_filledRect_scr_and = TGE_filledRect;
  647.   if (FP_OFF(grDrv->_filledRect_scr_not))    /* filledRect_scr_not */
  648.     (void*)grDrv->_filledRect_scr_not = MK_FP(seg, FP_OFF(grDrv->_filledRect_scr_not));
  649.   else
  650.     grDrv->_filledRect_scr_not = TGE_filledRect;
  651.   if (FP_OFF(grDrv->_filledRect_scr_or))    /* filledRect_scr_or */
  652.     (void*)grDrv->_filledRect_scr_or = MK_FP(seg, FP_OFF(grDrv->_filledRect_scr_or));
  653.   else
  654.     grDrv->_filledRect_scr_or = TGE_filledRect;
  655.   if (FP_OFF(grDrv->_filledRect_scr_xor))    /* filledRect_scr_xor */
  656.     (void*)grDrv->_filledRect_scr_xor = MK_FP(seg, FP_OFF(grDrv->_filledRect_scr_xor));
  657.   else
  658.     grDrv->_filledRect_scr_xor = TGE_filledRect;
  659.   if (FP_OFF(grDrv->_filledRect_mem_copy))    /* filledRect_mem_copy */
  660.     (void*)grDrv->_filledRect_mem_copy = MK_FP(seg, FP_OFF(grDrv->_filledRect_mem_copy));
  661.   else
  662.     grDrv->_filledRect_mem_copy = TGE_filledRect;
  663.   if (FP_OFF(grDrv->_filledRect_mem_and))    /* filledRect_mem_and */
  664.     (void*)grDrv->_filledRect_mem_and = MK_FP(seg, FP_OFF(grDrv->_filledRect_mem_and));
  665.   else
  666.     grDrv->_filledRect_mem_and = TGE_filledRect;
  667.   if (FP_OFF(grDrv->_filledRect_mem_not))    /* filledRect_mem_not */
  668.     (void*)grDrv->_filledRect_mem_not = MK_FP(seg, FP_OFF(grDrv->_filledRect_mem_not));
  669.   else
  670.     grDrv->_filledRect_mem_not = TGE_filledRect;
  671.   if (FP_OFF(grDrv->_filledRect_mem_or))    /* filledRect_mem_or */
  672.     (void*)grDrv->_filledRect_mem_or = MK_FP(seg, FP_OFF(grDrv->_filledRect_mem_or));
  673.   else
  674.     grDrv->_filledRect_mem_or = TGE_filledRect;
  675.   if (FP_OFF(grDrv->_filledRect_mem_xor))    /* filledRect_mem_xor */
  676.     (void*)grDrv->_filledRect_mem_xor = MK_FP(seg, FP_OFF(grDrv->_filledRect_mem_xor));
  677.   else
  678.     grDrv->_filledRect_mem_xor = TGE_filledRect;
  679.  
  680.   if (FP_OFF(grDrv->_clearGraphics_scr_copy))    /* clearGraphics_scr_copy */
  681.     (void*)grDrv->_clearGraphics_scr_copy = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_scr_copy));
  682.   else
  683.     grDrv->_clearGraphics_scr_copy = TGE_clearGraphics;
  684.   if (FP_OFF(grDrv->_clearGraphics_scr_and))    /* clearGraphics_scr_and */
  685.     (void*)grDrv->_clearGraphics_scr_and = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_scr_and));
  686.   else
  687.     grDrv->_clearGraphics_scr_and = TGE_clearGraphics;
  688.   if (FP_OFF(grDrv->_clearGraphics_scr_not))    /* clearGraphics_scr_not */
  689.     (void*)grDrv->_clearGraphics_scr_not = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_scr_not));
  690.   else
  691.     grDrv->_clearGraphics_scr_not = TGE_clearGraphics;
  692.   if (FP_OFF(grDrv->_clearGraphics_scr_or))    /* clearGraphics_scr_or */
  693.     (void*)grDrv->_clearGraphics_scr_or = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_scr_or));
  694.   else
  695.     grDrv->_clearGraphics_scr_or = TGE_clearGraphics;
  696.   if (FP_OFF(grDrv->_clearGraphics_scr_xor))    /* clearGraphics_scr_xor */
  697.     (void*)grDrv->_clearGraphics_scr_xor = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_scr_xor));
  698.   else
  699.     grDrv->_clearGraphics_scr_xor = TGE_clearGraphics;
  700.   if (FP_OFF(grDrv->_clearGraphics_mem_copy))    /* clearGraphics_mem_copy */
  701.     (void*)grDrv->_clearGraphics_mem_copy = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_mem_copy));
  702.   else
  703.     grDrv->_clearGraphics_mem_copy = TGE_clearGraphics;
  704.   if (FP_OFF(grDrv->_clearGraphics_mem_and))    /* clearGraphics_mem_and */
  705.     (void*)grDrv->_clearGraphics_mem_and = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_mem_and));
  706.   else
  707.     grDrv->_clearGraphics_mem_and = TGE_clearGraphics;
  708.   if (FP_OFF(grDrv->_clearGraphics_mem_not))    /* clearGraphics_mem_not */
  709.     (void*)grDrv->_clearGraphics_mem_not = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_mem_not));
  710.   else
  711.     grDrv->_clearGraphics_mem_not = TGE_clearGraphics;
  712.   if (FP_OFF(grDrv->_clearGraphics_mem_or))    /* clearGraphics_mem_or */
  713.     (void*)grDrv->_clearGraphics_mem_or = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_mem_or));
  714.   else
  715.     grDrv->_clearGraphics_mem_or = TGE_clearGraphics;
  716.   if (FP_OFF(grDrv->_clearGraphics_mem_xor))    /* clearGraphics_mem_xor */
  717.     (void*)grDrv->_clearGraphics_mem_xor = MK_FP(seg, FP_OFF(grDrv->_clearGraphics_mem_xor));
  718.   else
  719.     grDrv->_clearGraphics_mem_xor = TGE_clearGraphics;
  720.  
  721.   if (FP_OFF(grDrv->_ellipse_scr_copy))        /* ellipse_scr_copy */
  722.     (void*)grDrv->_ellipse_scr_copy = MK_FP(seg, FP_OFF(grDrv->_ellipse_scr_copy));
  723.   else
  724.     grDrv->_ellipse_scr_copy = TGE_ellipse;
  725.   if (FP_OFF(grDrv->_ellipse_scr_and))        /* ellipse_scr_and */
  726.     (void*)grDrv->_ellipse_scr_and = MK_FP(seg, FP_OFF(grDrv->_ellipse_scr_and));
  727.   else
  728.     grDrv->_ellipse_scr_and = TGE_ellipse;
  729.   if (FP_OFF(grDrv->_ellipse_scr_not))        /* ellipse_scr_not */
  730.     (void*)grDrv->_ellipse_scr_not = MK_FP(seg, FP_OFF(grDrv->_ellipse_scr_not));
  731.   else
  732.     grDrv->_ellipse_scr_not = TGE_ellipse;
  733.   if (FP_OFF(grDrv->_ellipse_scr_or))        /* ellipse_scr_or */
  734.     (void*)grDrv->_ellipse_scr_or = MK_FP(seg, FP_OFF(grDrv->_ellipse_scr_or));
  735.   else
  736.     grDrv->_ellipse_scr_or = TGE_ellipse;
  737.   if (FP_OFF(grDrv->_ellipse_scr_xor))        /* ellipse_scr_xor */
  738.     (void*)grDrv->_ellipse_scr_xor = MK_FP(seg, FP_OFF(grDrv->_ellipse_scr_xor));
  739.   else
  740.     grDrv->_ellipse_scr_xor = TGE_ellipse;
  741.   if (FP_OFF(grDrv->_ellipse_mem_copy))        /* ellipse_mem_copy */
  742.     (void*)grDrv->_ellipse_mem_copy = MK_FP(seg, FP_OFF(grDrv->_ellipse_mem_copy));
  743.   else
  744.     grDrv->_ellipse_mem_copy = TGE_ellipse;
  745.   if (FP_OFF(grDrv->_ellipse_mem_and))        /* ellipse_mem_and */
  746.     (void*)grDrv->_ellipse_mem_and = MK_FP(seg, FP_OFF(grDrv->_ellipse_mem_and));
  747.   else
  748.     grDrv->_ellipse_mem_and = TGE_ellipse;
  749.   if (FP_OFF(grDrv->_ellipse_mem_not))        /* ellipse_mem_not */
  750.     (void*)grDrv->_ellipse_mem_not = MK_FP(seg, FP_OFF(grDrv->_ellipse_mem_not));
  751.   else
  752.     grDrv->_ellipse_mem_not = TGE_ellipse;
  753.   if (FP_OFF(grDrv->_ellipse_mem_or))        /* ellipse_mem_or */
  754.     (void*)grDrv->_ellipse_mem_or = MK_FP(seg, FP_OFF(grDrv->_ellipse_mem_or));
  755.   else
  756.     grDrv->_ellipse_mem_or = TGE_ellipse;
  757.   if (FP_OFF(grDrv->_ellipse_mem_xor))        /* ellipse_mem_xor */
  758.     (void*)grDrv->_ellipse_mem_xor = MK_FP(seg, FP_OFF(grDrv->_ellipse_mem_xor));
  759.   else
  760.     grDrv->_ellipse_mem_xor = TGE_ellipse;
  761.  
  762.   if (FP_OFF(grDrv->_filledEllipse_scr_copy))    /* filledEllipse_scr_copy */
  763.     (void*)grDrv->_filledEllipse_scr_copy = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_scr_copy));
  764.   else
  765.     grDrv->_filledEllipse_scr_copy = TGE_filledEllipse;
  766.   if (FP_OFF(grDrv->_filledEllipse_scr_and))    /* filledEllipse_scr_and */
  767.     (void*)grDrv->_filledEllipse_scr_and = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_scr_and));
  768.   else
  769.     grDrv->_filledEllipse_scr_and = TGE_filledEllipse;
  770.   if (FP_OFF(grDrv->_filledEllipse_scr_not))    /* filledEllipse_scr_not */
  771.     (void*)grDrv->_filledEllipse_scr_not = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_scr_not));
  772.   else
  773.     grDrv->_filledEllipse_scr_not = TGE_filledEllipse;
  774.   if (FP_OFF(grDrv->_filledEllipse_scr_or))    /* filledEllipse_scr_or */
  775.     (void*)grDrv->_filledEllipse_scr_or = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_scr_or));
  776.   else
  777.     grDrv->_filledEllipse_scr_or = TGE_filledEllipse;
  778.   if (FP_OFF(grDrv->_filledEllipse_scr_xor))    /* filledEllipse_scr_xor */
  779.     (void*)grDrv->_filledEllipse_scr_xor = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_scr_xor));
  780.   else
  781.     grDrv->_filledEllipse_scr_xor = TGE_filledEllipse;
  782.   if (FP_OFF(grDrv->_filledEllipse_mem_copy))    /* filledEllipse_mem_copy */
  783.     (void*)grDrv->_filledEllipse_mem_copy = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_mem_copy));
  784.   else
  785.     grDrv->_filledEllipse_mem_copy = TGE_filledEllipse;
  786.   if (FP_OFF(grDrv->_filledEllipse_mem_and))    /* filledEllipse_mem_and */
  787.     (void*)grDrv->_filledEllipse_mem_and = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_mem_and));
  788.   else
  789.     grDrv->_filledEllipse_mem_and = TGE_filledEllipse;
  790.   if (FP_OFF(grDrv->_filledEllipse_mem_not))    /* filledEllipse_mem_not */
  791.     (void*)grDrv->_filledEllipse_mem_not = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_mem_not));
  792.   else
  793.     grDrv->_filledEllipse_mem_not = TGE_filledEllipse;
  794.   if (FP_OFF(grDrv->_filledEllipse_mem_or))    /* filledEllipse_mem_or */
  795.     (void*)grDrv->_filledEllipse_mem_or = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_mem_or));
  796.   else
  797.     grDrv->_filledEllipse_mem_or = TGE_filledEllipse;
  798.   if (FP_OFF(grDrv->_filledEllipse_mem_xor))    /* filledEllipse_mem_xor */
  799.     (void*)grDrv->_filledEllipse_mem_xor = MK_FP(seg, FP_OFF(grDrv->_filledEllipse_mem_xor));
  800.   else
  801.     grDrv->_filledEllipse_mem_xor = TGE_filledEllipse;
  802.  
  803.   if (FP_OFF(grDrv->_circle_scr_copy))        /* circle_scr_copy */
  804.     (void*)grDrv->_circle_scr_copy = MK_FP(seg, FP_OFF(grDrv->_circle_scr_copy));
  805.   else
  806.     grDrv->_circle_scr_copy = TGE_circle;
  807.   if (FP_OFF(grDrv->_circle_scr_and))        /* circle_scr_and */
  808.     (void*)grDrv->_circle_scr_and = MK_FP(seg, FP_OFF(grDrv->_circle_scr_and));
  809.   else
  810.     grDrv->_circle_scr_and = TGE_circle;
  811.   if (FP_OFF(grDrv->_circle_scr_not))        /* circle_scr_not */
  812.     (void*)grDrv->_circle_scr_not = MK_FP(seg, FP_OFF(grDrv->_circle_scr_not));
  813.   else
  814.     grDrv->_circle_scr_not = TGE_circle;
  815.   if (FP_OFF(grDrv->_circle_scr_or))        /* circle_scr_or */
  816.     (void*)grDrv->_circle_scr_or = MK_FP(seg, FP_OFF(grDrv->_circle_scr_or));
  817.   else
  818.     grDrv->_circle_scr_or = TGE_circle;
  819.   if (FP_OFF(grDrv->_circle_scr_xor))        /* circle_scr_xor */
  820.     (void*)grDrv->_circle_scr_xor = MK_FP(seg, FP_OFF(grDrv->_circle_scr_xor));
  821.   else
  822.     grDrv->_circle_scr_xor = TGE_circle;
  823.   if (FP_OFF(grDrv->_circle_mem_copy))        /* circle_mem_copy */
  824.     (void*)grDrv->_circle_mem_copy = MK_FP(seg, FP_OFF(grDrv->_circle_mem_copy));
  825.   else
  826.     grDrv->_circle_mem_copy = TGE_circle;
  827.   if (FP_OFF(grDrv->_circle_mem_and))        /* circle_mem_and */
  828.     (void*)grDrv->_circle_mem_and = MK_FP(seg, FP_OFF(grDrv->_circle_mem_and));
  829.   else
  830.     grDrv->_circle_mem_and = TGE_circle;
  831.   if (FP_OFF(grDrv->_circle_mem_not))        /* circle_mem_not */
  832.     (void*)grDrv->_circle_mem_not = MK_FP(seg, FP_OFF(grDrv->_circle_mem_not));
  833.   else
  834.     grDrv->_circle_mem_not = TGE_circle;
  835.   if (FP_OFF(grDrv->_circle_mem_or))        /* circle_mem_or */
  836.     (void*)grDrv->_circle_mem_or = MK_FP(seg, FP_OFF(grDrv->_circle_mem_or));
  837.   else
  838.     grDrv->_circle_mem_or = TGE_circle;
  839.   if (FP_OFF(grDrv->_circle_mem_xor))        /* circle_mem_xor */
  840.     (void*)grDrv->_circle_mem_xor = MK_FP(seg, FP_OFF(grDrv->_circle_mem_xor));
  841.   else
  842.     grDrv->_circle_mem_xor = TGE_circle;
  843.  
  844.   if (FP_OFF(grDrv->_filledCircle_scr_copy))    /* filledCircle_scr_copy */
  845.     (void*)grDrv->_filledCircle_scr_copy = MK_FP(seg, FP_OFF(grDrv->_filledCircle_scr_copy));
  846.   else
  847.     grDrv->_filledCircle_scr_copy = TGE_filledCircle;
  848.   if (FP_OFF(grDrv->_filledCircle_scr_and))    /* filledCircle_scr_and */
  849.     (void*)grDrv->_filledCircle_scr_and = MK_FP(seg, FP_OFF(grDrv->_filledCircle_scr_and));
  850.   else
  851.     grDrv->_filledCircle_scr_and = TGE_filledCircle;
  852.   if (FP_OFF(grDrv->_filledCircle_scr_not))    /* filledCircle_scr_not */
  853.     (void*)grDrv->_filledCircle_scr_not = MK_FP(seg, FP_OFF(grDrv->_filledCircle_scr_not));
  854.   else
  855.     grDrv->_filledCircle_scr_not = TGE_filledCircle;
  856.   if (FP_OFF(grDrv->_filledCircle_scr_or))    /* filledCircle_scr_or */
  857.     (void*)grDrv->_filledCircle_scr_or = MK_FP(seg, FP_OFF(grDrv->_filledCircle_scr_or));
  858.   else
  859.     grDrv->_filledCircle_scr_or = TGE_filledCircle;
  860.   if (FP_OFF(grDrv->_filledCircle_scr_xor))    /* filledCircle_scr_xor */
  861.     (void*)grDrv->_filledCircle_scr_xor = MK_FP(seg, FP_OFF(grDrv->_filledCircle_scr_xor));
  862.   else
  863.     grDrv->_filledCircle_scr_xor = TGE_filledCircle;
  864.   if (FP_OFF(grDrv->_filledCircle_mem_copy))    /* filledCircle_mem_copy */
  865.     (void*)grDrv->_filledCircle_mem_copy = MK_FP(seg, FP_OFF(grDrv->_filledCircle_mem_copy));
  866.   else
  867.     grDrv->_filledCircle_mem_copy = TGE_filledCircle;
  868.   if (FP_OFF(grDrv->_filledCircle_mem_and))    /* filledCircle_mem_and */
  869.     (void*)grDrv->_filledCircle_mem_and = MK_FP(seg, FP_OFF(grDrv->_filledCircle_mem_and));
  870.   else
  871.     grDrv->_filledCircle_mem_and = TGE_filledCircle;
  872.   if (FP_OFF(grDrv->_filledCircle_mem_not))    /* filledCircle_mem_not */
  873.     (void*)grDrv->_filledCircle_mem_not = MK_FP(seg, FP_OFF(grDrv->_filledCircle_mem_not));
  874.   else
  875.     grDrv->_filledCircle_mem_not = TGE_filledCircle;
  876.   if (FP_OFF(grDrv->_filledCircle_mem_or))    /* filledCircle_mem_or */
  877.     (void*)grDrv->_filledCircle_mem_or = MK_FP(seg, FP_OFF(grDrv->_filledCircle_mem_or));
  878.   else
  879.     grDrv->_filledCircle_mem_or = TGE_filledCircle;
  880.   if (FP_OFF(grDrv->_filledCircle_mem_xor))    /* filledCircle_mem_xor */
  881.     (void*)grDrv->_filledCircle_mem_xor = MK_FP(seg, FP_OFF(grDrv->_filledCircle_mem_xor));
  882.   else
  883.     grDrv->_filledCircle_mem_xor = TGE_filledCircle;
  884.  
  885.   if (FP_OFF(grDrv->_fillRegion_scr_copy))    /* fillRegion_scr_copy */
  886.     (void*)grDrv->_fillRegion_scr_copy = MK_FP(seg, FP_OFF(grDrv->_fillRegion_scr_copy));
  887.   else
  888.     grDrv->_fillRegion_scr_copy = TGE_fillRegion;
  889.   if (FP_OFF(grDrv->_fillRegion_scr_and))    /* fillRegion_scr_and */
  890.     (void*)grDrv->_fillRegion_scr_and = MK_FP(seg, FP_OFF(grDrv->_fillRegion_scr_and));
  891.   else
  892.     grDrv->_fillRegion_scr_and = TGE_fillRegion;
  893.   if (FP_OFF(grDrv->_fillRegion_scr_not))    /* fillRegion_scr_not */
  894.     (void*)grDrv->_fillRegion_scr_not = MK_FP(seg, FP_OFF(grDrv->_fillRegion_scr_not));
  895.   else
  896.     grDrv->_fillRegion_scr_not = TGE_fillRegion;
  897.   if (FP_OFF(grDrv->_fillRegion_scr_or))    /* fillRegion_scr_or */
  898.     (void*)grDrv->_fillRegion_scr_or = MK_FP(seg, FP_OFF(grDrv->_fillRegion_scr_or));
  899.   else
  900.     grDrv->_fillRegion_scr_or = TGE_fillRegion;
  901.   if (FP_OFF(grDrv->_fillRegion_scr_xor))    /* fillRegion_scr_xor */
  902.     (void*)grDrv->_fillRegion_scr_xor = MK_FP(seg, FP_OFF(grDrv->_fillRegion_scr_xor));
  903.   else
  904.     grDrv->_fillRegion_scr_xor = TGE_fillRegion;
  905.   if (FP_OFF(grDrv->_fillRegion_mem_copy))    /* fillRegion_mem_copy */
  906.     (void*)grDrv->_fillRegion_mem_copy = MK_FP(seg, FP_OFF(grDrv->_fillRegion_mem_copy));
  907.   else
  908.     grDrv->_fillRegion_mem_copy = TGE_fillRegion;
  909.   if (FP_OFF(grDrv->_fillRegion_mem_and))    /* fillRegion_mem_and */
  910.     (void*)grDrv->_fillRegion_mem_and = MK_FP(seg, FP_OFF(grDrv->_fillRegion_mem_and));
  911.   else
  912.     grDrv->_fillRegion_mem_and = TGE_fillRegion;
  913.   if (FP_OFF(grDrv->_fillRegion_mem_not))    /* fillRegion_mem_not */
  914.     (void*)grDrv->_fillRegion_mem_not = MK_FP(seg, FP_OFF(grDrv->_fillRegion_mem_not));
  915.   else
  916.     grDrv->_fillRegion_mem_not = TGE_fillRegion;
  917.   if (FP_OFF(grDrv->_fillRegion_mem_or))    /* fillRegion_mem_or */
  918.     (void*)grDrv->_fillRegion_mem_or = MK_FP(seg, FP_OFF(grDrv->_fillRegion_mem_or));
  919.   else
  920.     grDrv->_fillRegion_mem_or = TGE_fillRegion;
  921.   if (FP_OFF(grDrv->_fillRegion_mem_xor))    /* fillRegion_mem_xor */
  922.     (void*)grDrv->_fillRegion_mem_xor = MK_FP(seg, FP_OFF(grDrv->_fillRegion_mem_xor));
  923.   else
  924.     grDrv->_fillRegion_mem_xor = TGE_fillRegion;
  925.  
  926.   if (FP_OFF(grDrv->_fillLine_scr_copy))    /* fillLine_scr_copy */
  927.     (void*)grDrv->_fillLine_scr_copy = MK_FP(seg, FP_OFF(grDrv->_fillLine_scr_copy));
  928.   else
  929.     grDrv->_fillLine_scr_copy = TGEsys->_horizLine_scr_copy;
  930.   if (FP_OFF(grDrv->_fillLine_scr_and))        /* fillLine_scr_and */
  931.     (void*)grDrv->_fillLine_scr_and = MK_FP(seg, FP_OFF(grDrv->_fillLine_scr_and));
  932.   else
  933.     grDrv->_fillLine_scr_and = TGEsys->_horizLine_scr_and;
  934.   if (FP_OFF(grDrv->_fillLine_scr_not))        /* fillLine_scr_not */
  935.     (void*)grDrv->_fillLine_scr_not = MK_FP(seg, FP_OFF(grDrv->_fillLine_scr_not));
  936.   else
  937.     grDrv->_fillLine_scr_not = TGEsys->_horizLine_scr_not;
  938.   if (FP_OFF(grDrv->_fillLine_scr_or))        /* fillLine_scr_or */
  939.     (void*)grDrv->_fillLine_scr_or = MK_FP(seg, FP_OFF(grDrv->_fillLine_scr_or));
  940.   else
  941.     grDrv->_fillLine_scr_or = TGEsys->_horizLine_scr_or;
  942.   if (FP_OFF(grDrv->_fillLine_scr_xor))        /* fillLine_scr_xor */
  943.     (void*)grDrv->_fillLine_scr_xor = MK_FP(seg, FP_OFF(grDrv->_fillLine_scr_xor));
  944.   else
  945.     grDrv->_fillLine_scr_xor = TGEsys->_horizLine_scr_xor;
  946.   if (FP_OFF(grDrv->_fillLine_mem_copy))    /* fillLine_mem_copy */
  947.     (void*)grDrv->_fillLine_mem_copy = MK_FP(seg, FP_OFF(grDrv->_fillLine_mem_copy));
  948.   else
  949.     grDrv->_fillLine_mem_copy = TGEsys->_horizLine_mem_copy;
  950.   if (FP_OFF(grDrv->_fillLine_mem_and))        /* fillLine_mem_and */
  951.     (void*)grDrv->_fillLine_mem_and = MK_FP(seg, FP_OFF(grDrv->_fillLine_mem_and));
  952.   else
  953.     grDrv->_fillLine_mem_and = TGEsys->_horizLine_mem_and;
  954.   if (FP_OFF(grDrv->_fillLine_mem_not))        /* fillLine_mem_not */
  955.     (void*)grDrv->_fillLine_mem_not = MK_FP(seg, FP_OFF(grDrv->_fillLine_mem_not));
  956.   else
  957.     grDrv->_fillLine_mem_not = TGEsys->_horizLine_mem_not;
  958.   if (FP_OFF(grDrv->_fillLine_mem_or))        /* fillLine_mem_or */
  959.     (void*)grDrv->_fillLine_mem_or = MK_FP(seg, FP_OFF(grDrv->_fillLine_mem_or));
  960.   else
  961.     grDrv->_fillLine_mem_or = TGEsys->_horizLine_mem_or;
  962.   if (FP_OFF(grDrv->_fillLine_mem_xor))        /* fillLine_mem_xor */
  963.     (void*)grDrv->_fillLine_mem_xor = MK_FP(seg, FP_OFF(grDrv->_fillLine_mem_xor));
  964.   else
  965.     grDrv->_fillLine_mem_xor = TGEsys->_horizLine_mem_xor;
  966.  
  967.  
  968.   /* Set up currently active functions */
  969.   setInputFunctions(SCREEN);
  970.   setOutputFunctions(SCREEN, TGE_COPY_PUT);
  971.  
  972.   /* Set up the currently active viewports */
  973.   TGE_setViewports(0, 0, OUTMAXX, OUTMAXY);
  974. }
  975.  
  976.  
  977. /*****
  978. ****** Free graphics driver memory
  979. *****/
  980.  
  981. void TGE_unloadGraphDriver(void)
  982. {
  983.   if (drvAddr)
  984.   {
  985.     farfree(drvAddr);
  986.     drvAddr = NULL;
  987.   }
  988. }
  989.  
  990.  
  991. /*****
  992. ****** Virtual/real screen switching
  993. *****/
  994.  
  995. void far TGE_setGraphicsAddr(void far *addr)
  996. {
  997.   TGE_setGraphicsInputAddr(addr);        /* configure input */
  998.   TGE_setGraphicsOutputAddr(addr);        /* configure output */
  999. }
  1000.  
  1001. void far TGE_setGraphicsInputAddr(void far *addr)
  1002. {
  1003.   register unsigned wide, deep;
  1004.  
  1005.   if (addr != NULL)    /* make a virtual screen active */
  1006.   {
  1007.     wide = ((unsigned*)addr)[0];    /* get memory block dimensions */
  1008.     deep = ((unsigned*)addr)[1];
  1009.     INADDR = (char*) addr + 4;        /* store as active address */
  1010.     INSCREENWIDE = wide;        /* needed for virtual screens */
  1011.     INMAXX = wide - 1;            /* adjust current input */
  1012.     INMAXY = deep - 1;            /* screen dimensions    */
  1013.     TGE_setInputViewport(0, 0, wide-1, deep-1);    /* viewport */
  1014.     setInputFunctions(MEMORY);        /* update TGE's function pointers */
  1015.   }
  1016.   else            /* make the screen active */
  1017.   {
  1018.     INADDR = TGEsys->scrAddr;        /* revert to screen address */
  1019.     INSCREENWIDE = wide;        /* needed for virtual screens */
  1020.     INMAXX = SCREENMAXX;        /* restore screen dimensions */
  1021.     INMAXY = SCREENMAXY;
  1022.     TGE_setInputViewport(0, 0, INMAXX, INMAXY);    /* viewport */
  1023.     setInputFunctions(SCREEN);        /* update TGE's function pointers */
  1024.   }
  1025. }
  1026.  
  1027. void far TGE_setGraphicsOutputAddr(void far *addr)
  1028. {
  1029.   register unsigned wide, deep;
  1030.  
  1031.   if (addr != NULL)    /* make a virtual screen active */
  1032.   {
  1033.     wide = ((unsigned*)addr)[0];    /* get memory block dimensions */
  1034.     deep = ((unsigned*)addr)[1];
  1035.     OUTADDR = (char*) addr + 4;        /* store as active address */
  1036.     OUTSCREENWIDE = wide;        /* needed for virtual screens */
  1037.     OUTMAXX = wide - 1;            /* adjust current screen */
  1038.     OUTMAXY = deep - 1;            /* dimensions */
  1039.     TGE_setOutputViewport(0, 0, wide-1, deep-1); /* viewport */
  1040.     setOutputFunctions(MEMORY, curOutputMode);    /* update TGE's function pointers */
  1041.     curOutputDest = MEMORY;        /* store current destination */
  1042.   }
  1043.   else            /* make the screen active */
  1044.   {
  1045.     OUTADDR = TGEsys->scrAddr;        /* revert to screen address */
  1046.     OUTSCREENWIDE = wide;        /* needed for virtual screens */
  1047.     OUTMAXX = SCREENMAXX;        /* restore screen dimensions */
  1048.     OUTMAXY = SCREENMAXY;
  1049.     TGE_setOutputViewport(0, 0, OUTMAXX, OUTMAXY); /* viewport */
  1050.     setOutputFunctions(SCREEN, curOutputMode);    /* update TGE's function pointers */
  1051.     curOutputDest = SCREEN;        /* store current destination */
  1052.   }
  1053. }
  1054.  
  1055. void far *TGE_getGraphicsOutputAddr(void)
  1056. {
  1057.   if (OUTADDR == SCRADDR)
  1058.     return (NULL);
  1059.   else
  1060.     return (OUTADDR);
  1061. }
  1062.  
  1063. void far *TGE_getGraphicsInputAddr(void)
  1064. {
  1065.   if (INADDR == SCRADDR)
  1066.     return (NULL);
  1067.   else
  1068.     return (INADDR);
  1069. }
  1070.  
  1071. void far *TGE_makeVirtScreen(unsigned wide, unsigned deep)
  1072. {
  1073.   void far *addr;
  1074.  
  1075.   if (wide && deep)            /* ensure wide>0 and deep>0 */
  1076.   {
  1077.     addr = farmalloc(TGEsys->_imageSizeDim(wide,deep));    /* allocate some RAM */
  1078.     if (addr == NULL)
  1079.       return (NULL);
  1080.     else
  1081.     {
  1082.       ((unsigned*)addr)[0] = wide;    /* store image width */
  1083.       ((unsigned*)addr)[1] = deep;    /* store image depth */
  1084.       return (addr);            /* return the address */
  1085.     }
  1086.   }
  1087.   else
  1088.     return (NULL);
  1089. }
  1090.  
  1091.  
  1092. /*****
  1093. ****** Change the current output mode
  1094. *****/
  1095.  
  1096. void TGE_setOutputMode(int mode)
  1097. {
  1098.   curOutputMode = mode;                /* store as current mode */
  1099.   setOutputFunctions(curOutputDest, mode);    /* setup for the new mode */
  1100. }
  1101.  
  1102.  
  1103. /*****
  1104. ****** Update function pointers given output mode and destination.
  1105. *****/
  1106.  
  1107. void near setInputFunctions(int memOrScreen)
  1108. {
  1109.   if (memOrScreen == MEMORY)    /* set virtual screen active */
  1110.   {
  1111.     TGEsys->_getImage      = TGEsys->_getImage_mem;     /* getImage      */
  1112.     TGEsys->_getLine       = TGEsys->_getLine_mem;     /* getLine       */
  1113.     TGEsys->_getPixel      = TGEsys->_getPixel_mem;     /* getPixel      */
  1114.   }
  1115.   else                /* set real screen active */
  1116.   {
  1117.     TGEsys->_getImage      = TGEsys->_getImage_scr;     /* getImage      */
  1118.     TGEsys->_getLine       = TGEsys->_getLine_scr;     /* getLine       */
  1119.     TGEsys->_getPixel      = TGEsys->_getPixel_scr;     /* getPixel      */
  1120.   }
  1121. }
  1122.  
  1123. void near setOutputFunctions(int memOrScreen, int writeMode)
  1124. {
  1125.   if (memOrScreen == MEMORY)    /* set virtual screen active */
  1126.   {
  1127.     switch (writeMode)
  1128.     {
  1129.       case TGE_COPY_PUT:    /* output using COPY */
  1130.     TGEsys->_putImage      = TGEsys->_putImage_mem_copy;      /* putImage      */
  1131.     TGEsys->_putImageInv   = TGEsys->_putImageInv_mem_copy;      /* putImageInv   */
  1132.     TGEsys->_putLine       = TGEsys->_putLine_mem_copy;      /* putLine       */
  1133.     TGEsys->_putLineInv    = TGEsys->_putLineInv_mem_copy;      /* putLineInv    */
  1134.     TGEsys->_putPixel      = TGEsys->_putPixel_mem_copy;      /* putPixel      */
  1135.     TGEsys->_line          = TGEsys->_line_mem_copy;      /* line          */
  1136.     TGEsys->_horizLine     = TGEsys->_horizLine_mem_copy;     /* horizLine     */
  1137.     TGEsys->_vertLine      = TGEsys->_vertLine_mem_copy;         /* vertLine      */
  1138.     TGEsys->_drawRect      = TGEsys->_drawRect_mem_copy;      /* drawRect      */
  1139.     TGEsys->_filledRect    = TGEsys->_filledRect_mem_copy;    /* filledRect    */
  1140.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_mem_copy; /* clearGraphics */
  1141.     TGEsys->_ellipse       = TGEsys->_ellipse_mem_copy;      /* ellipse       */
  1142.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_mem_copy; /* filledEllipse */
  1143.     TGEsys->_circle        = TGEsys->_circle_mem_copy;      /* circle        */
  1144.     TGEsys->_filledCircle  = TGEsys->_filledCircle_mem_copy;  /* filledCircle  */
  1145.     TGEsys->_fillRegion    = TGEsys->_fillRegion_mem_copy;      /* fillRegion    */
  1146.     TGEsys->_fillLine      = TGEsys->_fillLine_mem_copy;      /* fillLine      */
  1147.     break;
  1148.       case TGE_AND_PUT:        /* output using AND */
  1149.     TGEsys->_putImage      = TGEsys->_putImage_mem_and;      /* putImage      */
  1150.     TGEsys->_putImageInv   = TGEsys->_putImageInv_mem_and;      /* putImageInv   */
  1151.     TGEsys->_putLine       = TGEsys->_putLine_mem_and;      /* putLine       */
  1152.     TGEsys->_putLineInv    = TGEsys->_putLineInv_mem_and;      /* putLineInv    */
  1153.     TGEsys->_putPixel      = TGEsys->_putPixel_mem_and;      /* putPixel      */
  1154.     TGEsys->_line          = TGEsys->_line_mem_and;          /* line          */
  1155.     TGEsys->_horizLine     = TGEsys->_horizLine_mem_and;      /* horizLine     */
  1156.     TGEsys->_vertLine      = TGEsys->_vertLine_mem_and;         /* vertLine      */
  1157.     TGEsys->_drawRect      = TGEsys->_drawRect_mem_and;      /* drawRect      */
  1158.     TGEsys->_filledRect    = TGEsys->_filledRect_mem_and;        /* filledRect    */
  1159.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_mem_and;  /* clearGraphics */
  1160.     TGEsys->_ellipse       = TGEsys->_ellipse_mem_and;      /* ellipse       */
  1161.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_mem_and;  /* filledEllipse */
  1162.     TGEsys->_circle        = TGEsys->_circle_mem_and;      /* circle        */
  1163.     TGEsys->_filledCircle  = TGEsys->_filledCircle_mem_and;      /* filledCircle  */
  1164.     TGEsys->_fillRegion    = TGEsys->_fillRegion_mem_and;      /* fillRegion    */
  1165.     TGEsys->_fillLine      = TGEsys->_fillLine_mem_and;      /* fillLine      */
  1166.     break;
  1167.       case TGE_NOT_PUT:        /* output using NOT */
  1168.     TGEsys->_putImage      = TGEsys->_putImage_mem_not;      /* putImage      */
  1169.     TGEsys->_putImageInv   = TGEsys->_putImageInv_mem_not;      /* putImageInv   */
  1170.     TGEsys->_putLine       = TGEsys->_putLine_mem_not;      /* putLine       */
  1171.     TGEsys->_putLineInv    = TGEsys->_putLineInv_mem_not;      /* putLineInv    */
  1172.     TGEsys->_putPixel      = TGEsys->_putPixel_mem_not;      /* putPixel      */
  1173.     TGEsys->_line          = TGEsys->_line_mem_not;          /* line          */
  1174.     TGEsys->_horizLine     = TGEsys->_horizLine_mem_not;      /* horizLine     */
  1175.     TGEsys->_vertLine      = TGEsys->_vertLine_mem_not;         /* vertLine      */
  1176.     TGEsys->_drawRect      = TGEsys->_drawRect_mem_not;      /* drawRect      */
  1177.     TGEsys->_filledRect    = TGEsys->_filledRect_mem_not;        /* filledRect    */
  1178.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_mem_not;  /* clearGraphics */
  1179.     TGEsys->_ellipse       = TGEsys->_ellipse_mem_not;      /* ellipse       */
  1180.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_mem_not;  /* filledEllipse */
  1181.     TGEsys->_circle        = TGEsys->_circle_mem_not;      /* circle        */
  1182.     TGEsys->_filledCircle  = TGEsys->_filledCircle_mem_not;      /* filledCircle  */
  1183.     TGEsys->_fillRegion    = TGEsys->_fillRegion_mem_not;      /* fillRegion    */
  1184.     TGEsys->_fillLine      = TGEsys->_fillLine_mem_not;      /* fillLine      */
  1185.     break;
  1186.       case TGE_OR_PUT:        /* output using OR */
  1187.     TGEsys->_putImage      = TGEsys->_putImage_mem_or;      /* putImage      */
  1188.     TGEsys->_putImageInv   = TGEsys->_putImageInv_mem_or;      /* putImageInv   */
  1189.     TGEsys->_putLine       = TGEsys->_putLine_mem_or;      /* putLine       */
  1190.     TGEsys->_putLineInv    = TGEsys->_putLineInv_mem_or;      /* putLineInv    */
  1191.     TGEsys->_putPixel      = TGEsys->_putPixel_mem_or;      /* putPixel      */
  1192.     TGEsys->_line          = TGEsys->_line_mem_or;          /* line          */
  1193.     TGEsys->_horizLine     = TGEsys->_horizLine_mem_or;       /* horizLine     */
  1194.     TGEsys->_vertLine      = TGEsys->_vertLine_mem_or;         /* vertLine      */
  1195.     TGEsys->_drawRect      = TGEsys->_drawRect_mem_or;      /* drawRect      */
  1196.     TGEsys->_filledRect    = TGEsys->_filledRect_mem_or;        /* filledRect    */
  1197.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_mem_or;      /* clearGraphics */
  1198.     TGEsys->_ellipse       = TGEsys->_ellipse_mem_or;      /* ellipse       */
  1199.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_mem_or;      /* filledEllipse */
  1200.     TGEsys->_circle        = TGEsys->_circle_mem_or;      /* circle        */
  1201.     TGEsys->_filledCircle  = TGEsys->_filledCircle_mem_or;      /* filledCircle  */
  1202.     TGEsys->_fillRegion    = TGEsys->_fillRegion_mem_or;      /* fillRegion    */
  1203.     TGEsys->_fillLine      = TGEsys->_fillLine_mem_or;      /* fillLine      */
  1204.     break;
  1205.       case TGE_XOR_PUT:        /* output using XOR */
  1206.     TGEsys->_putImage      = TGEsys->_putImage_mem_xor;      /* putImage      */
  1207.     TGEsys->_putImageInv   = TGEsys->_putImageInv_mem_xor;      /* putImageInv   */
  1208.     TGEsys->_putLine       = TGEsys->_putLine_mem_xor;      /* putLine       */
  1209.     TGEsys->_putLineInv    = TGEsys->_putLineInv_mem_xor;      /* putLineInv    */
  1210.     TGEsys->_putPixel      = TGEsys->_putPixel_mem_xor;      /* putPixel      */
  1211.     TGEsys->_line          = TGEsys->_line_mem_xor;          /* line          */
  1212.     TGEsys->_horizLine     = TGEsys->_horizLine_mem_xor;      /* horizLine     */
  1213.     TGEsys->_vertLine      = TGEsys->_vertLine_mem_xor;         /* vertLine      */
  1214.     TGEsys->_drawRect      = TGEsys->_drawRect_mem_xor;      /* drawRect      */
  1215.     TGEsys->_filledRect    = TGEsys->_filledRect_mem_xor;        /* filledRect    */
  1216.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_mem_xor;  /* clearGraphics */
  1217.     TGEsys->_ellipse       = TGEsys->_ellipse_mem_xor;      /* ellipse       */
  1218.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_mem_xor;  /* filledEllipse */
  1219.     TGEsys->_circle        = TGEsys->_circle_mem_xor;      /* circle        */
  1220.     TGEsys->_filledCircle  = TGEsys->_filledCircle_mem_xor;      /* filledCircle  */
  1221.     TGEsys->_fillRegion    = TGEsys->_fillRegion_mem_xor;      /* fillRegion    */
  1222.     TGEsys->_fillLine      = TGEsys->_fillLine_mem_xor;      /* fillLine      */
  1223.     break;
  1224.       default:
  1225.     ;
  1226.     }
  1227.   }
  1228.   else                /* set real screen active */
  1229.   {
  1230.     switch (writeMode)
  1231.     {
  1232.       case TGE_COPY_PUT:    /* output using COPY */
  1233.     TGEsys->_putImage      = TGEsys->_putImage_scr_copy;      /* putImage      */
  1234.     TGEsys->_putImageInv   = TGEsys->_putImageInv_scr_copy;      /* putImageInv   */
  1235.     TGEsys->_putLine       = TGEsys->_putLine_scr_copy;      /* putLine       */
  1236.     TGEsys->_putLineInv    = TGEsys->_putLineInv_scr_copy;      /* putLineInv    */
  1237.     TGEsys->_putPixel      = TGEsys->_putPixel_scr_copy;      /* putPixel      */
  1238.     TGEsys->_line          = TGEsys->_line_scr_copy;      /* line          */
  1239.     TGEsys->_horizLine     = TGEsys->_horizLine_scr_copy;     /* horizLine     */
  1240.     TGEsys->_vertLine      = TGEsys->_vertLine_scr_copy;         /* vertLine      */
  1241.     TGEsys->_drawRect      = TGEsys->_drawRect_scr_copy;      /* drawRect      */
  1242.     TGEsys->_filledRect    = TGEsys->_filledRect_scr_copy;    /* filledRect    */
  1243.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_scr_copy; /* clearGraphics */
  1244.     TGEsys->_ellipse       = TGEsys->_ellipse_scr_copy;      /* ellipse       */
  1245.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_scr_copy; /* filledEllipse */
  1246.     TGEsys->_circle        = TGEsys->_circle_scr_copy;      /* circle        */
  1247.     TGEsys->_filledCircle  = TGEsys->_filledCircle_scr_copy;  /* filledCircle  */
  1248.     TGEsys->_fillRegion    = TGEsys->_fillRegion_scr_copy;      /* fillRegion    */
  1249.     TGEsys->_fillLine      = TGEsys->_fillLine_scr_copy;      /* fillLine      */
  1250.     break;
  1251.       case TGE_AND_PUT:        /* output using AND */
  1252.     TGEsys->_putImage      = TGEsys->_putImage_scr_and;      /* putImage      */
  1253.     TGEsys->_putImageInv   = TGEsys->_putImageInv_scr_and;      /* putImageInv   */
  1254.     TGEsys->_putLine       = TGEsys->_putLine_scr_and;      /* putLine       */
  1255.     TGEsys->_putLineInv    = TGEsys->_putLineInv_scr_and;      /* putLineInv    */
  1256.     TGEsys->_putPixel      = TGEsys->_putPixel_scr_and;      /* putPixel      */
  1257.     TGEsys->_line          = TGEsys->_line_scr_and;          /* line          */
  1258.     TGEsys->_horizLine     = TGEsys->_horizLine_scr_and;      /* horizLine     */
  1259.     TGEsys->_vertLine      = TGEsys->_vertLine_scr_and;         /* vertLine      */
  1260.     TGEsys->_drawRect      = TGEsys->_drawRect_scr_and;      /* drawRect      */
  1261.     TGEsys->_filledRect    = TGEsys->_filledRect_scr_and;        /* filledRect    */
  1262.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_scr_and;  /* clearGraphics */
  1263.     TGEsys->_ellipse       = TGEsys->_ellipse_scr_and;      /* ellipse       */
  1264.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_scr_and;  /* filledEllipse */
  1265.     TGEsys->_circle        = TGEsys->_circle_scr_and;      /* circle        */
  1266.     TGEsys->_filledCircle  = TGEsys->_filledCircle_scr_and;      /* filledCircle  */
  1267.     TGEsys->_fillRegion    = TGEsys->_fillRegion_scr_and;      /* fillRegion    */
  1268.     TGEsys->_fillLine      = TGEsys->_fillLine_scr_and;      /* fillLine      */
  1269.     break;
  1270.       case TGE_NOT_PUT:        /* output using NOT */
  1271.     TGEsys->_putImage      = TGEsys->_putImage_scr_not;      /* putImage      */
  1272.     TGEsys->_putImageInv   = TGEsys->_putImageInv_scr_not;      /* putImageInv   */
  1273.     TGEsys->_putLine       = TGEsys->_putLine_scr_not;      /* putLine       */
  1274.     TGEsys->_putLineInv    = TGEsys->_putLineInv_scr_not;      /* putLineInv    */
  1275.     TGEsys->_putPixel      = TGEsys->_putPixel_scr_not;      /* putPixel      */
  1276.     TGEsys->_line          = TGEsys->_line_scr_not;          /* line          */
  1277.     TGEsys->_horizLine     = TGEsys->_horizLine_scr_not;      /* horizLine     */
  1278.     TGEsys->_vertLine      = TGEsys->_vertLine_scr_not;         /* vertLine      */
  1279.     TGEsys->_drawRect      = TGEsys->_drawRect_scr_not;      /* drawRect      */
  1280.     TGEsys->_filledRect    = TGEsys->_filledRect_scr_not;        /* filledRect    */
  1281.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_scr_not;  /* clearGraphics */
  1282.     TGEsys->_ellipse       = TGEsys->_ellipse_scr_not;      /* ellipse       */
  1283.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_scr_not;  /* TGEsys->_filledEllipse */
  1284.     TGEsys->_circle        = TGEsys->_circle_scr_not;      /* circle        */
  1285.     TGEsys->_filledCircle  = TGEsys->_filledCircle_scr_not;      /* filledCircle  */
  1286.     TGEsys->_fillRegion    = TGEsys->_fillRegion_scr_not;      /* fillRegion    */
  1287.     TGEsys->_fillLine      = TGEsys->_fillLine_scr_not;      /* fillLine      */
  1288.     break;
  1289.       case TGE_OR_PUT:        /* output using OR */
  1290.     TGEsys->_putImage      = TGEsys->_putImage_scr_or;      /* putImage      */
  1291.     TGEsys->_putImageInv   = TGEsys->_putImageInv_scr_or;      /* putImageInv   */
  1292.     TGEsys->_putLine       = TGEsys->_putLine_scr_or;      /* putLine       */
  1293.     TGEsys->_putLineInv    = TGEsys->_putLineInv_scr_or;      /* putLineInv    */
  1294.     TGEsys->_putPixel      = TGEsys->_putPixel_scr_or;      /* putPixel      */
  1295.     TGEsys->_line          = TGEsys->_line_scr_or;          /* line          */
  1296.     TGEsys->_horizLine     = TGEsys->_horizLine_scr_or;       /* horizLine     */
  1297.     TGEsys->_vertLine      = TGEsys->_vertLine_scr_or;         /* vertLine      */
  1298.     TGEsys->_drawRect      = TGEsys->_drawRect_scr_or;      /* drawRect      */
  1299.     TGEsys->_filledRect    = TGEsys->_filledRect_scr_or;        /* filledRect    */
  1300.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_scr_or;      /* clearGraphics */
  1301.     TGEsys->_ellipse       = TGEsys->_ellipse_scr_or;      /* ellipse       */
  1302.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_scr_or;      /* filledEllipse */
  1303.     TGEsys->_circle        = TGEsys->_circle_scr_or;      /* circle        */
  1304.     TGEsys->_filledCircle  = TGEsys->_filledCircle_scr_or;      /* filledCircle  */
  1305.     TGEsys->_fillRegion    = TGEsys->_fillRegion_scr_or;      /* fillRegion    */
  1306.     TGEsys->_fillLine      = TGEsys->_fillLine_scr_or;      /* fillLine      */
  1307.     break;
  1308.       case TGE_XOR_PUT:        /* output using XOR */
  1309.     TGEsys->_putImage      = TGEsys->_putImage_scr_xor;      /* putImage      */
  1310.     TGEsys->_putImageInv   = TGEsys->_putImageInv_scr_xor;      /* putImageInv   */
  1311.     TGEsys->_putLine       = TGEsys->_putLine_scr_xor;      /* putLine       */
  1312.     TGEsys->_putLineInv    = TGEsys->_putLineInv_scr_xor;      /* putLineInv    */
  1313.     TGEsys->_putPixel      = TGEsys->_putPixel_scr_xor;      /* putPixel      */
  1314.     TGEsys->_line          = TGEsys->_line_scr_xor;          /* line          */
  1315.     TGEsys->_horizLine     = TGEsys->_horizLine_scr_xor;      /* horizLine     */
  1316.     TGEsys->_vertLine      = TGEsys->_vertLine_scr_xor;         /* vertLine      */
  1317.     TGEsys->_drawRect      = TGEsys->_drawRect_scr_xor;      /* drawRect      */
  1318.     TGEsys->_filledRect    = TGEsys->_filledRect_scr_xor;        /* filledRect    */
  1319.     TGEsys->_clearGraphics = TGEsys->_clearGraphics_scr_xor;  /* clearGraphics */
  1320.     TGEsys->_ellipse       = TGEsys->_ellipse_scr_xor;      /* ellipse       */
  1321.     TGEsys->_filledEllipse = TGEsys->_filledEllipse_scr_xor;  /* filledEllipse */
  1322.     TGEsys->_circle        = TGEsys->_circle_scr_xor;      /* circle        */
  1323.     TGEsys->_filledCircle  = TGEsys->_filledCircle_scr_xor;      /* filledCircle  */
  1324.     TGEsys->_fillRegion    = TGEsys->_fillRegion_scr_xor;      /* fillRegion    */
  1325.     TGEsys->_fillLine      = TGEsys->_fillLine_scr_xor;      /* fillLine      */
  1326.     break;
  1327.       default:
  1328.     ;
  1329.     }
  1330.   }
  1331. }