GR.H 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/2d/rcs/gr.h $
  15. * $Revision: 1.45 $
  16. * $Author: john $
  17. * $Date: 1994/11/18 22:50:21 $
  18. *
  19. * Definitions for graphics lib.
  20. *
  21. * $Log: gr.h $
  22. * Revision 1.45 1994/11/18 22:50:21 john
  23. * Changed shorts to ints in parameters.
  24. *
  25. * Revision 1.44 1994/11/13 13:04:07 john
  26. * Added paged out bit in bitmap structure. Commented out the
  27. * poly code that is never used.
  28. *
  29. * Revision 1.43 1994/11/09 23:04:56 mike
  30. * Add avg_color field.
  31. *
  32. * Revision 1.42 1994/10/27 00:53:35 john
  33. * Added RLE Flag to bitmap structere.
  34. *
  35. * Revision 1.41 1994/10/26 23:55:52 john
  36. * Took out roller; Took out inverse table.
  37. *
  38. * Revision 1.40 1994/08/11 17:59:12 mike
  39. * Assembler merge functions written for 3 rotations of bitmaps.
  40. *
  41. * Revision 1.39 1994/08/10 12:24:56 matt
  42. * Added support for colors fonts & kerned fonts
  43. * Made our own font file format
  44. *
  45. * Revision 1.38 1994/07/27 18:30:18 john
  46. * Took away the blending table.
  47. *
  48. * Revision 1.37 1994/06/16 15:25:06 mike
  49. * Add flag BM_FLAG_NO_LIGHTING.
  50. *
  51. * Revision 1.36 1994/05/31 10:01:22 john
  52. * *** empty log message ***
  53. *
  54. * Revision 1.35 1994/05/31 07:53:34 john
  55. * *** empty log message ***
  56. *
  57. * Revision 1.34 1994/05/14 17:19:41 matt
  58. * Added externs
  59. *
  60. * Revision 1.33 1994/05/12 17:33:09 john
  61. * Added circle code.
  62. *
  63. * Revision 1.32 1994/05/06 12:50:16 john
  64. * Added supertransparency; neatend things up; took out warnings.
  65. *
  66. * Revision 1.31 1994/05/04 10:06:06 john
  67. * Added flag for bitmap super-transparency.
  68. *
  69. * Revision 1.30 1994/05/03 19:38:56 john
  70. * *** empty log message ***
  71. *
  72. * Revision 1.29 1994/04/22 11:16:05 john
  73. * *** empty log message ***
  74. *
  75. * Revision 1.28 1994/04/08 16:59:32 john
  76. * Add fading poly's; Made palette fade 32 instead of 16.
  77. *
  78. * Revision 1.27 1994/03/16 17:29:52 john
  79. * *** empty log message ***
  80. *
  81. * Revision 1.26 1994/03/16 17:20:51 john
  82. * Added slow palette searching options.
  83. *
  84. * Revision 1.25 1994/03/14 17:59:20 john
  85. * Added function to check bitmap's transparency.
  86. *
  87. * Revision 1.24 1994/03/14 16:56:26 john
  88. * Changed grs_bitmap structure to include bm_flags.
  89. *
  90. * Revision 1.23 1994/02/18 15:32:30 john
  91. * *** empty log message ***
  92. *
  93. * Revision 1.22 1994/01/25 11:40:48 john
  94. * Added gr_check_mode function.
  95. *
  96. * Revision 1.21 1994/01/12 13:45:24 john
  97. * Added scaler.
  98. *
  99. * Revision 1.20 1993/12/21 19:58:24 john
  100. * added selector stuff
  101. *
  102. * Revision 1.19 1993/12/21 11:40:40 john
  103. * *** empty log message ***
  104. *
  105. * Revision 1.18 1993/12/09 15:02:08 john
  106. * Changed palette stuff majorly
  107. *
  108. * Revision 1.17 1993/12/07 12:32:05 john
  109. * moved bmd_palette to gr_palette
  110. *
  111. * Revision 1.16 1993/11/28 12:08:06 mike
  112. * Change prototype for rotate_bitmap.
  113. *
  114. * Revision 1.15 1993/11/18 14:22:51 mike
  115. * Add prototype for rotate_bitmap.
  116. *
  117. * Revision 1.14 1993/11/17 19:00:59 mike
  118. * Add prototype for test_rotate_bitmap
  119. *
  120. * Revision 1.13 1993/11/16 11:28:58 john
  121. * *** empty log message ***
  122. *
  123. * Revision 1.12 1993/10/26 13:17:43 john
  124. * *** empty log message ***
  125. *
  126. * Revision 1.11 1993/10/15 16:23:37 john
  127. * y
  128. *
  129. * Revision 1.10 1993/09/28 15:32:33 john
  130. * added def for save/restore vidmode
  131. *
  132. * Revision 1.9 1993/09/28 12:51:46 matt
  133. * Added aspect ratio to grs_screen structure
  134. *
  135. * Revision 1.8 1993/09/26 22:45:12 matt
  136. * Changed prototypes for line functions to take fixes, not ints.
  137. *
  138. * Revision 1.7 1993/09/26 18:58:16 john
  139. * fadein/out stuff
  140. *
  141. * Revision 1.6 1993/09/14 16:26:44 matt
  142. * Changed gr_change_mode() to be gr_set_mode()
  143. *
  144. * Revision 1.4 1993/09/14 13:08:45 john
  145. * added gr_change_mode
  146. *
  147. * Revision 1.3 1993/09/08 13:56:03 matt
  148. * Put 'if' block around body of file; added bitmap type BM_RGB15
  149. *
  150. * Revision 1.2 1993/09/08 13:02:14 john
  151. * Changed structure definitions a bit.
  152. *
  153. * Revision 1.1 1993/09/08 11:25:15 john
  154. * Initial revision
  155. *
  156. *
  157. */
  158. #ifndef _GR_H
  159. #define _GR_H
  160. #include "types.h"
  161. #include "fix.h"
  162. #define GR_FADE_LEVELS 34
  163. #define GR_ACTUAL_FADE_LEVELS 32
  164. extern int Gr_scanline_darkening_level;
  165. typedef struct _grs_point {
  166. fix x,y;
  167. } grs_point;
  168. typedef struct _grs_font {
  169. short ft_w,ft_h; // Width and height in pixels
  170. short ft_flags; // Proportional?
  171. short ft_baseline; //
  172. ubyte ft_minchar, // The first and last chars defined by
  173. ft_maxchar; // This font
  174. short ft_bytewidth; // Width in unsigned chars
  175. ubyte * ft_data; // Ptr to raw data.
  176. ubyte ** ft_chars; // Ptrs to data for each char (required for prop font)
  177. short * ft_widths; // Array of widths (required for prop font)
  178. ubyte * ft_kerndata; // Array of kerning triplet data
  179. } grs_font;
  180. #define BM_LINEAR 0
  181. #define BM_MODEX 1
  182. #define BM_SVGA 2
  183. #define BM_RGB15 3 //5 bits each r,g,b stored at 16 bits
  184. #define BM_SVGA15 4
  185. #define BM_FLAG_TRANSPARENT 1
  186. #define BM_FLAG_SUPER_TRANSPARENT 2
  187. #define BM_FLAG_NO_LIGHTING 4
  188. #define BM_FLAG_RLE 8 // A run-length encoded bitmap.
  189. #define BM_FLAG_PAGED_OUT 16 // This bitmap's data is paged out.
  190. typedef struct _grs_bitmap {
  191. short bm_x,bm_y; // Offset from parent's origin
  192. short bm_w,bm_h; // width,height
  193. byte bm_type; // 0=Linear, 1=ModeX, 2=SVGA
  194. byte bm_flags; // bit 0 on means it has transparency.
  195. // bit 1 on means it has supertransparency
  196. // bit 2 on means it doesn't get passed through lighting.
  197. short bm_rowsize; // unsigned char offset to next row
  198. unsigned char * bm_data; // ptr to pixel data...
  199. // Linear = *parent+(rowsize*y+x)
  200. // ModeX = *parent+(rowsize*y+x/4)
  201. // SVGA = *parent+(rowsize*y+x)
  202. unsigned short bm_selector;
  203. ubyte avg_color; // Average color of all pixels in texture map.
  204. byte unused; // to 4-byte align.
  205. } grs_bitmap;
  206. typedef struct _grs_canvas {
  207. grs_bitmap cv_bitmap; // the bitmap for this canvas
  208. short cv_color; // current color
  209. short cv_drawmode; // fill,XOR,etc.
  210. grs_font * cv_font; // the currently selected font
  211. short cv_font_fg_color; // current font foreground color (-1==Invisible)
  212. short cv_font_bg_color; // current font background color (-1==Invisible)
  213. } grs_canvas;
  214. typedef struct _grs_screen { // This is a video screen
  215. grs_canvas sc_canvas; // Represents the entire screen
  216. short sc_mode; // Video mode number
  217. short sc_w, sc_h; // Actual Width and Height
  218. fix sc_aspect; //aspect ratio (w/h) for this screen
  219. } grs_screen;
  220. // Num Cols Rows Bpp Mode Pages Aspect
  221. // --- ---- ---- --- ---- ----- ------
  222. // 0 320 200 8 C 1.0 1.2:1
  223. // 1 320 200 8 U 4.0 1.2
  224. // 2 320 240 8 U 3.4 1.0
  225. // 3 360 200 8 U 3.6 1.4
  226. // 4 360 240 8 U 3.0 1.1
  227. // 5 376 282 8 U 2.5 1.0
  228. // 6 320 400 8 U 2.0 0.6
  229. // 7 320 480 8 U 1.7 0.5
  230. // 8 360 400 8 U 1.8 0.7
  231. // 9 360 480 8 U 1.5 0.6
  232. // 10 360 360 8 U 2.0 0.8
  233. // 11 376 308 8 U 2.3 0.9
  234. // 12 376 564 8 U 1.2 0.5
  235. // 13 640 400 8 V 4.1 1.2 (Assuming 1 Meg video RAM)
  236. // 14 640 480 8 V 3.4 1.0
  237. // 15 800 600 8 V 2.2 1.0
  238. // 16 1024 768 8 V 1.0 1.0
  239. // 17 640 480 15 V 1.0 1.0
  240. // 18 800 600 15 V 1.0 1.0
  241. #define SM_ORIGINAL -1
  242. #define SM_320x200C 0
  243. #define SM_320x200U 1
  244. #define SM_320x240U 2
  245. #define SM_360x200U 3
  246. #define SM_360x240U 4
  247. #define SM_376x282U 5
  248. #define SM_320x400U 6
  249. #define SM_320x480U 7
  250. #define SM_360x400U 8
  251. #define SM_360x480U 9
  252. #define SM_360x360U 10
  253. #define SM_376x308U 11
  254. #define SM_376x564U 12
  255. #define SM_640x400V 13
  256. #define SM_640x480V 14
  257. #define SM_800x600V 15
  258. #define SM_1024x768V 16
  259. #define SM_640x480V15 17
  260. #define SM_800x600V15 18
  261. //=========================================================================
  262. // System functions:
  263. // setup and set mode. this creates a grs_screen structure and sets
  264. // grd_curscreen to point to it. grs_curcanv points to this screen's
  265. // canvas. Saves the current VGA state and screen mode.
  266. int gr_init(int mode);
  267. int gr_set_mode(int mode);
  268. void gr_enable_default_palette_loading();
  269. void gr_disable_default_palette_loading();
  270. // These 4 functions actuall change screen colors.
  271. extern void gr_pal_fade_out(unsigned char * pal);
  272. extern void gr_pal_fade_in(unsigned char * pal);
  273. extern void gr_pal_clear();
  274. extern void gr_pal_setblock( int start, int number, unsigned char * pal );
  275. extern void gr_pal_getblock( int start, int number, unsigned char * pal );
  276. extern int gr_init_A0000(); // Initializes _A0000. Returns true if failed.
  277. extern unsigned short _A0000; // Selector for screen segment
  278. //shut down the 2d. Restore the screen mode.
  279. int gr_close();
  280. // 0=Mode set OK
  281. // 1=No VGA adapter installed
  282. // 2=Program doesn't support this VESA granularity
  283. // 3=Monitor doesn't support that VESA mode.:
  284. // 4=Video card doesn't support that VESA mode.
  285. // 5=No VESA driver found.
  286. // 6=Bad Status after VESA call/
  287. // 7=Not enough DOS memory to call VESA functions.
  288. // 8=Error using DPMI.
  289. // 9=Error setting logical line width.
  290. // 10=Error allocating selector for A0000h
  291. // 11=Not a valid mode support by gr.lib
  292. // Returns one of the above without setting mode
  293. int gr_check_mode(int mode);
  294. extern int gr_save_mode();
  295. extern void gr_restore_mode();
  296. //=========================================================================
  297. // Canvas functions:
  298. // Makes a new canvas. allocates memory for the canvas and its bitmap,
  299. // including the raw pixel buffer.
  300. grs_canvas *gr_create_canvas(int w, int h);
  301. // Creates a canvas that is part of another canvas. this can be used to make
  302. // a window on the screen. the canvas structure is malloc'd; the address of
  303. // the raw pixel data is inherited from the parent canvas.
  304. grs_canvas *gr_create_sub_canvas(grs_canvas *canv,int x,int y,int w, int h);
  305. // Initialize the specified canvas. the raw pixel data buffer is passed as
  306. // a parameter. no memory allocation is performed.
  307. gr_init_canvas(grs_canvas *canv,unsigned char *pixdata,int pixtype, int w,int h);
  308. // Initialize the specified sub canvas. no memory allocation is performed.
  309. gr_init_sub_canvas(grs_canvas *new,grs_canvas *src,int x,int y,int w, int h);
  310. // Free up the canvas and its pixel data.
  311. gr_free_canvas(grs_canvas *canv);
  312. // Free up the canvas. do not free the pixel data, which belongs to the
  313. // parent canvas.
  314. gr_free_sub_canvas(grs_canvas *canv);
  315. // Clear the current canvas to the specified color
  316. gr_clear_canvas(int color);
  317. //=========================================================================
  318. // Bitmap functions:
  319. // Allocate a bitmap and its pixel data buffer.
  320. grs_bitmap *gr_create_bitmap(int w,int h);
  321. // Allocated a bitmap and makes its data be raw_data that is already somewhere.
  322. grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data );
  323. // Creates a bitmap which is part of another bitmap
  324. grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm,int x,int y,int w, int h);
  325. // Free the bitmap and its pixel data
  326. gr_free_bitmap(grs_bitmap *bm);
  327. // Free the bitmap, but not the pixel data buffer
  328. gr_free_sub_bitmap(grs_bitmap *bm);
  329. void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color );
  330. void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color );
  331. void gr_bm_ubitblt( int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
  332. void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
  333. void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
  334. //=========================================================================
  335. // Color functions:
  336. // When this function is called, the guns are set to gr_palette, and
  337. // the palette stays the same until gr_close is called
  338. void gr_use_palette_table(char * filename );
  339. //=========================================================================
  340. // Drawing functions:
  341. // For solid, XOR, or other fill modes.
  342. gr_set_drawmode(int mode);
  343. // Sets the color in the current canvas. should be a macro
  344. // Use: gr_setcolor(int color);
  345. void gr_setcolor(int color);
  346. // Draw a polygon into the current canvas in the current color and drawmode.
  347. // verts points to an ordered list of x,y pairs. the polygon should be
  348. // convex; a concave polygon will be handled in some reasonable manner,
  349. // but not necessarily shaded as a concave polygon. It shouldn't hang.
  350. // probably good solution is to shade from minx to maxx on each scan line.
  351. // int should really be fix
  352. gr_poly(int nverts,int *verts);
  353. gr_upoly(int nverts,int *verts);
  354. // Draws a point into the current canvas in the current color and drawmode.
  355. gr_pixel(int x,int y);
  356. gr_upixel(int x,int y);
  357. // Gets a pixel;
  358. unsigned char gr_gpixel( grs_bitmap * bitmap, int x, int y );
  359. unsigned char gr_ugpixel( grs_bitmap * bitmap, int x, int y );
  360. // Draws a line into the current canvas in the current color and drawmode.
  361. int gr_line(fix x0,fix y0,fix x1,fix y1);
  362. int gr_uline(fix x0,fix y0,fix x1,fix y1);
  363. // Draws an anti-aliased line into the current canvas in the current color and drawmode.
  364. int gr_aaline(fix x0,fix y0,fix x1,fix y1);
  365. int gr_uaaline(fix x0,fix y0,fix x1,fix y1);
  366. // Draw the bitmap into the current canvas at the specified location.
  367. gr_bitmap(int x,int y,grs_bitmap *bm);
  368. gr_ubitmap(int x,int y,grs_bitmap *bm);
  369. // bitmap function with transparency
  370. gr_bitmapm( int x, int y, grs_bitmap *bm );
  371. gr_ubitmapm( int x, int y, grs_bitmap *bm );
  372. // Draw a rectangle into the current canvas.
  373. gr_rect(int left,int top,int right,int bot);
  374. gr_urect(int left,int top,int right,int bot);
  375. // Draw a filled circle
  376. int gr_disk(fix x,fix y,fix r);
  377. int gr_udisk(fix x,fix y,fix r);
  378. // Draw an outline circle
  379. gr_circle(fix x,fix y,fix r);
  380. gr_ucircle(fix x,fix y,fix r);
  381. // Draw an unfilled rectangle into the current canvas
  382. gr_box(int left,int top,int right,int bot);
  383. gr_ubox(int left,int top,int right,int bot);
  384. void gr_scanline( int x1, int x2, int y );
  385. void gr_uscanline( int x1, int x2, int y );
  386. // Reads in a font file... current font set to this one.
  387. grs_font * gr_init_font( char * fontfile );
  388. void gr_close_font( grs_font * font );
  389. // Writes a string using current font. Returns the next column after last char.
  390. void gr_set_fontcolor( int fg, int bg );
  391. void gr_set_curfont( grs_font * new );
  392. int gr_string(int x, int y, char *s );
  393. int gr_ustring(int x, int y, char *s );
  394. int gr_printf( int x, int y, char * format, ... );
  395. int gr_uprintf( int x, int y, char * format, ... );
  396. void gr_get_string_size(char *s, int *string_width, int *string_height, int *average_width );
  397. // From roller.c
  398. void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
  399. // From scale.c
  400. void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf );
  401. //===========================================================================
  402. // Global variables
  403. extern grs_canvas *grd_curcanv; //active canvas
  404. extern grs_screen *grd_curscreen; //active screen
  405. extern unsigned char Test_bitmap_data[64*64];
  406. extern unsigned int FixDivide( unsigned int x, unsigned int y );
  407. extern void gr_show_canvas( grs_canvas *canv );
  408. extern void gr_set_current_canvas( grs_canvas *canv );
  409. //flags for fonts
  410. #define FT_COLOR 1
  411. #define FT_PROPORTIONAL 2
  412. #define FT_KERNED 4
  413. extern void gr_vesa_update( grs_bitmap * source1, grs_bitmap * dest, grs_bitmap * source2 );
  414. // Special effects
  415. extern void gr_snow_out(int num_dots);
  416. extern void test_rotate_bitmap(void);
  417. extern void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
  418. extern ubyte gr_palette[256*3];
  419. extern ubyte gr_fade_table[256*GR_FADE_LEVELS];
  420. extern ubyte gr_inverse_table[32*32*32];
  421. extern ushort gr_palette_selector;
  422. extern ushort gr_inverse_table_selector;
  423. extern ushort gr_fade_table_selector;
  424. // Remaps a bitmap into the current palette. If transparent_color is between 0 and 255
  425. // then all occurances of that color are mapped to whatever color the 2d uses for
  426. // transparency. This is normally used right after a call to iff_read_bitmap like
  427. // this:
  428. // iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
  429. // if (iff_error != IFF_NO_ERROR) Error("Can't load IFF file <%s>, error=%d",filename,iff_error);
  430. // if ( iff_has_transparency )
  431. // gr_remap_bitmap( new, newpal, iff_transparent_color );
  432. // else
  433. // gr_remap_bitmap( new, newpal, -1 );
  434. extern void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
  435. // Same as above, but searches using gr_find_closest_color which uses 18-bit accurracy
  436. // instaed of 15bit when translating colors.
  437. extern void gr_remap_bitmap_good( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
  438. extern void gr_palette_step_up( int r, int g, int b );
  439. extern void gr_bitmap_check_transparency( grs_bitmap * bmp );
  440. // Allocates a selector that has a base address at 'address' and length 'size'.
  441. // Returns 0 if successful... BE SURE TO CHECK the return value since there
  442. // is a limited number of selectors available!!!
  443. extern int get_selector( void * address, int size, unsigned int * selector );
  444. // Assigns a selector to a bitmap. Returns 0 if successful. BE SURE TO CHECK
  445. // this return value since there is a limited number of selectors!!!!!!!
  446. extern int gr_bitmap_assign_selector( grs_bitmap * bmp );
  447. //#define GR_GETCOLOR(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
  448. //#define gr_getcolor(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
  449. //#define BM_XRGB(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
  450. #define BM_RGB(r,g,b) ( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )
  451. #define BM_XRGB(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
  452. #define GR_GETCOLOR(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
  453. #define gr_getcolor(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
  454. // Given: r,g,b, each in range of 0-63, return the color index that
  455. // best matches the input.
  456. int gr_find_closest_color( int r, int g, int b );
  457. extern void gr_merge_textures( ubyte * lower, ubyte * upper, ubyte * dest );
  458. extern void gr_merge_textures_1( ubyte * lower, ubyte * upper, ubyte * dest );
  459. extern void gr_merge_textures_2( ubyte * lower, ubyte * upper, ubyte * dest );
  460. extern void gr_merge_textures_3( ubyte * lower, ubyte * upper, ubyte * dest );
  461. #endif
  462.