2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Starfield/StarField.cpp $
15 * Code to handle and draw starfields, background space image bitmaps, floating
19 * Revision 1.10 2005/10/01 22:04:58 taylor
20 * fix FS1 (de)briefing voices, the directory names are different in FS1
21 * hard code the table values so that the fs1.vp file isn't needed
22 * hard code a mission fix for sm2-08a since a have no idea how to fix it otherwise
23 * generally cleanup some FS1 code
24 * fix volume sliders in the options screen that never went all the way up
26 * Revision 1.9 2004/09/20 01:31:45 theoddone33
29 * Revision 1.8 2004/07/04 11:40:26 taylor
30 * only load those background bitmaps that we are going to use this mission
32 * Revision 1.7 2003/05/25 02:30:44 taylor
35 * Revision 1.6 2002/06/22 23:57:39 relnev
36 * remove writable strings.
38 * fix compile for intel compiler.
40 * Revision 1.5 2002/06/17 06:33:11 relnev
41 * ryan's struct patch for gcc 2.95
43 * Revision 1.4 2002/06/09 04:41:27 relnev
44 * added copyright header
46 * Revision 1.3 2002/06/02 04:26:34 relnev
49 * Revision 1.2 2002/05/07 03:16:52 theoddone33
50 * The Great Newline Fix
52 * Revision 1.1.1.1 2002/05/03 03:28:10 root
56 * 34 9/07/99 4:01p Dave
57 * Fixed up a string.tbl paroblem (self destruct message). Make sure IPX
58 * does everything properly (setting up address when binding). Remove
59 * black rectangle background from UI_INPUTBOX.
61 * 33 9/01/99 10:14a Dave
64 * 32 8/30/99 5:01p Dave
65 * Made d3d do less state changing in the nebula. Use new chat server for
68 * 31 8/19/99 10:59a Dave
69 * Packet loss detection.
71 * 30 7/27/99 3:52p Dave
72 * Make star drawing a bit more robust to help lame D3D cards.
74 * 29 7/21/99 8:10p Dave
75 * First run of supernova effect.
77 * 28 7/13/99 2:01p Dave
78 * Don't draw background bitmaps in the nebula.
80 * 27 6/08/99 2:34p Jasenw
81 * Made perspective bitmaps render in Fred.
83 * 26 6/04/99 1:18p Dave
84 * Fixed briefing model rendering problems. Made show background option in
85 * fred toggle nebula rendering.
87 * 25 6/03/99 6:37p Dave
88 * More TNT fun. Made perspective bitmaps more flexible.
90 * 24 5/28/99 1:45p Dave
91 * Fixed up perspective bitmap drawing.
93 * 23 5/20/99 7:00p Dave
94 * Added alternate type names for ships. Changed swarm missile table
97 * 22 5/11/99 10:03a Dave
98 * Put a bunch of stuff into tables.
100 * 21 5/11/99 9:10a Dave
101 * Move default sun position.
103 * 20 5/09/99 6:00p Dave
104 * Lots of cool new effects. E3 build tweaks.
106 * 19 4/26/99 8:49p Dave
107 * Made all pof based nebula stuff full customizable through fred.
109 * 18 4/25/99 7:43p Dave
110 * Misc small bug fixes. Made sun draw properly.
112 * 17 4/23/99 5:53p Dave
113 * Started putting in new pof nebula support into Fred.
115 * 16 4/07/99 6:22p Dave
116 * Fred and Freespace support for multiple background bitmaps and suns.
117 * Fixed link errors on all subprojects. Moved encrypt_init() to
118 * cfile_init() and lcl_init(), since its safe to call twice.
120 * 15 3/31/99 8:24p Dave
121 * Beefed up all kinds of stuff, incluging beam weapons, nebula effects
122 * and background nebulae. Added per-ship non-dimming pixel colors.
124 * 14 3/20/99 5:09p Dave
125 * Fixed release build fred warnings and unhandled exception.
127 * 13 3/20/99 3:46p Dave
128 * Added support for model-based background nebulae. Added 3 new
131 * 12 3/20/99 2:04p Dave
132 * Removed unnecessary planet rendering.
134 * 11 3/19/99 9:51a Dave
135 * Checkin to repair massive source safe crash. Also added support for
136 * pof-style nebulae, and some new weapons code.
138 * 12 3/15/99 6:45p Daveb
139 * Put in rough nebula bitmap support.
141 * 11 3/11/99 5:53p Dave
142 * More network optimization. Spliced in Dell OEM planet bitmap crap.
144 * 10 2/03/99 11:44a Dave
145 * Fixed d3d transparent textures.
147 * 9 12/09/98 7:34p Dave
148 * Cleanup up nebula effect. Tweaked many values.
150 * 8 12/01/98 10:32a Johnson
151 * Fixed direct3d font problems. Fixed sun bitmap problem. Fixed direct3d
154 * 7 12/01/98 8:06a Dave
155 * Temporary checkin to fix some texture transparency problems in d3d.
157 * 6 11/14/98 5:33p Dave
158 * Lots of nebula work. Put in ship contrails.
160 * 5 11/05/98 5:55p Dave
161 * Big pass at reducing #includes
163 * 4 10/13/98 9:29a Dave
164 * Started neatening up freespace.h. Many variables renamed and
165 * reorganized. Added AlphaColors.[h,cpp]
167 * 3 10/07/98 11:16a Dave
170 * 2 10/07/98 10:54a Dave
173 * 1 10/07/98 10:51a Dave
175 * 106 5/23/98 4:14p John
176 * Added code to preload textures to video card for AGP. Added in code
177 * to page in some bitmaps that weren't getting paged in at level start.
179 * 105 5/13/98 2:53p John
180 * Made subspace effect work under software. Had to add new inner loop to
181 * tmapper. Added glows to end of subspace effect. Made subspace effect
182 * levels use gamepalette-subspace palette.
184 * 104 5/13/98 10:28a John
185 * made subpsace forward sliding 40% faster.
187 * 103 5/10/98 4:18p John
188 * Reversed the subspace effect direction
190 * 102 5/08/98 8:38p John
191 * Subspace tweaks. Made two layers rotate independentyl.
193 * 101 5/08/98 1:32p John
194 * Added code for using two layered subspace effects.
196 * 100 5/06/98 5:30p John
197 * Removed unused cfilearchiver. Removed/replaced some unused/little used
198 * graphics functions, namely gradient_h and _v and pixel_sp. Put in new
199 * DirectX header files and libs that fixed the Direct3D alpha blending
202 * 99 4/22/98 4:09p John
203 * String externalization
205 * 98 4/22/98 3:28p John
208 * 97 4/13/98 4:54p John
209 * Made uv rotate independently on subspace effect. Put in DCF function
210 * for setting subspace speeds.
212 * 96 4/12/98 5:55p John
213 * Made models work with subspace. Made subspace rotate also.
215 * 95 4/11/98 6:53p John
216 * Added first rev of subspace effect.
218 * 94 4/08/98 11:31a Dave
219 * AL: Fix syntax error for non-demo
221 * 93 4/08/98 10:46a Lawrance
222 * #ifdef out asteroid check for demo
224 * 92 4/08/98 9:25a John
225 * Made asteroid missions not show suns
227 * 91 4/07/98 4:17p John
228 * Made Fred be able to move suns. Made suns actually affect the lighting
231 * 90 4/07/98 11:19a Hoffoss
232 * Changed code to only use Sun01 for a bitmap by default, as John
239 #include "floating.h"
243 #include "starfield.h"
246 #include "freespace.h"
249 #include "linklist.h"
250 #include "lighting.h"
251 #include "asteroid.h"
252 #include "missionparse.h"
254 #include "alphacolors.h"
255 #include "supernova.h"
257 #define MAX_DEBRIS_VCLIPS 4
258 #define DEBRIS_ROT_MIN 10000
259 #define DEBRIS_ROT_RANGE 8
260 #define DEBRIS_ROT_RANGE_SCALER 10000
261 #define RND_MAX_MASK 0x3fff
262 #define HALF_RND_MAX 0x2000
264 typedef struct debris_vclip {
278 const int MAX_DEBRIS = 200;
279 const int MAX_STARS = 2000;
280 const float MAX_DIST = 50.0f;
281 const float MAX_DIST_RANGE = 60.0f;
282 const float MIN_DIST_RANGE = 14.0f;
283 const float BASE_SIZE = 0.12f;
284 float BASE_SIZE_NEB = 0.5f;
286 static int Subspace_model_inner = -1;
287 static int Subspace_model_outer = -1;
290 fix starfield_timestamp = 0;
292 // for drawing cool stuff on the background - comes from a table
293 starfield_bitmap Starfield_bitmaps[MAX_STARFIELD_BITMAPS];
294 starfield_bitmap_instance Starfield_bitmap_instance[MAX_STARFIELD_BITMAPS];
295 int Num_starfield_bitmaps = 0;
297 // sun bitmaps and sun glow bitmaps
298 starfield_bitmap Sun_bitmaps[MAX_STARFIELD_BITMAPS];
299 starfield_bitmap_instance Suns[MAX_STARFIELD_BITMAPS];
302 int last_stars_filled = 0;
303 color star_colors[8];
304 color star_aacolors[8];
306 typedef struct star {
308 vector last_star_pos;
311 star Stars[MAX_STARS];
313 old_debris odebris[MAX_DEBRIS];
316 debris_vclip debris_vclips_normal[MAX_DEBRIS_VCLIPS] = { { -1, -1, "debris01" }, { -1, -1, "debris02" }, { -1, -1, "debris03" }, { -1, -1, "debris04" } };
317 debris_vclip debris_vclips_nebula[MAX_DEBRIS_VCLIPS] = { { -1, -1, "Neb01-64" }, { -1, -1, "Neb01-64" }, { -1, -1, "Neb01-64" }, { -1, -1, "Neb01-64" } };
318 debris_vclip *debris_vclips = debris_vclips_normal;
321 int stars_debris_loaded = 0;
324 int Stars_background_inited = 0; // if we're inited
325 int Nmodel_num = -1; // model num
326 int Nmodel_bitmap = -1; // model texture
328 // given a starfield_bitmap_instance, return a pointer to its parent, for suns
329 starfield_bitmap *stars_lookup_sun(starfield_bitmap_instance *s)
339 for(idx=0; idx<MAX_STARFIELD_BITMAPS; idx++){
340 if(!SDL_strcasecmp(Sun_bitmaps[idx].filename, s->filename)){
341 return &Sun_bitmaps[idx];
349 void stars_load_debris()
353 // if we're in nebula mode
354 if(The_mission.flags & MISSION_FLAG_FULLNEB){
355 debris_vclips = debris_vclips_nebula;
357 debris_vclips = debris_vclips_normal;
360 for (i=0; i<MAX_DEBRIS_VCLIPS; i++ ) {
361 debris_vclips[i].bm = bm_load_animation( debris_vclips[i].name, &debris_vclips[i].nframes, NULL, 1 );
362 if ( debris_vclips[i].bm < 0 ) {
363 // try loading it as a single bitmap
364 debris_vclips[i].bm = bm_load(debris_vclips[i].name);
365 debris_vclips[i].nframes = 1;
367 if(debris_vclips[i].bm <= 0){
368 Error( LOCATION, "Couldn't load animation/bitmap '%s'\n", debris_vclips[i].name );
372 stars_debris_loaded = 1;
375 // call on game startup
379 starfield_bitmap *bm;
381 char filename[MAX_FILENAME_LEN+1] = "";
382 char glow_filename[MAX_FILENAME_LEN+1] = "";
386 read_file_text("stars.tbl");
389 // make all bitmaps invalid
390 for(idx=0; idx<MAX_STARFIELD_BITMAPS; idx++){
391 Starfield_bitmaps[idx].bitmap = -1;
392 Starfield_bitmaps[idx].glow_bitmap = -1;
393 SDL_strlcpy(Starfield_bitmaps[idx].filename, "", sizeof(Starfield_bitmaps[0].filename));
394 SDL_strlcpy(Starfield_bitmaps[idx].glow_filename, "", sizeof(Starfield_bitmaps[0].glow_filename));
396 Sun_bitmaps[idx].bitmap = -1;
397 Sun_bitmaps[idx].glow_bitmap = -1;
398 SDL_strlcpy(Sun_bitmaps[idx].filename, "", sizeof(Sun_bitmaps[0].filename));
399 SDL_strlcpy(Sun_bitmaps[idx].glow_filename, "", sizeof(Sun_bitmaps[0].glow_filename));
404 while(!optional_string("#end")){
405 // intensity alpha bitmap
406 if(optional_string("$Bitmap:")){
407 stuff_string(filename, F_NAME, NULL);
408 if(count < MAX_STARFIELD_BITMAPS){
409 bm = &Starfield_bitmaps[count++];
410 SDL_strlcpy(bm->filename, filename, sizeof(bm->filename));
412 bm->bitmap = bm_load(bm->filename);
413 SDL_assert(bm->bitmap != -1);
415 // if fred is running we should lock the bitmap now
416 if(Fred_running && (bm->bitmap >= 0)){
417 bm_lock(bm->bitmap, 8, BMP_TEX_OTHER);
418 bm_unlock(bm->bitmap);
422 // green xparency bitmap
423 else if(optional_string("$BitmapX:")){
424 stuff_string(filename, F_NAME, NULL);
425 if(count < MAX_STARFIELD_BITMAPS){
426 bm = &Starfield_bitmaps[count++];
427 SDL_strlcpy(bm->filename, filename, sizeof(bm->filename));
429 bm->bitmap = bm_load(bm->filename);
430 SDL_assert(bm->bitmap != -1);
432 // if fred is running we should lock as a 0, 255, 0 bitmap now
433 if(Fred_running && (bm->bitmap >= 0)){
434 bm_lock(bm->bitmap, 8, BMP_TEX_XPARENT);
435 bm_unlock(bm->bitmap);
443 while(!optional_string("#end")){
444 if(optional_string("$Sun:")){
445 stuff_string(filename, F_NAME, NULL);
448 required_string("$Sunglow:");
449 stuff_string(glow_filename, F_NAME, NULL);
451 // associated lighting values
452 required_string("$SunRGBI:");
458 if(count < MAX_STARFIELD_BITMAPS){
459 bm = &Sun_bitmaps[count++];
460 SDL_strlcpy(bm->filename, filename, sizeof(bm->filename));
461 SDL_strlcpy(bm->glow_filename, glow_filename, sizeof(bm->glow_filename));
463 bm->bitmap = bm_load(bm->filename);
464 bm->glow_bitmap = bm_load(bm->glow_filename);
465 SDL_assert(bm->bitmap != -1);
466 SDL_assert(bm->glow_bitmap != -1);
472 // if fred is running we should lock the bitmap now
475 bm_lock(bm->bitmap, 8, BMP_TEX_OTHER);
476 bm_unlock(bm->bitmap);
478 if(bm->glow_bitmap >= 0){
479 bm_lock(bm->glow_bitmap, 8, BMP_TEX_OTHER);
480 bm_unlock(bm->glow_bitmap);
487 // normal debris pieces
489 while(!optional_string("#end")){
490 required_string("$Debris:");
491 stuff_string(filename, F_NAME, NULL);
493 if(count < MAX_DEBRIS_VCLIPS){
494 SDL_strlcpy(debris_vclips_normal[count++].name, filename, sizeof(debris_vclips_normal[0].name));
497 SDL_assert(count == 4);
499 // nebula debris pieces
501 while(!optional_string("#end")){
502 required_string("$DebrisNeb:");
503 stuff_string(filename, F_NAME, NULL);
505 if(count < MAX_DEBRIS_VCLIPS){
506 SDL_strlcpy(debris_vclips_nebula[count++].name, filename, sizeof(debris_vclips_nebula[0].name));
510 SDL_assert(count == 4);
512 // hard-coded for FS1
513 starfield_bitmap *bm;
516 // make all bitmaps invalid
517 for (idx=0; idx<MAX_STARFIELD_BITMAPS; idx++) {
518 Starfield_bitmaps[idx].bitmap = -1;
519 Starfield_bitmaps[idx].glow_bitmap = -1;
520 SDL_strlcpy(Starfield_bitmaps[idx].filename, "", sizeof(Starfield_bitmaps[0].filename));
521 SDL_strlcpy(Starfield_bitmaps[idx].glow_filename, "", sizeof(Starfield_bitmaps[0].glow_filename));
523 Sun_bitmaps[idx].bitmap = -1;
524 Sun_bitmaps[idx].glow_bitmap = -1;
525 SDL_strlcpy(Sun_bitmaps[idx].filename, "", sizeof(Sun_bitmaps[0].filename));
526 SDL_strlcpy(Sun_bitmaps[idx].glow_filename, "", sizeof(Sun_bitmaps[0].glow_filename));
531 bm = &Sun_bitmaps[count++];
533 SDL_strlcpy(bm->filename, "Sun01", sizeof(bm->filename));
534 SDL_strlcpy(bm->glow_filename, "Sunglow01", sizeof(bm->glow_filename));
536 bm->bitmap = bm_load(bm->filename);
537 bm->glow_bitmap = bm_load(bm->glow_filename);
538 SDL_assert(bm->bitmap != -1);
539 SDL_assert(bm->glow_bitmap != -1);
545 // we use the default debris vclips so no need to specify those again here
549 // call this in game_post_level_init() so we know whether we're running in full nebula mode or not
550 void stars_level_init()
554 float dist, dist_max;
556 // reset to -1 so we reload it each mission (if we need to)
558 if(Nmodel_bitmap != -1){
559 bm_unload(Nmodel_bitmap);
563 // if (!stars_debris_loaded){
567 // following code randomly distributes star points within a sphere volume, which
568 // avoids there being denser areas along the edges and in corners that we had in the
569 // old rectangular distribution scheme.
570 dist_max = (float) (HALF_RND_MAX * HALF_RND_MAX);
571 for (i=0; i<MAX_STARS; i++) {
573 while (dist >= dist_max) {
574 v.xyz.x = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX);
575 v.xyz.y = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX);
576 v.xyz.z = (float) ((myrand() & RND_MAX_MASK) - HALF_RND_MAX);
578 dist = v.xyz.x * v.xyz.x + v.xyz.y * v.xyz.y + v.xyz.z * v.xyz.z;
580 vm_vec_copy_normalize(&Stars[i].pos, &v);
583 for (i=0; i<MAX_DEBRIS; i++) {
584 odebris[i].active = 0;
587 for (i=0; i<8; i++ ) {
588 ubyte intensity = (ubyte)((i + 1) * 24);
589 gr_init_alphacolor(&star_aacolors[i], 255, 255, 255, intensity, AC_TYPE_BLEND );
590 gr_init_color(&star_colors[i], intensity, intensity, intensity );
593 last_stars_filled = 0;
595 #ifndef MAKE_FS1 // some FS1 missions don't have a sun
596 // if we have no sun instances, create one
598 mprintf(("Adding default sun\n"));
601 SDL_strlcpy(Suns[0].filename, Sun_bitmaps[0].filename, sizeof(Suns[0].filename));
602 Suns[0].scale_x = 1.0f;
603 Suns[0].scale_y = 1.0f;
606 memset(&Suns[0].ang, 0, sizeof(angles));
607 Suns[0].ang.h = fl_radian(60.0f);
617 extern object * Player_obj;
619 #define STAR_AMOUNT_DEFAULT 0.75f
620 #define STAR_DIM_DEFAULT 7800.0f
621 #define STAR_CAP_DEFAULT 75.0f
622 #define STAR_MAX_LENGTH_DEFAULT 0.04f // 312
624 float Star_amount = STAR_AMOUNT_DEFAULT;
625 float Star_dim = STAR_DIM_DEFAULT;
626 float Star_cap = STAR_CAP_DEFAULT;
627 float Star_max_length = STAR_MAX_LENGTH_DEFAULT;
629 #define STAR_FLAG_TAIL (1<<0) // Draw a tail when moving
630 #define STAR_FLAG_DIM (1<<1) // Dim as you move
631 #define STAR_FLAG_ANTIALIAS (1<<2) // Draw the star using antialiased lines
632 #define STAR_FLAG_DEFAULT (STAR_FLAG_TAIL | STAR_FLAG_DIM)
634 uint Star_flags = STAR_FLAG_DEFAULT;
637 DCF(stars,"Set parameters for starfield")
640 dc_get_arg(ARG_STRING);
641 if ( !strcmp( Dc_arg, "tail" )) {
642 dc_get_arg(ARG_FLOAT);
643 if ( (Dc_arg_float < 0.0f) || (Dc_arg_float > 1.0f) ) {
646 Star_amount = Dc_arg_float;
648 } else if ( !strcmp( Dc_arg, "len" )) {
649 dc_get_arg(ARG_FLOAT);
650 Star_max_length = Dc_arg_float;
651 } else if ( !strcmp( Dc_arg, "dim" )) {
652 dc_get_arg(ARG_FLOAT);
653 if ( Dc_arg_float < 0.0f ) {
656 Star_dim = Dc_arg_float;
658 } else if ( !strcmp( Dc_arg, "flag" )) {
659 dc_get_arg(ARG_STRING);
660 if ( !strcmp( Dc_arg, "tail" )) {
661 Star_flags ^= STAR_FLAG_TAIL;
662 } else if ( !strcmp( Dc_arg, "dim" )) {
663 Star_flags ^= STAR_FLAG_DIM;
664 } else if ( !strcmp( Dc_arg, "aa" )) {
665 Star_flags ^= STAR_FLAG_ANTIALIAS;
669 } else if ( !strcmp( Dc_arg, "cap" )) {
670 dc_get_arg(ARG_FLOAT);
671 if ( (Dc_arg_float < 0.0f) || (Dc_arg_float > 255.0f) ) {
674 Star_cap = Dc_arg_float;
676 } else if ( !strcmp( Dc_arg, "m0" ) ) {
681 Star_max_length = STAR_MAX_LENGTH_DEFAULT;
682 } else if ( !strcmp( Dc_arg, "m1" ) || !strcmp( Dc_arg, "default" )) {
683 Star_amount = STAR_AMOUNT_DEFAULT;
684 Star_dim = STAR_DIM_DEFAULT;
685 Star_cap = STAR_CAP_DEFAULT;
686 Star_flags = STAR_FLAG_DEFAULT;
687 Star_max_length = STAR_MAX_LENGTH_DEFAULT;
688 } else if ( !strcmp( Dc_arg, "m2" )) {
692 Star_flags = STAR_FLAG_TAIL|STAR_FLAG_DIM|STAR_FLAG_ANTIALIAS;
693 Star_max_length = STAR_MAX_LENGTH_DEFAULT;
694 } else if ( !strcmp( Dc_arg, "num" )) {
696 if ( (Dc_arg_int < 0) || (Dc_arg_int > MAX_STARS) ) {
699 Num_stars = Dc_arg_int;
702 // print usage, not stats
708 dc_printf( "Usage: stars keyword\nWhere keyword can be in the following forms:\n" );
709 dc_printf( "stars default Resets stars to all default values\n" );
710 dc_printf( "stars num X Sets number of stars to X. Between 0 and %d.\n", MAX_STARS );
711 dc_printf( "stars tail X Where X is the percent of 'tail' between 0 and 1.0\n" );
712 dc_printf( "stars dim X Where X is the amount stars dim between 0 and 255.0\n" );
713 dc_printf( "stars cap X Where X is the cap of dimming between 0 and 255.\n" );
714 dc_printf( "stars len X Where X is the cap of length.\n" );
715 dc_printf( "stars m0 Macro0. Old 'pixel type' crappy stars. flags=none\n" );
716 dc_printf( "stars m1 Macro1. (default) tail=.75, dim=20.0, cap=75.0, flags=dim,tail\n" );
717 dc_printf( "stars m2 Macro2. tail=.75, dim=20.0, cap=75.0, flags=dim,tail,aa\n" );
718 dc_printf( "stars flag X Toggles flag X, where X is tail or dim or aa (aa=antialias)\n" );
719 dc_printf( "\nHINT: set cap to 0 to get dim rate and tail down, then use\n" );
720 dc_printf( "cap to keep the lines from going away when moving too fast.\n" );
721 dc_printf( "\nUse '? stars' to see current values.\n" );
722 Dc_status = 0; // don't print status if help is printed. Too messy.
726 dc_printf( "Num_stars: %d\n", Num_stars );
727 dc_printf( "Tail: %.2f\n", Star_amount );
728 dc_printf( "Dim: %.2f\n", Star_dim );
729 dc_printf( "Cap: %.2f\n", Star_cap );
730 dc_printf( "Max length: %.2f\n", Star_max_length );
731 dc_printf( "Flags:\n" );
732 dc_printf( " Tail: %s\n", (Star_flags&STAR_FLAG_TAIL?"On":"Off") );
733 dc_printf( " Dim: %s\n", (Star_flags&STAR_FLAG_DIM?"On":"Off") );
734 dc_printf( " Antialias: %s\n", (Star_flags&STAR_FLAG_ANTIALIAS?"On":"Off") );
735 dc_printf( "\nTHESE AREN'T SAVED TO DISK, SO IF YOU TWEAK\n" );
736 dc_printf( "THESE AND LIKE THEM, WRITE THEM DOWN!!\n" );
741 int reload_old_debris = 1; // If set to one, then reload all the last_pos of the debris
743 // Call this if camera "cuts" or moves long distances
744 // so blur effect doesn't draw lines all over the screen.
745 void stars_camera_cut()
747 last_stars_filled = 0;
748 reload_old_debris = 1;
751 //#define TIME_STAR_CODE // enable to time star code
754 extern float Viewer_zoom;
756 // get the world coords of the sun pos on the unit sphere.
757 void stars_get_sun_pos(int sun_n, vector *pos)
765 SDL_assert(sun_n < Num_suns);
766 if((sun_n >= Num_suns) || (sun_n < 0)){
770 // rotate the sun properly
771 temp = vmd_zero_vector;
776 // we aleady know what the matrix is so just rotate
777 vm_vec_rotate(pos, &temp, &Suns[sun_n].m);
779 vm_angles_2_matrix(&rot, &Suns[sun_n].ang);
780 vm_vec_rotate(pos, &temp, &rot);
785 void stars_draw_sun( int show_sun )
791 starfield_bitmap *bm;
792 float local_scale = 1.0f;
798 for(idx=0; idx<Num_suns; idx++){
800 bm = stars_lookup_sun(&Suns[idx]);
806 sun_pos = vmd_zero_vector;
807 sun_pos.xyz.y = 1.0f;
808 stars_get_sun_pos(idx, &sun_pos);
812 vm_vec_normalize(&sun_dir);
814 // add the light source corresponding to the sun
815 light_add_directional(&sun_dir, bm->i, bm->r, bm->g, bm->b);
818 if(supernova_active()){
819 local_scale = 1.0f + (SUPERNOVA_SUN_SCALE * supernova_pct_complete());
822 // draw the sun itself, keep track of how many we drew
823 gr_set_bitmap(bm->bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.999f, -1, -1);
824 g3_rotate_faraway_vertex(&sun_vex, &sun_pos);
826 // divide by 10 to make normal size
827 if(!g3_draw_bitmap(&sun_vex, 0, 0.05f * (Suns[idx].scale_x / 10) * local_scale, TMAP_FLAG_TEXTURED)){
829 if(!g3_draw_bitmap(&sun_vex, 0, 0.05f * Suns[idx].scale_x * local_scale, TMAP_FLAG_TEXTURED)){
836 // draw the corresponding glow for sun_n
837 void stars_draw_sun_glow(int sun_n)
839 starfield_bitmap *bm;
840 vector sun_pos, sun_dir;
842 float local_scale = 1.0f;
845 SDL_assert(sun_n < Num_suns);
846 if((sun_n >= Num_suns) || (sun_n < 0)){
851 bm = stars_lookup_sun(&Suns[sun_n]);
857 sun_pos = vmd_zero_vector;
858 sun_pos.xyz.y = 1.0f;
859 stars_get_sun_pos(sun_n, &sun_pos);
863 vm_vec_normalize(&sun_dir);
866 if(supernova_active()){
867 local_scale = 1.0f + (SUPERNOVA_SUN_SCALE * supernova_pct_complete());
870 // draw the sun itself, keep track of how many we drew
871 gr_set_bitmap(bm->glow_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.5f, -1, -1);
872 g3_rotate_faraway_vertex(&sun_vex, &sun_pos);
874 // divide by 10 to make normal size
875 g3_draw_bitmap(&sun_vex, 0, 0.10f * (Suns[sun_n].scale_x / 10) * local_scale, TMAP_FLAG_TEXTURED);
877 g3_draw_bitmap(&sun_vex, 0, 0.10f * Suns[sun_n].scale_x * local_scale, TMAP_FLAG_TEXTURED);
882 void stars_draw_bitmaps( int show_bitmaps )
887 // if we're in the nebula, don't render any backgrounds
888 if(The_mission.flags & MISSION_FLAG_FULLNEB){
893 if(!Detail.planets_suns){
897 // render all bitmaps
898 for(idx=0; idx<Num_starfield_bitmaps; idx++){
899 // lookup the info index
900 star_index = stars_find_bitmap(Starfield_bitmap_instance[idx].filename);
907 gr_set_bitmap(Starfield_bitmaps[star_index].bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.9999f, -1, -1);
908 g3_draw_perspective_bitmap(&Starfield_bitmap_instance[idx].ang, Starfield_bitmap_instance[idx].scale_x, Starfield_bitmap_instance[idx].scale_y, Starfield_bitmap_instance[idx].div_x, Starfield_bitmap_instance[idx].div_y, TMAP_FLAG_TEXTURED | TMAP_FLAG_CORRECT);
910 if(Starfield_bitmaps[star_index].xparent){
911 gr_set_bitmap(Starfield_bitmaps[star_index].bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
912 g3_draw_perspective_bitmap(&Starfield_bitmap_instance[idx].ang, Starfield_bitmap_instance[idx].scale_x, Starfield_bitmap_instance[idx].scale_y, Starfield_bitmap_instance[idx].div_x, Starfield_bitmap_instance[idx].div_y, TMAP_FLAG_TEXTURED | TMAP_FLAG_CORRECT | TMAP_FLAG_XPARENT);
914 gr_set_bitmap(Starfield_bitmaps[star_index].bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.9999f, -1, -1);
915 g3_draw_perspective_bitmap(&Starfield_bitmap_instance[idx].ang, Starfield_bitmap_instance[idx].scale_x, Starfield_bitmap_instance[idx].scale_y, Starfield_bitmap_instance[idx].div_x, Starfield_bitmap_instance[idx].div_y, TMAP_FLAG_TEXTURED | TMAP_FLAG_CORRECT);
922 void calculate_bitmap_matrix(starfield_bitmaps *bm, vector *v)
924 vm_vector_2_matrix(&bm->m, v, NULL, NULL);
925 vm_orthogonalize_matrix(&bm->m);
928 void calculate_bitmap_points(starfield_bitmaps *bm, float bank)
931 vector fvec, uvec, rvec, tmp;
934 vm_orthogonalize_matrix(&bm->m);
936 tangles.p = tangles.h = 0.0f;
938 vm_rotate_matrix_by_angles(&bm->m, &tangles);
942 vm_vec_scale(&fvec, bm->dist );
946 vm_vec_sub(&tmp, &fvec, &uvec);
947 vm_vec_sub(&bm->points[3], &tmp, &rvec);
949 vm_vec_sub(&tmp, &fvec, &uvec);
950 vm_vec_add(&bm->points[2], &tmp, &rvec);
952 vm_vec_add(&tmp, &fvec, &uvec);
953 vm_vec_add(&bm->points[1], &tmp, &rvec);
955 vm_vec_add(&tmp, &fvec, &uvec);
956 vm_vec_sub(&bm->points[0], &tmp, &rvec);
959 vm_vec_normalize(&bm->points[i]);
964 extern int Interp_subspace;
965 extern float Interp_subspace_offset_u;
966 extern float Interp_subspace_offset_u;
967 extern float Interp_subspace_offset_v;
969 float subspace_offset_u = 0.0f;
970 float subspace_offset_u_inner = 0.0f;
971 float subspace_offset_v = 0.0f;
973 float subspace_u_speed = 0.07f; // how fast u changes
974 float subspace_v_speed = 0.05f; // how fast v changes
976 int Subspace_glow_bitmap = -1;
978 float Subspace_glow_frame = 0.0f;
979 float Subspace_glow_rate = 1.0f;
983 DCF(subspace_set,"Set parameters for subspace effect")
986 dc_get_arg(ARG_STRING);
987 if ( !strcmp( Dc_arg, "u" )) {
988 dc_get_arg(ARG_FLOAT);
989 if ( Dc_arg_float < 0.0f ) {
992 subspace_u_speed = Dc_arg_float;
994 } else if ( !strcmp( Dc_arg, "v" )) {
995 dc_get_arg(ARG_FLOAT);
996 if ( Dc_arg_float < 0.0f ) {
999 subspace_v_speed = Dc_arg_float;
1002 // print usage, not stats
1008 dc_printf( "Usage: subspace keyword\nWhere keyword can be in the following forms:\n" );
1009 dc_printf( "subspace u X Where X is how fast u moves.\n", MAX_STARS );
1010 dc_printf( "subspace v X Where X is how fast v moves.\n" );
1011 dc_printf( "\nUse '? subspace' to see current values.\n" );
1012 Dc_status = 0; // don't print status if help is printed. Too messy.
1016 dc_printf( "u: %.2f\n", subspace_u_speed );
1017 dc_printf( "v: %.2f\n", subspace_v_speed );
1022 void subspace_render()
1024 if ( Subspace_model_inner == -1 ) {
1025 Subspace_model_inner = model_load( "subspace_small.pof", 0, NULL );
1026 SDL_assert(Subspace_model_inner>-1);
1029 if ( Subspace_model_outer == -1 ) {
1030 Subspace_model_outer = model_load( "subspace_big.pof", 0, NULL );
1031 SDL_assert(Subspace_model_outer>-1);
1034 if ( Subspace_glow_bitmap == -1 ) {
1035 Subspace_glow_bitmap = bm_load( NOX("SunGlow01"));
1036 SDL_assert(Subspace_glow_bitmap>-1);
1039 Subspace_glow_frame += flFrametime * 1.0f;
1041 float total_time = i2fl(NOISE_NUM_FRAMES) / 15.0f;
1044 if ( Subspace_glow_frame < 0.0f ) Subspace_glow_frame = 0.0f;
1045 if ( Subspace_glow_frame > 100.0f ) Subspace_glow_frame = 0.0f;
1047 while ( Subspace_glow_frame > total_time ) {
1048 Subspace_glow_frame -= total_time;
1050 int framenum = fl2i( (Subspace_glow_frame*NOISE_NUM_FRAMES) / total_time );
1051 if ( framenum < 0 ) framenum = 0;
1052 if ( framenum >= NOISE_NUM_FRAMES ) framenum = NOISE_NUM_FRAMES-1;
1054 subspace_offset_u += flFrametime*subspace_u_speed;
1055 if (subspace_offset_u > 1.0f ) {
1056 subspace_offset_u -= 1.0f;
1059 subspace_offset_u_inner += flFrametime*subspace_u_speed*3.0f;
1060 if (subspace_offset_u > 1.0f ) {
1061 subspace_offset_u -= 1.0f;
1064 subspace_offset_v += flFrametime*subspace_v_speed;
1065 if (subspace_offset_v > 1.0f ) {
1066 subspace_offset_v -= 1.0f;
1072 angles angs = { 0.0f, 0.0f, 0.0f };
1073 angs.b = subspace_offset_v * PI2;
1075 vm_angles_2_matrix(&tmp,&angs);
1077 int saved_gr_zbuffering = gr_zbuffer_get();
1079 gr_zbuffer_set(GR_ZBUFF_NONE);
1081 int render_flags = MR_NO_LIGHTING | MR_ALWAYS_REDRAW;
1083 Interp_subspace = 1;
1084 Interp_subspace_offset_u = 1.0f - subspace_offset_u;
1085 Interp_subspace_offset_v = 0.0f;
1087 model_set_thrust( Subspace_model_inner, 1.0f, -1, Subspace_glow_bitmap, Noise[framenum] );
1088 render_flags |= MR_SHOW_THRUSTERS;
1089 model_render( Subspace_model_outer, &tmp, &Eye_position, render_flags ); //MR_NO_CORRECT|MR_SHOW_OUTLINE
1091 Interp_subspace = 1;
1092 Interp_subspace_offset_u = 1.0f - subspace_offset_u_inner;
1093 Interp_subspace_offset_v = 0.0f;
1095 angs.b = -subspace_offset_v * PI2;
1097 vm_angles_2_matrix(&tmp,&angs);
1099 model_set_outline_color(255,255,255);
1101 model_set_thrust( Subspace_model_inner, 1.0f, -1, Subspace_glow_bitmap, Noise[framenum] );
1102 render_flags |= MR_SHOW_THRUSTERS;
1104 model_render( Subspace_model_inner, &tmp, &Eye_position, render_flags ); //MR_NO_CORRECT|MR_SHOW_OUTLINE
1106 Interp_subspace = 0;
1107 gr_zbuffer_set(saved_gr_zbuffering);
1110 void stars_draw( int show_stars, int show_suns, int show_nebulas, int show_subspace )
1116 int gr_zbuffering_save = gr_zbuffer_get();
1117 gr_zbuffer_set(GR_ZBUFF_NONE);
1119 if ( show_subspace ) {
1124 if (Num_stars >= MAX_STARS){
1125 Num_stars = MAX_STARS;
1128 #ifdef TIME_STAR_CODE
1130 xt1 = timer_get_fixed_seconds();
1133 if ( show_nebulas && (Game_detail_flags & DETAIL_FLAG_NEBULAS) && (Neb2_render_mode != NEB2_RENDER_POF) && (Neb2_render_mode != NEB2_RENDER_LAME)) {
1137 // draw background stuff
1138 if((Neb2_render_mode != NEB2_RENDER_POLY) && (Neb2_render_mode != NEB2_RENDER_LAME) && show_stars){
1139 // semi-hack, do we don't fog the background
1140 int neb_save = Neb2_render_mode;
1141 Neb2_render_mode = NEB2_RENDER_NONE;
1142 extern void stars_draw_background();
1143 stars_draw_background();
1144 Neb2_render_mode = neb_save;
1147 if (show_stars && ( Game_detail_flags & DETAIL_FLAG_STARS) && !(The_mission.flags & MISSION_FLAG_FULLNEB) && (supernova_active() < 3)) {
1152 if ( !last_stars_filled ) {
1153 for (sp=Stars,i=0; i<Num_stars; i++, sp++ ) {
1155 g3_rotate_faraway_vertex(&p2, &sp->pos);
1156 sp->last_star_pos.xyz.x = p2.x;
1157 sp->last_star_pos.xyz.y = p2.y;
1158 sp->last_star_pos.xyz.z = p2.z;
1164 tmp_num_stars = (Detail.num_stars*Num_stars)/MAX_DETAIL_LEVEL;
1165 if (tmp_num_stars < 0 ) {
1167 } else if ( tmp_num_stars > Num_stars ) {
1168 tmp_num_stars = Num_stars;
1171 for (sp=Stars,i=0; i<tmp_num_stars; i++, sp++ ) {
1175 memset(&p1, 0, sizeof(vertex));
1177 // This makes a star look "proper" by not translating the
1178 // point around the viewer's eye before rotation. In other
1179 // words, when the ship translates, the stars do not change.
1181 g3_rotate_faraway_vertex(&p2, &sp->pos);
1185 g3_project_vertex(&p2);
1186 if ( p2.flags & PF_OVERFLOW ) {
1193 if ( can_draw && (Star_flags & (STAR_FLAG_TAIL|STAR_FLAG_DIM)) ) {
1195 dist = vm_vec_dist_quick( &sp->last_star_pos, (vector *)&p2.x );
1198 if ( dist > Star_max_length ) {
1199 ratio = Star_max_length / dist;
1200 dist = Star_max_length;
1204 ratio *= Star_amount;
1206 p1.x = p2.x + (sp->last_star_pos.xyz.x-p2.x)*ratio;
1207 p1.y = p2.y + (sp->last_star_pos.xyz.y-p2.y)*ratio;
1208 p1.z = p2.z + (sp->last_star_pos.xyz.z-p2.z)*ratio;
1210 p1.flags = 0; // not projected
1211 g3_code_vertex( &p1 );
1216 g3_project_vertex(&p1);
1217 if ( p1.flags & PF_OVERFLOW ) {
1223 sp->last_star_pos.xyz.x = p2.x;
1224 sp->last_star_pos.xyz.y = p2.y;
1225 sp->last_star_pos.xyz.z = p2.z;
1227 if ( !can_draw ) continue;
1231 if ( Star_flags & STAR_FLAG_DIM ) {
1233 float colorf = 255.0f - dist*Star_dim;
1235 if ( colorf < Star_cap )
1238 color = (fl2i(colorf)*(i&7))/256;
1244 gr_set_color_fast( &star_aacolors[color] );
1246 // if the two points are the same, fudge it, since some D3D cards (G200 and G400) are lame.
1247 if ( (fl2i(p1.sx) == fl2i(p2.sx)) && (fl2i(p1.sy) == fl2i(p2.sy)) ) {
1255 last_stars_filled = 1;
1257 #ifdef TIME_STAR_CODE
1258 xt2 = timer_get_fixed_seconds();
1259 mprintf(( "Stars: %d\n", xt2-xt1 ));
1263 if ( (Game_detail_flags & DETAIL_FLAG_MOTION) && (!Fred_running) && (supernova_active() < 3) ) {
1265 gr_set_color( 0, 0, 0 );
1268 if(The_mission.flags & MISSION_FLAG_FULLNEB){
1269 gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0, -1.0f, -1.0f);
1272 old_debris * d = odebris;
1273 for (i=0; i<MAX_DEBRIS; i++, d++ ) {
1277 d->pos.xyz.x = f2fl(myrand() - MY_RAND_MAX/2);
1278 d->pos.xyz.y = f2fl(myrand() - MY_RAND_MAX/2);
1279 d->pos.xyz.z = f2fl(myrand() - MY_RAND_MAX/2);
1281 vm_vec_normalize(&d->pos);
1283 vm_vec_scale(&d->pos, MAX_DIST);
1284 vm_vec_add2(&d->pos, &Eye_position );
1285 // vm_vec_add2(&d->pos, &Player_obj->pos );
1287 d->vclip = i % MAX_DEBRIS_VCLIPS; //rand()
1289 // if we're in full neb mode
1290 if((The_mission.flags & MISSION_FLAG_FULLNEB) && (Neb2_render_mode != NEB2_RENDER_NONE)){
1291 d->size = i2fl(myrand() % 4)*BASE_SIZE_NEB;
1293 d->size = i2fl(myrand() % 4)*BASE_SIZE;
1296 vm_vec_sub( &d->last_pos, &d->pos, &Eye_position );
1299 if ( reload_old_debris ) {
1300 vm_vec_sub( &d->last_pos, &d->pos, &Eye_position );
1303 g3_rotate_vertex(&p, &d->pos);
1306 int frame = Missiontime / (DEBRIS_ROT_MIN + (i % DEBRIS_ROT_RANGE) * DEBRIS_ROT_RANGE_SCALER);
1307 frame %= debris_vclips[d->vclip].nframes;
1309 if((The_mission.flags & MISSION_FLAG_FULLNEB) && (Neb2_render_mode != NEB2_RENDER_NONE)){
1310 gr_set_bitmap( debris_vclips[d->vclip].bm + frame, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.3f, -1, -1);
1312 gr_set_bitmap( debris_vclips[d->vclip].bm + frame, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1316 vm_vec_add( &tmp, &d->last_pos, &Eye_position );
1317 g3_draw_laser( &d->pos,d->size,&tmp,d->size, TMAP_FLAG_TEXTURED|TMAP_FLAG_XPARENT, 25.0f );
1320 vm_vec_sub( &d->last_pos, &d->pos, &Eye_position );
1322 vdist = vm_vec_mag_quick(&d->last_pos);
1324 if (vdist > MAX_DIST_RANGE)
1326 else if (vdist < MIN_DIST_RANGE)
1330 // vm_vec_sub( &tmp, &d->pos, &Player_obj->pos );
1331 // vdist = vm_vec_dot( &tmp, &Player_obj->orient.fvec );
1332 // if ( vdist < 0.0f )
1337 reload_old_debris = 0;
1341 stars_draw_sun( show_suns );
1342 stars_draw_bitmaps( show_suns );
1344 gr_zbuffer_set( gr_zbuffering_save );
1347 void stars_page_in()
1351 // Initialize the subspace stuff
1353 if ( Game_subspace_effect ) {
1355 Subspace_model_inner = model_load( "subspace_small.pof", 0, NULL );
1356 SDL_assert(Subspace_model_inner>-1);
1357 Subspace_model_outer = model_load( "subspace_big.pof", 0, NULL );
1358 SDL_assert(Subspace_model_outer>-1);
1362 pm = model_get(Subspace_model_inner);
1364 nprintf(( "Paging", "Paging in textures for subspace effect.\n" ));
1366 for (j=0; j<pm->n_textures; j++ ) {
1367 int bitmap_num = pm->original_textures[j];
1369 if ( bitmap_num > -1 ) {
1370 bm_page_in_texture( bitmap_num );
1374 pm = model_get(Subspace_model_outer);
1376 nprintf(( "Paging", "Paging in textures for subspace effect.\n" ));
1378 for (j=0; j<pm->n_textures; j++ ) {
1379 int bitmap_num = pm->original_textures[j];
1381 if ( bitmap_num > -1 ) {
1382 bm_page_in_texture( bitmap_num );
1386 Subspace_model_inner = -1;
1387 Subspace_model_outer = -1;
1390 Subspace_glow_bitmap = bm_load( NOX("SunGlow01"));
1391 bm_page_in_xparent_texture(Subspace_glow_bitmap);
1393 // page in starfield bitmaps
1396 while((idx < MAX_STARFIELD_BITMAPS) && (Starfield_bitmaps[idx].bitmap != -1)){
1397 // make sure it's used in this mission before loading
1398 for (t=0; t<Num_starfield_bitmaps; t++) {
1399 if (!SDL_strcasecmp(Starfield_bitmaps[idx].filename, Starfield_bitmap_instance[t].filename)) {
1400 if(Starfield_bitmaps[idx].xparent){
1401 bm_page_in_xparent_texture(Starfield_bitmaps[idx].bitmap);
1403 bm_page_in_texture(Starfield_bitmaps[idx].bitmap);
1412 // sun bitmaps and glows
1414 while((idx < MAX_STARFIELD_BITMAPS) && (Sun_bitmaps[idx].bitmap != -1) && (Sun_bitmaps[idx].glow_bitmap != -1)){
1415 // make sure it's used in this mission before loading
1416 for (t=0; t<Num_suns; t++) {
1417 if (!SDL_strcasecmp(Sun_bitmaps[idx].filename, Suns[t].filename)) {
1418 bm_page_in_texture(Sun_bitmaps[idx].bitmap);
1419 bm_page_in_texture(Sun_bitmaps[idx].glow_bitmap);
1427 for (i=0; i<MAX_DEBRIS_VCLIPS; i++ ) {
1428 for (j=0; j<debris_vclips[i].nframes; j++ ) {
1429 bm_page_in_xparent_texture(debris_vclips[i].bm + j);
1434 // background nebula models and planets
1435 void stars_draw_background()
1437 if((Nmodel_num < 0) || (Nmodel_bitmap < 0)){
1441 // draw the model at the player's eye wif no z-buffering
1442 model_set_alpha(1.0f);
1443 model_set_forced_texture(Nmodel_bitmap);
1444 model_render(Nmodel_num, &vmd_identity_matrix, &Eye_position, MR_NO_ZBUFFER | MR_NO_CULL | MR_ALL_XPARENT | MR_NO_LIGHTING | MR_FORCE_TEXTURE);
1445 model_set_forced_texture(-1);
1448 // call this to set a specific model as the background model
1449 void stars_set_background_model(const char *model_name, const char *texture_name)
1451 Nmodel_num = model_load(model_name, 0, NULL);
1452 Nmodel_bitmap = bm_load(texture_name);
1455 // lookup a starfield bitmap, return index or -1 on fail
1456 int stars_find_bitmap(const char *name)
1461 for(idx=0; idx<MAX_STARFIELD_BITMAPS; idx++){
1462 if(!strcmp(name, Starfield_bitmaps[idx].filename)){
1471 // lookup a sun by bitmap filename, return index or -1 on fail
1472 int stars_find_sun(const char *name)
1477 for(idx=0; idx<MAX_STARFIELD_BITMAPS; idx++){
1478 if(!strcmp(name, Sun_bitmaps[idx].filename)){