]> icculus.org git repositories - btb/d2x.git/blob - include/gr.h
remove unused, redundant files
[btb/d2x.git] / include / gr.h
1 /* $Id: gr.h,v 1.22 2003-10-25 01:44:23 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Definitions for graphics lib.
18  *
19  * Old Log:
20  * Revision 1.7  1995/09/13  08:39:44  allender
21  * added prototype for gr_bitblt_cockpit
22  *
23  * Revision 1.6  1995/08/23  18:47:01  allender
24  * fixed compiler warnings on mcc
25  *
26  * Revision 1.5  1995/08/14  15:51:01  allender
27  * added #define for transparency color
28  *
29  * Revision 1.4  1995/06/13  13:03:55  allender
30  * added graphics mode
31  *
32  * Revision 1.3  1995/04/18  09:50:16  allender
33  * *** empty log message ***
34  *
35  * Revision 1.2  1995/04/07  07:32:33  allender
36  * *** empty log message ***
37  *
38  * Revision 1.1  1995/03/09  09:04:16  allender
39  * Initial revision
40  *
41  *
42  * --- PC RCS information ---
43  * Revision 1.45  1994/11/18  22:50:21  john
44  * Changed shorts to ints in parameters.
45  *
46  * Revision 1.44  1994/11/13  13:04:07  john
47  * Added paged out bit in bitmap structure.  Commented out the
48  * poly code that is never used.
49  *
50  * Revision 1.43  1994/11/09  23:04:56  mike
51  * Add avg_color field.
52  *
53  * Revision 1.42  1994/10/27  00:53:35  john
54  * Added RLE Flag to bitmap structere.
55  *
56  * Revision 1.41  1994/10/26  23:55:52  john
57  * Took out roller; Took out inverse table.
58  *
59  * Revision 1.40  1994/08/11  17:59:12  mike
60  * Assembler merge functions written for 3 rotations of bitmaps.
61  *
62  * Revision 1.39  1994/08/10  12:24:56  matt
63  * Added support for colors fonts & kerned fonts
64  * Made our own font file format
65  *
66  * Revision 1.38  1994/07/27  18:30:18  john
67  * Took away the blending table.
68  *
69  * Revision 1.37  1994/06/16  15:25:06  mike
70  * Add flag BM_FLAG_NO_LIGHTING.
71  *
72  * Revision 1.36  1994/05/31  10:01:22  john
73  * *** empty log message ***
74  *
75  * Revision 1.35  1994/05/31  07:53:34  john
76  * *** empty log message ***
77  *
78  * Revision 1.34  1994/05/14  17:19:41  matt
79  * Added externs
80  *
81  * Revision 1.33  1994/05/12  17:33:09  john
82  * Added circle code.
83  *
84  * Revision 1.32  1994/05/06  12:50:16  john
85  * Added supertransparency; neatend things up; took out warnings.
86  *
87  * Revision 1.31  1994/05/04  10:06:06  john
88  * Added flag for bitmap super-transparency.
89  *
90  * Revision 1.30  1994/05/03  19:38:56  john
91  * *** empty log message ***
92  *
93  * Revision 1.29  1994/04/22  11:16:05  john
94  * *** empty log message ***
95  *
96  * Revision 1.28  1994/04/08  16:59:32  john
97  * Add fading poly's; Made palette fade 32 instead of 16.
98  *
99  * Revision 1.27  1994/03/16  17:29:52  john
100  * *** empty log message ***
101  *
102  * Revision 1.26  1994/03/16  17:20:51  john
103  * Added slow palette searching options.
104  *
105  * Revision 1.25  1994/03/14  17:59:20  john
106  * Added function to check bitmap's transparency.
107  *
108  * Revision 1.24  1994/03/14  16:56:26  john
109  * Changed grs_bitmap structure to include bm_flags.
110  *
111  * Revision 1.23  1994/02/18  15:32:30  john
112  * *** empty log message ***
113  *
114  * Revision 1.22  1994/01/25  11:40:48  john
115  * Added gr_check_mode function.
116  *
117  * Revision 1.21  1994/01/12  13:45:24  john
118  * Added scaler.
119  *
120  * Revision 1.20  1993/12/21  19:58:24  john
121  * added selector stuff
122  *
123  * Revision 1.19  1993/12/21  11:40:40  john
124  * *** empty log message ***
125  *
126  * Revision 1.18  1993/12/09  15:02:08  john
127  * Changed palette stuff majorly
128  *
129  * Revision 1.17  1993/12/07  12:32:05  john
130  * moved bmd_palette to gr_palette
131  *
132  * Revision 1.16  1993/11/28  12:08:06  mike
133  * Change prototype for rotate_bitmap.
134  *
135  * Revision 1.15  1993/11/18  14:22:51  mike
136  * Add prototype for rotate_bitmap.
137  *
138  * Revision 1.14  1993/11/17  19:00:59  mike
139  * Add prototype for test_rotate_bitmap
140  *
141  * Revision 1.13  1993/11/16  11:28:58  john
142  * *** empty log message ***
143  *
144  * Revision 1.12  1993/10/26  13:17:43  john
145  * *** empty log message ***
146  *
147  * Revision 1.11  1993/10/15  16:23:37  john
148  * y
149  *
150  * Revision 1.10  1993/09/28  15:32:33  john
151  * added def for save/restore vidmode
152  *
153  * Revision 1.9  1993/09/28  12:51:46  matt
154  * Added aspect ratio to grs_screen structure
155  *
156  * Revision 1.8  1993/09/26  22:45:12  matt
157  * Changed prototypes for line functions to take fixes, not ints.
158  *
159  * Revision 1.7  1993/09/26  18:58:16  john
160  * fadein/out stuff
161  *
162  * Revision 1.6  1993/09/14  16:26:44  matt
163  * Changed gr_change_mode() to be gr_set_mode()
164  *
165  * Revision 1.4  1993/09/14  13:08:45  john
166  * added gr_change_mode
167  *
168  * Revision 1.3  1993/09/08  13:56:03  matt
169  * Put 'if' block around body of file; added bitmap type BM_RGB15
170  *
171  * Revision 1.2  1993/09/08  13:02:14  john
172  * Changed structure definitions a bit.
173  *
174  * Revision 1.1  1993/09/08  11:25:15  john
175  * Initial revision
176  *
177  *
178  */
179
180 #ifndef _GR_H
181 #define _GR_H
182
183 #include "pstypes.h"
184 #include "fix.h"
185
186 #if defined(MACINTOSH) || defined(MACDATA)
187 #error foo
188 #define SWAP_0_255              // swap black and white
189 #define TRANSPARENCY_COLOR  0   // palette entry of transparency color -- 0 on the mac
190 #define TRANSPARENCY_COLOR_STR  "0"
191 #else
192 /* #undef  SWAP_0_255 */        // no swapping for PC people
193 #define TRANSPARENCY_COLOR  255 // palette entry of transparency color -- 255 on the PC
194 #define TRANSPARENCY_COLOR_STR  "255"
195 #endif
196
197 #define GR_FADE_LEVELS 34
198 #define GR_ACTUAL_FADE_LEVELS 32
199
200 #define GWIDTH  grd_curcanv->cv_bitmap.bm_w
201 #define GHEIGHT grd_curcanv->cv_bitmap.bm_h
202 #define SWIDTH  (grd_curscreen->sc_w)
203 #define SHEIGHT (grd_curscreen->sc_h)
204
205
206 extern int Gr_scanline_darkening_level;
207
208 typedef struct _grs_point {
209         fix x,y;
210 } grs_point;
211
212 //these are control characters that have special meaning in the font code
213
214 #define CC_COLOR        1   //next char is new foreground color
215 #define CC_LSPACING     2   //next char specifies line spacing
216 #define CC_UNDERLINE    3   //next char is underlined
217
218 //now have string versions of these control characters (can concat inside a string)
219
220 #define CC_COLOR_S      "\x1"   //next char is new foreground color
221 #define CC_LSPACING_S   "\x2"   //next char specifies line spacing
222 #define CC_UNDERLINE_S  "\x3"   //next char is underlined
223
224 #define BM_LINEAR   0
225 #define BM_MODEX    1
226 #define BM_SVGA     2
227 #define BM_RGB15    3   //5 bits each r,g,b stored at 16 bits
228 #define BM_SVGA15   4
229 #ifdef OGL
230 #define BM_OGL      5
231 #endif
232
233 //@@// Define these modes for Gameplay too, since the game was developed under
234 //@@// DOS, we will adapt these modes to other systems thru rendering.
235 //@@#define SM_ORIGINAL         -1
236 //@@#define SM_320x200C     0
237 //@@#define SM_320x200U     1
238 //@@#define SM_320x240U     2
239 //@@#define SM_360x200U     3
240 //@@#define SM_360x240U     4
241 //@@#define SM_376x282U     5
242 //@@#define SM_320x400U     6
243 //@@#define SM_320x480U     7
244 //@@#define SM_360x400U     8
245 //@@#define SM_360x480U     9
246 //@@#define SM_360x360U     10
247 //@@#define SM_376x308U     11
248 //@@#define SM_376x564U     12
249 //@@#define SM_640x400V     13
250 //@@#define SM_640x480V     14
251 //@@#define SM_800x600V     15
252 //@@#define SM_1024x768V    16
253 //@@#define SM_640x480V15   17
254 //@@#define SM_800x600V15   18
255
256 #define SM(w,h) ((((u_int32_t)w)<<16)+(((u_int32_t)h)&0xFFFF))
257 #define SM_W(m) (m>>16)
258 #define SM_H(m) (m&0xFFFF)
259
260
261 #define BM_FLAG_TRANSPARENT         1
262 #define BM_FLAG_SUPER_TRANSPARENT   2
263 #define BM_FLAG_NO_LIGHTING         4
264 #define BM_FLAG_RLE                 8   // A run-length encoded bitmap.
265 #define BM_FLAG_PAGED_OUT           16  // This bitmap's data is paged out.
266 #define BM_FLAG_RLE_BIG             32  // for bitmaps that RLE to > 255 per row (i.e. cockpits)
267
268 typedef struct _grs_bitmap {
269         short   bm_x,bm_y;  // Offset from parent's origin
270         short   bm_w,bm_h;  // width,height
271         sbyte   bm_type;    // 0=Linear, 1=ModeX, 2=SVGA
272         sbyte   bm_flags;   // bit 0 on means it has transparency.
273                             // bit 1 on means it has supertransparency
274                             // bit 2 on means it doesn't get passed through lighting.
275         short   bm_rowsize; // unsigned char offset to next row
276         unsigned char *     bm_data;    // ptr to pixel data...
277                                         //   Linear = *parent+(rowsize*y+x)
278                                         //   ModeX = *parent+(rowsize*y+x/4)
279                                         //   SVGA = *parent+(rowsize*y+x)
280         unsigned short      bm_handle;  //for application.  initialized to 0
281         ubyte   avg_color;  //  Average color of all pixels in texture map.
282         sbyte   unused;     // to 4-byte align.
283 #ifdef OGL
284         struct _ogl_texture *gltexture;
285         struct _grs_bitmap  *bm_parent;
286 #endif
287 } grs_bitmap;
288
289 //font structure
290 typedef struct _grs_font {
291         short       ft_w;           // Width in pixels
292         short       ft_h;           // Height in pixels
293         short       ft_flags;       // Proportional?
294         short       ft_baseline;    //
295         ubyte       ft_minchar;     // First char defined by this font
296         ubyte       ft_maxchar;     // Last char defined by this font
297         short       ft_bytewidth;   // Width in unsigned chars
298         ubyte     * ft_data;        // Ptr to raw data.
299         ubyte    ** ft_chars;       // Ptrs to data for each char (required for prop font)
300         short     * ft_widths;      // Array of widths (required for prop font)
301         ubyte     * ft_kerndata;    // Array of kerning triplet data
302 #ifdef OGL
303         // These fields do not participate in disk i/o!
304         grs_bitmap *ft_bitmaps;
305         grs_bitmap ft_parent_bitmap;
306 #endif
307 } __pack__ grs_font;
308
309 #define GRS_FONT_SIZE 28    // how much space it takes up on disk
310
311 typedef struct _grs_canvas {
312         grs_bitmap  cv_bitmap;      // the bitmap for this canvas
313         short       cv_color;       // current color
314         short       cv_drawmode;    // fill,XOR,etc.
315         grs_font *  cv_font;        // the currently selected font
316         short       cv_font_fg_color;   // current font foreground color (-1==Invisible)
317         short       cv_font_bg_color;   // current font background color (-1==Invisible)
318 } grs_canvas;
319
320 //shortcuts
321 #define cv_w cv_bitmap.bm_w
322 #define cv_h cv_bitmap.bm_h
323
324 typedef struct _grs_screen {    // This is a video screen
325         grs_canvas  sc_canvas;  // Represents the entire screen
326         int     sc_mode;        // Video mode number
327         short   sc_w, sc_h;     // Actual Width and Height
328         fix     sc_aspect;      //aspect ratio (w/h) for this screen
329 } grs_screen;
330
331
332 //=========================================================================
333 // System functions:
334 // setup and set mode. this creates a grs_screen structure and sets
335 // grd_curscreen to point to it.  grs_curcanv points to this screen's
336 // canvas.  Saves the current VGA state and screen mode.
337
338 int gr_init(void);
339
340 // This function sets up the main screen.  It should be called whenever
341 // the video mode changes.
342 int gr_init_screen(int mode, int w, int h, int x, int y, int rowsize, ubyte *data);
343
344 int gr_check_mode(u_int32_t mode);
345 int gr_set_mode(u_int32_t mode);
346
347
348 // These 4 functions actuall change screen colors.
349
350 extern void gr_pal_fade_out(unsigned char * pal);
351 extern void gr_pal_fade_in(unsigned char * pal);
352 extern void gr_pal_clear(void);
353 extern void gr_pal_setblock( int start, int number, unsigned char * pal );
354 extern void gr_pal_getblock( int start, int number, unsigned char * pal );
355
356
357 extern unsigned char *gr_video_memory;
358                                                     // All graphic modules will define this value.
359
360 //shut down the 2d.  Restore the screen mode.
361 void gr_close(void);
362
363 //=========================================================================
364 // Canvas functions:
365
366 // Makes a new canvas. allocates memory for the canvas and its bitmap,
367 // including the raw pixel buffer.
368
369 grs_canvas *gr_create_canvas(int w, int h);
370 #if defined(POLY_ACC)
371 grs_canvas *gr_create_canvas2(int w, int h, int type);
372 #endif
373
374 // Creates a canvas that is part of another canvas.  this can be used to make
375 // a window on the screen.  the canvas structure is malloc'd; the address of
376 // the raw pixel data is inherited from the parent canvas.
377
378 grs_canvas *gr_create_sub_canvas(grs_canvas *canv,int x,int y,int w, int h);
379
380 // Initialize the specified canvas. the raw pixel data buffer is passed as
381 // a parameter. no memory allocation is performed.
382
383 void gr_init_canvas(grs_canvas *canv,unsigned char *pixdata,int pixtype, int w,int h);
384
385 // Initialize the specified sub canvas. no memory allocation is performed.
386
387 void gr_init_sub_canvas(grs_canvas *new,grs_canvas *src,int x,int y,int w, int h);
388
389 // Free up the canvas and its pixel data.
390
391 void gr_free_canvas(grs_canvas *canv);
392
393 // Free up the canvas. do not free the pixel data, which belongs to the
394 // parent canvas.
395
396 void gr_free_sub_canvas(grs_canvas *canv);
397
398 // Clear the current canvas to the specified color
399 void gr_clear_canvas(int color);
400
401 //=========================================================================
402 // Bitmap functions:
403
404 // Allocate a bitmap and its pixel data buffer.
405 grs_bitmap *gr_create_bitmap(int w,int h);
406
407 // Allocated a bitmap and makes its data be raw_data that is already somewhere.
408 grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data );
409
410 #if defined(POLY_ACC)
411 // Allocates a bitmap of a specific type. data is either NULL or raw data.
412 grs_bitmap *gr_create_bitmap2(int w, int h, int type, void *data );
413 #endif
414
415 // Creates a bitmap which is part of another bitmap
416 grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm,int x,int y,int w, int h);
417
418 // Free the bitmap and its pixel data
419 void gr_free_bitmap(grs_bitmap *bm);
420
421 // Free the bitmap's data
422 void gr_free_bitmap_data (grs_bitmap *bm);
423 void gr_init_bitmap_data (grs_bitmap *bm);
424
425 // Free the bitmap, but not the pixel data buffer
426 void gr_free_sub_bitmap(grs_bitmap *bm);
427
428 void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color );
429 void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color );
430 void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
431 void gr_bm_ubitblt( int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
432 void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
433
434 #ifdef MACINTOSH
435 void gr_bm_ubitblt_double(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap *src, grs_bitmap *dest);
436 void gr_linear_movsd_double(ubyte *src, ubyte *dest, int num_pixels);
437 #endif
438
439 void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
440
441 //=========================================================================
442 // Color functions:
443
444 // When this function is called, the guns are set to gr_palette, and
445 // the palette stays the same until gr_close is called
446
447 void gr_use_palette_table(char * filename );
448 void gr_copy_palette(ubyte *gr_palette, ubyte *pal, int size);
449
450 //=========================================================================
451 // Drawing functions:
452
453 // For solid, XOR, or other fill modes.
454 int gr_set_drawmode(int mode);
455
456 // Sets the color in the current canvas.  should be a macro
457 // Use: gr_setcolor(int color);
458 void gr_setcolor(int color);
459
460 // Draw a polygon into the current canvas in the current color and drawmode.
461 // verts points to an ordered list of x,y pairs.  the polygon should be
462 // convex; a concave polygon will be handled in some reasonable manner,
463 // but not necessarily shaded as a concave polygon. It shouldn't hang.
464 // probably good solution is to shade from minx to maxx on each scan line.
465 // int should really be fix
466 int gr_poly(int nverts,int *verts);
467 int gr_upoly(int nverts,int *verts);
468
469
470 // Draws a point into the current canvas in the current color and drawmode.
471 void gr_pixel(int x,int y);
472 void gr_upixel(int x,int y);
473
474 // Gets a pixel;
475 unsigned char gr_gpixel( grs_bitmap * bitmap, int x, int y );
476 unsigned char gr_ugpixel( grs_bitmap * bitmap, int x, int y );
477
478 // Draws a line into the current canvas in the current color and drawmode.
479 int gr_line(fix x0,fix y0,fix x1,fix y1);
480 int gr_uline(fix x0,fix y0,fix x1,fix y1);
481
482 // Draws an anti-aliased line into the current canvas in the current color and drawmode.
483 int gr_aaline(fix x0,fix y0,fix x1,fix y1);
484 int gr_uaaline(fix x0,fix y0,fix x1,fix y1);
485
486 // Draw the bitmap into the current canvas at the specified location.
487 void gr_bitmap(int x,int y,grs_bitmap *bm);
488 void gr_ubitmap(int x,int y,grs_bitmap *bm);
489 void gr_bitmap_scale_to(grs_bitmap *src, grs_bitmap *dst);
490 void show_fullscr(grs_bitmap *bm);
491
492 // bitmap function with transparency
493 void gr_bitmapm( int x, int y, grs_bitmap *bm );
494 void gr_ubitmapm( int x, int y, grs_bitmap *bm );
495
496 // Draw a rectangle into the current canvas.
497 void gr_rect(int left,int top,int right,int bot);
498 void gr_urect(int left,int top,int right,int bot);
499
500 // Draw a filled circle
501 int gr_disk(fix x,fix y,fix r);
502 int gr_udisk(fix x,fix y,fix r);
503
504 // Draw an outline circle
505 int gr_circle(fix x,fix y,fix r);
506 int gr_ucircle(fix x,fix y,fix r);
507
508 // Draw an unfilled rectangle into the current canvas
509 void gr_box(int left,int top,int right,int bot);
510 void gr_ubox(int left,int top,int right,int bot);
511
512 void gr_scanline( int x1, int x2, int y );
513 void gr_uscanline( int x1, int x2, int y );
514
515
516 // Reads in a font file... current font set to this one.
517 grs_font * gr_init_font( char * fontfile );
518 void gr_close_font( grs_font * font );
519
520 //remap a font, re-reading its data & palette
521 void gr_remap_font( grs_font *font, char * fontname, char *font_data );
522
523 //remap (by re-reading) all the color fonts
524 void gr_remap_color_fonts();
525
526 // Writes a string using current font. Returns the next column after last char.
527 void gr_set_fontcolor( int fg, int bg );
528 void gr_set_curfont( grs_font * new );
529 int gr_string(int x, int y, char *s );
530 int gr_ustring(int x, int y, char *s );
531 int gr_printf( int x, int y, char * format, ... );
532 int gr_uprintf( int x, int y, char * format, ... );
533 void gr_get_string_size(char *s, int *string_width, int *string_height, int *average_width );
534
535
536 //  From roller.c
537 void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
538
539 // From scale.c
540 void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf, int orientation );
541
542 //===========================================================================
543 // Global variables
544 extern grs_canvas *grd_curcanv;             //active canvas
545 extern grs_screen *grd_curscreen;           //active screen
546 extern unsigned char Test_bitmap_data[64*64];
547
548 //shortcut to look at current font
549 #define grd_curfont grd_curcanv->cv_font
550
551 extern unsigned int FixDivide( unsigned int x, unsigned int y );
552
553 extern void gr_show_canvas( grs_canvas *canv );
554 extern void gr_set_current_canvas( grs_canvas *canv );
555
556 //flags for fonts
557 #define FT_COLOR        1
558 #define FT_PROPORTIONAL 2
559 #define FT_KERNED       4
560
561 extern void gr_vesa_update( grs_bitmap * source1, grs_bitmap * dest, grs_bitmap * source2 );
562
563 // Special effects
564 extern void gr_snow_out(int num_dots);
565
566 extern void test_rotate_bitmap(void);
567 extern void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
568
569 extern ubyte gr_palette[256*3];
570 extern ubyte gr_fade_table[256*GR_FADE_LEVELS];
571 extern ubyte gr_inverse_table[32*32*32];
572
573 extern ushort gr_palette_selector;
574 extern ushort gr_inverse_table_selector;
575 extern ushort gr_fade_table_selector;
576
577 // Remaps a bitmap into the current palette. If transparent_color is
578 // between 0 and 255 then all occurances of that color are mapped to
579 // whatever color the 2d uses for transparency. This is normally used
580 // right after a call to iff_read_bitmap like this:
581 //              iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
582 //              if (iff_error != IFF_NO_ERROR) Error("Can't load IFF file <%s>, error=%d",filename,iff_error);
583 //              if ( iff_has_transparency )
584 //                      gr_remap_bitmap( new, newpal, iff_transparent_color );
585 //              else
586 //                      gr_remap_bitmap( new, newpal, -1 );
587 extern void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
588
589 // Same as above, but searches using gr_find_closest_color which uses
590 // 18-bit accurracy instead of 15bit when translating colors.
591 extern void gr_remap_bitmap_good( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
592
593 extern void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq );
594
595 extern void gr_palette_step_up( int r, int g, int b );
596
597 extern void gr_bitmap_check_transparency( grs_bitmap * bmp );
598
599 // Allocates a selector that has a base address at 'address' and length 'size'.
600 // Returns 0 if successful... BE SURE TO CHECK the return value since there
601 // is a limited number of selectors available!!!
602 extern int get_selector( void * address, int size, unsigned int * selector );
603
604 // Assigns a selector to a bitmap. Returns 0 if successful.  BE SURE TO CHECK
605 // this return value since there is a limited number of selectors!!!!!!!
606 extern int gr_bitmap_assign_selector( grs_bitmap * bmp );
607
608 //#define GR_GETCOLOR(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
609 //#define gr_getcolor(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
610 //#define BM_XRGB(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
611
612 #define BM_RGB(r,g,b) ( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )
613 #define BM_XRGB(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
614 #define GR_GETCOLOR(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
615 #define gr_getcolor(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
616
617 // Given: r,g,b, each in range of 0-63, return the color index that
618 // best matches the input.
619 int gr_find_closest_color( int r, int g, int b );
620 int gr_find_closest_color_15bpp( int rgb );
621
622 extern void gr_merge_textures( ubyte * lower, ubyte * upper, ubyte * dest );
623 extern void gr_merge_textures_1( ubyte * lower, ubyte * upper, ubyte * dest );
624 extern void gr_merge_textures_2( ubyte * lower, ubyte * upper, ubyte * dest );
625 extern void gr_merge_textures_3( ubyte * lower, ubyte * upper, ubyte * dest );
626
627 extern void gr_update(void);
628
629 /*
630  * currently SDL and OGL are the only things that supports toggling
631  * fullscreen.  otherwise add other checks to the #if -MPM
632  */
633 #if (defined(SDL_VIDEO) || defined(OGL))
634 #define GR_SUPPORTS_FULLSCREEN_TOGGLE
635
636 /*
637  * must return 0 if windowed, 1 if fullscreen
638  */
639 int gr_check_fullscreen(void);
640
641 /*
642  * returns state after toggling (ie, same as if you had called
643  * check_fullscreen immediatly after)
644  */
645 int gr_toggle_fullscreen(void);
646
647 #endif
648
649 int gr_toggle_fullscreen_menu(void);//returns state after toggling (ie, same as if you had called check_fullscreen immediatly after)
650
651 #endif