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 * Routines to display title screens...
49 void DoBriefingColorStuff ();
50 int get_new_message_num(char **message);
51 int DefineBriefingBox (char **buf);
53 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
58 char CurBriefScreenName[15]="brief03.pcx";
62 //Begin D1X modification
63 #define MAX_BRIEFING_COLORS 7
64 //End D1X modification
66 #define SHAREWARE_ENDING_FILENAME "ending.tex"
69 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
70 int Skip_briefing_screens=0;
72 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
73 int Current_color = 0;
77 // added by Jan Bobrowski for variable-size menu screen
78 static int rescale_x(int x)
80 return x * GWIDTH / 320;
83 static int rescale_y(int y)
85 return y * GHEIGHT / 200;
89 int local_key_inkey(void)
93 rval = newmenu_inkey();
95 if (rval == KEY_PRINT_SCREEN) {
97 return 0; //say no key pressed
100 if (mouse_button_state(0)) // mouse button pressed?
103 if ( rval == KEY_Q+KEY_COMMAND )
110 void delay_until(fix time)
112 fix t = timer_get_fixed_seconds();
114 timer_delay(time - t);
118 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
123 ubyte palette_save[768];
124 char new_filename[FILENAME_LEN+1] = "";
128 strcpy(new_filename,"\x01"); //only read from hog file
131 strcat(new_filename,filename);
132 filename = new_filename;
134 title_bm.bm_data=NULL;
135 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
136 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
137 mprintf((0, "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error));
138 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
141 memcpy(palette_save,gr_palette,sizeof(palette_save));
143 //vfx_set_palette_sub( New_pal );
146 gr_set_current_canvas( NULL );
147 show_fullscr(&title_bm);
149 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
151 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
153 gr_palette_load( New_pal );
154 timer = timer_get_fixed_seconds() + i2f(3);
156 if ( local_key_inkey() && allow_keys ) break;
157 if ( timer_get_fixed_seconds() > timer ) break;
159 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
161 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
162 d_free(title_bm.bm_data);
166 int intro_played = 0;
168 void show_titles(void)
171 int played=MOVIE_NOT_PLAYED; //default is not played
173 int song_playing = 0;
176 #define MOVIE_REQUIRED 0
178 #define MOVIE_REQUIRED 1
181 { //show bundler screens
182 char filename[FILENAME_LEN];
184 played=MOVIE_NOT_PLAYED; //default is not played
186 played = PlayMovie("pre_i.mve",0);
189 strcpy(filename,MenuHires?"pre_i1b.pcx":"pre_i1.pcx");
191 while (PHYSFS_exists(filename))
193 show_title_screen( filename, 1, 0 );
200 init_subtitles("intro.tex");
201 played = PlayMovie("intro.mve",MOVIE_REQUIRED);
205 if (played != MOVIE_NOT_PLAYED)
208 { //didn't get intro movie, try titles
210 played = PlayMovie("titles.mve",MOVIE_REQUIRED);
212 if (played == MOVIE_NOT_PLAYED)
214 char filename[FILENAME_LEN];
216 vid_set_mode(MenuHires?SM(640,480):SM(320,200));
218 set_screen_mode(SCREEN_MENU);
220 con_printf( CON_DEBUG, "\nPlaying title song..." );
221 songs_play_song( SONG_TITLE, 1);
223 con_printf( CON_DEBUG, "\nShowing logo screens..." );
225 strcpy(filename, MenuHires?"iplogo1b.pcx":"iplogo1.pcx"); // OEM
226 if (! cfexist(filename))
227 strcpy(filename, "iplogo1.pcx"); // SHAREWARE
228 if (! cfexist(filename))
229 strcpy(filename, "mplogo.pcx"); // MAC SHAREWARE
230 if (cfexist(filename))
231 show_title_screen(filename, 1, 1);
233 strcpy(filename, MenuHires?"logob.pcx":"logo.pcx"); // OEM
234 if (! cfexist(filename))
235 strcpy(filename, "logo.pcx"); // SHAREWARE
236 if (! cfexist(filename))
237 strcpy(filename, "plogo.pcx"); // MAC SHAREWARE
238 if (cfexist(filename))
239 show_title_screen(filename, 1, 1);
243 { //show bundler movie or screens
245 char filename[FILENAME_LEN];
246 PHYSFS_file *movie_handle;
248 played=MOVIE_NOT_PLAYED; //default is not played
250 //check if OEM movie exists, so we don't stop the music if it doesn't
251 movie_handle = PHYSFS_openRead("oem.mve");
254 PHYSFS_close(movie_handle);
255 played = PlayMovie("oem.mve",0);
256 song_playing = 0; //movie will kill sound
261 strcpy(filename,MenuHires?"oem1b.pcx":"oem1.pcx");
263 while (PHYSFS_exists(filename))
265 show_title_screen( filename, 1, 0 );
272 songs_play_song( SONG_TITLE, 1);
275 void show_loading_screen(ubyte *title_pal)
277 //grs_bitmap title_bm;
281 strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx");
282 if (! cfexist(filename))
283 strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM
284 if (! cfexist(filename))
285 strcpy(filename, "descentd.pcx"); // SHAREWARE
286 if (! cfexist(filename))
287 strcpy(filename, "descentb.pcx"); // MAC SHAREWARE
289 vid_set_mode(MenuHires?SM(640,480):SM(320,200));
291 set_screen_mode(SCREEN_MENU);
294 FontHires = FontHiresAvailable && MenuHires;
296 if ((pcx_error=pcx_read_fullscr( filename, title_pal ))==PCX_ERROR_NONE) {
297 //vfx_set_palette_sub( title_pal );
299 gr_palette_fade_in( title_pal, 32, 0 );
302 Error( "Couldn't load pcx file '%s', PCX load error: %s\n",filename, pcx_errormsg(pcx_error));
306 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
309 short text_ulx, text_uly; // upper left x,y of text window
310 short text_width, text_height; // width and height of text window
313 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
314 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
316 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
317 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
320 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
322 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
325 #define MAX_BRIEFING_SCREENS 60
327 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
328 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
330 briefing_screen D1_Briefing_screens[] = {
331 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
332 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
333 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
334 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
336 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
337 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
338 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
340 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
341 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
343 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
344 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
345 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
348 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
349 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
350 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
351 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
352 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
354 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
355 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
356 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
357 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
358 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
360 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
361 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
362 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
363 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
364 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
366 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
367 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
368 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
369 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
371 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
372 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
373 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
375 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
376 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
377 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
379 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
380 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
381 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
384 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
386 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
387 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
388 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
393 #define NUM_D1_BRIEFING_SCREENS (sizeof(D1_Briefing_screens)/sizeof(briefing_screen))
395 int Briefing_text_x, Briefing_text_y;
397 void init_char_pos(int x, int y)
401 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
404 grs_canvas *Robot_canv = NULL;
405 vms_angvec Robot_angles;
407 ubyte Bitmap_palette[768];
409 char Bitmap_name[32] = "";
410 #define EXIT_DOOR_MAX 14
411 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
412 #define DOOR_DIV_INIT 3
413 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
415 //-----------------------------------------------------------------------------
416 void show_bitmap_frame(void)
418 grs_canvas *curcanv_save, *bitmap_canv=0;
420 grs_bitmap *bitmap_ptr;
422 // Only plot every nth frame.
423 if (Door_div_count) {
428 Door_div_count = DOOR_DIV_INIT;
430 if (Bitmap_name[0] != 0) {
434 // Set supertransparency color to black
435 if (!New_pal_254_bash) {
436 New_pal_254_bash = 1;
438 New_pal[254*3+1] = 0;
439 New_pal[254*3+2] = 0;
440 gr_palette_load( New_pal );
443 switch (Animating_bitmap_type) {
445 bitmap_canv = gr_create_canvas(rescale_x(64), rescale_y(64));
448 bitmap_canv = gr_create_canvas(rescale_x(94), rescale_y(94));
451 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
453 Int3(); // Impossible, illegal value for Animating_bitmap_type
456 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv;
458 pound_signp = strchr(Bitmap_name, '#');
459 Assert(pound_signp != NULL);
461 dig1 = *(pound_signp+1);
462 dig2 = *(pound_signp+2);
466 num = (dig1-'0')*10 + (dig2-'0');
468 switch (Animating_bitmap_type) {
471 if (num > EXIT_DOOR_MAX) {
474 } else if (num < 0) {
481 if (num > OTHER_THING_MAX)
488 *(pound_signp+1) = (num / 10) + '0';
489 *(pound_signp+2) = (num % 10) + '0';
490 *(pound_signp+3) = 0;
492 *(pound_signp+1) = (num % 10) + '0';
493 *(pound_signp+2) = 0;
498 bi = piggy_find_bitmap(Bitmap_name);
499 bitmap_ptr = &GameBitmaps[bi.index];
503 gr_bitmap_scale_to(bitmap_ptr, &bitmap_canv->cv_bitmap);
505 grd_curcanv = curcanv_save;
506 gr_remap_bitmap_good(&bitmap_canv->cv_bitmap, Bitmap_palette, 255, 254);
507 gr_bitmapm(rescale_x(220), rescale_y(45), &bitmap_canv->cv_bitmap);
510 switch (Animating_bitmap_type) {
512 if (num == EXIT_DOOR_MAX) {
515 } else if (num == 0) {
527 //-----------------------------------------------------------------------------
528 void show_briefing_bitmap(grs_bitmap *bmp)
530 grs_canvas *curcanv_save, *bitmap_canv;
532 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
533 curcanv_save = grd_curcanv;
534 gr_set_current_canvas(bitmap_canv);
535 gr_bitmapm(0, 0, bmp);
536 gr_set_current_canvas(curcanv_save);
541 //-----------------------------------------------------------------------------
542 void show_spinning_robot_frame(int robot_num)
544 grs_canvas *curcanv_save;
546 if (robot_num != -1) {
547 Robot_angles.h += 150;
549 curcanv_save = grd_curcanv;
550 grd_curcanv = Robot_canv;
551 Assert(Robot_info[robot_num].model_num != -1);
552 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
553 grd_curcanv = curcanv_save;
554 gr_copy_palette(gr_palette, New_pal, sizeof(New_pal));
555 gr_remap_bitmap_good(&Robot_canv->cv_bitmap, Bitmap_palette, 255, 254);
560 //-----------------------------------------------------------------------------
561 void init_spinning_robot(void) //(int x,int y,int w,int h)
563 //Robot_angles.p += 0;
564 //Robot_angles.b += 0;
565 //Robot_angles.h += 0;
567 int x = rescale_x(138);
568 int y = rescale_y(55);
569 int w = rescale_x(166);
570 int h = rescale_y(138);
572 gr_use_palette_table(DEFAULT_LEVEL_PALETTE);
573 memcpy(Bitmap_palette, gr_palette, sizeof(Bitmap_palette));
575 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
579 //---------------------------------------------------------------------------
580 // Returns char width.
581 // If show_robot_flag set, then show a frame of the spinning robot.
582 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
586 static fix start_time=0;
588 message[0] = the_char;
591 if (start_time==0 && timer_get_fixed_seconds()<0)
592 start_time=timer_get_fixed_seconds();
594 gr_get_string_size(message, &w, &h, &aw );
596 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
598 // Draw cursor if there is some delay and caller says to draw cursor
599 if (cursor_flag && delay) {
600 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
601 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
605 if ((Bitmap_name[0] != 0) && (delay != 0))
608 if (RobotPlaying && (delay != 0))
611 if ((robot_num != -1) && (delay != 0))
612 show_spinning_robot_frame(robot_num);
614 while (timer_get_fixed_seconds() < (start_time + delay)) {
617 if (RobotPlaying && delay != 0)
620 if ((robot_num != -1) && (delay != 0))
621 show_spinning_robot_frame(robot_num);
623 if ((Bitmap_name[0] != 0) && (delay != 0))
626 delay_until(start_time + delay/2);
629 start_time = timer_get_fixed_seconds();
632 if (cursor_flag && delay) {
633 gr_set_fontcolor(Erase_color, -1);
634 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
637 // Draw the character
638 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
639 gr_printf(Briefing_text_x, Briefing_text_y, message );
641 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
642 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
644 if (delay) vid_update();
646 // if (the_char != ' ')
647 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
648 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
653 //-----------------------------------------------------------------------------
654 int load_briefing_screen( int screen_num )
659 strcpy (CurBriefScreenName, Briefing_screens[screen_num].bs_name);
661 if ((pcx_error = pcx_read_fullscr(CurBriefScreenName, New_pal)) != PCX_ERROR_NONE)
662 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
667 int load_new_briefing_screen( char *fname )
669 mprintf ((0,"Loading new briefing <%s>\n",fname));
670 strcpy (CurBriefScreenName,fname);
673 memcpy(New_pal, gr_palette, sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
676 if (gr_palette_fade_out( New_pal, 32, 0 ))
679 load_briefing_screen(-1);
681 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
683 if (gr_palette_fade_in( New_pal, 32, 0 ))
685 DoBriefingColorStuff();
692 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
694 //-----------------------------------------------------------------------------
695 int get_message_num(char **message)
699 while (**message == ' ')
702 while ((**message >= '0') && (**message <= '9')) {
703 num = 10*num + **message-'0';
707 while (*(*message)++ != 10) // Get and drop eoln
713 //-----------------------------------------------------------------------------
714 void get_message_name(char **message, char *result)
716 while (**message == ' ')
719 while ((**message != ' ') && (**message != 10)) {
720 if (**message != '\n')
721 *result++ = **message;
726 while (*(*message)++ != 10) // Get and drop eoln
732 //-----------------------------------------------------------------------------
733 void flash_cursor(int cursor_flag)
735 if (cursor_flag == 0)
738 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
739 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
741 gr_set_fontcolor(Erase_color, -1);
743 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
747 extern int InitMovieBriefing();
749 static int robot_movie_model_map(char kludge)
751 switch (tolower(kludge)) {
752 case 'a': return 24; // bper
753 case 'b': return 25; // smelter
754 case 'c': return 34; // unused?
755 case 'd': return 26; // ice spindle
756 case 'e': return 27; // bulk destroyer
757 case 'f': return 28; // trn racer
758 case 'g': return 29; // fox
759 case 'h': return 30; // sidearm
760 case 'i': return 51; // lou guard
761 case 'j': return 33; // guide bot
762 case 'k': return 36; // itsc
763 case 'l': return 49; // omega defense spawn
764 case 'm': return 37; // itd
765 case 'n': return 38; // pest
766 case 'o': return 50; // sidearm modula
767 case 'p': return 39; // pig
768 case 'q': return 61; // spawn
769 case 'r': return 40; // diamond claw
770 case 's': return 43; // seeker
771 case 't': return 42; // bandit
772 case 'u': return 44; // e-bandit
773 case 'w': return 47; // boarshead
774 case 'x': return 48; // spider
775 case 'y': return 41; // red hornet
776 /* vertigo robots, possibly not constant */
777 case '1': return 70; // smelter ii
778 case '2': return 74; // canary
779 case '3': return 66; // compact lifter
780 case '4': return 69; // class 2 heavy driller
781 case '5': return 73; // logikill
782 case '6': return 71; // max
783 case '7': return 72; // sniper ng
784 case '8': return 68; // fiddler
785 case '9': return 67; // fervid 99
786 case '$': return 77; // spike
787 default: Int3(); return -1;
791 //-----------------------------------------------------------------------------
792 // Return true if message got aborted by user (pressed ESC), else return false.
793 int show_briefing_message(int screen_num, char *message)
797 briefing_screen *bsp;
798 int delay_count = KEY_DELAY_DEFAULT;
802 static int tab_stop=0;
803 int flashing_cursor=0;
804 int new_page=0,GotZ=0;
805 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
809 int hum_channel=-1,printing_channel=-1;
810 int LineAdjustment=1;
819 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
822 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
823 gr_set_curfont( GAME_FONT );
827 MALLOC(bsp, briefing_screen, 1);
828 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
829 bsp->text_ulx = rescale_x(bsp->text_ulx);
830 bsp->text_uly = rescale_y(bsp->text_uly);
831 bsp->text_width = rescale_x(bsp->text_width);
832 bsp->text_height = rescale_y(bsp->text_height);
833 init_char_pos(bsp->text_ulx, bsp->text_uly);
835 bsp=&Briefing_screens[0];
836 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
844 screen_num=DefineBriefingBox (&message);
845 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
847 bsp = &Briefing_screens[screen_num];
848 init_char_pos(bsp->text_ulx, bsp->text_uly);
850 prev_ch = 10; // read to eoln
851 } else if (ch=='U') {
852 screen_num=get_message_num(&message);
853 bsp = &Briefing_screens[screen_num];
854 init_char_pos(bsp->text_ulx, bsp->text_uly);
855 prev_ch = 10; // read to eoln
856 } else if (ch == 'C') {
857 Current_color = get_message_num(&message)-1;
858 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
860 } else if (ch == 'F') { // toggle flashing cursor
861 flashing_cursor = !flashing_cursor;
863 while (*message++ != 10)
865 } else if (ch == 'T') {
866 tab_stop = get_message_num(&message);
867 tab_stop*=(1+MenuHires);
868 prev_ch = 10; // read to eoln
869 } else if (ch == 'R') {
870 if (Robot_canv != NULL) {
880 init_spinning_robot();
881 robot_num = get_message_num(&message);
882 while (*message++ != 10)
886 spinRobotName[2]=kludge; // ugly but proud
888 RobotPlaying=InitRobotMovie(spinRobotName);
890 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
894 DoBriefingColorStuff ();
895 mprintf ((0,"Robot playing is %d!!!\n",RobotPlaying));
897 init_spinning_robot();
898 robot_num = robot_movie_model_map(kludge);
901 prev_ch = 10; // read to eoln
902 } else if (ch == 'N') {
903 //--grs_bitmap *bitmap_ptr;
904 if (Robot_canv != NULL) {
909 get_message_name(&message, Bitmap_name);
910 strcat(Bitmap_name, "#0");
911 Animating_bitmap_type = 0;
913 } else if (ch == 'O') {
914 if (Robot_canv != NULL) {
919 get_message_name(&message, Bitmap_name);
920 strcat(Bitmap_name, "#0");
921 Animating_bitmap_type = 1;
923 } else if (ch=='A') {
924 LineAdjustment=1-LineAdjustment;
925 } else if (ch=='Z') {
926 //mprintf ((0,"Got a Z!\n"));
928 if (LineAdjustment==1 || is_D2_OEM || is_MAC_SHARE)
934 while ((fname[i]=*message) != '\n') {
940 while (*message++ != 10) // Get and drop eoln
947 while (fname[i]!='.') {
948 fname2[i] = fname[i];
958 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
959 load_new_briefing_screen (fname2);
961 load_new_briefing_screen (fname);
964 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
966 } else if (ch == 'B') {
967 char bitmap_name[32];
968 grs_bitmap guy_bitmap;
969 ubyte temp_palette[768];
972 if (Robot_canv != NULL) {
977 get_message_name(&message, bitmap_name);
978 strcat(bitmap_name, ".bbm");
979 guy_bitmap.bm_data = NULL;
980 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
981 Assert(iff_error == IFF_NO_ERROR);
982 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
984 show_briefing_bitmap(&guy_bitmap);
985 d_free(guy_bitmap.bm_data);
987 // } else if (ch==EOF) {
989 // } else if (ch == 'B') {
990 // if (Robot_canv != NULL) {
991 // d_free(Robot_canv);
995 // bitmap_num = get_message_num(&message);
996 // if (bitmap_num != -1)
997 // show_briefing_bitmap(Textures[bitmap_num]);
998 // prev_ch = 10; // read to eoln
999 } else if (ch == 'S') {
1004 if (printing_channel>-1)
1005 digi_stop_sound( printing_channel );
1006 printing_channel=-1;
1010 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1011 start_time = timer_get_fixed_seconds();
1013 flash_cursor(flashing_cursor);
1017 if (robot_num != -1)
1018 show_spinning_robot_frame(robot_num);
1020 if (Bitmap_name[0] != 0)
1021 show_bitmap_frame();
1023 delay_until(start_time + KEY_DELAY_DEFAULT/2);
1027 if (keypress == KEY_BACKSP)
1030 if (keypress == KEY_ESC)
1033 flashing_cursor = 0;
1035 } else if (ch == 'P') { // New page.
1037 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1038 // printing to it! You know, $Z !!!
1039 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1043 while (*message != 10) {
1044 message++; // drop carriage return after special escape sequence
1050 } else if (ch == '\t') { // Tab
1051 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1052 Briefing_text_x = bsp->text_ulx + tab_stop;
1053 } else if ((ch == ';') && (prev_ch == 10)) {
1054 while (*message++ != 10)
1057 } else if (ch == '\\') {
1059 } else if (ch == 10) {
1060 if (prev_ch != '\\') {
1064 Briefing_text_y += (8*(MenuHires*1.4+1));
1066 Briefing_text_y += (8*(MenuHires+1));
1069 Briefing_text_x = bsp->text_ulx;
1070 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1071 load_briefing_screen(screen_num);
1072 Briefing_text_x = bsp->text_ulx;
1073 Briefing_text_y = bsp->text_uly;
1076 if (ch == 13) //Can this happen? Above says ch==10
1083 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1084 // printing to it! You know, $Z !!!
1085 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1091 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1095 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1099 // Check for Esc -> abort.
1101 key_check=local_key_inkey();
1106 if (_RedrawScreen) {
1107 _RedrawScreen = FALSE;
1108 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1109 key_check = KEY_ESC;
1112 if ( key_check == KEY_ESC ) {
1117 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1120 #ifdef VID_SUPPORTS_FULLSCREEN_TOGGLE
1121 if ((key_check == KEY_COMMAND+KEY_SHIFTED+KEY_F) ||
1122 (key_check == KEY_ALTED+KEY_ENTER) ||
1123 (key_check == KEY_ALTED+KEY_PADENTER))
1124 vid_toggle_fullscreen();
1127 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1128 Briefing_text_x = bsp->text_ulx;
1129 Briefing_text_y += bsp->text_uly;
1132 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1138 if (printing_channel>-1)
1139 digi_stop_sound( printing_channel );
1140 printing_channel=-1;
1144 start_time = timer_get_fixed_seconds();
1145 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1147 flash_cursor(flashing_cursor);
1150 if (robot_num != -1)
1151 show_spinning_robot_frame(robot_num);
1152 if (Bitmap_name[0] != 0)
1153 show_bitmap_frame();
1154 start_time += KEY_DELAY_DEFAULT/2;
1155 delay_until(start_time + KEY_DELAY_DEFAULT/2);
1164 if (keypress == KEY_BACKSP)
1167 if (keypress == KEY_ESC) {
1172 load_briefing_screen(screen_num);
1173 Briefing_text_x = bsp->text_ulx;
1174 Briefing_text_y = bsp->text_uly;
1175 delay_count = KEY_DELAY_DEFAULT;
1184 if (Robot_canv != NULL)
1185 {d_free(Robot_canv); Robot_canv=NULL;}
1188 digi_stop_sound( hum_channel );
1189 if (printing_channel>-1)
1190 digi_stop_sound( printing_channel );
1198 //-----------------------------------------------------------------------------
1199 // Return a pointer to the start of text for screen #screen_num.
1200 char * get_briefing_message(int screen_num)
1202 char *tptr = Briefing_text;
1206 Assert(screen_num >= 0);
1208 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1213 cur_screen = get_message_num(&tptr);
1217 if (screen_num!=cur_screen)
1223 //-----------------------------------------------------------------------------
1224 // Load Descent briefing text.
1225 int load_screen_text(char *filename, char **buf)
1230 int have_binary = 0;
1232 if ((tfile = cfopen(filename,"rb")) == NULL) {
1233 char nfilename[30], *ptr;
1235 strcpy(nfilename, filename);
1236 if ((ptr = strrchr(nfilename, '.')))
1238 strcat(nfilename, ".txb");
1239 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1240 mprintf ((0,"can't open %s!\n",nfilename));
1242 //Error("Cannot open file %s or %s", filename, nfilename);
1245 mprintf ((0,"reading...\n"));
1248 len = cfilelength(ifile);
1249 MALLOC(*buf, char, len+500);
1250 mprintf ((0,"len=%d\n",len));
1251 for (x=0, i=0; i < len; i++, x++) {
1252 cfread (*buf+x,1,1,ifile);
1253 // mprintf ((0,"%c",*(*buf+x)));
1260 len = cfilelength(tfile);
1261 MALLOC(*buf, char, len+500);
1262 for (x=0, i=0; i < len; i++, x++) {
1263 cfread (*buf+x,1,1,tfile);
1264 // mprintf ((0,"%c",*(*buf+x)));
1270 //cfread(*buf, 1, len, tfile);
1275 decode_text(*buf, len);
1280 //-----------------------------------------------------------------------------
1281 // Return true if message got aborted, else return false.
1282 int show_briefing_text(int screen_num)
1286 message_ptr = get_briefing_message
1287 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1289 if (message_ptr==NULL)
1292 DoBriefingColorStuff();
1294 return show_briefing_message(screen_num, message_ptr);
1297 void DoBriefingColorStuff ()
1299 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1300 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1302 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1303 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1305 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1306 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1310 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1311 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1313 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1314 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1316 //Begin D1X addition
1318 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1319 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1322 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1323 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1325 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1326 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1328 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1329 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1331 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1332 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1335 Erase_color = gr_find_closest_color_current(0, 0, 0);
1338 //-----------------------------------------------------------------------------
1339 // Return true if screen got aborted by user, else return false.
1340 int show_briefing_screen( int screen_num, int allow_keys)
1343 //ubyte palette_save[768];
1345 New_pal_254_bash = 0;
1347 if (Skip_briefing_screens) {
1348 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1353 load_briefing_screen(screen_num);
1357 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1362 key_close(); // kill the keyboard handler during briefing screens for movies
1364 rval = show_briefing_text(screen_num);
1370 memcpy(New_pal, gr_palette, sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1373 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1376 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1378 //d_free(briefing_bm.bm_data);
1384 //-----------------------------------------------------------------------------
1385 void do_briefing_screens(char *filename,int level_num)
1387 int abort_briefing_screens = 0;
1388 int cur_briefing_screen = 0;
1390 if (Skip_briefing_screens) {
1391 mprintf((0, "Skipping all briefing screens.\n"));
1396 return; // no briefing screens at all for demo
1400 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1402 if (!filename || !*filename)
1405 if (!load_screen_text(filename, &Briefing_text))
1409 songs_play_song( SONG_BRIEFING, 1 );
1414 set_screen_mode( SCREEN_MENU );
1416 gr_set_current_canvas(NULL);
1418 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1425 for (i = 0; i < NUM_D1_BRIEFING_SCREENS; i++)
1426 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1428 if (level_num == 1) {
1429 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1430 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1431 cur_briefing_screen++;
1435 if (!abort_briefing_screens) {
1436 for (cur_briefing_screen = 0; cur_briefing_screen < NUM_D1_BRIEFING_SCREENS; cur_briefing_screen++)
1437 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1438 if (show_briefing_screen(cur_briefing_screen, 0))
1443 show_briefing_screen(level_num,0);
1445 d_free (Briefing_text);
1452 int DefineBriefingBox (char **buf)
1457 n=get_new_message_num (buf);
1459 Assert(n < MAX_BRIEFING_SCREENS);
1461 while (**buf!=' ') {
1466 name[i]='\0'; // slap a delimiter on this guy
1468 strcpy (Briefing_screens[n].bs_name,name);
1469 Briefing_screens[n].level_num=get_new_message_num (buf);
1470 Briefing_screens[n].message_num=get_new_message_num (buf);
1471 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1472 Briefing_screens[n].text_uly=get_new_message_num (buf);
1473 Briefing_screens[n].text_width=get_new_message_num (buf);
1474 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1476 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1477 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1478 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1479 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1484 int get_new_message_num(char **message)
1488 while (**message == ' ')
1491 while ((**message >= '0') && (**message <= '9')) {
1492 num = 10*num + **message-'0';
1501 void show_order_form()
1506 unsigned char title_pal[768];
1507 char exit_screen[16];
1509 gr_set_current_canvas( NULL );
1514 strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM
1515 if (! cfexist(exit_screen))
1516 strcpy(exit_screen, MenuHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires
1517 if (! cfexist(exit_screen))
1518 strcpy(exit_screen, MenuHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale
1519 if (! cfexist(exit_screen))
1520 strcpy(exit_screen, MenuHires?"warningb.pcx":"warning.pcx"); // D1
1521 if (! cfexist(exit_screen))
1522 return; // D2 registered
1524 if ((pcx_error=pcx_read_fullscr( exit_screen, title_pal ))==PCX_ERROR_NONE) {
1525 //vfx_set_palette_sub( title_pal );
1526 gr_palette_fade_in( title_pal, 32, 0 );
1528 while (!key_inkey() && !mouse_button_state(0)) {} //newmenu_getch();
1529 gr_palette_fade_out( title_pal, 32, 0 );
1532 Int3(); //can't load order screen