1 /* $Id: titles.c,v 1.40 2006-07-29 03:49:00 chris Exp $ */
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.
17 * Routines to display title screens...
67 void DoBriefingColorStuff ();
68 int get_new_message_num(char **message);
69 int DefineBriefingBox (char **buf);
71 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
76 char CurBriefScreenName[15]="brief03.pcx";
80 //Begin D1X modification
81 #define MAX_BRIEFING_COLORS 7
82 //End D1X modification
84 #define SHAREWARE_ENDING_FILENAME "ending.tex"
86 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
87 int Skip_briefing_screens=0;
88 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
89 int Current_color = 0;
92 extern int check_button_press();
95 extern void macintosh_quit(void);
98 // added by Jan Bobrowski for variable-size menu screen
99 static int rescale_x(int x)
101 return x * GWIDTH / 320;
104 static int rescale_y(int y)
106 return y * GHEIGHT / 200;
110 int local_key_inkey(void)
116 if (rval == KEY_PRINT_SCREEN) {
118 return 0; //say no key pressed
121 if (check_button_press()) //joystick or mouse button pressed?
123 else if (mouse_button_state(0))
126 if ( rval == KEY_Q+KEY_COMMAND )
132 int local_key_inkey(void)
137 if (!GetOSEvent(everyEvent, &event))
140 if (event.what != keyDown)
143 rval = (int)((event.message & keyCodeMask) >> 8);
145 if (rval == KEY_PRINT_SCREEN) {
147 return 0; //say no key pressed
150 if (check_button_press()) //joystick or mouse button pressed?
153 if ( rval == KEY_Q+KEY_COMMAND )
160 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
165 ubyte palette_save[768];
166 char new_filename[FILENAME_LEN+1] = "";
170 strcpy(new_filename,"\x01"); //only read from hog file
173 strcat(new_filename,filename);
174 filename = new_filename;
176 title_bm.bm_data=NULL;
177 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
178 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
179 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));
180 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
183 memcpy(palette_save,gr_palette,sizeof(palette_save));
185 //vfx_set_palette_sub( New_pal );
188 gr_set_current_canvas( NULL );
189 show_fullscr(&title_bm);
191 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
193 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
195 gr_palette_load( New_pal );
196 timer = timer_get_fixed_seconds() + i2f(3);
198 if ( local_key_inkey() && allow_keys ) break;
199 if ( timer_get_fixed_seconds() > timer ) break;
201 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
203 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
204 d_free(title_bm.bm_data);
208 int intro_played = 0;
210 void show_titles(void)
213 int played=MOVIE_NOT_PLAYED; //default is not played
215 int song_playing = 0;
218 #define MOVIE_REQUIRED 0
220 #define MOVIE_REQUIRED 1
223 { //show bundler screens
224 char filename[FILENAME_LEN];
226 played=MOVIE_NOT_PLAYED; //default is not played
228 played = PlayMovie("pre_i.mve",0);
231 strcpy(filename,MenuHires?"pre_i1b.pcx":"pre_i1.pcx");
233 while (PHYSFS_exists(filename))
235 show_title_screen( filename, 1, 0 );
242 init_subtitles("intro.tex");
243 played = PlayMovie("intro.mve",MOVIE_REQUIRED);
247 if (played != MOVIE_NOT_PLAYED)
250 { //didn't get intro movie, try titles
252 played = PlayMovie("titles.mve",MOVIE_REQUIRED);
254 if (played == MOVIE_NOT_PLAYED)
256 char filename[FILENAME_LEN];
258 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
260 set_screen_mode(SCREEN_MENU);
262 con_printf( CON_DEBUG, "\nPlaying title song..." );
263 songs_play_song( SONG_TITLE, 1);
265 con_printf( CON_DEBUG, "\nShowing logo screens..." );
267 strcpy(filename, MenuHires?"iplogo1b.pcx":"iplogo1.pcx"); // OEM
268 if (! cfexist(filename))
269 strcpy(filename, "iplogo1.pcx"); // SHAREWARE
270 if (! cfexist(filename))
271 strcpy(filename, "mplogo.pcx"); // MAC SHAREWARE
272 if (cfexist(filename))
273 show_title_screen(filename, 1, 1);
275 strcpy(filename, MenuHires?"logob.pcx":"logo.pcx"); // OEM
276 if (! cfexist(filename))
277 strcpy(filename, "logo.pcx"); // SHAREWARE
278 if (! cfexist(filename))
279 strcpy(filename, "plogo.pcx"); // MAC SHAREWARE
280 if (cfexist(filename))
281 show_title_screen(filename, 1, 1);
285 { //show bundler movie or screens
287 char filename[FILENAME_LEN];
288 PHYSFS_file *movie_handle;
290 played=MOVIE_NOT_PLAYED; //default is not played
292 //check if OEM movie exists, so we don't stop the music if it doesn't
293 movie_handle = PHYSFS_openRead("oem.mve");
296 PHYSFS_close(movie_handle);
297 played = PlayMovie("oem.mve",0);
298 song_playing = 0; //movie will kill sound
303 strcpy(filename,MenuHires?"oem1b.pcx":"oem1.pcx");
305 while (PHYSFS_exists(filename))
307 show_title_screen( filename, 1, 0 );
314 songs_play_song( SONG_TITLE, 1);
317 void show_loading_screen(ubyte *title_pal)
319 //grs_bitmap title_bm;
323 strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx");
324 if (! cfexist(filename))
325 strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM
326 if (! cfexist(filename))
327 strcpy(filename, "descentd.pcx"); // SHAREWARE
328 if (! cfexist(filename))
329 strcpy(filename, "descentb.pcx"); // MAC SHAREWARE
331 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
333 set_screen_mode(SCREEN_MENU);
336 FontHires = FontHiresAvailable && MenuHires;
338 if ((pcx_error=pcx_read_fullscr( filename, title_pal ))==PCX_ERROR_NONE) {
339 //vfx_set_palette_sub( title_pal );
341 gr_palette_fade_in( title_pal, 32, 0 );
344 Error( "Couldn't load pcx file '%s', PCX load error: %s\n",filename, pcx_errormsg(pcx_error));
348 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
351 short text_ulx, text_uly; // upper left x,y of text window
352 short text_width, text_height; // width and height of text window
355 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
356 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
358 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
359 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
362 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
364 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
367 #define MAX_BRIEFING_SCREENS 60
369 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
370 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
372 briefing_screen D1_Briefing_screens[] = {
373 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
374 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
375 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
376 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
378 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
379 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
380 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
382 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
383 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
385 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
386 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
387 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
390 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
391 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
392 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
393 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
394 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
396 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
397 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
398 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
399 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
400 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
402 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
403 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
404 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
405 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
406 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
408 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
409 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
410 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
411 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
413 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
414 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
415 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
417 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
418 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
419 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
421 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
422 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
423 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
426 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
428 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
429 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
430 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
435 #define NUM_D1_BRIEFING_SCREENS (sizeof(D1_Briefing_screens)/sizeof(briefing_screen))
437 int Briefing_text_x, Briefing_text_y;
439 void init_char_pos(int x, int y)
443 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
446 grs_canvas *Robot_canv = NULL;
447 vms_angvec Robot_angles;
449 char Bitmap_name[32] = "";
450 #define EXIT_DOOR_MAX 14
451 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
452 #define DOOR_DIV_INIT 6
453 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
455 //-----------------------------------------------------------------------------
456 void show_bitmap_frame(void)
458 grs_canvas *curcanv_save, *bitmap_canv=0;
460 grs_bitmap *bitmap_ptr;
462 // Only plot every nth frame.
463 if (Door_div_count) {
468 Door_div_count = DOOR_DIV_INIT;
470 if (Bitmap_name[0] != 0) {
474 // Set supertransparency color to black
475 if (!New_pal_254_bash) {
476 New_pal_254_bash = 1;
478 New_pal[254*3+1] = 0;
479 New_pal[254*3+2] = 0;
480 gr_palette_load( New_pal );
483 switch (Animating_bitmap_type) {
485 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64);
488 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94);
491 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
493 Int3(); // Impossible, illegal value for Animating_bitmap_type
496 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv;
498 pound_signp = strchr(Bitmap_name, '#');
499 Assert(pound_signp != NULL);
501 dig1 = *(pound_signp+1);
502 dig2 = *(pound_signp+2);
506 num = (dig1-'0')*10 + (dig2-'0');
508 switch (Animating_bitmap_type) {
511 if (num > EXIT_DOOR_MAX) {
514 } else if (num < 0) {
521 if (num > OTHER_THING_MAX)
528 *(pound_signp+1) = (num / 10) + '0';
529 *(pound_signp+2) = (num % 10) + '0';
530 *(pound_signp+3) = 0;
532 *(pound_signp+1) = (num % 10) + '0';
533 *(pound_signp+2) = 0;
538 bi = piggy_find_bitmap(Bitmap_name);
539 bitmap_ptr = &GameBitmaps[bi.index];
543 gr_bitmapm(0, 0, bitmap_ptr);
545 grd_curcanv = curcanv_save;
548 switch (Animating_bitmap_type) {
550 if (num == EXIT_DOOR_MAX) {
553 } else if (num == 0) {
565 //-----------------------------------------------------------------------------
566 void show_briefing_bitmap(grs_bitmap *bmp)
568 grs_canvas *curcanv_save, *bitmap_canv;
570 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
571 curcanv_save = grd_curcanv;
572 gr_set_current_canvas(bitmap_canv);
573 gr_bitmapm(0, 0, bmp);
574 gr_set_current_canvas(curcanv_save);
579 //-----------------------------------------------------------------------------
580 void show_spinning_robot_frame(int robot_num)
582 grs_canvas *curcanv_save;
584 if (robot_num != -1) {
585 Robot_angles.h += 150;
587 curcanv_save = grd_curcanv;
588 grd_curcanv = Robot_canv;
589 Assert(Robot_info[robot_num].model_num != -1);
590 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
591 grd_curcanv = curcanv_save;
596 //-----------------------------------------------------------------------------
597 void init_spinning_robot(void) //(int x,int y,int w,int h)
599 //Robot_angles.p += 0;
600 //Robot_angles.b += 0;
601 //Robot_angles.h += 0;
603 int x = rescale_x(138);
604 int y = rescale_y(55);
605 int w = rescale_x(166);
606 int h = rescale_y(138);
608 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
612 //---------------------------------------------------------------------------
613 // Returns char width.
614 // If show_robot_flag set, then show a frame of the spinning robot.
615 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
619 static fix start_time=0;
621 message[0] = the_char;
624 if (start_time==0 && timer_get_fixed_seconds()<0)
625 start_time=timer_get_fixed_seconds();
627 gr_get_string_size(message, &w, &h, &aw );
629 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
631 // Draw cursor if there is some delay and caller says to draw cursor
632 if (cursor_flag && delay) {
633 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
634 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
639 delay=fixdiv (F1_0,i2f(15));
641 if ((Bitmap_name[0] != 0) && (delay != 0))
644 if (RobotPlaying && (delay != 0))
647 while (timer_get_fixed_seconds() < (start_time + delay)) {
648 if (RobotPlaying && delay != 0)
652 show_spinning_robot_frame(robot_num);
654 start_time = timer_get_fixed_seconds();
657 if (cursor_flag && delay) {
658 gr_set_fontcolor(Erase_color, -1);
659 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
662 // Draw the character
663 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
664 gr_printf(Briefing_text_x, Briefing_text_y, message );
666 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
667 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
669 if (delay) gr_update();
671 // if (the_char != ' ')
672 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
673 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
678 //-----------------------------------------------------------------------------
679 int load_briefing_screen( int screen_num )
685 fname = Briefing_screens[screen_num].bs_name;
687 fname = CurBriefScreenName;
689 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
690 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
691 printf( "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error), pcx_error);
692 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
698 int load_new_briefing_screen( char *fname )
702 mprintf ((0,"Loading new briefing <%s>\n",fname));
703 strcpy (CurBriefScreenName,fname);
705 #if 1 //defined (MACINTOSH) || defined(WINDOWS)
706 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
708 if (gr_palette_fade_out( New_pal, 32, 0 ))
711 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
712 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
713 printf( "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",fname, pcx_errormsg(pcx_error), pcx_error);
714 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
717 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
719 if (gr_palette_fade_in( New_pal, 32, 0 ))
721 DoBriefingColorStuff();
728 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
730 //-----------------------------------------------------------------------------
731 int get_message_num(char **message)
735 while (**message == ' ')
738 while ((**message >= '0') && (**message <= '9')) {
739 num = 10*num + **message-'0';
743 while (*(*message)++ != 10) // Get and drop eoln
749 //-----------------------------------------------------------------------------
750 void get_message_name(char **message, char *result)
752 while (**message == ' ')
755 while ((**message != ' ') && (**message != 10)) {
756 if (**message != '\n')
757 *result++ = **message;
762 while (*(*message)++ != 10) // Get and drop eoln
768 //-----------------------------------------------------------------------------
769 void flash_cursor(int cursor_flag)
771 if (cursor_flag == 0)
774 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
775 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
777 gr_set_fontcolor(Erase_color, -1);
779 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
783 extern int InitMovieBriefing();
786 //-----------------------------------------------------------------------------
787 // Return true if message got aborted by user (pressed ESC), else return false.
788 int show_briefing_message(int screen_num, char *message)
792 briefing_screen *bsp;
793 int delay_count = KEY_DELAY_DEFAULT;
797 static int tab_stop=0;
798 int flashing_cursor=0;
799 int new_page=0,GotZ=0;
800 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
804 int hum_channel=-1,printing_channel=-1;
805 int LineAdjustment=1;
814 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
817 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
818 gr_set_curfont( GAME_FONT );
822 MALLOC(bsp, briefing_screen, 1);
823 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
824 bsp->text_ulx = rescale_x(bsp->text_ulx);
825 bsp->text_uly = rescale_y(bsp->text_uly);
826 bsp->text_width = rescale_x(bsp->text_width);
827 bsp->text_height = rescale_y(bsp->text_height);
828 init_char_pos(bsp->text_ulx, bsp->text_uly);
830 bsp=&Briefing_screens[0];
831 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
839 screen_num=DefineBriefingBox (&message);
840 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
842 bsp = &Briefing_screens[screen_num];
843 init_char_pos(bsp->text_ulx, bsp->text_uly);
845 prev_ch = 10; // read to eoln
846 } else if (ch=='U') {
847 screen_num=get_message_num(&message);
848 bsp = &Briefing_screens[screen_num];
849 init_char_pos(bsp->text_ulx, bsp->text_uly);
850 prev_ch = 10; // read to eoln
851 } else if (ch == 'C') {
852 Current_color = get_message_num(&message)-1;
853 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
855 } else if (ch == 'F') { // toggle flashing cursor
856 flashing_cursor = !flashing_cursor;
858 while (*message++ != 10)
860 } else if (ch == 'T') {
861 tab_stop = get_message_num(&message);
862 tab_stop*=(1+MenuHires);
863 prev_ch = 10; // read to eoln
864 } else if (ch == 'R') {
865 if (Robot_canv != NULL) {
875 init_spinning_robot();
876 robot_num = get_message_num(&message);
877 while (*message++ != 10)
881 spinRobotName[2]=kludge; // ugly but proud
883 RobotPlaying=InitRobotMovie(spinRobotName);
885 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
889 DoBriefingColorStuff ();
890 mprintf ((0,"Robot playing is %d!!!\n",RobotPlaying));
893 prev_ch = 10; // read to eoln
894 } else if (ch == 'N') {
895 //--grs_bitmap *bitmap_ptr;
896 if (Robot_canv != NULL) {
901 get_message_name(&message, Bitmap_name);
902 strcat(Bitmap_name, "#0");
903 Animating_bitmap_type = 0;
905 } else if (ch == 'O') {
906 if (Robot_canv != NULL) {
911 get_message_name(&message, Bitmap_name);
912 strcat(Bitmap_name, "#0");
913 Animating_bitmap_type = 1;
915 } else if (ch=='A') {
916 LineAdjustment=1-LineAdjustment;
917 } else if (ch=='Z') {
918 //mprintf ((0,"Got a Z!\n"));
920 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
923 if (LineAdjustment==1)
930 while ((fname[i]=*message) != '\n') {
936 while (*message++ != 10) // Get and drop eoln
943 while (fname[i]!='.') {
944 fname2[i] = fname[i];
954 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
955 load_new_briefing_screen (fname2);
957 load_new_briefing_screen (fname);
960 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
962 } else if (ch == 'B') {
963 char bitmap_name[32];
964 grs_bitmap guy_bitmap;
965 ubyte temp_palette[768];
968 if (Robot_canv != NULL) {
973 get_message_name(&message, bitmap_name);
974 strcat(bitmap_name, ".bbm");
975 guy_bitmap.bm_data = NULL;
976 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
977 Assert(iff_error == IFF_NO_ERROR);
978 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
980 show_briefing_bitmap(&guy_bitmap);
981 d_free(guy_bitmap.bm_data);
983 // } else if (ch==EOF) {
985 // } else if (ch == 'B') {
986 // if (Robot_canv != NULL) {
987 // d_free(Robot_canv);
991 // bitmap_num = get_message_num(&message);
992 // if (bitmap_num != -1)
993 // show_briefing_bitmap(Textures[bitmap_num]);
994 // prev_ch = 10; // read to eoln
995 } else if (ch == 'S') {
1000 if (printing_channel>-1)
1001 digi_stop_sound( printing_channel );
1002 printing_channel=-1;
1006 start_time = timer_get_fixed_seconds();
1007 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1009 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1011 flash_cursor(flashing_cursor);
1015 if (robot_num != -1)
1016 show_spinning_robot_frame(robot_num);
1018 if (Bitmap_name[0] != 0)
1019 show_bitmap_frame();
1020 start_time += KEY_DELAY_DEFAULT/2;
1024 if (keypress == KEY_BACKSP)
1027 if (keypress == KEY_ESC)
1030 flashing_cursor = 0;
1032 } else if (ch == 'P') { // New page.
1034 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1035 // printing to it! You know, $Z !!!
1036 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1040 while (*message != 10) {
1041 message++; // drop carriage return after special escape sequence
1047 } else if (ch == '\t') { // Tab
1048 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1049 Briefing_text_x = bsp->text_ulx + tab_stop;
1050 } else if ((ch == ';') && (prev_ch == 10)) {
1051 while (*message++ != 10)
1054 } else if (ch == '\\') {
1056 } else if (ch == 10) {
1057 if (prev_ch != '\\') {
1060 Briefing_text_y += (8*(MenuHires+1));
1063 Briefing_text_x = bsp->text_ulx;
1064 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1065 load_briefing_screen(screen_num);
1066 Briefing_text_x = bsp->text_ulx;
1067 Briefing_text_y = bsp->text_uly;
1070 if (ch == 13) //Can this happen? Above says ch==10
1077 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1078 // printing to it! You know, $Z !!!
1079 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1085 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1089 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1093 // Check for Esc -> abort.
1095 key_check=local_key_inkey();
1100 if (_RedrawScreen) {
1101 _RedrawScreen = FALSE;
1102 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1103 key_check = KEY_ESC;
1106 if ( key_check == KEY_ESC ) {
1111 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1114 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1115 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1116 (key_check == KEY_ALTED+KEY_PADENTER))
1117 gr_toggle_fullscreen();
1120 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1121 Briefing_text_x = bsp->text_ulx;
1122 Briefing_text_y += bsp->text_uly;
1125 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1131 if (printing_channel>-1)
1132 digi_stop_sound( printing_channel );
1133 printing_channel=-1;
1137 start_time = timer_get_fixed_seconds();
1138 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1139 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1141 flash_cursor(flashing_cursor);
1144 if (robot_num != -1)
1145 show_spinning_robot_frame(robot_num);
1146 if (Bitmap_name[0] != 0)
1147 show_bitmap_frame();
1148 start_time += KEY_DELAY_DEFAULT/2;
1157 if (keypress == KEY_BACKSP)
1160 if (keypress == KEY_ESC) {
1165 load_briefing_screen(screen_num);
1166 Briefing_text_x = bsp->text_ulx;
1167 Briefing_text_y = bsp->text_uly;
1168 delay_count = KEY_DELAY_DEFAULT;
1177 if (Robot_canv != NULL)
1178 {d_free(Robot_canv); Robot_canv=NULL;}
1181 digi_stop_sound( hum_channel );
1182 if (printing_channel>-1)
1183 digi_stop_sound( printing_channel );
1191 //-----------------------------------------------------------------------------
1192 // Return a pointer to the start of text for screen #screen_num.
1193 char * get_briefing_message(int screen_num)
1195 char *tptr = Briefing_text;
1199 Assert(screen_num >= 0);
1201 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1206 cur_screen = get_message_num(&tptr);
1210 if (screen_num!=cur_screen)
1216 //-----------------------------------------------------------------------------
1217 // Load Descent briefing text.
1218 int load_screen_text(char *filename, char **buf)
1223 int have_binary = 0;
1225 if ((tfile = cfopen(filename,"rb")) == NULL) {
1226 char nfilename[30], *ptr;
1228 strcpy(nfilename, filename);
1229 if ((ptr = strrchr(nfilename, '.')))
1231 strcat(nfilename, ".txb");
1232 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1233 mprintf ((0,"can't open %s!\n",nfilename));
1235 //Error("Cannot open file %s or %s", filename, nfilename);
1238 mprintf ((0,"reading...\n"));
1241 len = cfilelength(ifile);
1242 MALLOC(*buf, char, len+500);
1243 mprintf ((0,"len=%d\n",len));
1244 for (x=0, i=0; i < len; i++, x++) {
1245 cfread (*buf+x,1,1,ifile);
1246 // mprintf ((0,"%c",*(*buf+x)));
1253 len = cfilelength(tfile);
1254 MALLOC(*buf, char, len+500);
1255 for (x=0, i=0; i < len; i++, x++) {
1256 cfread (*buf+x,1,1,tfile);
1257 // mprintf ((0,"%c",*(*buf+x)));
1263 //cfread(*buf, 1, len, tfile);
1268 decode_text(*buf, len);
1273 //-----------------------------------------------------------------------------
1274 // Return true if message got aborted, else return false.
1275 int show_briefing_text(int screen_num)
1279 message_ptr = get_briefing_message
1280 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1282 if (message_ptr==NULL)
1285 DoBriefingColorStuff();
1287 return show_briefing_message(screen_num, message_ptr);
1290 void DoBriefingColorStuff ()
1292 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1293 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1295 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1296 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1298 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1299 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1303 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1304 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1306 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1307 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1309 //Begin D1X addition
1311 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1312 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1315 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1316 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1318 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1319 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1321 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1322 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1324 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1325 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1328 Erase_color = gr_find_closest_color_current(0, 0, 0);
1331 //-----------------------------------------------------------------------------
1332 // Return true if screen got aborted by user, else return false.
1333 int show_briefing_screen( int screen_num, int allow_keys)
1336 //ubyte palette_save[768];
1338 New_pal_254_bash = 0;
1340 if (Skip_briefing_screens) {
1341 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1348 grs_bitmap briefing_bm;
1350 gr_init_bitmap_data(&briefing_bm);
1351 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1353 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1355 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1356 mprintf((0, "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n", Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error));
1362 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1363 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1365 //vfx_set_palette_sub( New_pal );
1367 gr_set_current_canvas( NULL );
1368 show_fullscr(&briefing_bm);
1371 //added on 9/13/98 by adb to make arch's requiring updates work
1373 //end changes by adb
1376 gr_free_bitmap_data (&briefing_bm);
1379 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1382 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1387 key_close(); // kill the keyboard handler during briefing screens for movies
1389 rval = show_briefing_text(screen_num);
1394 #if 1 //defined (MACINTOSH) || defined(WINDOWS)
1395 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1399 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1402 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1404 //d_free(briefing_bm.bm_data);
1410 //-----------------------------------------------------------------------------
1411 void do_briefing_screens(char *filename,int level_num)
1413 int abort_briefing_screens = 0;
1414 int cur_briefing_screen = 0;
1416 if (Skip_briefing_screens) {
1417 mprintf((0, "Skipping all briefing screens.\n"));
1422 return; // no briefing screens at all for demo
1426 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1428 if (!filename || !*filename)
1431 if (!load_screen_text(filename, &Briefing_text))
1435 songs_play_song( SONG_BRIEFING, 1 );
1440 set_screen_mode( SCREEN_MENU );
1442 gr_set_current_canvas(NULL);
1444 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1451 for (i = 0; i < NUM_D1_BRIEFING_SCREENS; i++)
1452 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1454 if (level_num == 1) {
1455 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1456 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1457 cur_briefing_screen++;
1461 if (!abort_briefing_screens) {
1462 for (cur_briefing_screen = 0; cur_briefing_screen < NUM_D1_BRIEFING_SCREENS; cur_briefing_screen++)
1463 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1464 if (show_briefing_screen(cur_briefing_screen, 0))
1469 show_briefing_screen(level_num,0);
1471 d_free (Briefing_text);
1478 int DefineBriefingBox (char **buf)
1483 n=get_new_message_num (buf);
1485 Assert(n < MAX_BRIEFING_SCREENS);
1487 while (**buf!=' ') {
1492 name[i]='\0'; // slap a delimiter on this guy
1494 strcpy (Briefing_screens[n].bs_name,name);
1495 Briefing_screens[n].level_num=get_new_message_num (buf);
1496 Briefing_screens[n].message_num=get_new_message_num (buf);
1497 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1498 Briefing_screens[n].text_uly=get_new_message_num (buf);
1499 Briefing_screens[n].text_width=get_new_message_num (buf);
1500 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1502 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1503 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1504 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1505 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1510 int get_new_message_num(char **message)
1514 while (**message == ' ')
1517 while ((**message >= '0') && (**message <= '9')) {
1518 num = 10*num + **message-'0';
1527 void show_order_form()
1532 unsigned char title_pal[768];
1533 char exit_screen[16];
1535 gr_set_current_canvas( NULL );
1540 strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM
1541 if (! cfexist(exit_screen))
1542 strcpy(exit_screen, MenuHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires
1543 if (! cfexist(exit_screen))
1544 strcpy(exit_screen, MenuHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale
1545 if (! cfexist(exit_screen))
1546 strcpy(exit_screen, MenuHires?"warningb.pcx":"warning.pcx"); // D1
1547 if (! cfexist(exit_screen))
1548 return; // D2 registered
1550 if ((pcx_error=pcx_read_fullscr( exit_screen, title_pal ))==PCX_ERROR_NONE) {
1551 //vfx_set_palette_sub( title_pal );
1552 gr_palette_fade_in( title_pal, 32, 0 );
1554 while (!key_inkey() && !mouse_button_state(0)) {} //key_getch();
1555 gr_palette_fade_out( title_pal, 32, 0 );
1558 Int3(); //can't load order screen