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))
127 if ( rval == KEY_Q+KEY_COMMAND )
134 int local_key_inkey(void)
139 if (!GetOSEvent(everyEvent, &event))
142 if (event.what != keyDown)
145 rval = (int)((event.message & keyCodeMask) >> 8);
147 if (rval == KEY_PRINT_SCREEN) {
149 return 0; //say no key pressed
152 if (check_button_press()) //joystick or mouse button pressed?
156 if ( rval == KEY_Q+KEY_COMMAND )
164 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
169 ubyte palette_save[768];
170 char new_filename[FILENAME_LEN+1] = "";
174 strcpy(new_filename,"\x01"); //only read from hog file
177 strcat(new_filename,filename);
178 filename = new_filename;
180 title_bm.bm_data=NULL;
181 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
182 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
183 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));
184 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
187 memcpy(palette_save,gr_palette,sizeof(palette_save));
189 //vfx_set_palette_sub( New_pal );
191 gr_palette_load( New_pal );
196 gr_set_current_canvas( NULL );
197 show_fullscr(&title_bm);
199 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
201 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
203 gr_palette_load( New_pal );
204 timer = timer_get_fixed_seconds() + i2f(3);
206 if ( local_key_inkey() && allow_keys ) break;
207 if ( timer_get_fixed_seconds() > timer ) break;
209 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
211 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
212 d_free(title_bm.bm_data);
216 int intro_played = 0;
218 void show_titles(void)
221 int played=MOVIE_NOT_PLAYED; //default is not played
223 int song_playing = 0;
226 #define MOVIE_REQUIRED 0
228 #define MOVIE_REQUIRED 1
231 { //show bundler screens
232 char filename[FILENAME_LEN];
234 played=MOVIE_NOT_PLAYED; //default is not played
236 played = PlayMovie("pre_i.mve",0);
239 strcpy(filename,MenuHires?"pre_i1b.pcx":"pre_i1.pcx");
241 while (PHYSFS_exists(filename))
243 show_title_screen( filename, 1, 0 );
250 init_subtitles("intro.tex");
251 played = PlayMovie("intro.mve",MOVIE_REQUIRED);
255 if (played != MOVIE_NOT_PLAYED)
258 { //didn't get intro movie, try titles
260 played = PlayMovie("titles.mve",MOVIE_REQUIRED);
262 if (played == MOVIE_NOT_PLAYED)
264 char filename[FILENAME_LEN];
266 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
268 set_screen_mode(SCREEN_MENU);
270 con_printf( CON_DEBUG, "\nPlaying title song..." );
271 songs_play_song( SONG_TITLE, 1);
273 con_printf( CON_DEBUG, "\nShowing logo screens..." );
275 strcpy(filename, MenuHires?"iplogo1b.pcx":"iplogo1.pcx"); // OEM
276 if (! cfexist(filename))
277 strcpy(filename, "iplogo1.pcx"); // SHAREWARE
278 if (! cfexist(filename))
279 strcpy(filename, "mplogo.pcx"); // MAC SHAREWARE
280 if (cfexist(filename))
281 show_title_screen(filename, 1, 1);
283 strcpy(filename, MenuHires?"logob.pcx":"logo.pcx"); // OEM
284 if (! cfexist(filename))
285 strcpy(filename, "logo.pcx"); // SHAREWARE
286 if (! cfexist(filename))
287 strcpy(filename, "plogo.pcx"); // MAC SHAREWARE
288 if (cfexist(filename))
289 show_title_screen(filename, 1, 1);
293 { //show bundler movie or screens
295 char filename[FILENAME_LEN];
296 PHYSFS_file *movie_handle;
298 played=MOVIE_NOT_PLAYED; //default is not played
300 //check if OEM movie exists, so we don't stop the music if it doesn't
301 movie_handle = PHYSFS_openRead("oem.mve");
304 PHYSFS_close(movie_handle);
305 played = PlayMovie("oem.mve",0);
306 song_playing = 0; //movie will kill sound
311 strcpy(filename,MenuHires?"oem1b.pcx":"oem1.pcx");
313 while (PHYSFS_exists(filename))
315 show_title_screen( filename, 1, 0 );
322 songs_play_song( SONG_TITLE, 1);
325 void show_loading_screen(ubyte *title_pal)
327 //grs_bitmap title_bm;
331 strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx");
332 if (! cfexist(filename))
333 strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM
334 if (! cfexist(filename))
335 strcpy(filename, "descentd.pcx"); // SHAREWARE
336 if (! cfexist(filename))
337 strcpy(filename, "descentb.pcx"); // MAC SHAREWARE
339 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
341 set_screen_mode(SCREEN_MENU);
344 FontHires = FontHiresAvailable && MenuHires;
346 if ((pcx_error=pcx_read_fullscr( filename, title_pal ))==PCX_ERROR_NONE) {
347 //vfx_set_palette_sub( title_pal );
349 gr_palette_fade_in( title_pal, 32, 0 );
352 Error( "Couldn't load pcx file '%s', PCX load error: %s\n",filename, pcx_errormsg(pcx_error));
356 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
359 short text_ulx, text_uly; // upper left x,y of text window
360 short text_width, text_height; // width and height of text window
363 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
364 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
366 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
367 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
370 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
372 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
375 #define MAX_BRIEFING_SCREENS 60
377 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
378 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
380 briefing_screen D1_Briefing_screens[] = {
381 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
382 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
383 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
384 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
386 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
387 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
388 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
390 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
391 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
393 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
394 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
395 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
398 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
399 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
400 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
401 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
402 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
404 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
405 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
406 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
407 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
408 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
410 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
411 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
412 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
413 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
414 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
416 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
417 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
418 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
419 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
421 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
422 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
423 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
425 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
426 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
427 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
429 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
430 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
431 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
434 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
436 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
437 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
438 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
443 #define NUM_D1_BRIEFING_SCREENS (sizeof(D1_Briefing_screens)/sizeof(briefing_screen))
445 int Briefing_text_x, Briefing_text_y;
447 void init_char_pos(int x, int y)
451 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
454 grs_canvas *Robot_canv = NULL;
455 vms_angvec Robot_angles;
457 char Bitmap_name[32] = "";
458 #define EXIT_DOOR_MAX 14
459 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
460 #define DOOR_DIV_INIT 6
461 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
463 //-----------------------------------------------------------------------------
464 void show_bitmap_frame(void)
466 grs_canvas *curcanv_save, *bitmap_canv=0;
468 grs_bitmap *bitmap_ptr;
470 // Only plot every nth frame.
471 if (Door_div_count) {
476 Door_div_count = DOOR_DIV_INIT;
478 if (Bitmap_name[0] != 0) {
482 // Set supertransparency color to black
483 if (!New_pal_254_bash) {
484 New_pal_254_bash = 1;
486 New_pal[254*3+1] = 0;
487 New_pal[254*3+2] = 0;
488 gr_palette_load( New_pal );
491 switch (Animating_bitmap_type) {
493 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64);
496 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94);
499 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
501 Int3(); // Impossible, illegal value for Animating_bitmap_type
504 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv;
506 pound_signp = strchr(Bitmap_name, '#');
507 Assert(pound_signp != NULL);
509 dig1 = *(pound_signp+1);
510 dig2 = *(pound_signp+2);
514 num = (dig1-'0')*10 + (dig2-'0');
516 switch (Animating_bitmap_type) {
519 if (num > EXIT_DOOR_MAX) {
522 } else if (num < 0) {
529 if (num > OTHER_THING_MAX)
536 *(pound_signp+1) = (num / 10) + '0';
537 *(pound_signp+2) = (num % 10) + '0';
538 *(pound_signp+3) = 0;
540 *(pound_signp+1) = (num % 10) + '0';
541 *(pound_signp+2) = 0;
546 bi = piggy_find_bitmap(Bitmap_name);
547 bitmap_ptr = &GameBitmaps[bi.index];
551 gr_bitmapm(0, 0, bitmap_ptr);
553 grd_curcanv = curcanv_save;
556 switch (Animating_bitmap_type) {
558 if (num == EXIT_DOOR_MAX) {
561 } else if (num == 0) {
573 //-----------------------------------------------------------------------------
574 void show_briefing_bitmap(grs_bitmap *bmp)
576 grs_canvas *curcanv_save, *bitmap_canv;
578 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
579 curcanv_save = grd_curcanv;
580 gr_set_current_canvas(bitmap_canv);
581 gr_bitmapm(0, 0, bmp);
582 gr_set_current_canvas(curcanv_save);
587 //-----------------------------------------------------------------------------
588 void show_spinning_robot_frame(int robot_num)
590 grs_canvas *curcanv_save;
592 if (robot_num != -1) {
593 Robot_angles.h += 150;
595 curcanv_save = grd_curcanv;
596 grd_curcanv = Robot_canv;
597 Assert(Robot_info[robot_num].model_num != -1);
598 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
599 grd_curcanv = curcanv_save;
604 //-----------------------------------------------------------------------------
605 void init_spinning_robot(void) //(int x,int y,int w,int h)
607 //Robot_angles.p += 0;
608 //Robot_angles.b += 0;
609 //Robot_angles.h += 0;
611 int x = rescale_x(138);
612 int y = rescale_y(55);
613 int w = rescale_x(166);
614 int h = rescale_y(138);
616 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
620 //---------------------------------------------------------------------------
621 // Returns char width.
622 // If show_robot_flag set, then show a frame of the spinning robot.
623 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
627 static fix start_time=0;
629 message[0] = the_char;
632 if (start_time==0 && timer_get_fixed_seconds()<0)
633 start_time=timer_get_fixed_seconds();
635 gr_get_string_size(message, &w, &h, &aw );
637 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
639 // Draw cursor if there is some delay and caller says to draw cursor
640 if (cursor_flag && delay) {
641 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
642 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
647 delay=fixdiv (F1_0,i2f(15));
649 if ((Bitmap_name[0] != 0) && (delay != 0))
652 if (RobotPlaying && (delay != 0))
655 while (timer_get_fixed_seconds() < (start_time + delay)) {
656 if (RobotPlaying && delay != 0)
660 show_spinning_robot_frame(robot_num);
662 start_time = timer_get_fixed_seconds();
665 if (cursor_flag && delay) {
666 gr_set_fontcolor(Erase_color, -1);
667 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
670 // Draw the character
671 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
672 gr_printf(Briefing_text_x, Briefing_text_y, message );
674 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
675 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
677 if (delay) gr_update();
679 // if (the_char != ' ')
680 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
681 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
686 //-----------------------------------------------------------------------------
687 int load_briefing_screen( int screen_num )
693 fname = Briefing_screens[screen_num].bs_name;
695 fname = CurBriefScreenName;
697 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
698 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
699 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);
700 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
706 int load_new_briefing_screen( char *fname )
710 mprintf ((0,"Loading new briefing <%s>\n",fname));
711 strcpy (CurBriefScreenName,fname);
713 if (gr_palette_fade_out( New_pal, 32, 0 ))
716 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
717 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
718 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);
719 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
722 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
724 if (gr_palette_fade_in( New_pal, 32, 0 ))
726 DoBriefingColorStuff();
733 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
735 //-----------------------------------------------------------------------------
736 int get_message_num(char **message)
740 while (**message == ' ')
743 while ((**message >= '0') && (**message <= '9')) {
744 num = 10*num + **message-'0';
748 while (*(*message)++ != 10) // Get and drop eoln
754 //-----------------------------------------------------------------------------
755 void get_message_name(char **message, char *result)
757 while (**message == ' ')
760 while ((**message != ' ') && (**message != 10)) {
761 if (**message != '\n')
762 *result++ = **message;
767 while (*(*message)++ != 10) // Get and drop eoln
773 //-----------------------------------------------------------------------------
774 void flash_cursor(int cursor_flag)
776 if (cursor_flag == 0)
779 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
780 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
782 gr_set_fontcolor(Erase_color, -1);
784 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
788 extern int InitMovieBriefing();
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!!!",RobotPlaying));
898 prev_ch = 10; // read to eoln
899 } else if (ch == 'N') {
900 //--grs_bitmap *bitmap_ptr;
901 if (Robot_canv != NULL) {
906 get_message_name(&message, Bitmap_name);
907 strcat(Bitmap_name, "#0");
908 Animating_bitmap_type = 0;
910 } else if (ch == 'O') {
911 if (Robot_canv != NULL) {
916 get_message_name(&message, Bitmap_name);
917 strcat(Bitmap_name, "#0");
918 Animating_bitmap_type = 1;
920 } else if (ch=='A') {
921 LineAdjustment=1-LineAdjustment;
922 } else if (ch=='Z') {
923 //mprintf ((0,"Got a Z!\n"));
925 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
928 if (LineAdjustment==1)
935 while ((fname[i]=*message) != '\n') {
941 while (*message++ != 10) // Get and drop eoln
948 while (fname[i]!='.') {
949 fname2[i] = fname[i];
959 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
960 load_new_briefing_screen (fname2);
962 load_new_briefing_screen (fname);
965 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
967 } else if (ch == 'B') {
968 char bitmap_name[32];
969 grs_bitmap guy_bitmap;
970 ubyte temp_palette[768];
973 if (Robot_canv != NULL) {
978 get_message_name(&message, bitmap_name);
979 strcat(bitmap_name, ".bbm");
980 guy_bitmap.bm_data = NULL;
981 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
982 Assert(iff_error == IFF_NO_ERROR);
983 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
985 show_briefing_bitmap(&guy_bitmap);
986 d_free(guy_bitmap.bm_data);
988 // } else if (ch==EOF) {
990 // } else if (ch == 'B') {
991 // if (Robot_canv != NULL) {
992 // d_free(Robot_canv);
996 // bitmap_num = get_message_num(&message);
997 // if (bitmap_num != -1)
998 // show_briefing_bitmap(Textures[bitmap_num]);
999 // prev_ch = 10; // read to eoln
1000 } else if (ch == 'S') {
1005 if (printing_channel>-1)
1006 digi_stop_sound( printing_channel );
1007 printing_channel=-1;
1011 start_time = timer_get_fixed_seconds();
1012 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1014 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1016 flash_cursor(flashing_cursor);
1020 if (robot_num != -1)
1021 show_spinning_robot_frame(robot_num);
1023 if (Bitmap_name[0] != 0)
1024 show_bitmap_frame();
1025 start_time += KEY_DELAY_DEFAULT/2;
1029 if (keypress == KEY_BACKSP)
1032 if (keypress == KEY_ESC)
1035 flashing_cursor = 0;
1037 } else if (ch == 'P') { // New page.
1039 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1040 // printing to it! You know, $Z !!!
1041 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1045 while (*message != 10) {
1046 message++; // drop carriage return after special escape sequence
1052 } else if (ch == '\t') { // Tab
1053 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1054 Briefing_text_x = bsp->text_ulx + tab_stop;
1055 } else if ((ch == ';') && (prev_ch == 10)) {
1056 while (*message++ != 10)
1059 } else if (ch == '\\') {
1061 } else if (ch == 10) {
1062 if (prev_ch != '\\') {
1065 Briefing_text_y += (8*(MenuHires+1));
1068 Briefing_text_x = bsp->text_ulx;
1069 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1070 load_briefing_screen(screen_num);
1071 Briefing_text_x = bsp->text_ulx;
1072 Briefing_text_y = bsp->text_uly;
1075 if (ch == 13) //Can this happen? Above says ch==10
1082 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1083 // printing to it! You know, $Z !!!
1084 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1090 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1094 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1098 // Check for Esc -> abort.
1100 key_check=local_key_inkey();
1105 if (_RedrawScreen) {
1106 _RedrawScreen = FALSE;
1107 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1108 key_check = KEY_ESC;
1111 if ( key_check == KEY_ESC ) {
1116 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1119 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1120 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1121 (key_check == KEY_ALTED+KEY_PADENTER))
1122 gr_toggle_fullscreen();
1125 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1126 Briefing_text_x = bsp->text_ulx;
1127 Briefing_text_y += bsp->text_uly;
1130 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1136 if (printing_channel>-1)
1137 digi_stop_sound( printing_channel );
1138 printing_channel=-1;
1142 start_time = timer_get_fixed_seconds();
1143 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1144 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1146 flash_cursor(flashing_cursor);
1149 if (robot_num != -1)
1150 show_spinning_robot_frame(robot_num);
1151 if (Bitmap_name[0] != 0)
1152 show_bitmap_frame();
1153 start_time += KEY_DELAY_DEFAULT/2;
1162 if (keypress == KEY_BACKSP)
1165 if (keypress == KEY_ESC) {
1170 load_briefing_screen(screen_num);
1171 Briefing_text_x = bsp->text_ulx;
1172 Briefing_text_y = bsp->text_uly;
1173 delay_count = KEY_DELAY_DEFAULT;
1182 if (Robot_canv != NULL)
1183 {d_free(Robot_canv); Robot_canv=NULL;}
1186 digi_stop_sound( hum_channel );
1187 if (printing_channel>-1)
1188 digi_stop_sound( printing_channel );
1196 //-----------------------------------------------------------------------------
1197 // Return a pointer to the start of text for screen #screen_num.
1198 char * get_briefing_message(int screen_num)
1200 char *tptr = Briefing_text;
1204 Assert(screen_num >= 0);
1206 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1211 cur_screen = get_message_num(&tptr);
1215 if (screen_num!=cur_screen)
1221 //-----------------------------------------------------------------------------
1222 // Load Descent briefing text.
1223 int load_screen_text(char *filename, char **buf)
1228 int have_binary = 0;
1230 if ((tfile = cfopen(filename,"rb")) == NULL) {
1231 char nfilename[30], *ptr;
1233 strcpy(nfilename, filename);
1234 if ((ptr = strrchr(nfilename, '.')))
1236 strcat(nfilename, ".txb");
1237 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1238 mprintf ((0,"can't open %s!\n",nfilename));
1240 //Error("Cannot open file %s or %s", filename, nfilename);
1243 mprintf ((0,"reading...\n"));
1246 len = cfilelength(ifile);
1247 MALLOC(*buf, char, len+500);
1248 mprintf ((0,"len=%d\n",len));
1249 for (x=0, i=0; i < len; i++, x++) {
1250 cfread (*buf+x,1,1,ifile);
1251 // mprintf ((0,"%c",*(*buf+x)));
1258 len = cfilelength(tfile);
1259 MALLOC(*buf, char, len+500);
1260 for (x=0, i=0; i < len; i++, x++) {
1261 cfread (*buf+x,1,1,tfile);
1262 // mprintf ((0,"%c",*(*buf+x)));
1268 //cfread(*buf, 1, len, tfile);
1273 decode_text(*buf, len);
1278 //-----------------------------------------------------------------------------
1279 // Return true if message got aborted, else return false.
1280 int show_briefing_text(int screen_num)
1284 message_ptr = get_briefing_message
1285 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1287 if (message_ptr==NULL)
1290 DoBriefingColorStuff();
1292 return show_briefing_message(screen_num, message_ptr);
1295 void DoBriefingColorStuff ()
1297 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1298 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1300 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1301 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1303 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1304 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1308 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1309 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1311 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1312 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1314 //Begin D1X addition
1316 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1317 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1320 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1321 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1323 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1324 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1326 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1327 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1329 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1330 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1333 Erase_color = gr_find_closest_color_current(0, 0, 0);
1336 //-----------------------------------------------------------------------------
1337 // Return true if screen got aborted by user, else return false.
1338 int show_briefing_screen( int screen_num, int allow_keys)
1341 //ubyte palette_save[768];
1343 New_pal_254_bash = 0;
1345 if (Skip_briefing_screens) {
1346 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1353 grs_bitmap briefing_bm;
1355 gr_init_bitmap_data(&briefing_bm);
1356 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1358 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1360 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1361 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));
1367 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1368 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1370 //vfx_set_palette_sub( New_pal );
1372 gr_palette_load(New_pal);
1376 gr_set_current_canvas( NULL );
1377 show_fullscr(&briefing_bm);
1380 //added on 9/13/98 by adb to make arch's requiring updates work
1382 //end changes by adb
1385 gr_free_bitmap_data (&briefing_bm);
1388 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1391 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1396 key_close(); // kill the keyboard handler during briefing screens for movies
1398 rval = show_briefing_text(screen_num);
1403 #if defined (MACINTOSH) || defined(WINDOWS)
1404 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1408 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1411 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1413 //d_free(briefing_bm.bm_data);
1419 //-----------------------------------------------------------------------------
1420 void do_briefing_screens(char *filename,int level_num)
1422 int abort_briefing_screens = 0;
1423 int cur_briefing_screen = 0;
1425 if (Skip_briefing_screens) {
1426 mprintf((0, "Skipping all briefing screens.\n"));
1431 return; // no briefing screens at all for demo
1435 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1437 if (!filename || !*filename)
1440 if (!load_screen_text(filename, &Briefing_text))
1444 songs_play_song( SONG_BRIEFING, 1 );
1449 set_screen_mode( SCREEN_MENU );
1451 gr_set_current_canvas(NULL);
1453 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1460 for (i = 0; i < NUM_D1_BRIEFING_SCREENS; i++)
1461 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1463 if (level_num == 1) {
1464 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1465 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1466 cur_briefing_screen++;
1470 if (!abort_briefing_screens) {
1471 for (cur_briefing_screen = 0; cur_briefing_screen < NUM_D1_BRIEFING_SCREENS; cur_briefing_screen++)
1472 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1473 if (show_briefing_screen(cur_briefing_screen, 0))
1478 show_briefing_screen(level_num,0);
1480 d_free (Briefing_text);
1487 int DefineBriefingBox (char **buf)
1492 n=get_new_message_num (buf);
1494 Assert(n < MAX_BRIEFING_SCREENS);
1496 while (**buf!=' ') {
1501 name[i]='\0'; // slap a delimiter on this guy
1503 strcpy (Briefing_screens[n].bs_name,name);
1504 Briefing_screens[n].level_num=get_new_message_num (buf);
1505 Briefing_screens[n].message_num=get_new_message_num (buf);
1506 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1507 Briefing_screens[n].text_uly=get_new_message_num (buf);
1508 Briefing_screens[n].text_width=get_new_message_num (buf);
1509 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1511 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1512 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1513 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1514 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1519 int get_new_message_num(char **message)
1523 while (**message == ' ')
1526 while ((**message >= '0') && (**message <= '9')) {
1527 num = 10*num + **message-'0';
1536 void show_order_form()
1541 unsigned char title_pal[768];
1542 char exit_screen[16];
1544 gr_set_current_canvas( NULL );
1549 strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM
1550 if (! cfexist(exit_screen))
1551 strcpy(exit_screen, MenuHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires
1552 if (! cfexist(exit_screen))
1553 strcpy(exit_screen, MenuHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale
1554 if (! cfexist(exit_screen))
1555 strcpy(exit_screen, MenuHires?"warningb.pcx":"warning.pcx"); // D1
1556 if (! cfexist(exit_screen))
1557 return; // D2 registered
1559 if ((pcx_error=pcx_read_fullscr( exit_screen, title_pal ))==PCX_ERROR_NONE) {
1560 //vfx_set_palette_sub( title_pal );
1561 gr_palette_fade_in( title_pal, 32, 0 );
1563 while (!key_inkey() && !mouse_button_state(0)) {} //key_getch();
1564 gr_palette_fade_out( title_pal, 32, 0 );
1567 Int3(); //can't load order screen