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-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Functions for loading palettes
35 extern void g3_remap_interp_colors(void);
37 char Current_level_palette[FILENAME_LEN];
39 extern int Color_0_31_0, HUD_color;
41 //background for boxed messages
43 short x, y, w, h; // The location of the menu.
44 grs_bitmap * bmp; // The background under the menu.
49 void load_background_bitmap(void);
51 char last_palette_loaded[FILENAME_LEN]="";
52 char last_palette_loaded_pig[FILENAME_LEN]="";
54 ubyte last_palette_for_color_fonts[768];
56 void remap_fonts_and_menus(int do_fadetable_hack)
58 nm_remap_background();
59 gr_remap_color_fonts();
61 if (do_fadetable_hack) {
67 intensity = (double)(14)/(double)(32);
69 gamma[i] = (int)((pow(intensity, 1.0/g)*i) + 0.5);
72 c = gr_find_closest_color(gamma[gr_palette[i*3]],gamma[gr_palette[i*3+1]],gamma[gr_palette[i*3+2]]);
73 gr_fade_table[14*256+i] = c;
77 memcpy(last_palette_for_color_fonts,gr_palette,sizeof(last_palette_for_color_fonts));
80 //load a palette by name. returns 1 if new palette loaded, else 0
81 //if used_for_level is set, load pig, etc.
82 //if no_change_screen is set, the current screen does not get remapped,
83 //and the hardware palette does not get changed
84 int load_palette(char *name,int used_for_level,int no_change_screen)
86 char pigname[FILENAME_LEN];
89 //special hack to tell that palette system about a pig that's been loaded elsewhere
90 if (used_for_level == -2) {
91 strncpy(last_palette_loaded_pig,name,sizeof(last_palette_loaded_pig));
96 name = last_palette_loaded_pig;
98 if (used_for_level && stricmp(last_palette_loaded_pig,name) != 0) {
100 _splitpath(name,NULL,NULL,pigname,NULL);
101 strcat(pigname,".pig");
102 //if not editor, load pig first so small install message can come
103 //up in old palette. If editor version, we must load the pig after
104 //the palette is loaded so we can remap new textures.
106 piggy_new_pigfile(pigname);
110 if (stricmp(last_palette_loaded,name) != 0) {
112 memcpy(old_pal,gr_palette,sizeof(old_pal));
114 strncpy(last_palette_loaded,name,sizeof(last_palette_loaded));
116 gr_use_palette_table(name);
118 if (Function_mode == FMODE_GAME && !no_change_screen)
119 gr_remap_bitmap_good( &grd_curscreen->sc_canvas.cv_bitmap, old_pal, -1, -1 );
122 gr_remap_bitmap_good( bg.bmp, old_pal, -1, -1 );
124 if (!gr_palette_faded_out && !no_change_screen)
125 gr_palette_load(gr_palette);
127 remap_fonts_and_menus(0);
129 Color_0_31_0 = -1; //for gauges
132 load_background_bitmap();
134 g3_remap_interp_colors();
138 if (used_for_level && stricmp(last_palette_loaded_pig,name) != 0) {
140 strncpy(last_palette_loaded_pig,name,sizeof(last_palette_loaded_pig));
143 piggy_new_pigfile(pigname);