mgraph.h 73 KB

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