home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 14 / MA_Cover_14.iso / source / c / q1source_amy / qw / scitech / include / mgraph.h < prev   
Encoding:
C/C++ Source or Header  |  1997-03-11  |  75.1 KB  |  1,952 lines

  1. /****************************************************************************
  2. *
  3. *                        MegaGraph Graphics Library
  4. *
  5. *                   Copyright (C) 1996 SciTech Software.
  6. *                            All rights reserved.
  7. *
  8. * Filename:        $Workfile:   mgraph.h  $
  9. * Version:        $Revision:   1.29  $
  10. *
  11. * Language:        ANSI C
  12. * Environment:    IBM PC (MS DOS)
  13. *
  14. * Description:    Header file for the MegaGraph Graphics Library. You can
  15. *                defined one of the following to specify which MGL API you
  16. *                wish to use.
  17. *
  18. *                    MGL_LITE    - Compile for the MGL/Lite API
  19. *                    MGL_PRO        - Compile for the MGL/Pro API
  20. *                    MGL_FIX3D    - Compile for the MGL/3D API (fixed point)
  21. *                    MGL_FLT3D    - Compile for the MGL/3D API (floating point)
  22. *
  23. *                If you do not define any of these, MGL_FIX3D will be defined
  24. *                automatically for compatibility with older versions of the
  25. *                MGL.
  26. *
  27. * $Date:   11 Mar 1997 16:46:42  $ $Author:   KendallB  $
  28. *
  29. ****************************************************************************/
  30.  
  31. #ifndef    __MGRAPH_H
  32. #define    __MGRAPH_H
  33.  
  34. #include <stdio.h>
  35.  
  36. #ifndef    __DEBUG_H
  37. #include "debug.h"
  38. #endif
  39.  
  40. #if    !defined(MGL_LITE) && !defined(MGL_PRO) && !defined(MGL_FIX3D) \
  41.     && !defined(MGL_FLT3D)
  42. #define    MGL_FIX3D
  43. #endif
  44.  
  45. #if    defined(MGL_FIX3D) || defined(MGL_FLT3D)
  46. #define    MGL_3D
  47. #endif
  48.  
  49. /*---------------------- Macros and type definitions ----------------------*/
  50.  
  51. #pragma pack(1)                /* Pack structures to byte granularity        */
  52.  
  53. /* Define the version number for the MGL release */
  54.  
  55. #define MGL_VERSION_STR     "3.1"
  56.  
  57. /* Define the calling conventions for all public MGL functions. If we
  58.  * are compiling the MGL as a DLL, then all public functions are compiled
  59.  * and exported with standard C calling conventions, otherwise we use
  60.  * the default calling conventions provided by the compiler.
  61.  *
  62.  * Note that because Watcom C++ uses register based parameter passing
  63.  * by default we also provide special DLL's for watcom that are compiled
  64.  * with register parameter passing. This is necessary to work with all
  65.  * the extra libraries provided as they are all compiled to call MGL
  66.  * functions with arguments in registers whenever possible. You can still
  67.  * use the standard DLL but if you do you will need to re-compile all
  68.  * of the extra libraries with the MGL_DLL #define to change the calling
  69.  * conventions for the MGL functions.
  70.  */
  71.  
  72. #if        defined(MGL_DLL)
  73. #define    MGLAPI    _EXPORT __cdecl
  74. #else
  75. #define    MGLAPI    _EXPORT _PUBAPI
  76. #endif
  77. #define    ASMAPI    _EXPORT __cdecl
  78.  
  79. /* Define a type for integers used in the library. For most environments
  80.  * we simply define it as a normal integer (16 or 32 bits), however for
  81.  * 16 bit Windows it is defined as a 32 bit integer as all the real code
  82.  * lives in a 32 bit DLL that uses 32 bit integers.
  83.  */
  84.  
  85. #ifndef    __M_INT_DEFINED
  86. #if    defined(__WINDOWS16__)
  87. typedef    long            m_int;
  88. typedef unsigned long    m_uint;
  89. #else
  90. typedef int                m_int;
  91. typedef    unsigned int    m_uint;
  92. #endif
  93. #define    __M_INT_DEFINED
  94. #endif
  95.  
  96. /* Define the graphics subsystems available    */
  97.  
  98. typedef enum {
  99.     grDETECT        = -1,    /* Auto detect the graphics subsystem        */
  100.     grNONE            = 0,    /* No graphics hardware detected            */
  101.     grVGA,                    /* Standard VGA                                */
  102.     grVESA,                    /* VESA VBE compliant SuperVGA                */
  103.     grSVGA,                    /* Unaccelerated SuperVGA                    */
  104.     grACCEL,                /* Accelerated SuperVGA                        */
  105.     grDDRAW,                /* Unaccelerated DirectDraw                    */
  106.     grDDRAWACCEL,            /* Accelerated DirectDraw                     */
  107.     grDDRAW3D,                /* 3D Accelerated DirectDraw                 */
  108.     grMAXDRIVER,            /* Maximum driver number                    */
  109.     } MGL_driverType;
  110.  
  111. /* Graphics modes supported    - the only video modes supported by this
  112.  * graphics library are those that support at least 16 colors per pixel.
  113.  */
  114.  
  115. typedef enum {
  116.     /* 16 color VGA video modes */
  117.  
  118.     grVGA_320x200x16,
  119.     grVGA_640x200x16,
  120.     grVGA_640x350x16,
  121.     grVGA_640x400x16,
  122.     grVGA_640x480x16,
  123.     grSVGA_800x600x16,
  124.  
  125.     /* 256 color VGA ModeX video modes */
  126.  
  127.     grVGAX_320x200x256,
  128.     grVGAX_320x240x256,
  129.     grVGAX_320x400x256,
  130.     grVGAX_320x480x256,
  131.  
  132.     /* 256 color VGA video modes */
  133.  
  134.     grVGA_320x200x256,
  135.  
  136.     /* 256 color VGA/SuperVGA video modes */
  137.  
  138.     grSVGA_320x200x256,
  139.     grSVGA_320x240x256,
  140.     grSVGA_320x400x256,
  141.     grSVGA_320x480x256,
  142.     grSVGA_400x300x256,
  143.     grSVGA_512x384x256,
  144.     grSVGA_640x350x256,
  145.     grSVGA_640x400x256,
  146.     grSVGA_640x480x256,
  147.     grSVGA_800x600x256,
  148.     grSVGA_1024x768x256,
  149.     grSVGA_1152x864x256,
  150.     grSVGA_1280x960x256,
  151.     grSVGA_1280x1024x256,
  152.     grSVGA_1600x1200x256,
  153.  
  154.     /* 32,768 color Super VGA video modes */
  155.  
  156.     grSVGA_320x200x32k,
  157.     grSVGA_320x240x32k,
  158.     grSVGA_320x400x32k,
  159.     grSVGA_320x480x32k,
  160.     grSVGA_400x300x32k,
  161.     grSVGA_512x384x32k,
  162.     grSVGA_640x350x32k,
  163.     grSVGA_640x400x32k,
  164.     grSVGA_640x480x32k,
  165.     grSVGA_800x600x32k,
  166.     grSVGA_1024x768x32k,
  167.     grSVGA_1152x864x32k,
  168.     grSVGA_1280x960x32k,
  169.     grSVGA_1280x1024x32k,
  170.     grSVGA_1600x1200x32k,
  171.  
  172.     /* 65,536 color Super VGA video modes */
  173.  
  174.     grSVGA_320x200x64k,
  175.     grSVGA_320x240x64k,
  176.     grSVGA_320x400x64k,
  177.     grSVGA_320x480x64k,
  178.     grSVGA_400x300x64k,
  179.     grSVGA_512x384x64k,
  180.     grSVGA_640x350x64k,
  181.     grSVGA_640x400x64k,
  182.     grSVGA_640x480x64k,
  183.     grSVGA_800x600x64k,
  184.     grSVGA_1024x768x64k,
  185.     grSVGA_1152x864x64k,
  186.     grSVGA_1280x960x64k,
  187.     grSVGA_1280x1024x64k,
  188.     grSVGA_1600x1200x64k,
  189.  
  190.     /* 16 million color, 24 bits per pixel Super VGA video modes */
  191.  
  192.     grSVGA_320x200x16m,
  193.     grSVGA_320x240x16m,
  194.     grSVGA_320x400x16m,
  195.     grSVGA_320x480x16m,
  196.     grSVGA_400x300x16m,
  197.     grSVGA_512x384x16m,
  198.     grSVGA_640x350x16m,
  199.     grSVGA_640x400x16m,
  200.     grSVGA_640x480x16m,
  201.     grSVGA_800x600x16m,
  202.     grSVGA_1024x768x16m,
  203.     grSVGA_1152x864x16m,
  204.     grSVGA_1280x960x16m,
  205.     grSVGA_1280x1024x16m,
  206.     grSVGA_1600x1200x16m,
  207.  
  208.     /* 16 million color, 32 bits per pixel Super VGA video modes */
  209.  
  210.     grSVGA_320x200x4G,
  211.     grSVGA_320x240x4G,
  212.     grSVGA_320x400x4G,
  213.     grSVGA_320x480x4G,
  214.     grSVGA_400x300x4G,
  215.     grSVGA_512x384x4G,
  216.     grSVGA_640x350x4G,
  217.     grSVGA_640x400x4G,
  218.     grSVGA_640x480x4G,
  219.     grSVGA_800x600x4G,
  220.     grSVGA_1024x768x4G,
  221.     grSVGA_1152x864x4G,
  222.     grSVGA_1280x960x4G,
  223.     grSVGA_1280x1024x4G,
  224.     grSVGA_1600x1200x4G,
  225.  
  226.     /* Render into Windowing System DC (Windows, OS/2 PM, X11) */
  227.  
  228.     grWINDOWED,
  229.  
  230.     grMAXMODE,                    /* Maximum mode number                    */
  231.     } MGL_modeType;
  232.  
  233. /* MGL_result() error codes    */
  234.  
  235. typedef enum {
  236.     grOK            = 0,    /* No error                                    */
  237.     grNoInit        = -1,    /* Graphics driver has not been installed    */
  238.     grNotDetected    = -2,    /* Graphics hardware was not detected        */
  239.     grDriverNotFound= -3,    /* Graphics driver file not found            */
  240.     grBadDriver        = -4,    /* File loaded was not a graphics driver    */
  241.     grLoadMem        = -5,    /* Not enough memory to load graphics driver*/
  242.     grInvalidMode    = -6,    /* Invalid graphics mode for selected driver*/
  243.     grError            = -8,    /* General graphics error                    */
  244.     grInvalidName    = -9,    /* Invalid driver name                        */
  245.     grNoMem            = -10,    /* Not enough memory to perform operation    */
  246.     grNoModeSupport    = -11,    /* Select video mode not supported by hard.    */
  247.     grInvalidFont    = -12,    /* Invalid font data                        */
  248.     grBadFontFile    = -13,    /* File loaded was not a font file            */
  249.     grFontNotFound    = -14,    /* Font file was not found                    */
  250.     grOldDriver     = -15,    /* Driver file is an old version            */
  251.     grInvalidDevice    = -16,    /* Invalid device for selected operation    */
  252.     grInvalidDC        = -17,    /* Invalid device context                    */
  253.     grInvalidCursor    = -18,    /* Invalid cursor file                        */
  254.     grCursorNotFound= -19,    /* Cursor file was not found                */
  255.     grInvalidIcon    = -20,    /* Invalid icon file                        */
  256.     grIconNotFound    = -21,    /* Icon file was not found                    */
  257.     grInvalidBitmap = -22,    /* Invalid bitmap file                        */
  258.     grBitmapNotFound= -23,    /* Bitmap file was not found                */
  259.     grZbufferTooBig    = -24,    /* Zbuffer allocation is too large            */
  260.     grNewFontFile    = -25,    /* Only Windows 2.x font files supported    */
  261.     grNoDoubleBuff  = -26,    /* Double buffering is not available        */
  262.     grNoHardwareBlt    = -28,    /* No hardware bitBlt for OffscreenDC        */
  263.     grNoOffscreenMem= -29,    /* No available offscreen memory            */
  264.     grInvalidPF        = -30,    /* Invalid pixel format for memory DC        */
  265.  
  266.     grLastError        = -31,    /* Last error number in list                */
  267.     } MGL_errorType;
  268.  
  269. #define    MGL_CLIPON        true
  270. #define    MGL_CLIPOFF        false
  271.  
  272. /* Color mapped modes */
  273.  
  274. typedef enum {
  275.     MGL_CMAP_MODE,                    /* Normal Color mapped mode     */
  276.     MGL_DITHER_RGB_MODE,            /* 24 bit RGB halftone dithered    */
  277.     } MGL_colorModes;
  278.  
  279. /* Standard colors - this is the standard set of colors for the IBM PC. The
  280.  * default palette will have been programmed to contain these values when a
  281.  * graphics modes is started. If the palette has been changed, they will
  282.  * not correspond to the actual colors on the screen. Under a Windowing
  283.  * manage environment these colors will also not be setup by default.
  284.  */
  285.  
  286. enum MGL_COLORS {
  287.     MGL_BLACK,                        /* dark colors    */
  288.     MGL_BLUE,
  289.     MGL_GREEN,
  290.     MGL_CYAN,
  291.     MGL_RED,
  292.     MGL_MAGENTA,
  293.     MGL_BROWN,
  294.     MGL_LIGHTGRAY,
  295.     MGL_DARKGRAY,                    /* light colors    */
  296.     MGL_LIGHTBLUE,
  297.     MGL_LIGHTGREEN,
  298.     MGL_LIGHTCYAN,
  299.     MGL_LIGHTRED,
  300.     MGL_LIGHTMAGENTA,
  301.     MGL_YELLOW,
  302.     MGL_WHITE,
  303.     };
  304.  
  305. /* Windows standard color indices for 256 color bitmaps. 8,9,246,247 are
  306.  * reserved and you should not count on these colors always being the
  307.  * same. For 16 color bitmaps, colors 248-255 map to colors 8-15.
  308.  */
  309.  
  310. enum MGL_WIN_COLORS {
  311.     MGL_WIN_BLACK             = 0,
  312.     MGL_WIN_DARKRED            = 1,
  313.     MGL_WIN_DARKGREEN        = 2,
  314.     MGL_WIN_DARKYELLOW        = 3,
  315.     MGL_WIN_DARKBLUE        = 4,
  316.     MGL_WIN_DARKMAGENTA        = 5,
  317.     MGL_WIN_DARKCYAN        = 6,
  318.     MGL_WIN_LIGHTGRAY        = 7,
  319.     MGL_WIN_TURQUOISE        = 8,        /* Reserved; dont count on this    */
  320.     MGL_WIN_SKYBLUE            = 9,        /* Reserved; dont count on this    */
  321.     MGL_WIN_CREAM            = 246,        /* Reserved; dont count on this    */
  322.     MGL_WIN_MEDIUMGRAY        = 247,        /* Reserved; dont count on this    */
  323.     MGL_WIN_DARKGRAY        = 248,
  324.     MGL_WIN_LIGHTRED        = 249,
  325.     MGL_WIN_LIGHTGREEN        = 250,
  326.     MGL_WIN_LIGHTYELLOW        = 251,
  327.     MGL_WIN_LIGHTBLUE        = 252,
  328.     MGL_WIN_LIGHTMAGENTA    = 253,
  329.     MGL_WIN_LIGHTCYAN        = 254,
  330.     MGL_WIN_WHITE             = 255,
  331.     };
  332.  
  333. typedef enum {
  334.     MGL_MARKER_SQUARE,
  335.     MGL_MARKER_CIRCLE,
  336.     MGL_MARKER_X,
  337.     } MGL_markerStyleType;
  338.  
  339. typedef enum {                        /* Write mode operators                */
  340.     MGL_REPLACE_MODE,                /* Replace mode                        */
  341.     MGL_AND_MODE,                    /* AND mode                            */
  342.     MGL_OR_MODE,                    /* OR mode                            */
  343.     MGL_XOR_MODE,                    /* XOR mode                            */
  344.     } MGL_writeModeType;
  345.  
  346. typedef enum {
  347.     MGL_BITMAP_SOLID,
  348.     MGL_BITMAP_OPAQUE,
  349.     MGL_BITMAP_TRANSPARENT,
  350.     MGL_PIXMAP,
  351.     } MGL_fillStyleType;
  352.  
  353. typedef enum {
  354.     MGL_LINE_PENSTYLE,                /* Line drawn in current pen style    */
  355.     MGL_LINE_STIPPLE,                /* Line drawn with current stipple    */
  356.     } MGL_lineStyleType;
  357.  
  358. typedef enum {
  359.     MGL_CONVEX_POLYGON,                /* Monotone vertical polygon        */
  360.     MGL_COMPLEX_POLYGON,            /* Non-Simple polygons                */
  361.     MGL_AUTO_POLYGON,                /* Auto detect the polygon type        */
  362.     } MGL_polygonType;
  363.  
  364. /* Text manipulation defines */
  365.  
  366. typedef enum {
  367.     MGL_LEFT_TEXT        =    0,        /* Justify from left                */
  368.     MGL_TOP_TEXT        =    0,        /* Justify from top                    */
  369.     MGL_CENTER_TEXT        =    1,        /* Center the text                    */
  370.     MGL_RIGHT_TEXT        =    2,        /* Justify from right                */
  371.     MGL_BOTTOM_TEXT        =    2,        /* Justify from bottom                */
  372.     MGL_BASELINE_TEXT    =    3,        /* Justify from the baseline        */
  373.     } MGL_textJustType;
  374.  
  375. typedef enum {
  376.     MGL_LEFT_DIR        =    0,        /* Text goes to left                */
  377.     MGL_UP_DIR            =    1,        /* Text goes up                        */
  378.     MGL_RIGHT_DIR        =    2,        /* Text goes right                    */
  379.     MGL_DOWN_DIR        =    3,        /* Text goes down                    */
  380.     } MGL_textDirType;
  381.  
  382. /* Font types */
  383.  
  384. typedef enum {
  385.     MGL_VECTORFONT = 1,                /* Vector font                        */
  386.     MGL_FIXEDFONT,                    /* Fixed width bitmap font            */
  387.     MGL_PROPFONT,                    /* Proportional width bitmap font    */
  388.     } MGL_fontType;
  389.  
  390. /* Palette rotation directions */
  391.  
  392. typedef enum {
  393.     MGL_ROTATE_UP,                    /* Rotate the palette values up        */
  394.     MGL_ROTATE_DOWN,                /* Rotate the palette values down    */
  395.     } MGL_palRotateType;
  396.  
  397. /* Border drawing routine styles */
  398.  
  399. typedef enum {
  400.     MGL_BDR_INSET,                    /* Interior is inset into screen    */
  401.     MGL_BDR_OUTSET,                    /* Interior is outset from screen    */
  402.     MGL_BDR_OUTLINE,                /* Border is 3d outline                */
  403.     } MGL_bdrStyleType;
  404.  
  405. /* Standard display driver names     */
  406.  
  407. #define    MGL_VGA4NAME        "VGA4.DRV"        /* Standard VGA drivers            */
  408. #define    MGL_VGA8NAME        "VGA8.DRV"
  409. #define    MGL_VGAXNAME        "VGAX.DRV"
  410.  
  411. #define    MGL_SVGA4NAME        "SVGA4.DRV"        /* Generic SuperVGA drivers        */
  412. #define    MGL_SVGA8NAME        "SVGA8.DRV"
  413. #define    MGL_SVGA16NAME        "SVGA16.DRV"
  414. #define    MGL_SVGA24NAME        "SVGA24.DRV"
  415. #define    MGL_SVGA32NAME        "SVGA32.DRV"
  416.  
  417. #define    MGL_LINEAR8NAME        "LINEAR8.DRV"    /* Linear framebuffer drivers    */
  418. #define    MGL_LINEAR16NAME    "LINEAR16.DRV"
  419. #define    MGL_LINEAR24NAME    "LINEAR24.DRV"
  420. #define    MGL_LINEAR32NAME    "LINEAR32.DRV"
  421.  
  422. #define    MGL_ACCEL8NAME        "ACCEL8.DRV"    /* VBE/AF Accelerated drivers    */
  423. #define    MGL_ACCEL16NAME        "ACCEL16.DRV"
  424. #define    MGL_ACCEL24NAME        "ACCEL24.DRV"
  425. #define    MGL_ACCEL32NAME        "ACCEL32.DRV"
  426.  
  427. #define    MGL_DDRAW8NAME        "DDRAW8.DRV"    /* DirectDraw drivers            */
  428. #define    MGL_DDRAW16NAME        "DDRAW16.DRV"
  429. #define    MGL_DDRAW24NAME        "DDRAW24.DRV"
  430. #define    MGL_DDRAW32NAME        "DDRAW32.DRV"
  431.  
  432. /* Standard memory driver names     */
  433.  
  434. #define    MGL_PACKED1NAME        "PACK1.DRV"
  435. #define    MGL_PACKED4NAME        "PACK4.DRV"
  436. #define    MGL_PACKED8NAME        "PACK8.DRV"
  437. #define    MGL_PACKED16NAME    "PACK16.DRV"
  438. #define    MGL_PACKED24NAME    "PACK24.DRV"
  439. #define    MGL_PACKED32NAME    "PACK32.DRV"
  440.  
  441. /* Standard bitmap names    */
  442.  
  443. #define    MGL_EMPTY_FILL    _MGL_getEmptyPat()
  444. #define    MGL_GRAY_FILL    _MGL_getGrayPat()
  445. #define    MGL_SOLID_FILL    _MGL_getSolidPat()
  446.  
  447. /* Event message masks for keyDown events */
  448.  
  449. #define    EVT_ASCIIMASK    0x00FF    /* Ascii code of key pressed            */
  450. #define    EVT_SCANMASK    0xFF00    /* Scan code of key pressed                */
  451. #define    EVT_COUNTMASK    0x7FFF0000L        /* Count for KEYREPEAT's        */
  452.  
  453. #define    EVT_asciiCode(m)    ( (uchar) (m & EVT_ASCIIMASK) )
  454. #define    EVT_scanCode(m)        ( (uchar) ( (m & EVT_SCANMASK) >> 8 ) )
  455. #define    EVT_repeatCount(m)    ( (short) ( (m & EVT_COUNTMASK) >> 16 ) )
  456.  
  457. /* Event message masks for mouse events */
  458.  
  459. #define    EVT_LEFTBMASK    0x0001    /* Left button is bit 0                    */
  460. #define    EVT_RIGHTBMASK    0x0004    /* Right button is bit 1                */
  461. #define    EVT_BOTHBMASK    0x0005    /* Both left and right together            */
  462. #define    EVT_ALLBMASK    0x0005    /* All buttons pressed                    */
  463.  
  464. /* Modifier masks */
  465.  
  466. #define    EVT_LEFTBUT        0x0001    /* Set if left button was down            */
  467. #define    EVT_RIGHTBUT    0x0002    /* Set if right button was down            */
  468. #define    EVT_RIGHTSHIFT    0x0008    /* Set if right shift down                */
  469. #define    EVT_LEFTSHIFT    0x0010    /* Set if left shift down                */
  470. #define    EVT_CTRLSTATE    0x0020    /* Set if ctrl key down                    */
  471. #define    EVT_ALTSTATE    0x0040    /* Set if alt key down                    */
  472. #define    EVT_LEFTCTRL    0x0080    /* Set if left ctrl key down            */
  473. #define    EVT_LEFTALT        0x0100    /* Set if left alt key down                */
  474. #define    EVT_SHIFTKEY    0x0018    /* Any shift key                        */
  475.  
  476. /* Event codes */
  477.  
  478. #define    EVT_NULLEVT        0x0000    /* A null event                            */
  479. #define    EVT_KEYDOWN        0x0001    /* Key down event                        */
  480. #define    EVT_KEYREPEAT    0x0002    /* Key repeat event                        */
  481. #define    EVT_KEYUP        0x0004    /* Key up event                            */
  482. #define    EVT_MOUSEDOWN    0x0008    /* Mouse down event                        */
  483. #define    EVT_MOUSEUP        0x0010    /* Mouse up event                        */
  484. #define    EVT_MOUSEMOVE    0x0020    /* Mouse movement event                    */
  485. #define    EVT_TIMERTICK    0x0040    /* Timer tick event                        */
  486. #define    EVT_USEREVT        0x0080    /* First user event                        */
  487.  
  488. /* Event code masks */
  489.  
  490. #define    EVT_KEYEVT        (EVT_KEYDOWN | EVT_KEYREPEAT | EVT_KEYUP)
  491. #define    EVT_MOUSEEVT    (EVT_MOUSEDOWN | EVT_MOUSEUP | EVT_MOUSEMOVE)
  492. #define    EVT_MOUSECLICK    (EVT_MOUSEDOWN | EVT_MOUSEUP)
  493. #define    EVT_EVERYEVT    0xFFFF
  494.  
  495. /* Suspend Application callback type codes. This callback is called
  496.  * when the user presses one of the corresponding keys indicating that
  497.  * they wish to change the active application. The MGL will catch these
  498.  * events and if you have registered a callback, will call the callback to
  499.  * save the state of the application so that it can be properly restored
  500.  * when the user switches back to your application. The MGL takes care of
  501.  * all the details about saving and restoring the state of the hardware,
  502.  * and all your application needs to do is save its own state so that you can
  503.  * re-draw the application screen upon re-activation.
  504.  *
  505.  * NOTE: Your application suspend callback may get called twice with the
  506.  *         MGL_DEACTIVATE flag in order to test whether the switch should
  507.  *         occur (under both DirectDraw and WinDirect fullscreen modes).
  508.  *
  509.  * NOTE: When your callback is called with the MGL_DEACTIVATE flag, you
  510.  *         cannot assume that you have access to the display memory surfaces
  511.  *         as they may have been lost by the time your callback has been called. 
  512.  */
  513.  
  514. #define    MGL_DEACTIVATE    0x0001    /* Application losing active focus        */
  515. #define    MGL_REACTIVATE    0x0002    /* Application regaining active focus    */
  516.  
  517. /* Return codes from the suspend application callback. The normal value
  518.  * to be returned is MGL_SUSPEND_APP and this will cause the app to be
  519.  * suspended while back in GDI mode until the app is re-activated again
  520.  * by the user.
  521.  *
  522.  * MGL_NO_DEACTIVATE signals to WinDirect that the application does not want
  523.  * to allow switching to occur, and the switch request will be ignored and
  524.  * the app will remain in fullscreen mode.
  525.  *
  526.  * MGL_NO_SUSPEND_APP can be used to tell WinDirect to switch back to the
  527.  * desktop, but not to suspend the application. This must be used with
  528.  * care as the suspend application callback is then responsible for setting
  529.  * a flag in the application that will stop the application from doing any
  530.  * rendering to the framebuffer while the application is in GDI mode. This
  531.  * return value is useful for games that need to maintain network
  532.  * connectivity while the user has temporarily switched back to GDI mode.
  533.  */
  534.  
  535. #define    MGL_NO_DEACTIVATE    0    /* Dont allow app to be deactivated     */
  536. #define    MGL_SUSPEND_APP        1    /* Suspend application until restored    */
  537. #define    MGL_NO_SUSPEND_APP    2    /* Dont suspend, but allow switch        */
  538.  
  539. /* Here we define the structures used to represent points and rectangles */
  540.  
  541. typedef struct {
  542.     m_int    x,y;
  543.     } point_t;
  544.  
  545. typedef    struct {
  546.     m_int    left;
  547.     m_int    top;
  548.     m_int    right;
  549.     m_int    bottom;
  550.     } rect_t;
  551.  
  552. /* All colors are represented as longs by the library. This allows
  553.  * code to work correctly with up to 24 bit color device drivers. The
  554.  * device drivers themselves expect the color to be a color index if in
  555.  * a color mapped mode, or a 15/16/24 bit RGB tuple in a hicolor or truecolor
  556.  * mode. You can use the appropriate routines to pack and unpack
  557.  * colors into the color_t format.
  558.  */
  559.  
  560. typedef    ulong        color_t;
  561.  
  562. /* Define the value used to clear the software ZBuffer. The MGL always uses
  563.  * a > operator for the z compare, and the smallest value is 0.
  564.  */
  565.  
  566. #define    MGL_ZCLEARVAL    0
  567.  
  568. /* Structures for passing vertex information to polygon rendering routines.
  569.  * All fixed point coordinates are passed in 16.16 signed fixed point
  570.  * format, while zbuffer coordinates are passed in 4.28 signed fixed point
  571.  * format. The sign bit is used purely for overflow and arithmetic
  572.  * internally, and all user passed zbuffer values should be greater than
  573.  * 0. All shaded rendering routines either take a color index in 8.16 fixed
  574.  * point format (range 0-255.9) or separate RGB components in 8.16 fixed
  575.  * point format (range 0-255.9).
  576.  */
  577.  
  578. #ifdef    __FX_FIXED_H
  579. #define    fix32_t            FXFixed
  580. #else
  581. typedef    long            fix32_t;
  582. #endif
  583. typedef    fix32_t            fxcolor_t;
  584. typedef    long            zfix32_t;
  585.  
  586. typedef    struct {
  587.     fix32_t x,y;
  588.     } fxpoint_t;
  589.  
  590. typedef    struct {
  591.     fxcolor_t    r,g,b;
  592.     } fxrgb_t;
  593.  
  594. typedef struct {
  595.     fix32_t        w,s,t;
  596.     } fxtex_t;
  597.  
  598. typedef    struct {
  599.     fxcolor_t    c;
  600.     fxpoint_t   p;
  601.     } fxpointc_t;
  602.  
  603. typedef    struct {
  604.     fxrgb_t        c;
  605.     fxpoint_t    p;
  606.     } fxpointrgb_t;
  607.  
  608. typedef    struct {
  609.     fxpoint_t    p;
  610.     zfix32_t    z;
  611.     } fxpointz_t;
  612.  
  613. typedef    struct {
  614.     fxcolor_t    c;
  615.     fxpoint_t    p;
  616.     zfix32_t    z;
  617.     } fxpointcz_t;
  618.  
  619. typedef    struct {
  620.     fxrgb_t        c;
  621.     fxpoint_t    p;
  622.     zfix32_t    z;
  623.     } fxpointrgbz_t;
  624.  
  625. /* Macros to convert between integer and 32 bit fixed point format */
  626.  
  627. #define    MGL_FIX_1            0x10000L
  628. #define    MGL_FIX_2            0x20000L
  629. #define    MGL_FIX_HALF        0x08000L
  630. #define    MGL_TOFIX(i)        ((long)(i) << 16)
  631. #define MGL_FIXTOINT(f)        ((m_int)((f) >> 16))
  632. #define    MGL_FIXROUND(f)     ((m_int)(((f) + MGL_FIX_HALF) >> 16))
  633.  
  634. #define    MGL_ZFIX_1            0x10000000L
  635. #define    MGL_ZFIX_HALF        0x08000000L
  636. #define MGL_FIXTOZ(i)        ((i) << 12)
  637. #define    MGL_ZTOFIX(i)        ((i) >> 12)
  638. #define    MGL_TOZFIX(i)        ((long)(i) << 28)
  639. #define MGL_ZFIXTOINT(f)    ((m_int)((f) >> 28))
  640. #define    MGL_ZFIXROUND(f)     ((m_int)(((f) + MGL_ZFIX_HALF) >> 28))
  641.  
  642. /* Region structure */
  643.  
  644. #ifdef    BUILD_MGL
  645. struct _span_t;
  646. typedef    struct _span_t    span_t;
  647. #else
  648. typedef void        span_t;
  649. #endif
  650.  
  651. typedef struct {
  652.     rect_t      rect;            /* Bounding rectangle for region        */
  653.     span_t        *spans;            /* Start of span list for region        */
  654.     } region_t;
  655.  
  656. /* Palette entry structure    */
  657.  
  658. typedef struct {
  659.     uchar    blue;                /* Blue component of color                */
  660.     uchar    green;                /* Green component of color                */
  661.     uchar    red;                /* Blue component of color                */
  662.     uchar    alpha;                /* Alpha or alignment byte                */
  663.     } palette_t;
  664.  
  665. /* Maximum value for each palette entry component */
  666.  
  667. #define    PALMAX        255                /* Max value for palette components    */
  668.  
  669. /* Pixel format structure */
  670.  
  671. typedef struct {
  672.     uchar    redMask,greenMask;        /* Mask values for pixels            */
  673.     uchar    blueMask,rsvdMask;
  674.     m_int    redPos,redAdjust;        /* Red position and adjustment        */
  675.     m_int    greenPos,greenAdjust;    /* Green position and adjustment    */
  676.     m_int    bluePos,blueAdjust;        /* Blue position and adjustment        */
  677.     m_int    rsvdPos,rsvdAdjust;        /* Reserved position and adjustment */
  678.     } pixel_format_t;
  679.  
  680. /* Structure to hold arc coordinate information */
  681.  
  682. typedef struct {
  683.     m_int    x,y;                    /* Centre point of the arc            */
  684.     m_int    startX,startY;            /* Starting point on arc            */
  685.     m_int    endX,endY;                /* Ending point on arc                */
  686.     } arc_coords_t;
  687.  
  688. /* Mouse cursor structure */
  689.  
  690. typedef    struct {
  691.     ulong        xorMask[32];
  692.     ulong        andMask[32];
  693.     m_int        xHotSpot;
  694.     m_int        yHotSpot;
  695.     } cursor_t;
  696.  
  697. /* Bitmap structure - always packed pixel DIB format */
  698.  
  699. typedef struct {
  700.     m_int        width;                /* Width of bitmap in pixels        */
  701.     m_int        height;                /* Height of bitmap in pixels        */
  702.     m_int        bitsPerPixel;        /* Pixel width                        */
  703.     m_int        bytesPerLine;        /* Bytes per line value for surface */
  704.     uchar        *surface;            /* Pointer to bitmap surface        */
  705.     palette_t    *pal;                /* Palette (NULL if not loaded)        */
  706.     pixel_format_t *pf;                /* Pixel format (NULL if none)        */
  707.  
  708.     /* ... palette, pixel format and bitmap data are store contiguously */
  709.     } bitmap_t;
  710.  
  711. /* Icon structure - can be 32x23, 64x64 or in fact any size */
  712.  
  713. typedef struct {
  714.     m_int        byteWidth;            /* Byte with for AND mask            */
  715.     uchar        *andMask;            /* Hold punch mask for icon            */
  716.     bitmap_t    xorMask;            /* XOR mask for the icon            */
  717.  
  718.     /* ... AND mask and bitmap structure are stored contiguously */
  719.     } icon_t;
  720.  
  721. /* Default cursor name */
  722.  
  723. #define    MGL_DEF_CURSOR        _MGL_getDefCursor()
  724.  
  725. /* Generic Font structure */
  726.  
  727. #define    _MGL_FNAMESIZE        58
  728.  
  729. typedef struct {
  730.     char            name[_MGL_FNAMESIZE];/* Name of the font            */
  731.     short            fontType;        /* Type of font                        */
  732.     short            maxWidth;        /* Maximum character width            */
  733.     short            maxKern;        /* Maximum character kern            */
  734.     short            fontWidth;        /* Font width                        */
  735.     short            fontHeight;        /* Font height                        */
  736.     short            ascent;            /* Font ascent value                */
  737.     short            descent;        /* Font descent value                */
  738.     short            leading;        /* Font leading value                */
  739.     } font_t;
  740.  
  741. /* Character and font metrics structure */
  742.  
  743. typedef struct {
  744.     m_int            width;            /* Width of character or font        */
  745.     m_int            fontWidth;        /* Character width (tightest fit)    */
  746.     m_int            fontHeight;        /* Height of the font                */
  747.     m_int            ascent;            /* Ascent value                        */
  748.     m_int            descent;        /* Descent value                    */
  749.     m_int            leading;        /* Leading value                    */
  750.     m_int            kern;            /* Kern value                        */
  751.     } metrics_t;
  752.  
  753. /* Text settings structure */
  754.  
  755. typedef struct {
  756.     m_int            horizJust;        /* Horizontal justfication            */
  757.     m_int            vertJust;        /* Vertical justification            */
  758.     m_int            dir;            /* Text drawing direction            */
  759.     m_int             szNumerx;        /* Text x size numerator            */
  760.     m_int             szNumery;        /* Text y size numerator            */
  761.     m_int            szDenomx;        /* Text x size denominator            */
  762.     m_int            szDenomy;        /* Text y size denominator            */
  763.     m_int            spaceExtra;        /* Space extra term                    */
  764.     font_t             *font;            /* Currently selected font            */
  765.     } text_settings_t;
  766.  
  767. /* Macros to access the (left,top) and (right,bottom) points of a
  768.  * rectangle.
  769.  */
  770.  
  771. #define    MGL_leftTop(r)        (((point_t *) &(r))[0])
  772. #define    MGL_rightBottom(r)    (((point_t *) &(r))[1])
  773.  
  774. typedef uchar    pattern_t[8];
  775. typedef color_t    pixpattern_t[8][8];
  776.  
  777. /* Attributes structure */
  778.  
  779. typedef struct {
  780.     color_t            color;            /* Foreground color                    */
  781.     color_t            backColor;        /* Background color                    */
  782.     m_int            colorMode;        /* Current color mode                */
  783.     m_int            markerSize;        /* Size of markers in pixels        */
  784.     m_int            markerStyle;    /* Style of markers                    */
  785.     color_t            markerColor;    /* Color to draw markers in            */
  786.     color_t            bdrBright;        /* Border bright color                */
  787.     color_t            bdrDark;        /* Border dark color                */
  788.     point_t            CP;                /* Graphics pen position            */
  789.     m_int            writeMode;        /* Scan conversion write mode op.    */
  790.     m_int            penStyle;        /* Pen style                        */
  791.     m_int            penHeight;        /* Height of pen                    */
  792.     m_int            penWidth;        /* Width of pen                        */
  793.     pattern_t        penPat;            /* Pattern for pen                    */
  794.     pixpattern_t    penPixPat;        /* Pixmap pattern for pen            */
  795.     m_int            lineStyle;        /* Line style                        */
  796.     ushort            lineStipple;    /* Line stipple                        */
  797.     m_uint            stippleCount;    /* Current line stipple count        */
  798.     rect_t            viewPort;        /* Viewport dimensions                */
  799.     point_t            viewPortOrg;    /* Logical viewport origin            */
  800.     rect_t            clipRect;        /* Clipping rectangle dimensions    */
  801.     m_int            clip;            /* Is clipping on?                    */
  802.     m_int            polyType;        /* Polygon drawing type                */
  803.     text_settings_t    ts;                /* Text drawing attributes            */
  804.     } attributes_t;
  805.  
  806. /* Mode specific format information. This structrure can be used by
  807.  * the device driver to build tables of values for all supported modes
  808.  */
  809.  
  810. typedef struct {
  811.     m_int    xRes;            /* Device x resolution - 1                    */
  812.     m_int    yRes;            /* Device y resolution - 1                    */
  813.     m_int    bitsPerPixel;    /* Number of bits per pixel                    */
  814.     m_int    numberOfPlanes;    /* Number of planes in image                */
  815.     color_t    maxColor;        /* Maximum number of colors - 1                */
  816.     m_int    maxPage;        /* Maximum number of video pages - 1        */
  817.     m_int    bytesPerLine;    /* Number of bytes in a line                */
  818.     m_int    aspectRatio;    /* Mode aspect ratio (horiz/vert * 1000)    */
  819.     long    pageSize;        /* Number of bytes in a page                */
  820.     m_int    scratch1;        /* Scratch pad value 1                        */
  821.     m_int    scratch2;        /* Scratch pad value 2                        */
  822.     char    redMaskSize;            /* Size of direct color red mask    */
  823.     char    redFieldPosition;       /* Bit posn of lsb of red mask      */
  824.     char    greenMaskSize;          /* Size of direct color green mask  */
  825.     char    greenFieldPosition;     /* Bit posn of lsb of green mask    */
  826.     char    blueMaskSize;           /* Size of direct color blue mask   */
  827.     char    blueFieldPosition;      /* Bit posn of lsb of blue mask     */
  828.     char    rsvdMaskSize;            /* Size of reserved mask            */
  829.     char    rsvdFieldPosition;        /* Bit posn of reserved mask        */
  830.     } gmode_t;
  831.  
  832. /* Public Device Context Structure. The 'surface' member along with the
  833.  * gmode_t information block, provides direct access to the active
  834.  * display surface for user applications. The MGL virtualises the surface
  835.  * in SuperVGA modes that dont have a real linear framebuffer.
  836.  */
  837.  
  838. typedef struct {
  839.     attributes_t a;            /* Active device attributes                    */
  840.     void    *surface;        /* Pointer to active device surface            */
  841.     void    *zbuffer;        /* Pointer to Z-buffer if allocated            */
  842.     m_int    zbits;            /* Bits per zbuffer element                    */
  843.     m_int   zwidth;            /* Width of the zbuffer in pixels            */
  844.     gmode_t    mi;                /* Mode specific information block            */
  845.     pixel_format_t pf;        /* Current pixel format for device context    */
  846.     color_t    *colorTab;        /* Color lookup table cache                    */
  847.     color_t    *shadeTab;        /* Currently active shade table                */
  848.     m_int    bankOffset;        /* Offset of starting bank number            */
  849.  
  850.     /* Remainder of Device Context structure is private and internal    */
  851.     } publicDevCtx_t;
  852.  
  853. #ifndef    BUILD_MGL
  854. typedef publicDevCtx_t            MGLDC;
  855. #else
  856. struct internalDevCtx_t;
  857. typedef struct internalDevCtx_t    MGLDC;
  858. #endif
  859.  
  860. typedef    struct {
  861.     ulong        which;            /* Which window for window manager code    */
  862.     m_uint        what;            /* Event code                            */
  863.     ulong        when;            /* Clock ticks since midnight            */
  864.     m_int        where_x;        /* Mouse location                         */
  865.     m_int        where_y;
  866.     ulong        message;        /* Event specific message                */
  867.     ulong        modifiers;        /* Modifier flags                        */
  868.     m_int        next;           /* Next event in queue                    */
  869.     m_int        prev;            /* Previous event in queue                */
  870.     } event_t;
  871.  
  872. /* Structure containing file I/O functions allowing the user application to
  873.  * completely replace the MGL's file I/O functions with their own. This
  874.  * allows the app to store all MGL related files in a single large file,
  875.  * with encryption or compression is desired. By default normal file I/O
  876.  * functions will be used.
  877.  */
  878.  
  879. typedef struct {
  880.     FILE *    (*fopen)(const char *filename,const char *mode);
  881.     int     (*fclose)(FILE *f);
  882.     int     (*fseek)(FILE *f,long offset,int whence);
  883.     long     (*ftell)(FILE *f);
  884.     size_t    (*fread)(void *ptr,size_t size,size_t n,FILE *f);
  885.     size_t    (*fwrite)(const void *ptr,size_t size,size_t n,FILE *f);
  886.     } fileio_t;
  887.  
  888. /* Define the flags for the types of direct surface access provided */
  889.  
  890. #define    MGL_NO_ACCESS        0x0        /* Surface cannot be accessed        */
  891. #define    MGL_VIRTUAL_ACCESS    0x1        /* Surface is virtualised             */
  892. #define    MGL_LINEAR_ACCESS    0x2        /* Surface can be linearly accessed    */
  893. #define    MGL_SURFACE_FLAGS    0x3
  894.  
  895. /* Define the flags for the types of direct zbuffer access provided */
  896.  
  897. #define    MGL_NO_ZACCESS        0x0        /* Zbuffer cannot be accessed        */
  898. #define    MGL_VIRTUAL_ZACCESS    0x4        /* Zbuffer is virtualised in         */
  899. #define    MGL_LINEAR_ZACCESS    0x8        /* Zbuffer can be linearly accessed    */
  900. #define    MGL_ZBUFFER_FLAGS    0xC
  901.  
  902. /* Define the flags for the types of hardware acceleration supported by
  903.  * the device context. This will allow the application to tailor the use of
  904.  * MGL functions depending upon whether specific hardware support is
  905.  * available. Hence applications can use specialised software rendering
  906.  * support if the desired hardware support is not available.
  907.  *
  908.  * NOTE: If the hardware flags are not MGL_HW_NONE, you *must* call
  909.  *         the MGL_beginDirectAccess() and MGL_endDirectAccess() functions
  910.  *         before and after any custom code that does direct framebuffer
  911.  *         rendering!!
  912.  *
  913.  *         This is not necessary for non-accelerated device context, so you
  914.  *         might want to optimise these calls out if there is no hardware
  915.  *         acceleration support.
  916.  */
  917.  
  918. #define    MGL_HW_NONE            0x0000    /* No hardware acceleration            */
  919. #define    MGL_HW_LINE            0x0010    /* Hardware line drawing            */
  920. #define    MGL_HW_STIPPLE_LINE    0x0020    /* Hardware stippled line drawing    */
  921. #define    MGL_HW_POLY            0x0040    /* Hardware polygon filling            */
  922. #define    MGL_HW_RECT            0x0080    /* Hardware rectangle fill            */
  923. #define    MGL_HW_PATT_RECT    0x0100    /* Hardware pattern rectangle fill    */
  924. #define    MGL_HW_CLRPATT_RECT    0x0200    /* Hardware color pattern fill        */
  925. #define    MGL_HW_SCR_BLT        0x0400    /* Hardware screen/screen bitBlt    */
  926. #define    MGL_HW_SRCTRANS_BLT    0x0800    /* Hardware source transparent blt    */
  927. #define    MGL_HW_DSTTRANS_BLT    0x1000    /* Hardware dest. transparent blt    */
  928. #define    MGL_HW_MONO_BLT        0x2000    /* Hardware monochrome blt            */
  929. #define    MGL_HW_CLIP            0x4000    /* Hardware clipping                */
  930. #define    MGL_HW_FLAGS        0xFFF0
  931.  
  932. #ifdef    __cplusplus
  933. extern "C" {            /* Use "C" linkage when in C++ mode    */
  934. #endif
  935.  
  936. /*------------------------- Function Prototypes ---------------------------*/
  937.  
  938. /*---------------------------------------------------------------------------
  939.  * Routines bound to a specific device context. These routines all take
  940.  * an MGLDC as a parmeter for the context to work with and hence dont work
  941.  * with the current context. If however the context passed is the currently
  942.  * active context, all changes to that context are reflected in the
  943.  * currently active context as well.
  944.  *-------------------------------------------------------------------------*/
  945.  
  946. /* Environment detection and initialisation */
  947.  
  948. m_int     MGLAPI MGL_registerDriver(const char *name,void *driver);
  949. void    MGLAPI MGL_unregisterAllDrivers(void);
  950. void    MGLAPI MGL_registerAllDispDrivers(bool useLinear,bool useDirectDraw,bool useWinDirect);
  951. void    MGLAPI MGL_registerAllMemDrivers(void);
  952. void     MGLAPI MGL_detectGraph(m_int *driver,m_int *mode);
  953. uchar *    MGLAPI MGL_availableModes(void);
  954. m_int    MGLAPI MGL_availablePages(m_int mode);
  955. m_int    MGLAPI MGL_modeResolution(m_int mode,m_int *xRes,m_int *yRes,m_int *bitsPerPixel);
  956. bool    MGLAPI MGL_isDisplayDC(MGLDC *dc);
  957. bool    MGLAPI MGL_isWindowedDC(MGLDC *dc);
  958. bool    MGLAPI MGL_isMemoryDC(MGLDC *dc);
  959. void     MGLAPI MGL_exit(void);
  960. void     MGLAPI MGL_setBufSize(unsigned size);
  961. void    MGLAPI MGL_fatalError(const char *msg);
  962. m_int     MGLAPI MGL_result(void);
  963. void    MGLAPI MGL_setResult(m_int result);
  964. const char * MGLAPI MGL_errorMsg(m_int err);
  965. const char * MGLAPI MGL_modeName(m_int mode);
  966. const char * MGLAPI MGL_modeDriverName(m_int mode);
  967. const char * MGLAPI MGL_driverName(m_int driver);
  968. m_int    MGLAPI MGL_getDriver(MGLDC *dc);
  969. m_int    MGLAPI MGL_getMode(MGLDC *dc);
  970. m_int    MGLAPI MGL_surfaceAccessType(MGLDC *dc);
  971. m_int    MGLAPI MGL_zbufferAccessType(MGLDC *dc);
  972. long    MGLAPI MGL_getHardwareFlags(MGLDC *dc);
  973. void     MGLAPI MGL_defaultAttributes(MGLDC *dc);
  974. void     MGLAPI MGL_makeSubDC(MGLDC *dc,m_int left,m_int top,m_int right,m_int bottom);
  975.  
  976. /* Viewport and clip rectangle manipulation bound to a specific DC */
  977.  
  978. void     MGLAPI MGL_setViewportDC(MGLDC *dc,rect_t view);
  979. void    MGLAPI MGL_setRelViewportDC(MGLDC *dc,rect_t view);
  980. void     MGLAPI MGL_getViewportDC(MGLDC *dc,rect_t *view);
  981. void     MGLAPI MGL_setViewportOrgDC(MGLDC *dc,point_t org);
  982. void    MGLAPI MGL_getViewportOrgDC(MGLDC *dc,point_t *org);
  983. void    MGLAPI MGL_globalToLocalDC(MGLDC *dc,point_t *p);
  984. void    MGLAPI MGL_localToGlobalDC(MGLDC *dc,point_t *p);
  985. m_int     MGLAPI MGL_maxxDC(MGLDC *dc);
  986. m_int     MGLAPI MGL_maxyDC(MGLDC *dc);
  987. void     MGLAPI MGL_setClipRectDC(MGLDC *dc,rect_t clip);
  988. void     MGLAPI MGL_getClipRectDC(MGLDC *dc,rect_t *clip);
  989. void     MGLAPI MGL_setClipModeDC(MGLDC *dc,bool mode);
  990. bool     MGLAPI MGL_getClipModeDC(MGLDC *dc);
  991.  
  992. /* Color and palette manipulation */
  993.  
  994. color_t    MGLAPI MGL_realColor(MGLDC *dc,m_int color);
  995. color_t    MGLAPI MGL_rgbColor(MGLDC *dc,uchar R,uchar G,uchar B);
  996. void     MGLAPI MGL_setPaletteEntry(MGLDC *dc,m_int entry,uchar red,uchar green,uchar blue);
  997. void     MGLAPI MGL_getPaletteEntry(MGLDC *dc,m_int entry,uchar *red,uchar *green,uchar *blue);
  998. void     MGLAPI MGL_setPalette(MGLDC *dc,palette_t *pal,m_int numColors,m_int startIndex);
  999. void     MGLAPI MGL_getPalette(MGLDC *dc,palette_t *pal,m_int numColors,m_int startIndex);
  1000. void    ASMAPI MGL_rotatePalette(MGLDC *dc,m_int numColors,m_int startIndex,m_int direction);
  1001. bool    ASMAPI MGL_fadePalette(MGLDC *dc,palette_t *fullIntensity,m_int numColors,m_int startIndex,uchar intensity);
  1002. void    MGLAPI MGL_realizePalette(MGLDC *dc,m_int numColors,m_int startIndex,m_int waitVRT);
  1003. m_int    MGLAPI MGL_getPaletteSize(MGLDC *dc);
  1004. void    MGLAPI MGL_getDefaultPalette(MGLDC *dc,palette_t *pal);
  1005. void     MGLAPI MGL_setDefaultPalette(MGLDC *dc);
  1006. #ifndef    MGL_LITE
  1007. bool    MGLAPI MGL_checkIdentityPalette(bool enable);
  1008. void    MGLAPI MGL_mapToPalette(MGLDC *dc,palette_t *pal);
  1009. #endif
  1010.  
  1011. /* Generic device context information and manipulation */
  1012.  
  1013. bool     MGLAPI MGL_haveWidePalette(MGLDC *dc);
  1014. m_int    MGLAPI MGL_getBitsPerPixel(MGLDC *dc);
  1015. color_t    MGLAPI MGL_maxColor(MGLDC *dc);
  1016. m_int    MGLAPI MGL_maxPage(MGLDC *dc);
  1017. m_int     MGLAPI MGL_sizex(MGLDC *dc);
  1018. m_int     MGLAPI MGL_sizey(MGLDC *dc);
  1019. void     MGLAPI MGL_getPixelFormat(MGLDC *dc,pixel_format_t *pf);
  1020. void    * MGLAPI MGL_computePixelAddr(MGLDC *dc,int x,int y);
  1021.  
  1022. /* Double buffering support */
  1023.  
  1024. void    MGLAPI MGL_setActivePage(MGLDC *dc,m_int page);
  1025. m_int    MGLAPI MGL_getActivePage(MGLDC *dc);
  1026. void    MGLAPI MGL_setVisualPage(MGLDC *dc,m_int page,m_int waitVRT);
  1027. m_int    MGLAPI MGL_getVisualPage(MGLDC *dc);
  1028. void    MGLAPI MGL_setDisplayStart(MGLDC *dc,m_int x,m_int y,m_int waitFlag);
  1029. void    MGLAPI MGL_getDisplayStart(MGLDC *dc,m_int *x,m_int *y);
  1030. void    MGLAPI MGL_vSync(MGLDC *dc);
  1031. bool    MGLAPI MGL_doubleBuffer(MGLDC *dc);
  1032. void    MGLAPI MGL_singleBuffer(MGLDC *dc);
  1033. void    MGLAPI MGL_swapBuffers(MGLDC *dc,m_int waitVRT);
  1034.  
  1035. /* Zbuffering support */
  1036.  
  1037. #ifdef    MGL_3D
  1038. m_int    MGLAPI MGL_getHardwareZBufferDepth(MGLDC *dc);
  1039. bool    ASMAPI MGL_zBegin(MGLDC *dc,m_int zbits);
  1040. bool    MGLAPI MGL_zShareZBuffer(MGLDC *dc,MGLDC *dcShared,m_int zbits);
  1041. #endif
  1042.  
  1043. /* Event handling support */
  1044.  
  1045. bool     MGLAPI EVT_getNext(event_t *evt,m_uint mask);
  1046. bool    MGLAPI EVT_peekNext(event_t *evt,m_uint mask);
  1047. bool    MGLAPI EVT_post(ulong which,m_uint what,ulong message,ulong modifiers);
  1048. void    MGLAPI EVT_flush(m_uint mask);
  1049. void     MGLAPI EVT_halt(event_t *evt,m_uint mask);
  1050. m_int    MGLAPI EVT_setTimerTick(m_int ticks);
  1051.  
  1052. /*---------------------------------------------------------------------------
  1053.  * Routines bound to the currently active context. All these routines work
  1054.  * with the currently active context and do not reflect any changes made
  1055.  * to the global context to the original user supplied context (because it
  1056.  * may be cached). The cached DC is automatically flushed back to the
  1057.  * original DC when a new context is enabled with MGL_makeCurrentDC().
  1058.  *
  1059.  * Before destroying a DC that is current, make sure you call
  1060.  * MGL_makeCurrentDC(NULL) first!
  1061.  *-------------------------------------------------------------------------*/
  1062.  
  1063. /* Routines to change the active global device context */
  1064.  
  1065. MGLDC *    MGLAPI MGL_makeCurrentDC(MGLDC *dc);
  1066. bool    MGLAPI MGL_isCurrentDC(MGLDC *dc);
  1067.  
  1068. /* Current device context information and manipulation */
  1069.  
  1070. m_int     MGLAPI MGL_getAspectRatio(void);
  1071. void     MGLAPI MGL_setAspectRatio(m_int aspectRatio);
  1072. void     ASMAPI MGL_setColor(color_t color);
  1073. void    MGLAPI MGL_setColorRGB(uchar R,uchar G,uchar B);
  1074. void    MGLAPI MGL_setColorCI(m_int index);
  1075. color_t MGLAPI MGL_getColor(void);
  1076. void     ASMAPI MGL_setBackColor(color_t color);
  1077. color_t MGLAPI MGL_getBackColor(void);
  1078. color_t    ASMAPI MGL_packColor(pixel_format_t *pf,uchar R,uchar G,uchar B);
  1079. void    MGLAPI MGL_unpackColor(pixel_format_t *pf,color_t color,uchar *R,uchar *G,uchar *B);
  1080. color_t    ASMAPI MGL_packColorRGB(uchar R,uchar G,uchar B);
  1081. void    MGLAPI MGL_unpackColorRGB(color_t color,uchar *R,uchar *G,uchar *B);
  1082. color_t    MGLAPI MGL_defaultColor(void);
  1083. #ifndef    MGL_LITE
  1084. void    MGLAPI MGL_setMarkerSize(m_int size);
  1085. m_int    MGLAPI MGL_getMarkerSize(void);
  1086. void    MGLAPI MGL_setMarkerStyle(m_int style);
  1087. m_int    MGLAPI MGL_getMarkerStyle(void);
  1088. void    MGLAPI MGL_setMarkerColor(color_t color);
  1089. color_t    MGLAPI MGL_getMarkerColor(void);
  1090. void    MGLAPI MGL_setBorderColors(color_t bright,color_t dark);
  1091. void    MGLAPI MGL_getBorderColors(color_t *bright,color_t *dark);
  1092. void     ASMAPI MGL_setWriteMode(m_int mode);
  1093. m_int     MGLAPI MGL_getWriteMode(void);
  1094. void     ASMAPI MGL_setPenStyle(m_int style);
  1095. m_int     MGLAPI MGL_getPenStyle(void);
  1096. void     MGLAPI MGL_setLineStyle(m_int style);
  1097. m_int     MGLAPI MGL_getLineStyle(void);
  1098. void     ASMAPI MGL_setLineStipple(ushort stipple);
  1099. ushort    MGLAPI MGL_getLineStipple(void);
  1100. void     ASMAPI MGL_setLineStippleCount(m_uint stippleCount);
  1101. m_uint    MGLAPI MGL_getLineStippleCount(void);
  1102. void     ASMAPI MGL_setPenBitmapPattern(const pattern_t *pat);
  1103. void     MGLAPI MGL_getPenBitmapPattern(pattern_t *pat);
  1104. void     ASMAPI MGL_setPenPixmapPattern(const pixpattern_t *pat);
  1105. void     MGLAPI MGL_getPenPixmapPattern(pixpattern_t *pat);
  1106. void    MGLAPI MGL_setPenSize(m_int height,m_int width);
  1107. void     MGLAPI MGL_getPenSize(m_int *height,m_int *width);
  1108. #ifndef    MGL_LITE
  1109. void     MGLAPI MGL_setColorMapMode(m_int mode);
  1110. m_int    MGLAPI MGL_getColorMapMode(void);
  1111. #endif
  1112. void    MGLAPI MGL_setPolygonType(m_int type);
  1113. m_int    MGLAPI MGL_getPolygonType(void);
  1114. #endif
  1115. void     MGLAPI MGL_getAttributes(attributes_t *attr);
  1116. void     MGLAPI MGL_restoreAttributes(attributes_t *attr);
  1117.  
  1118. /* Device clearing */
  1119.  
  1120. void    ASMAPI MGL_clearDevice(void);
  1121. void     MGLAPI MGL_clearViewport(void);
  1122.  
  1123. /* Viewport and clip rectangle manipulation */
  1124.  
  1125. void     MGLAPI MGL_setViewport(rect_t view);
  1126. void    MGLAPI MGL_setRelViewport(rect_t view);
  1127. void     MGLAPI MGL_getViewport(rect_t *view);
  1128. void     MGLAPI MGL_setViewportOrg(point_t org);
  1129. void    MGLAPI MGL_getViewportOrg(point_t *org);
  1130. void    MGLAPI MGL_globalToLocal(point_t *p);
  1131. void    MGLAPI MGL_localToGlobal(point_t *p);
  1132. m_int     MGLAPI MGL_maxx(void);
  1133. m_int     MGLAPI MGL_maxy(void);
  1134. void     MGLAPI MGL_setClipRect(rect_t clip);
  1135. void     MGLAPI MGL_getClipRect(rect_t *clip);
  1136. void     MGLAPI MGL_setClipMode(bool mode);
  1137. bool     MGLAPI MGL_getClipMode(void);
  1138.  
  1139. /* Pixel plotting */
  1140.  
  1141. void     MGLAPI MGL_pixelCoord(m_int x,m_int y);
  1142. color_t    MGLAPI MGL_getPixelCoord(m_int x,m_int y);
  1143. void    ASMAPI MGL_beginPixel(void);
  1144. void     MGLAPI MGL_pixelCoordFast(m_int x,m_int y);
  1145. color_t    MGLAPI MGL_getPixelCoordFast(m_int x,m_int y);
  1146. void    ASMAPI MGL_endPixel(void);
  1147.  
  1148. /* Line drawing and clipping */
  1149.  
  1150. void     MGLAPI MGL_moveToCoord(m_int x,m_int y);
  1151. void     MGLAPI MGL_moveRelCoord(m_int dx,m_int dy);
  1152. void     MGLAPI MGL_lineToCoord(m_int x,m_int y);
  1153. void     MGLAPI MGL_lineRelCoord(m_int dx,m_int dy);
  1154. m_int     MGLAPI MGL_getX(void);
  1155. m_int     MGLAPI MGL_getY(void);
  1156. void    MGLAPI MGL_getCP(point_t* CP);
  1157. void     MGLAPI MGL_lineCoord(m_int x1,m_int y1,m_int x2,m_int y2);
  1158. void     MGLAPI MGL_lineCoordFX(fix32_t x1,fix32_t y1,fix32_t x2,fix32_t y2);
  1159. void    MGLAPI MGL_lineCoordFast(m_int x1,m_int y1,m_int x2,m_int y2);
  1160. void    MGLAPI MGL_lineCoordFastFX(fix32_t x1,fix32_t y1,fix32_t x2,fix32_t y2);
  1161. void    MGLAPI MGL_lineEngine(fix32_t x1,fix32_t y1,fix32_t x2,fix32_t y2,void (ASMAPI *plotPoint)(m_int x,m_int y));
  1162. bool    MGLAPI MGL_clipLineFX(fix32_t *x1,fix32_t *y1,fix32_t *x2,fix32_t *y2,fix32_t left,fix32_t top,fix32_t right,fix32_t bottom);
  1163. #ifndef    MGL_LITE
  1164. void     ASMAPI MGL_scanLine(m_int y,m_int x1,m_int x2);
  1165. #endif
  1166.  
  1167. /* Routines to perform bank switching for banked framebuffers for custom
  1168.  * rendering code. The first version is callable only from assembler and
  1169.  * requires the new bank value to be passed in the DL register. The second
  1170.  * version is callable directly from C. DO NOT CALL THESE FUNCTIONS WHEN
  1171.  * RUNNING WITH A LINEAR FRAMEBUFFER!!!
  1172.  */
  1173.  
  1174. void    _ASMAPI SVGA_setBank(void);
  1175. void    _ASMAPI SVGA_setBankC(int bank);
  1176.  
  1177. /* Routines to begin/end direct framebuffer access. You must call these
  1178.  * functions is you wish to render directly to a hardware accelerated
  1179.  * device surface.
  1180.  */
  1181.  
  1182. void     ASMAPI MGL_beginDirectAccess(void);
  1183. void     ASMAPI MGL_endDirectAccess(void);
  1184.  
  1185. /* Routines to begin/end fast rendering of flat shaded lines, scanlines
  1186.  * and polygons.
  1187.  */
  1188.  
  1189. void     ASMAPI MGL_beginDrawing(void);
  1190. void     ASMAPI MGL_endDrawing(void);
  1191.  
  1192. /* Routines to begin/end fast rendering of smooth shaded lines, scanlines
  1193.  * and polygons.
  1194.  */
  1195.  
  1196. #ifdef    MGL_3D
  1197. void     ASMAPI MGL_beginShadedDrawing(void);
  1198. void     ASMAPI MGL_endShadedDrawing(void);
  1199. #endif
  1200.  
  1201. /* Routines to begin/end fast rendering of flat shaded, zbuffered lines and
  1202.  * polygons.
  1203.  */
  1204.  
  1205. #ifdef    MGL_3D
  1206. void     ASMAPI MGL_beginZDrawing(void);
  1207. void     ASMAPI MGL_endZDrawing(void);
  1208. #endif
  1209.  
  1210. /* Routines to begin/end fast rendering of smooth shaded, zbuffered lines and
  1211.  * polygons.
  1212.  */
  1213.  
  1214. #ifdef    MGL_3D
  1215. void     ASMAPI MGL_beginZShadedDrawing(void);
  1216. void     ASMAPI MGL_endZShadedDrawing(void);
  1217. #endif
  1218.  
  1219. /* Polygon drawing: Note that the following fast polygon routines
  1220.  * only work with convex polygons. The integer coordinate versions are
  1221.  * provided for compatibility only, and convert the coordinates to fixed
  1222.  * point and call the appropriate fixed point routines below.
  1223.  */
  1224.  
  1225. #ifndef    MGL_LITE
  1226. void    MGLAPI MGL_fillPolygon(m_int count,point_t *vArray,m_int xOffset,m_int yOffset);
  1227. void    MGLAPI MGL_fillPolygonFast(m_int count,point_t *vArray,m_int xOffset,m_int yOffset);
  1228. void    ASMAPI MGL_fillPolygonFX(m_int count,fxpoint_t *vArray,m_int vinc,fix32_t xOffset,fix32_t yOffset);
  1229. void    ASMAPI MGL_fillPolygonFastFX(m_int count,fxpoint_t *vArray,m_int vinc,fix32_t xOffset,fix32_t yOffset);
  1230. #endif
  1231.  
  1232. /* 3D rasterization routines */
  1233.  
  1234. #ifdef    MGL_3D
  1235. void    MGLAPI MGL_zClearCoord(m_int left,m_int top,m_int right,m_int bottom,zfix32_t clearVal);
  1236. #endif
  1237.  
  1238. #ifdef    MGL_FIX3D
  1239. void    ASMAPI MGL_cLineCoordFast(fix32_t x1,fix32_t y1,fix32_t c1,fix32_t x2,fix32_t y2,fix32_t c2);
  1240. void    ASMAPI MGL_rgbLineCoordFast(fix32_t x1,fix32_t y1,fix32_t r1,fix32_t g1,fix32_t b1,fix32_t x2,fix32_t y2,fix32_t r2,fix32_t g2,fix32_t b2);
  1241. void    ASMAPI MGL_zLineCoordFast(fix32_t x1,fix32_t y1,zfix32_t z1,fix32_t x2,fix32_t y2,zfix32_t z2);
  1242. void    ASMAPI MGL_czLineCoordFast(fix32_t x1,fix32_t y1,zfix32_t z1,fix32_t c1,fix32_t x2,fix32_t y2,zfix32_t z2,fix32_t c2);
  1243. void    ASMAPI MGL_rgbzLineCoordFast(fix32_t x1,fix32_t y1,zfix32_t z1,fix32_t r1,fix32_t g1,fix32_t b1,fix32_t x2,fix32_t y2,zfix32_t z2,fix32_t r2,fix32_t g2,fix32_t b2);
  1244.  
  1245. void    ASMAPI MGL_triFast(fxpoint_t *v1,fxpoint_t *v2,fxpoint_t *v3,fix32_t xOffset,fix32_t yOffset);
  1246. void    ASMAPI MGL_cTriFast(fxpointc_t *v1,fxpointc_t *v2,fxpointc_t *v3,fix32_t xOffset,fix32_t yOffset);
  1247. void    ASMAPI MGL_rgbTriFast(fxpointrgb_t *v1,fxpointrgb_t *v2,fxpointrgb_t *v3,fix32_t xOffset,fix32_t yOffset);
  1248. void    ASMAPI MGL_zTriFast(fxpointz_t *v1,fxpointz_t *v2,fxpointz_t *v3,fix32_t xOffset,fix32_t yOffset,zfix32_t zOffset);
  1249. void    ASMAPI MGL_czTriFast(fxpointcz_t *v1,fxpointcz_t *v2,fxpointcz_t *v3,fix32_t xOffset,fix32_t yOffset,zfix32_t zOffset);
  1250. void    ASMAPI MGL_rgbzTriFast(fxpointrgbz_t *v1,fxpointrgbz_t *v2,fxpointrgbz_t *v3,fix32_t xOffset,fix32_t yOffset,zfix32_t zOffset);
  1251.  
  1252. void    ASMAPI MGL_quadFast(fxpoint_t *v1,fxpoint_t *v2,fxpoint_t *v3,fxpoint_t *v4,fix32_t xOffset,fix32_t yOffset);
  1253. void    ASMAPI MGL_cQuadFast(fxpointc_t *v1,fxpointc_t *v2,fxpointc_t *v3,fxpointc_t *v4,fix32_t xOffset,fix32_t yOffset);
  1254. void    ASMAPI MGL_rgbQuadFast(fxpointrgb_t *v1,fxpointrgb_t *v2,fxpointrgb_t *v3,fxpointrgb_t *v4,fix32_t xOffset,fix32_t yOffset);
  1255. void    ASMAPI MGL_zQuadFast(fxpointz_t *v1,fxpointz_t *v2,fxpointz_t *v3,fxpointz_t *v4,fix32_t xOffset,fix32_t yOffset,zfix32_t zOffset);
  1256. void    ASMAPI MGL_czQuadFast(fxpointcz_t *v1,fxpointcz_t *v2,fxpointcz_t *v3,fxpointcz_t *v4,fix32_t xOffset,fix32_t yOffset,zfix32_t zOffset);
  1257. void    ASMAPI MGL_rgbzQuadFast(fxpointrgbz_t *v1,fxpointrgbz_t *v2,fxpointrgbz_t *v3,fxpointrgbz_t *v4,fix32_t xOffset,fix32_t yOffset,zfix32_t zOffset);
  1258. #endif
  1259.  
  1260. /* Routine to set the currently active shade table. In HiColor and TrueColor
  1261.  * video modes, you must set a valid shadeTable before you call any of the
  1262.  * color index shaded rendering routines (MGL_cTri() etc). These routines
  1263.  * will interpolate an index into the current shade table rather than
  1264.  * each of the RGB color channels, and the appropriate full RGB color is
  1265.  * extracted directly from the shade table. The shade table can be any size,
  1266.  * but the application must ensure that the indices passed in are within
  1267.  * the range of the current shade table.
  1268.  */
  1269.  
  1270. #ifdef    MGL_3D
  1271. void    MGLAPI MGL_setShadeTable(color_t *shadeTab);
  1272. #endif
  1273.  
  1274. /* Polyline drawing */
  1275.  
  1276. #ifndef    MGL_LITE
  1277. void     MGLAPI MGL_marker(point_t p);
  1278. void    MGLAPI MGL_polyPoint(m_int count,point_t *vArray);
  1279. void     MGLAPI MGL_polyMarker(m_int count,point_t *vArray);
  1280. void     MGLAPI MGL_polyLine(m_int count,point_t *vArray);
  1281. #endif
  1282.  
  1283. /* Rectangle drawing */
  1284.  
  1285. #ifndef    MGL_LITE
  1286. void     MGLAPI MGL_rectCoord(m_int left,m_int top,m_int right,m_int bottom);
  1287. void     MGLAPI MGL_fillRectCoord(m_int left,m_int top,m_int right,m_int bottom);
  1288. #endif
  1289.  
  1290. /* Scanline color scanning. Thee routines are primitive, and do not perform
  1291.  * any clipping or viewport mapping, so can be used to build you own
  1292.  * high performance floodfilling routines (see the example file ffill.c
  1293.  * for pre-built high speed floodfill routines).
  1294.  */
  1295.  
  1296. #ifndef    MGL_LITE
  1297. m_int    ASMAPI MGL_scanRightForColor(m_int x,m_int y,color_t color);
  1298. m_int    ASMAPI MGL_scanLeftForColor(m_int x,m_int y,color_t color);
  1299. m_int     ASMAPI MGL_scanRightWhileColor(m_int x,m_int y,color_t color);
  1300. m_int    ASMAPI MGL_scanLeftWhileColor(m_int x,m_int y,color_t color);
  1301. #endif
  1302.  
  1303. /* Psuedo 3D border drawing */
  1304.  
  1305. #ifndef    MGL_LITE
  1306. void    MGLAPI MGL_drawBorderCoord(m_int left,m_int top,m_int right,m_int bottom,m_int style,m_int thickness);
  1307. void     MGLAPI MGL_drawHDivider(m_int y,m_int x1,m_int x2);
  1308. void     MGLAPI MGL_drawVDivider(m_int x,m_int y1,m_int y2);
  1309. #endif
  1310.  
  1311. /* Ellipse drawing */
  1312.  
  1313. #ifndef    MGL_LITE
  1314. void    MGLAPI MGL_ellipseArc(rect_t extentRect,m_int startAngle,m_int endAngle);
  1315. void    MGLAPI MGL_ellipseArcCoord(m_int x,m_int y,m_int xradius,m_int yradius,m_int startAngle,m_int endAngle);
  1316. void    ASMAPI MGL_getArcCoords(arc_coords_t *coords);
  1317. void    MGLAPI MGL_ellipse(rect_t extentRect);
  1318. void    MGLAPI MGL_ellipseCoord(m_int x,m_int y,m_int xradius,m_int yradius);
  1319. void    MGLAPI MGL_fillEllipseArc(rect_t extentRect,m_int startAngle,m_int endAngle);
  1320. void    MGLAPI MGL_fillEllipseArcCoord(m_int x,m_int y,m_int xradius,m_int yradius,m_int startAngle,m_int endAngle);
  1321. void    MGLAPI MGL_fillEllipse(rect_t extentRect);
  1322. void    MGLAPI MGL_fillEllipseCoord(m_int x,m_int y,m_int xradius,m_int yradius);
  1323. void    MGLAPI MGL_ellipseEngine(rect_t extentRect,void (ASMAPI *setup)(m_int topY,m_int botY,m_int left,m_int right),void (ASMAPI *set4pixels)(bool inc_x,bool inc_y,bool region1),void (ASMAPI *finished)(void));
  1324. void     MGLAPI MGL_ellipseArcEngine(rect_t extentRect,m_int startAngle,m_int endAngle,arc_coords_t *ac,void (ASMAPI *plotPoint)(m_int x,m_int y));
  1325. #endif
  1326.  
  1327. /* Text attribute manipulation */
  1328.  
  1329. #ifndef    MGL_LITE
  1330. void     MGLAPI MGL_setTextJustify(m_int horiz,m_int vert);
  1331. void     MGLAPI MGL_getTextJustify(m_int *horiz,m_int *vert);
  1332. void     MGLAPI MGL_setTextDirection(m_int direction);
  1333. m_int   MGLAPI MGL_getTextDirection(void);
  1334. void    MGLAPI MGL_setTextSize(m_int numerx,m_int denomx,m_int numery,m_int denomy);
  1335. void    MGLAPI MGL_getTextSize(m_int *numerx,m_int *denomx,m_int *numery,m_int *denomy);
  1336. void    MGLAPI MGL_setSpaceExtra(m_int extra);
  1337. m_int    MGLAPI MGL_getSpaceExtra(void);
  1338. void    MGLAPI MGL_setTextSettings(text_settings_t *settings);
  1339. void    MGLAPI MGL_getTextSettings(text_settings_t *settings);
  1340. m_int     MGLAPI MGL_textHeight(void);
  1341. m_int     MGLAPI MGL_textWidth(const char *str);
  1342. void    MGLAPI MGL_textBounds(m_int x,m_int y,const char *str,rect_t *bounds);
  1343. m_int    MGLAPI MGL_charWidth(char ch);
  1344. void    MGLAPI MGL_getFontMetrics(metrics_t *metrics);
  1345. void    MGLAPI MGL_getCharMetrics(char ch,metrics_t *metrics);
  1346. m_int    MGLAPI MGL_maxCharWidth(void);
  1347. void    MGLAPI MGL_underScoreLocation(m_int *x,m_int *y,const char *str);
  1348. #endif
  1349.  
  1350. /* Text drawing */
  1351.  
  1352. #ifndef    MGL_LITE
  1353. void     MGLAPI MGL_drawStr(const char *str);
  1354. void    MGLAPI MGL_drawStrXY(m_int x,m_int y,const char *str);
  1355. bool    MGLAPI MGL_useFont(font_t *font);
  1356. font_t     * MGLAPI MGL_getFont(void);
  1357. bool    MGLAPI MGL_vecFontEngine(m_int x,m_int y,const char *str,void (ASMAPI *move)(m_int x,m_int y),void (ASMAPI *draw)(m_int x,m_int y));
  1358. #endif
  1359.  
  1360. /* BitBlt support */
  1361.  
  1362. void     MGLAPI MGL_bitBltCoord(MGLDC *dst,MGLDC *src,m_int left,m_int top,m_int right,m_int bottom,m_int dstLeft,m_int dstTop,m_int op);
  1363. void     MGLAPI MGL_stretchBltCoord(MGLDC *dst,MGLDC *src,m_int left,m_int top,m_int right,m_int bottom,m_int dstLeft,m_int dstTop,m_int dstRight,m_int dstBottom);
  1364. #ifndef    MGL_LITE
  1365. void     MGLAPI MGL_getDivotCoord(MGLDC *dc,m_int left,m_int top,m_int right,m_int bottom,void *divot);
  1366. void     MGLAPI MGL_putDivot(MGLDC *dc,void *divot);
  1367. long     MGLAPI MGL_divotSizeCoord(MGLDC *dc,m_int left,m_int top,m_int right,m_int bottom);
  1368. void     MGLAPI MGL_putMonoImage(MGLDC *dc,m_int x,m_int y,m_int byteWidth,m_int height,void *image);
  1369. void    MGLAPI MGL_putBitmap(MGLDC *dc,m_int x,m_int y,const bitmap_t *bitmap,m_int op);
  1370. void    MGLAPI MGL_putBitmapSection(MGLDC *dc,m_int left,m_int top,m_int right,m_int bottom,m_int dstLeft,m_int dstTop,const bitmap_t *bitmap,m_int op);
  1371. void    MGLAPI MGL_putBitmapTransparent(MGLDC *dc,m_int x,m_int y,const bitmap_t *bitmap,color_t transparent,bool sourceTrans);
  1372. void    MGLAPI MGL_putBitmapTransparentSection(MGLDC *dc,m_int left,m_int top,m_int right,m_int bottom,m_int dstLeft,m_int dstTop,const bitmap_t *bitmap,color_t transparent,bool sourceTrans);
  1373. void    MGLAPI MGL_putBitmapMask(MGLDC *dc,m_int x,m_int y,const bitmap_t *mask,color_t color);
  1374. void    MGLAPI MGL_stretchBitmap(MGLDC *dc,m_int left,m_int top,m_int right,m_int bottom,const bitmap_t *bitmap);
  1375. void    MGLAPI MGL_putIcon(MGLDC *dc,m_int x,m_int y,const icon_t *icon);
  1376. void     MGLAPI MGL_transBltCoord(MGLDC *dst,MGLDC *src,m_int left,m_int top,m_int right,m_int bottom,m_int dstLeft,m_int dstTop,color_t transparent,bool sourceTrans);
  1377. #endif
  1378.  
  1379. /* Linear offscreen DC BitBlt support */
  1380.  
  1381. #ifndef    MGL_LITE
  1382. void     MGLAPI MGL_bitBltLinCoord(MGLDC *dst,MGLDC *src,ulong srcOfs,m_int dstLeft,m_int dstTop,m_int dstRight,m_int dstBottom,m_int op);
  1383. void     MGLAPI MGL_transBltLinCoord(MGLDC *dst,MGLDC *src,ulong srcOfs,m_int dstLeft,m_int dstTop,m_int dstRight,m_int dstBottom,color_t transparent,bool sourceTrans);
  1384. #endif
  1385.  
  1386. /* Monochrome bitmap manipulation */
  1387.  
  1388. #ifndef    MGL_LITE
  1389. void    MGLAPI MGL_drawGlyph(font_t *g,m_int x,m_int y,uchar glyph);
  1390. m_int    MGLAPI MGL_getGlyphWidth(font_t *font,uchar glyph);
  1391. m_int    MGLAPI MGL_getGlyphHeight(font_t *font);
  1392. void     MGLAPI MGL_rotateGlyph(uchar *dst,uchar *src,m_int *byteWidth,m_int *height,m_int rotation);
  1393. void     MGLAPI MGL_mirrorGlyph(uchar *dst,uchar *src,m_int byteWidth,m_int height);
  1394. #endif
  1395.  
  1396. /* Region management */
  1397.  
  1398. #ifndef    MGL_LITE
  1399. region_t * MGLAPI MGL_newRegion(void);
  1400. region_t * MGLAPI MGL_copyRegion(const region_t *s);
  1401. void    MGLAPI MGL_clearRegion(region_t *r);
  1402. void     MGLAPI MGL_freeRegion(region_t *r);
  1403. void     MGLAPI MGL_drawRegion(m_int x,m_int y,const region_t *r);
  1404. #endif
  1405.  
  1406. /* Region generation primitives */
  1407.  
  1408. #ifndef    MGL_LITE
  1409. region_t * MGLAPI MGL_rgnLineCoord(m_int x1,m_int y1,m_int x2,m_int y2,const region_t *pen);
  1410. region_t * MGLAPI MGL_rgnLineCoordFX(fix32_t x1,fix32_t y1,fix32_t x2,fix32_t y2,const region_t *pen);
  1411. /*region_t * MGLAPI MGL_rgnPolygon(m_int count,point_t *vArray);*/
  1412. /*region_t * MGLAPI MGL_rgnPolygonFast(m_int count,point_t *vArray);*/
  1413. region_t * MGLAPI MGL_rgnSolidRectCoord(m_int left,m_int top,m_int right,m_int bottom);
  1414. region_t * MGLAPI MGL_rgnEllipse(rect_t extentRect,const region_t *pen);
  1415. region_t * MGLAPI MGL_rgnEllipseArc(rect_t extentRect,m_int startAngle,m_int endAngle,const region_t *pen);
  1416. void    MGLAPI MGL_rgnGetArcCoords(arc_coords_t *coords);
  1417. region_t * MGLAPI MGL_rgnSolidEllipse(rect_t extentRect);
  1418. region_t * MGLAPI MGL_rgnSolidEllipseArc(rect_t extentRect,m_int startAngle,m_int endAngle);
  1419. #endif
  1420.  
  1421. /* Region alegbra */
  1422.  
  1423. #ifndef    MGL_LITE
  1424. region_t * MGLAPI MGL_sectRegion(const region_t *r1,const region_t *r2);
  1425. region_t * MGLAPI MGL_sectRegionRect(const region_t *r1,const rect_t *r2);
  1426. bool    MGLAPI MGL_unionRegion(region_t *r1,const region_t *r2);
  1427. bool    MGLAPI MGL_unionRegionRect(region_t *r1,const rect_t *r2);
  1428. bool     MGLAPI MGL_unionRegionOfs(region_t *r1,const region_t *r2,m_int xOffset,m_int yOffset);
  1429. bool    MGLAPI MGL_diffRegion(region_t *r1,const region_t *r2);
  1430. bool    MGLAPI MGL_diffRegionRect(region_t *r1,const rect_t *r2);
  1431. void    MGLAPI MGL_optimizeRegion(region_t *r);
  1432. void     MGLAPI MGL_offsetRegion(region_t *r,m_int dx,m_int dy);
  1433. bool    MGLAPI MGL_emptyRegion(const region_t *r);
  1434. bool    MGLAPI MGL_equalRegion(const region_t *r1,const region_t *r2);
  1435. bool    MGLAPI MGL_ptInRegionCoord(m_int x,m_int y,const region_t *r);
  1436. #endif
  1437.  
  1438. /* Region traversal */
  1439.  
  1440. #ifndef    MGL_LITE
  1441. typedef void (ASMAPI *rgncallback_t)(const rect_t *r);
  1442.  
  1443. void     MGLAPI MGL_traverseRegion(region_t *rgn,rgncallback_t doRect);
  1444. #endif
  1445.  
  1446. /* RGB to 8 bit halftone dithering routines */
  1447.  
  1448. #ifndef    MGL_LITE
  1449. void     MGLAPI MGL_getHalfTonePalette(palette_t *pal);
  1450. uchar    MGLAPI MGL_halfTonePixel(m_int x,m_int y,uchar R,uchar G,uchar B);
  1451. #endif
  1452.  
  1453. /* Resource loading/unloading */
  1454.  
  1455. font_t * MGLAPI MGL_loadFont(const char *fontname);
  1456. bool    MGLAPI MGL_availableFont(const char *fontname);
  1457. void    MGLAPI MGL_unloadFont(font_t *font);
  1458. cursor_t * MGLAPI MGL_loadCursor(const char *cursorName);
  1459. bool    MGLAPI MGL_availableCursor(const char *cursorName);
  1460. void     MGLAPI MGL_unloadCursor(cursor_t *cursor);
  1461. #ifndef    MGL_LITE
  1462. icon_t * MGLAPI MGL_loadIcon(const char *iconName,bool loadPalette);
  1463. bool    MGLAPI MGL_availableIcon(const char *iconName);
  1464. void    MGLAPI MGL_unloadIcon(icon_t *icon);
  1465. #endif
  1466.  
  1467. /* Windows BMP bitmap loading/unloading/saving */
  1468.  
  1469. #ifndef    MGL_LITE
  1470. bitmap_t * MGLAPI MGL_loadBitmap(const char *bitmapName,bool loadPalette);
  1471. bool    MGLAPI MGL_availableBitmap(const char *bitmapName);
  1472. void    MGLAPI MGL_unloadBitmap(bitmap_t *bitmap);
  1473. bool    MGLAPI MGL_getBitmapSize(const char *bitmapName,m_int *width,m_int *height,m_int *bitsPerPixel,pixel_format_t *pf);
  1474. bool    MGLAPI MGL_loadBitmapIntoDC(MGLDC *dc,const char *bitmapName,m_int dstLeft,m_int dstTop,bool loadPalette);
  1475. bool    MGLAPI MGL_saveBitmapFromDC(MGLDC *dc,const char *bitmapName,m_int left,m_int top,m_int right,m_int bottom);
  1476. bitmap_t * MGLAPI MGL_getBitmapFromDC(MGLDC *dc,m_int left,m_int top,m_int right,m_int bottom,bool savePalette);
  1477. bitmap_t * MGLAPI MGL_buildMonoMask(bitmap_t *bitmap,color_t transparent);
  1478. #endif
  1479.  
  1480. /* PCX bitmap loading/unloading/saving (1/4/8 bpp only) */
  1481.  
  1482. #ifndef    MGL_LITE
  1483. bitmap_t * MGLAPI MGL_loadPCX(const char *bitmapName,bool loadPalette);
  1484. bool    MGLAPI MGL_availablePCX(const char *bitmapName);
  1485. bool    MGLAPI MGL_getPCXSize(const char *bitmapName,m_int *width,m_int *height,m_int *bitsPerPixel);
  1486. bool    MGLAPI MGL_loadPCXIntoDC(MGLDC *dc,const char *bitmapName,m_int dstLeft,m_int dstTop,bool loadPalette);
  1487. bool    MGLAPI MGL_savePCXFromDC(MGLDC *dc,const char *bitmapName,m_int left,m_int top,m_int right,m_int bottom);
  1488. #endif
  1489.  
  1490. /* Random number generation routines for shorts and longs with full range */
  1491.  
  1492. void    ASMAPI MGL_srand(m_uint seed);
  1493. ushort    ASMAPI MGL_random(ushort max);
  1494. ulong    ASMAPI MGL_randoml(ulong max);
  1495.  
  1496. /* Mouse support */
  1497.  
  1498. bool    MGLAPI MS_available(void);
  1499. void    MGLAPI MS_show(void);
  1500. void    MGLAPI MS_hide(void);
  1501. void    MGLAPI MS_obscure(void);
  1502. void    MGLAPI MS_setCursor(cursor_t *curs);
  1503. void    MGLAPI MS_setCursorColor(color_t color);
  1504. void     MGLAPI MS_moveTo(m_int x,m_int y);
  1505. void    MGLAPI MS_getPos(m_int *x,m_int *y);
  1506. void    MGLAPI MS_drawCursor(void);
  1507.  
  1508. /* Rectangle and Point manipulation */
  1509.  
  1510. rect_t     MGLAPI MGL_defRect(m_int left,m_int top,m_int right,m_int bottom);
  1511. rect_t     MGLAPI MGL_defRectPt(point_t leftTop,point_t rightBottom);
  1512. bool     MGLAPI MGL_sectRect(rect_t s1,rect_t s2,rect_t *d);
  1513. bool     MGLAPI MGL_sectRectCoord(m_int left1,m_int top1,m_int right1,m_int bottom1,m_int left2,m_int top2,m_int right2,m_int bottom2,rect_t *d);
  1514. void     MGLAPI MGL_unionRect(rect_t s1,rect_t s2,rect_t *d);
  1515. void     MGLAPI MGL_unionRectCoord(m_int left1,m_int top1,m_int right1,m_int bottom1,m_int left2,m_int top2,m_int right2,m_int bottom2,rect_t *d);
  1516.  
  1517. /* Built-in patterns and mouse cursor */
  1518.  
  1519. #ifndef    MGL_LITE
  1520. pattern_t    * MGLAPI _MGL_getEmptyPat(void);
  1521. pattern_t   * MGLAPI _MGL_getGrayPat(void);
  1522. pattern_t   * MGLAPI _MGL_getSolidPat(void);
  1523. #endif
  1524. cursor_t    * MGLAPI _MGL_getDefCursor(void);
  1525.  
  1526. /* Fixed point multiplication/divide routines */
  1527.  
  1528. #if defined(__WATCOMC__) && defined(__386__)
  1529.  
  1530. /* For Watcom C++ we can use special inline assembler code that is much
  1531.  * faster than calling the 386 assembler functions. Currently this is the
  1532.  * the only compiler that will allow inline assembler to be expanded
  1533.  * directly as inline functions.
  1534.  */
  1535.  
  1536. fix32_t    MGL_FixMul(fix32_t a,fix32_t b);
  1537. #pragma aux MGL_FixMul =            \
  1538.     "imul    edx"                    \
  1539.     "add    eax,8000h"                \
  1540.     "adc    edx,0"                    \
  1541.     "shrd    eax,edx,16"                \
  1542.     parm [eax] [edx]                \
  1543.     value [eax]                        \
  1544.     modify exact [eax edx];
  1545.  
  1546. fix32_t    MGL_FixDiv(fix32_t a,fix32_t b);
  1547. #pragma aux MGL_FixDiv =            \
  1548.     "xor    eax,eax"                \
  1549.     "shrd    eax,edx,16"                \
  1550.     "sar    edx,16"                    \
  1551.     "idiv    ebx"                      \
  1552.     parm [edx] [ebx]                 \
  1553.     value [eax]                     \
  1554.     modify exact [eax edx];
  1555.  
  1556. fix32_t    MGL_FixMulDiv(fix32_t a,fix32_t b,fix32_t c);
  1557. #pragma aux MGL_FixMulDiv =            \
  1558.     "imul    ebx"                    \
  1559.     "idiv    ecx"                      \
  1560.     parm [eax] [ebx] [ecx]             \
  1561.     value [eax]                     \
  1562.     modify exact [eax edx];
  1563.  
  1564. m_int    MGL_backfacing(fix32_t dx1,fix32_t dy1,fix32_t dx2,fix32_t dy2);
  1565. #pragma aux MGL_backfacing =        \
  1566.     "imul    ebx"                    \
  1567.     "mov    ebx,eax"                \
  1568.     "mov    ecx,edx"                \
  1569.     "mov    eax,esi"                \
  1570.     "imul    edi"                    \
  1571.     "sub    eax,ebx"                \
  1572.     "mov    eax,1"                    \
  1573.     "sbb    edx,ecx"                \
  1574.     "jns    @@Backfacing"            \
  1575.     "xor    eax,eax"                \
  1576.     "@@Backfacing:"                    \
  1577.     parm [eax] [esi] [edi] [ebx]    \
  1578.     value [eax]                     \
  1579.     modify exact [eax ecx edx];
  1580.  
  1581. void MGL_memcpy(void *dst,void *src,m_int n);
  1582. #pragma aux MGL_memcpy =            \
  1583.     "mov    eax,ecx"                \
  1584.     "shr    ecx,2"                  \
  1585.     "rep    movsd"                  \
  1586.     "mov    cl,al"                    \
  1587.     "and    cl,3"                    \
  1588.     "rep    movsb"                    \
  1589.     parm [edi] [esi] [ecx]            \
  1590.     modify exact [eax ecx esi edi];
  1591.  
  1592. #else
  1593.  
  1594. fix32_t    ASMAPI MGL_FixMul(fix32_t a,fix32_t b);
  1595. fix32_t    ASMAPI MGL_FixDiv(fix32_t a,fix32_t b);
  1596. fix32_t    ASMAPI MGL_FixMulDiv(fix32_t a,fix32_t b,fix32_t c);
  1597. m_int    ASMAPI MGL_backfacing(fix32_t dx1,fix32_t dy1,fix32_t dx2,fix32_t dy2);
  1598. void     ASMAPI MGL_memcpy(void *dst,void *src,m_int n);
  1599.  
  1600. #endif
  1601.  
  1602. /* The following are special memcpy routines that properly handler reading
  1603.  * and writing to virtual linear buffer memory by forcing the proper
  1604.  * alignment. Note that the copy is extended to use a DWORD copy of speed.
  1605.  */
  1606.  
  1607. void     ASMAPI MGL_memcpyVIRTSRC(void *dst,void *src,m_int n);
  1608. void     ASMAPI MGL_memcpyVIRTDST(void *dst,void *src,m_int n);
  1609.  
  1610. /* Function to find an MGL system file's full pathname */
  1611.  
  1612. bool    MGLAPI _MGL_findFile(char *validpath,const char *dir, const char *filename, const char *mode);
  1613.  
  1614. /* Override the internal MGL file I/O functions */
  1615.  
  1616. void    MGLAPI MGL_setFileIO(fileio_t *fio);
  1617.  
  1618. /* The following dummy symbols are used to link in driver files to be used. A
  1619.  * driver is not active until it is linked in with the MGL_registerDriver
  1620.  * call. Because we dont export globals in DLLs, we provide functions to
  1621.  * get the address of the drivers. However for a static link library we
  1622.  * need to use globals so that if the driver data is unreferenced, it will
  1623.  * not be linked in with the code. 
  1624.  */
  1625.  
  1626. #ifndef    BUILD_MGL
  1627. #if    defined(MGL_DLL) && !defined(BUILD_MGLDLL)
  1628. void * MGLAPI VGA4_getDriverAddr(void);
  1629. void * MGLAPI VGAX_getDriverAddr(void);
  1630. void * MGLAPI SVGA4_getDriverAddr(void);
  1631. void * MGLAPI SVGA8_getDriverAddr(void);
  1632. void * MGLAPI SVGA16_getDriverAddr(void);
  1633. void * MGLAPI SVGA24_getDriverAddr(void);
  1634. void * MGLAPI SVGA32_getDriverAddr(void);
  1635. #if !defined(__16BIT__)
  1636. void * MGLAPI VGA8_getDriverAddr(void);
  1637. void * MGLAPI LINEAR8_getDriverAddr(void);
  1638. void * MGLAPI LINEAR16_getDriverAddr(void);
  1639. void * MGLAPI LINEAR24_getDriverAddr(void);
  1640. void * MGLAPI LINEAR32_getDriverAddr(void);
  1641. void * MGLAPI ACCEL8_getDriverAddr(void);
  1642. void * MGLAPI ACCEL16_getDriverAddr(void);
  1643. void * MGLAPI ACCEL24_getDriverAddr(void);
  1644. void * MGLAPI ACCEL32_getDriverAddr(void);
  1645. #if defined(MGLWIN) || defined(__WINDOWS__)
  1646. void * MGLAPI DDRAW8_getDriverAddr(void);
  1647. void * MGLAPI DDRAW16_getDriverAddr(void);
  1648. void * MGLAPI DDRAW24_getDriverAddr(void);
  1649. void * MGLAPI DDRAW32_getDriverAddr(void);
  1650. #endif
  1651. #endif
  1652. void * MGLAPI PACKED1_getDriverAddr(void);
  1653. void * MGLAPI PACKED4_getDriverAddr(void);
  1654. void * MGLAPI PACKED8_getDriverAddr(void);
  1655. void * MGLAPI PACKED16_getDriverAddr(void);
  1656. void * MGLAPI PACKED24_getDriverAddr(void);
  1657. void * MGLAPI PACKED32_getDriverAddr(void);
  1658. #define VGA4_driver            VGA4_getDriverAddr()
  1659. #define VGAX_driver            VGAX_getDriverAddr()
  1660. #define SVGA4_driver        SVGA4_getDriverAddr()
  1661. #define SVGA8_driver        SVGA8_getDriverAddr()
  1662. #define SVGA16_driver        SVGA16_getDriverAddr()
  1663. #define SVGA24_driver        SVGA24_getDriverAddr()
  1664. #define SVGA32_driver        SVGA32_getDriverAddr()
  1665. #if !defined(__16BIT__)
  1666. #define VGA8_driver            VGA8_getDriverAddr()
  1667. #define LINEAR8_driver        LINEAR8_getDriverAddr()
  1668. #define LINEAR16_driver        LINEAR16_getDriverAddr()
  1669. #define LINEAR24_driver     LINEAR24_getDriverAddr()
  1670. #define LINEAR32_driver     LINEAR32_getDriverAddr()
  1671. #define ACCEL8_driver       ACCEL8_getDriverAddr()
  1672. #define ACCEL16_driver      ACCEL16_getDriverAddr()
  1673. #define ACCEL24_driver      ACCEL24_getDriverAddr()
  1674. #define ACCEL32_driver      ACCEL32_getDriverAddr()
  1675. #if defined(MGLWIN) || defined(__WINDOWS__)
  1676. #define DDRAW8_driver       DDRAW8_getDriverAddr()
  1677. #define DDRAW16_driver      DDRAW16_getDriverAddr()
  1678. #define DDRAW24_driver      DDRAW24_getDriverAddr()
  1679. #define DDRAW32_driver      DDRAW32_getDriverAddr()
  1680. #endif
  1681. #endif
  1682. #define PACKED1_driver      PACKED1_getDriverAddr()
  1683. #define PACKED4_driver      PACKED4_getDriverAddr()
  1684. #define PACKED8_driver      PACKED8_getDriverAddr()
  1685. #define PACKED16_driver     PACKED16_getDriverAddr()
  1686. #define PACKED24_driver     PACKED24_getDriverAddr()
  1687. #define PACKED32_driver        PACKED32_getDriverAddr()
  1688. #else
  1689. extern m_int _VARAPI VGA4_driver[];
  1690. extern m_int _VARAPI VGAX_driver[];
  1691. extern m_int _VARAPI SVGA4_driver[];
  1692. extern m_int _VARAPI SVGA8_driver[];
  1693. extern m_int _VARAPI SVGA16_driver[];
  1694. extern m_int _VARAPI SVGA24_driver[];
  1695. extern m_int _VARAPI SVGA32_driver[];
  1696. #if !defined(__16BIT__)
  1697. extern m_int _VARAPI VGA8_driver[];
  1698. extern m_int _VARAPI LINEAR8_driver[];
  1699. extern m_int _VARAPI LINEAR16_driver[];
  1700. extern m_int _VARAPI LINEAR24_driver[];
  1701. extern m_int _VARAPI LINEAR32_driver[];
  1702. extern m_int _VARAPI ACCEL8_driver[];
  1703. extern m_int _VARAPI ACCEL16_driver[];
  1704. extern m_int _VARAPI ACCEL24_driver[];
  1705. extern m_int _VARAPI ACCEL32_driver[];
  1706. #if defined(MGLWIN) || defined(__WINDOWS__)
  1707. extern m_int _VARAPI DDRAW8_driver[];
  1708. extern m_int _VARAPI DDRAW16_driver[];
  1709. extern m_int _VARAPI DDRAW24_driver[];
  1710. extern m_int _VARAPI DDRAW32_driver[];
  1711. #endif
  1712. #endif
  1713. extern m_int _VARAPI PACKED1_driver[];
  1714. extern m_int _VARAPI PACKED4_driver[];
  1715. extern m_int _VARAPI PACKED8_driver[];
  1716. extern m_int _VARAPI PACKED16_driver[];
  1717. extern m_int _VARAPI PACKED24_driver[];
  1718. extern m_int _VARAPI PACKED32_driver[];
  1719. #endif
  1720. #endif
  1721.  
  1722. /*---------------------------------------------------------------------------
  1723.  * Memory allocation and utility functions.
  1724.  *-------------------------------------------------------------------------*/
  1725.  
  1726. #ifndef    __16BIT__
  1727. #define    _HUGE
  1728. #else
  1729. #define    _HUGE    _huge
  1730. #endif
  1731.  
  1732. void MGL_availableMemory(ulong *physical,ulong *total);
  1733. void MGL_useLocalMalloc(void _HUGE * (*malloc)(long size),void (*free)(void _HUGE *p));
  1734. void * MGLAPI MGL_malloc(long size);
  1735. void * MGLAPI MGL_calloc(long size,long n);
  1736. void MGLAPI MGL_free(void _HUGE *p);
  1737. void MGLAPI MGL_memset(void _HUGE *s,m_int c,long n);
  1738. void MGLAPI MGL_memsetw(void _HUGE *s,m_int c,long n);
  1739. void MGLAPI MGL_memsetl(void _HUGE *s,long c,long n);
  1740.  
  1741. /*---------------------------------------------------------------------------
  1742.  * Set a fullscreen suspend application callback function. This is used in
  1743.  * fullscreen video modes to allow switching back to the normal operating
  1744.  * system graphical shell (such as Windows GDI, OS/2 PM etc).
  1745.  *-------------------------------------------------------------------------*/
  1746.  
  1747. typedef m_int (ASMAPI *MGL_suspend_cb_t)(MGLDC *dc,m_int flags);
  1748. void    MGLAPI MGL_setSuspendAppCallback(MGL_suspend_cb_t staveState);
  1749.  
  1750. /*---------------------------------------------------------------------------
  1751.  * Tell the MGL to use a pre-loaded ACCEL.DRV driver file. This allows
  1752.  * you to link with the SciTech WinDirect/Pro and WinDirect/Ultra device
  1753.  * support libraries and tell the MGL to use the device support drivers.
  1754.  * If the user has a real ACCEL.DRV driver file in the standard location
  1755.  * on their machine, this driver file will still be used.
  1756.  *-------------------------------------------------------------------------*/
  1757.  
  1758. void    MGLAPI MGL_setACCELDriver(void *driver);
  1759.  
  1760. /*---------------------- Inline functions as Macros -----------------------*/
  1761.  
  1762. #define    MGL_equalPoint(p1,p2)    ((p1).x == (p2).x && (p1).y == (p2).y)
  1763.  
  1764. #define    MGL_equalRect(r1,r2)    ((r1).left == (r2).left &&            \
  1765.                                  (r1).top == (r2).top &&            \
  1766.                                  (r1).right == (r2).right &&        \
  1767.                                  (r1).bottom == (r2).bottom)
  1768.  
  1769. #define    MGL_emptyRect(r)        ((r).bottom <= (r).top ||             \
  1770.                                  (r).right <= (r).left)
  1771.  
  1772. #define    MGL_disjointRect(r1,r2)    ((r1).right <= (r2).left ||            \
  1773.                                  (r1).left >= (r2).right ||            \
  1774.                                  (r1).bottom <= (r2).top ||            \
  1775.                                  (r1).top >= (r2).bottom)
  1776.  
  1777. #define    MGL_sectRect(s1,s2,d)                                        \
  1778.    ((d)->left = MAX((s1).left,(s2).left),                           \
  1779.     (d)->right = MIN((s1).right,(s2).right),                        \
  1780.     (d)->top = MAX((s1).top,(s2).top),                              \
  1781.     (d)->bottom = MIN((s1).bottom,(s2).bottom),                     \
  1782.     !MGL_emptyRect(*d))
  1783.  
  1784. #define    MGL_sectRectFast(s1,s2,d)                                    \
  1785.     (d)->left = MAX((s1).left,(s2).left);                           \
  1786.     (d)->right = MIN((s1).right,(s2).right);                        \
  1787.     (d)->top = MAX((s1).top,(s2).top);                              \
  1788.     (d)->bottom = MIN((s1).bottom,(s2).bottom)
  1789.  
  1790. #define    MGL_sectRectCoord(l1,t1,r1,b1,l2,t2,r2,b2,d)                \
  1791.    ((d)->left = MAX(l1,l2),                                            \
  1792.     (d)->right = MIN(r1,r2),                                        \
  1793.     (d)->top = MAX(t1,t2),                                            \
  1794.     (d)->bottom = MIN(b1,b2),                                        \
  1795.     !MGL_emptyRect(*d))
  1796.  
  1797. #define    MGL_sectRectFastCoord(l1,t1,r1,b1,l2,t2,r2,b2,d)            \
  1798.     (d)->left = MAX(l1,l2);                                            \
  1799.     (d)->right = MIN(r1,r2);                                        \
  1800.     (d)->top = MAX(t1,t2);                                            \
  1801.     (d)->bottom = MIN(b1,b2)
  1802.  
  1803. #define    MGL_unionRect(s1,s2,d)                                        \
  1804.     (d)->left = MIN((s1).left,(s2).left);                           \
  1805.     (d)->right = MAX((s1).right,(s2).right);                        \
  1806.     (d)->top = MIN((s1).top,(s2).top);                              \
  1807.     (d)->bottom = MAX((s1).bottom,(s2).bottom)
  1808.  
  1809. #define MGL_unionRectCoord(l1,t1,r1,b1,l2,t2,r2,b2,d)                \
  1810.     (d)->left = MIN(l1,l2);                                         \
  1811.     (d)->right = MAX(r1,r2);                                          \
  1812.     (d)->top = MIN(t1,t2);                                            \
  1813.     (d)->bottom = MAX(b1,b2)
  1814.  
  1815. #define    MGL_offsetRect(r,dx,dy)                                        \
  1816.     {    (r).left += dx; (r).right += dx;                            \
  1817.         (r).top += dy; (r).bottom += dy; }
  1818.  
  1819. #define    MGL_insetRect(r,dx,dy)                                        \
  1820.     {    (r).left += dx; (r).right -= dx;                            \
  1821.         (r).top += dy; (r).bottom -= dy;                            \
  1822.         if (MGL_emptyRect(r))                                        \
  1823.             (r).left = (r).right = (r).top = (r).bottom = 0; }
  1824.  
  1825. #define    MGL_ptInRect(p,r)        ((p).x >= (r).left &&                \
  1826.                                  (p).x < (r).right &&                \
  1827.                                  (p).y >= (r).top &&                \
  1828.                                  (p).y < (r).bottom)
  1829.  
  1830. #define    MGL_ptInRectCoord(x,y,r)    ((x) >= (r).left &&                \
  1831.                                      (x) < (r).right &&                \
  1832.                                      (y) >= (r).top &&                \
  1833.                                      (y) < (r).bottom)
  1834.  
  1835. #define    MGL_ptInRegion(p,r)        MGL_ptInRegionCoord((p).x,(p).y,r)
  1836.  
  1837. #define    MGL_pixel(p)            MGL_pixelCoord((p).x,(p).y)
  1838. #define    MGL_getPixel(p)            MGL_getPixelCoord((p).x,(p).y)
  1839. #define    MGL_pixelFast(p)        MGL_pixelCoordFast((p).x,(p).y)
  1840. #define    MGL_getPixelFast(p)        MGL_getPixelCoordFast((p).x,(p).y)
  1841. #define    MGL_moveTo(p)            MGL_moveToCoord((p).x,(p).y)
  1842. #define MGL_moveRel(p)            MGL_moveRelCoord((p).x,(p).y)
  1843. #define    MGL_line(p1,p2)            MGL_lineCoord((p1).x,(p1).y,(p2).x,(p2).y)
  1844. #define    MGL_lineFast(p1,p2)        MGL_lineCoordFast((p1).x,(p1).y,(p2).x,(p2).y)
  1845. #define    MGL_lineFX(p1,p2)        MGL_lineCoordFX((p1).x,(p1).y,(p2).x,(p2).y)
  1846. #define    MGL_lineFastFX(p1,p2)    MGL_lineCoordFastFX((p1).x,(p1).y,(p2).x,(p2).y)
  1847. #define    MGL_cLineFast(p1,p2)    MGL_cLineCoordFast((p1).p.x,(p1).p.y,(p1).c,(p2).p.x,(p2).p.y,(p2).c)
  1848. #define    MGL_rgbLineFast(p1,p2)    MGL_rgbLineCoordFast((p1).p.x,(p1).p.y,(p1).c.r,(p1).c.g,(p1).c.b,(p2).p.x,(p2).p.y,(p2).c.r,(p2).c.g,(p2).c.b)
  1849. #define    MGL_zLineFast(p1,p2)    MGL_zLineCoordFast((p1).p.x,(p1).p.y,(p1).z,(p2).p.x,(p2).p.y,(p2).z)
  1850. #define    MGL_czLineFast(p1,p2)    MGL_czLineCoordFast((p1).p.x,(p1).p.y,(p1).z,(p1).c,(p2).p.x,(p2).p.y,(p2).z,(p2).c)
  1851. #define    MGL_rgbzLineFast(p1,p2)    MGL_rgbzLineCoordFast((p1).p.x,(p1).p.y,(p1).z,(p1).c.r,(p1).c.g,(p1).c.b,(p2).p.x,(p2).p.y,(p2).z,(p2).c.r,(p2).c.g,(p2).c.b)
  1852.  
  1853. #define    MGL_zClearPt(lt,rb,z)    MGL_zClearCoord((lt).x,(lt).y,    \
  1854.                                     (rb).x,(rb).y,z)
  1855. #define    MGL_zClear(r,z)            MGL_zClearCoord((r).left,(r).top,    \
  1856.                                     (r).right,(r).bottom,z)
  1857. #define    MGL_lineTo(p)            MGL_lineToCoord((p).x,(p).y)
  1858. #define    MGL_lineRel(p)            MGL_lineRelCoord((p).x,(p).y);
  1859. #define    MGL_rectPt(lt,rb)        MGL_rectCoord((lt).x,(lt).y,(rb).x,(rb).y)
  1860. #define    MGL_rect(r)                MGL_rectCoord((r).left,(r).top,            \
  1861.                                     (r).right,(r).bottom)
  1862. #define    MGL_drawBorder(r,s,t)    MGL_drawBorderCoord((r).left,(r).top,    \
  1863.                                     (r).right,(r).bottom,(s),(t))
  1864. #define    MGL_fillRectPt(lt,rb)    MGL_fillRectCoord((lt).x,(lt).y,    \
  1865.                                     (rb).x,(rb).y)
  1866. #define    MGL_fillRect(r)            MGL_fillRectCoord((r).left,(r).top,    \
  1867.                                     (r).right,(r).bottom)
  1868. #define    MGL_bitBlt(d,s,r,dl,dt,op)     MGL_bitBltCoord((d),(s),(r).left,        \
  1869.                                     (r).top,(r).right,(r).bottom,dl,dt,op)
  1870. #define    MGL_bitBltLin(d,s,so,r,op) MGL_bitBltLinCoord((d),(s),so,            \
  1871.                                     (r).left,(r).top,(r).right,(r).bottom,op)
  1872. #define    MGL_stretchBlt(d,s,sr,dr)     MGL_stretchBltCoord((d),(s),(sr).left,        \
  1873.                                     (sr).top,(sr).right,(sr).bottom,    \
  1874.                                     (dr).left,(dr).top,(dr).right,(dr).bottom)
  1875. #define    MGL_transBlt(d,s,r,dl,dt,c,st)    MGL_transBltCoord((d),(s),(r).left,        \
  1876.                                     (r).top,(r).right,(r).bottom,dl,dt,c,st)
  1877. #define    MGL_transBltLin(d,s,so,r,c,st) MGL_transBltLinCoord((d),(s),so,    \
  1878.                                     (r).left,(r).top,(r).right,(r).bottom,c,st)
  1879. #define    MGL_getDivot(dc,r,divot) MGL_getDivotCoord(dc,(r).left,(r).top,    \
  1880.                                     (r).right,(r).bottom,divot)
  1881. #define    MGL_divotSize(dc,r)        MGL_divotSizeCoord(dc,(r).left,(r).top,\
  1882.                                     (r).right,(r).bottom)
  1883. #define    MGL_isSimpleRegion(r)    (((region_t*)(r))->spans == NULL)
  1884. #define    MGL_rgnLine(p1,p2,p)    MGL_rgnLineCoord((p1).x,(p1).y,(p2).x,(p2).y,p)
  1885. #define    MGL_rgnLineFX(p1,p2,p)    MGL_rgnLineCoordFX((p1).x,(p1).y,(p2).x,(p2).y,p)
  1886. #define    MGL_rgnSolidRectPt(lt,rb)    MGL_rgnSolidRectCoord((lt).x,(lt).y,    \
  1887.                                     (rb).x,(rb).y)
  1888. #define    MGL_rgnSolidRect(r)            MGL_rgnSolidRectCoord((r).left,(r).top,    \
  1889.                                     (r).right,(r).bottom)
  1890.  
  1891. /* Fast color packing/unpacking routines implemented as macros */
  1892.  
  1893. #define    MGL_packColorFast(pf,R,G,B)                                                    \
  1894.  ((ulong)(((uchar)(R) >> (pf)->redAdjust) & (pf)->redMask) << (pf)->redPos)            \
  1895.  | ((ulong)(((uchar)(G) >> (pf)->greenAdjust) & (pf)->greenMask) << (pf)->greenPos)    \
  1896.  | ((ulong)(((uchar)(B) >> (pf)->blueAdjust) & (pf)->blueMask) << (pf)->bluePos)
  1897.  
  1898. #define    MGL_unpackColorFast(pf,c,R,G,B)                                                \
  1899. {                                                                                    \
  1900.  (R) = (uchar)((((ulong)(c) >> (pf)->redPos) & (pf)->redMask) << (pf)->redAdjust);        \
  1901.  (G) = (uchar)((((ulong)(c) >> (pf)->greenPos) & (pf)->greenMask) << (pf)->greenAdjust);\
  1902.  (B) = (uchar)((((ulong)(c) >> (pf)->bluePos) & (pf)->blueMask) << (pf)->blueAdjust);    \
  1903. }
  1904.  
  1905. /* Macros to access the RGB components in a packed 24 bit RGB tuple */
  1906.  
  1907. #define    MGL_rgbRed(c)    (((uchar*)&(c))[2])
  1908. #define    MGL_rgbGreen(c)    (((uchar*)&(c))[1])
  1909. #define    MGL_rgbBlue(c)    (((uchar*)&(c))[0])
  1910.  
  1911. /* Fast 24 bit color packing/unpacking routines implemented as macros */
  1912.  
  1913. #define    MGL_packColorRGBFast(R,G,B)                                            \
  1914.  (((ulong)((uchar)(R)) << 16) | ((ulong)((uchar)(G)) << 8) | (uchar)(B))
  1915.  
  1916. #define    MGL_packColorRGBFast2(c,R,G,B)                                        \
  1917. {                                                                            \
  1918.  MGL_rgbRed(c) = (uchar)(R);                                                \
  1919.  MGL_rgbGreen(c) = (uchar)(G);                                                \
  1920.  MGL_rgbBlue(c) = (uchar)(B);                                                \
  1921. }
  1922.  
  1923. #define    MGL_unpackColorRGBFast(c,R,G,B)                                        \
  1924. {                                                                            \
  1925.  (R) = MGL_rgbRed(c);                                                        \
  1926.  (G) = MGL_rgbGreen(c);                                                        \
  1927.  (B) = MGL_rgbBlue(c);                                                        \
  1928. }
  1929.  
  1930. #ifdef    __cplusplus
  1931. }                        /* End of "C" linkage for C++    */
  1932.  
  1933. #include "mglrect.hpp"    /* Include C++ point/rectangle classes            */
  1934.  
  1935. #endif    /* __cplusplus */
  1936.  
  1937. /* Include appropriate platform specific bindings */
  1938.  
  1939. #if defined(MGLWIN) || defined(__WINDOWS__)
  1940. #include "mglwin.h"
  1941. #elif defined(MGLPM) || defined(__OS2__)
  1942. /*#include "mglpm.h"*/
  1943. #elif defined(MGLX) || defined(__UNIX__)
  1944. /*#include "mglx.h"*/
  1945. #else
  1946. #include "mgldos.h"
  1947. #endif
  1948.  
  1949. #pragma pack()                /* Return to default packing                */
  1950.  
  1951. #endif    /* __MGRAPH_H */
  1952.