home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / 2d / gr.h < prev    next >
Text File  |  1998-06-08  |  20KB  |  551 lines

  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.  
  159. #ifndef _GR_H
  160. #define _GR_H
  161.  
  162. #include "types.h"
  163. #include "fix.h"
  164.  
  165. #define GR_FADE_LEVELS 34
  166. #define GR_ACTUAL_FADE_LEVELS 32
  167.  
  168. extern int Gr_scanline_darkening_level;
  169.  
  170. typedef struct _grs_point {
  171.     fix    x,y;
  172. } grs_point;
  173.  
  174. typedef struct _grs_font {
  175.     short        ft_w,ft_h;        // Width and height in pixels
  176.     short        ft_flags;        // Proportional?
  177.     short        ft_baseline;    //
  178.     ubyte        ft_minchar,        // The first and last chars defined by
  179.                 ft_maxchar;        // This font
  180.     short        ft_bytewidth;    // Width in unsigned chars
  181.     ubyte    *     ft_data;            // Ptr to raw data.
  182.     ubyte    **    ft_chars;        // Ptrs to data for each char (required for prop font)
  183.     short    *    ft_widths;        // Array of widths (required for prop font)
  184.     ubyte *  ft_kerndata;    // Array of kerning triplet data
  185. } grs_font;
  186.  
  187. #define BM_LINEAR   0
  188. #define BM_MODEX    1
  189. #define BM_SVGA     2
  190. #define BM_RGB15    3   //5 bits each r,g,b stored at 16 bits
  191. #define BM_SVGA15   4
  192.  
  193. #define BM_FLAG_TRANSPARENT            1
  194. #define BM_FLAG_SUPER_TRANSPARENT    2
  195. #define BM_FLAG_NO_LIGHTING            4
  196. #define BM_FLAG_RLE                        8            // A run-length encoded bitmap.
  197. #define BM_FLAG_PAGED_OUT                16            // This bitmap's data is paged out.
  198.  
  199. typedef struct _grs_bitmap {
  200.     short       bm_x,bm_y;      // Offset from parent's origin
  201.     short       bm_w,bm_h;      // width,height
  202.     byte           bm_type;        // 0=Linear, 1=ModeX, 2=SVGA
  203.     byte            bm_flags;        // bit 0 on means it has transparency.
  204.                                         // bit 1 on means it has supertransparency
  205.                                         // bit 2 on means it doesn't get passed through lighting.
  206.     short        bm_rowsize;     // unsigned char offset to next row
  207.     unsigned char *      bm_data;         // ptr to pixel data...
  208.                                 //   Linear = *parent+(rowsize*y+x)
  209.                                 //   ModeX = *parent+(rowsize*y+x/4)
  210.                                 //   SVGA = *parent+(rowsize*y+x)
  211.     unsigned short bm_selector;
  212.     ubyte            avg_color;        //    Average color of all pixels in texture map.
  213.     byte            unused;            //    to 4-byte align.
  214. } grs_bitmap;
  215.  
  216. typedef struct _grs_canvas {
  217.     grs_bitmap  cv_bitmap;      // the bitmap for this canvas
  218.     short       cv_color;       // current color
  219.     short       cv_drawmode;    // fill,XOR,etc.
  220.     grs_font *  cv_font;        // the currently selected font
  221.     short       cv_font_fg_color;   // current font foreground color (-1==Invisible)
  222.     short       cv_font_bg_color;   // current font background color (-1==Invisible)
  223. } grs_canvas;
  224.  
  225. typedef struct _grs_screen {     // This is a video screen
  226.     grs_canvas  sc_canvas;      // Represents the entire screen
  227.     short       sc_mode;        // Video mode number
  228.     short       sc_w, sc_h;     // Actual Width and Height
  229.     fix            sc_aspect;        //aspect ratio (w/h) for this screen
  230. } grs_screen;
  231.  
  232. // Num Cols Rows Bpp Mode Pages Aspect
  233. // --- ---- ---- --- ---- ----- ------
  234. // 0   320  200  8   C    1.0   1.2:1
  235. // 1   320  200  8   U    4.0   1.2
  236. // 2   320  240  8   U    3.4   1.0
  237. // 3   360  200  8   U    3.6   1.4
  238. // 4   360  240  8   U    3.0   1.1
  239. // 5   376  282  8   U    2.5   1.0
  240. // 6   320  400  8   U    2.0   0.6
  241. // 7   320  480  8   U    1.7   0.5
  242. // 8   360  400  8   U    1.8   0.7
  243. // 9   360  480  8   U    1.5   0.6
  244. // 10  360  360  8   U    2.0   0.8
  245. // 11  376  308  8   U    2.3   0.9
  246. // 12  376  564  8   U    1.2   0.5
  247. // 13  640  400  8   V    4.1   1.2     (Assuming 1 Meg video RAM)
  248. // 14  640  480  8   V    3.4   1.0
  249. // 15  800  600  8   V    2.2   1.0
  250. // 16  1024 768  8   V    1.0   1.0
  251. // 17  640  480  15  V    1.0   1.0
  252. // 18  800  600  15  V    1.0   1.0
  253.  
  254. #define SM_ORIGINAL        -1
  255. #define SM_320x200C     0
  256. #define SM_320x200U     1
  257. #define SM_320x240U     2
  258. #define SM_360x200U     3
  259. #define SM_360x240U     4
  260. #define SM_376x282U     5
  261. #define SM_320x400U     6
  262. #define SM_320x480U     7
  263. #define SM_360x400U     8
  264. #define SM_360x480U     9
  265. #define SM_360x360U     10
  266. #define SM_376x308U     11
  267. #define SM_376x564U     12
  268. #define SM_640x400V     13
  269. #define SM_640x480V     14
  270. #define SM_800x600V     15
  271. #define SM_1024x768V    16
  272. #define SM_640x480V15   17
  273. #define SM_800x600V15   18
  274.  
  275. //=========================================================================
  276. // System functions:
  277. // setup and set mode. this creates a grs_screen structure and sets
  278. // grd_curscreen to point to it.  grs_curcanv points to this screen's
  279. // canvas.  Saves the current VGA state and screen mode.
  280.  
  281. int gr_init(int mode);
  282. int gr_set_mode(int mode);
  283. void gr_enable_default_palette_loading();
  284. void gr_disable_default_palette_loading();
  285.  
  286. // These 4 functions actuall change screen colors.
  287. extern void gr_pal_fade_out(unsigned char * pal);
  288. extern void gr_pal_fade_in(unsigned char * pal);
  289. extern void gr_pal_clear();
  290. extern void gr_pal_setblock( int start, int number, unsigned char * pal );
  291. extern void gr_pal_getblock( int start, int number, unsigned char * pal );
  292.  
  293. extern int gr_init_A0000();         // Initializes _A0000. Returns true if failed.
  294. extern unsigned short _A0000;       // Selector for screen segment
  295.  
  296. //shut down the 2d.  Restore the screen mode.
  297. int gr_close();
  298.  
  299. //  0=Mode set OK
  300. //  1=No VGA adapter installed
  301. //  2=Program doesn't support this VESA granularity
  302. //  3=Monitor doesn't support that VESA mode.:
  303. //  4=Video card doesn't support that VESA mode.
  304. //  5=No VESA driver found.
  305. //  6=Bad Status after VESA call/
  306. //  7=Not enough DOS memory to call VESA functions.
  307. //  8=Error using DPMI.
  308. //  9=Error setting logical line width.
  309. // 10=Error allocating selector for A0000h
  310. // 11=Not a valid mode support by gr.lib
  311. // Returns one of the above without setting mode
  312. int gr_check_mode(int mode);    
  313.  
  314.  
  315. extern int gr_save_mode();
  316. extern void gr_restore_mode();
  317.  
  318. //=========================================================================
  319. // Canvas functions:
  320.  
  321. // Makes a new canvas. allocates memory for the canvas and its bitmap,
  322. // including the raw pixel buffer.
  323.  
  324. grs_canvas *gr_create_canvas(int w, int h);
  325.  
  326. // Creates a canvas that is part of another canvas.  this can be used to make
  327. // a window on the screen.  the canvas structure is malloc'd; the address of
  328. // the raw pixel data is inherited from the parent canvas.
  329.  
  330. grs_canvas *gr_create_sub_canvas(grs_canvas *canv,int x,int y,int w, int h);
  331.  
  332. // Initialize the specified canvas. the raw pixel data buffer is passed as
  333. // a parameter. no memory allocation is performed.
  334.  
  335. gr_init_canvas(grs_canvas *canv,unsigned char *pixdata,int pixtype, int w,int h);
  336.  
  337. // Initialize the specified sub canvas. no memory allocation is performed.
  338.  
  339. gr_init_sub_canvas(grs_canvas *new,grs_canvas *src,int x,int y,int w, int h);
  340.  
  341. // Free up the canvas and its pixel data.
  342.  
  343. gr_free_canvas(grs_canvas *canv);
  344.  
  345. // Free up the canvas. do not free the pixel data, which belongs to the
  346. // parent canvas.
  347.  
  348. gr_free_sub_canvas(grs_canvas *canv);
  349.  
  350. // Clear the current canvas to the specified color
  351. gr_clear_canvas(int color);
  352.  
  353. //=========================================================================
  354. // Bitmap functions:
  355.  
  356. // Allocate a bitmap and its pixel data buffer.
  357. grs_bitmap *gr_create_bitmap(int w,int h);
  358.  
  359. // Allocated a bitmap and makes its data be raw_data that is already somewhere.
  360. grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data );
  361.  
  362. // Creates a bitmap which is part of another bitmap
  363. grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm,int x,int y,int w, int h);
  364.  
  365. // Free the bitmap and its pixel data
  366. gr_free_bitmap(grs_bitmap *bm);
  367.  
  368. // Free the bitmap, but not the pixel data buffer
  369. gr_free_sub_bitmap(grs_bitmap *bm);
  370.  
  371. void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color );
  372. void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color );
  373. void gr_bm_ubitblt( int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
  374. void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
  375.  
  376. void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
  377.  
  378. //=========================================================================
  379. // Color functions:
  380.  
  381. // When this function is called, the guns are set to gr_palette, and
  382. // the palette stays the same until gr_close is called
  383.  
  384. void gr_use_palette_table(char * filename );
  385.  
  386. //=========================================================================
  387. // Drawing functions:
  388.  
  389. // For solid, XOR, or other fill modes.
  390. gr_set_drawmode(int mode);
  391.  
  392. // Sets the color in the current canvas.  should be a macro
  393. // Use: gr_setcolor(int color);
  394. void gr_setcolor(int color);
  395.  
  396. // Draw a polygon into the current canvas in the current color and drawmode.
  397. // verts points to an ordered list of x,y pairs.  the polygon should be
  398. // convex; a concave polygon will be handled in some reasonable manner,
  399. // but not necessarily shaded as a concave polygon. It shouldn't hang.
  400. // probably good solution is to shade from minx to maxx on each scan line.
  401. // int should really be fix
  402. gr_poly(int nverts,int *verts);
  403. gr_upoly(int nverts,int *verts);
  404.  
  405.  
  406. // Draws a point into the current canvas in the current color and drawmode.
  407. gr_pixel(int x,int y);
  408. gr_upixel(int x,int y);
  409.  
  410. // Gets a pixel;
  411. unsigned char gr_gpixel( grs_bitmap * bitmap, int x, int y );
  412. unsigned char gr_ugpixel( grs_bitmap * bitmap, int x, int y );
  413.  
  414. // Draws a line into the current canvas in the current color and drawmode.
  415. int gr_line(fix x0,fix y0,fix x1,fix y1);
  416. int gr_uline(fix x0,fix y0,fix x1,fix y1);
  417.  
  418. // Draws an anti-aliased line into the current canvas in the current color and drawmode.
  419. int gr_aaline(fix x0,fix y0,fix x1,fix y1);
  420. int gr_uaaline(fix x0,fix y0,fix x1,fix y1);
  421.  
  422. // Draw the bitmap into the current canvas at the specified location.
  423. gr_bitmap(int x,int y,grs_bitmap *bm);
  424. gr_ubitmap(int x,int y,grs_bitmap *bm);
  425. // bitmap function with transparency
  426. gr_bitmapm( int x, int y, grs_bitmap *bm );
  427. gr_ubitmapm( int x, int y, grs_bitmap *bm );
  428.  
  429. // Draw a rectangle into the current canvas.
  430. gr_rect(int left,int top,int right,int bot);
  431. gr_urect(int left,int top,int right,int bot);
  432.  
  433. // Draw a filled circle
  434. int gr_disk(fix x,fix y,fix r);
  435. int gr_udisk(fix x,fix y,fix r);
  436.  
  437. // Draw an outline circle
  438. gr_circle(fix x,fix y,fix r);
  439. gr_ucircle(fix x,fix y,fix r);
  440.  
  441. // Draw an unfilled rectangle into the current canvas
  442. gr_box(int left,int top,int right,int bot);
  443. gr_ubox(int left,int top,int right,int bot);
  444.  
  445. void gr_scanline( int x1, int x2, int y );
  446. void gr_uscanline( int x1, int x2, int y );
  447.  
  448.  
  449. // Reads in a font file... current font set to this one.
  450. grs_font * gr_init_font( char * fontfile );
  451. void gr_close_font( grs_font * font );
  452.  
  453. // Writes a string using current font. Returns the next column after last char.
  454. void gr_set_fontcolor( int fg, int bg );
  455. void gr_set_curfont( grs_font * new );
  456. int gr_string(int x, int y, char *s );
  457. int gr_ustring(int x, int y, char *s );
  458. int gr_printf( int x, int y, char * format, ... );
  459. int gr_uprintf( int x, int y, char * format, ... );
  460. void gr_get_string_size(char *s, int *string_width, int *string_height, int *average_width );
  461.  
  462.  
  463. //    From roller.c
  464. void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
  465.  
  466. // From scale.c
  467. void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf );
  468.  
  469. //===========================================================================
  470. // Global variables
  471. extern grs_canvas *grd_curcanv;             //active canvas
  472. extern grs_screen *grd_curscreen;           //active screen
  473. extern unsigned char Test_bitmap_data[64*64];
  474.  
  475. extern unsigned int FixDivide( unsigned int x, unsigned int y );
  476.  
  477. extern void gr_show_canvas( grs_canvas *canv );
  478. extern void gr_set_current_canvas( grs_canvas *canv );
  479.  
  480. //flags for fonts
  481. #define FT_COLOR            1
  482. #define FT_PROPORTIONAL    2
  483. #define FT_KERNED            4
  484.  
  485. extern void gr_vesa_update( grs_bitmap * source1, grs_bitmap * dest, grs_bitmap * source2 );
  486.  
  487. // Special effects
  488. extern void gr_snow_out(int num_dots);
  489.  
  490. extern void test_rotate_bitmap(void);
  491. extern void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
  492.  
  493. extern ubyte gr_palette[256*3];
  494. extern ubyte gr_fade_table[256*GR_FADE_LEVELS];
  495. extern ubyte gr_inverse_table[32*32*32];
  496.  
  497. extern ushort gr_palette_selector;
  498. extern ushort gr_inverse_table_selector;
  499. extern ushort gr_fade_table_selector;
  500.  
  501. // Remaps a bitmap into the current palette. If transparent_color is between 0 and 255
  502. // then all occurances of that color are mapped to whatever color the 2d uses for 
  503. // transparency. This is normally used right after a call to iff_read_bitmap like
  504. // this:
  505. //        iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
  506. //        if (iff_error != IFF_NO_ERROR) Error("Can't load IFF file <%s>, error=%d",filename,iff_error);
  507. //        if ( iff_has_transparency )
  508. //            gr_remap_bitmap( new, newpal, iff_transparent_color );
  509. //        else
  510. //            gr_remap_bitmap( new, newpal, -1 );
  511. extern void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
  512.  
  513. // Same as above, but searches using gr_find_closest_color which uses 18-bit accurracy
  514. // instaed of 15bit when translating colors.
  515. extern void gr_remap_bitmap_good( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
  516.  
  517. extern void gr_palette_step_up( int r, int g, int b );
  518.  
  519. extern void gr_bitmap_check_transparency( grs_bitmap * bmp );
  520.  
  521. // Allocates a selector that has a base address at 'address' and length 'size'.
  522. // Returns 0 if successful... BE SURE TO CHECK the return value since there
  523. // is a limited number of selectors available!!!
  524. extern int get_selector( void * address, int size, unsigned int * selector );
  525.  
  526. // Assigns a selector to a bitmap. Returns 0 if successful.  BE SURE TO CHECK
  527. // this return value since there is a limited number of selectors!!!!!!!
  528. extern int gr_bitmap_assign_selector( grs_bitmap * bmp );
  529.  
  530. //#define GR_GETCOLOR(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
  531. //#define gr_getcolor(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
  532. //#define BM_XRGB(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
  533.  
  534. #define BM_RGB(r,g,b) ( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )
  535. #define BM_XRGB(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
  536. #define GR_GETCOLOR(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
  537. #define gr_getcolor(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
  538.  
  539. // Given: r,g,b, each in range of 0-63, return the color index that
  540. // best matches the input.
  541. int gr_find_closest_color( int r, int g, int b );
  542.  
  543. extern void gr_merge_textures( ubyte * lower, ubyte * upper, ubyte * dest );
  544. extern void gr_merge_textures_1( ubyte * lower, ubyte * upper, ubyte * dest );
  545. extern void gr_merge_textures_2( ubyte * lower, ubyte * upper, ubyte * dest );
  546. extern void gr_merge_textures_3( ubyte * lower, ubyte * upper, ubyte * dest );
  547.  
  548. #endif
  549.  
  550. 
  551.