1 /* $Id: titles.c,v 1.38 2005-08-02 06:13:56 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);
217 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
220 short text_ulx, text_uly; // upper left x,y of text window
221 short text_width, text_height; // width and height of text window
224 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
225 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
227 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
228 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
231 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
233 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
236 #define MAX_BRIEFING_SCREENS 60
238 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
239 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
241 briefing_screen D1_Briefing_screens[] = {
242 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
243 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
244 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
245 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
247 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
248 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
249 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
251 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
252 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
254 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
255 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
256 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
259 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
260 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
261 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
262 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
263 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
265 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
266 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
267 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
268 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
269 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
271 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
272 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
273 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
274 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
275 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
277 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
278 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
279 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
280 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
282 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
283 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
284 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
286 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
287 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
288 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
290 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
291 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
292 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
295 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
297 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
298 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
299 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
305 int Briefing_text_x, Briefing_text_y;
307 void init_char_pos(int x, int y)
311 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
314 grs_canvas *Robot_canv = NULL;
315 vms_angvec Robot_angles;
317 char Bitmap_name[32] = "";
318 #define EXIT_DOOR_MAX 14
319 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
320 #define DOOR_DIV_INIT 6
321 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
323 //-----------------------------------------------------------------------------
324 void show_bitmap_frame(void)
326 grs_canvas *curcanv_save, *bitmap_canv=0;
328 grs_bitmap *bitmap_ptr;
330 // Only plot every nth frame.
331 if (Door_div_count) {
336 Door_div_count = DOOR_DIV_INIT;
338 if (Bitmap_name[0] != 0) {
342 // Set supertransparency color to black
343 if (!New_pal_254_bash) {
344 New_pal_254_bash = 1;
346 New_pal[254*3+1] = 0;
347 New_pal[254*3+2] = 0;
348 gr_palette_load( New_pal );
351 switch (Animating_bitmap_type) {
353 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64);
356 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94);
359 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
361 Int3(); // Impossible, illegal value for Animating_bitmap_type
364 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv;
366 pound_signp = strchr(Bitmap_name, '#');
367 Assert(pound_signp != NULL);
369 dig1 = *(pound_signp+1);
370 dig2 = *(pound_signp+2);
374 num = (dig1-'0')*10 + (dig2-'0');
376 switch (Animating_bitmap_type) {
379 if (num > EXIT_DOOR_MAX) {
382 } else if (num < 0) {
389 if (num > OTHER_THING_MAX)
396 *(pound_signp+1) = (num / 10) + '0';
397 *(pound_signp+2) = (num % 10) + '0';
398 *(pound_signp+3) = 0;
400 *(pound_signp+1) = (num % 10) + '0';
401 *(pound_signp+2) = 0;
406 bi = piggy_find_bitmap(Bitmap_name);
407 bitmap_ptr = &GameBitmaps[bi.index];
411 gr_bitmapm(0, 0, bitmap_ptr);
413 grd_curcanv = curcanv_save;
416 switch (Animating_bitmap_type) {
418 if (num == EXIT_DOOR_MAX) {
421 } else if (num == 0) {
433 //-----------------------------------------------------------------------------
434 void show_briefing_bitmap(grs_bitmap *bmp)
436 grs_canvas *curcanv_save, *bitmap_canv;
438 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
439 curcanv_save = grd_curcanv;
440 gr_set_current_canvas(bitmap_canv);
441 gr_bitmapm(0, 0, bmp);
442 gr_set_current_canvas(curcanv_save);
447 //-----------------------------------------------------------------------------
448 void show_spinning_robot_frame(int robot_num)
450 grs_canvas *curcanv_save;
452 if (robot_num != -1) {
453 Robot_angles.h += 150;
455 curcanv_save = grd_curcanv;
456 grd_curcanv = Robot_canv;
457 Assert(Robot_info[robot_num].model_num != -1);
458 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
459 grd_curcanv = curcanv_save;
464 //-----------------------------------------------------------------------------
465 void init_spinning_robot(void) //(int x,int y,int w,int h)
467 //Robot_angles.p += 0;
468 //Robot_angles.b += 0;
469 //Robot_angles.h += 0;
471 int x = rescale_x(138);
472 int y = rescale_y(55);
473 int w = rescale_x(166);
474 int h = rescale_y(138);
476 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
480 //---------------------------------------------------------------------------
481 // Returns char width.
482 // If show_robot_flag set, then show a frame of the spinning robot.
483 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
487 static fix start_time=0;
489 message[0] = the_char;
492 if (start_time==0 && timer_get_fixed_seconds()<0)
493 start_time=timer_get_fixed_seconds();
495 gr_get_string_size(message, &w, &h, &aw );
497 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
499 // Draw cursor if there is some delay and caller says to draw cursor
500 if (cursor_flag && delay) {
501 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
502 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
507 delay=fixdiv (F1_0,i2f(15));
509 if ((Bitmap_name[0] != 0) && (delay != 0))
512 if (RobotPlaying && (delay != 0))
515 while (timer_get_fixed_seconds() < (start_time + delay)) {
516 if (RobotPlaying && delay != 0)
520 show_spinning_robot_frame(robot_num);
522 start_time = timer_get_fixed_seconds();
525 if (cursor_flag && delay) {
526 gr_set_fontcolor(Erase_color, -1);
527 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
530 // Draw the character
531 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
532 gr_printf(Briefing_text_x, Briefing_text_y, message );
534 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
535 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
537 if (delay) gr_update();
539 // if (the_char != ' ')
540 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
541 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
546 //-----------------------------------------------------------------------------
547 int load_briefing_screen( int screen_num )
553 fname = Briefing_screens[screen_num].bs_name;
555 fname = CurBriefScreenName;
557 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
558 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
559 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);
560 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
566 int load_new_briefing_screen( char *fname )
570 mprintf ((0,"Loading new briefing <%s>\n",fname));
571 strcpy (CurBriefScreenName,fname);
573 if (gr_palette_fade_out( New_pal, 32, 0 ))
576 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
577 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
578 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);
579 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
582 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
584 if (gr_palette_fade_in( New_pal, 32, 0 ))
586 DoBriefingColorStuff();
593 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
595 //-----------------------------------------------------------------------------
596 int get_message_num(char **message)
600 while (**message == ' ')
603 while ((**message >= '0') && (**message <= '9')) {
604 num = 10*num + **message-'0';
608 while (*(*message)++ != 10) // Get and drop eoln
614 //-----------------------------------------------------------------------------
615 void get_message_name(char **message, char *result)
617 while (**message == ' ')
620 while ((**message != ' ') && (**message != 10)) {
621 if (**message != '\n')
622 *result++ = **message;
627 while (*(*message)++ != 10) // Get and drop eoln
633 //-----------------------------------------------------------------------------
634 void flash_cursor(int cursor_flag)
636 if (cursor_flag == 0)
639 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
640 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
642 gr_set_fontcolor(Erase_color, -1);
644 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
648 extern int InitMovieBriefing();
651 //-----------------------------------------------------------------------------
652 // Return true if message got aborted by user (pressed ESC), else return false.
653 int show_briefing_message(int screen_num, char *message)
657 briefing_screen *bsp;
658 int delay_count = KEY_DELAY_DEFAULT;
662 static int tab_stop=0;
663 int flashing_cursor=0;
664 int new_page=0,GotZ=0;
665 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
669 int hum_channel=-1,printing_channel=-1;
670 int LineAdjustment=1;
679 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
682 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
683 gr_set_curfont( GAME_FONT );
687 MALLOC(bsp, briefing_screen, 1);
688 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
689 bsp->text_ulx = rescale_x(bsp->text_ulx);
690 bsp->text_uly = rescale_y(bsp->text_uly);
691 bsp->text_width = rescale_x(bsp->text_width);
692 bsp->text_height = rescale_y(bsp->text_height);
693 init_char_pos(bsp->text_ulx, bsp->text_uly);
695 bsp=&Briefing_screens[0];
696 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
704 screen_num=DefineBriefingBox (&message);
705 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
707 bsp = &Briefing_screens[screen_num];
708 init_char_pos(bsp->text_ulx, bsp->text_uly);
710 prev_ch = 10; // read to eoln
711 } else if (ch=='U') {
712 screen_num=get_message_num(&message);
713 bsp = &Briefing_screens[screen_num];
714 init_char_pos(bsp->text_ulx, bsp->text_uly);
715 prev_ch = 10; // read to eoln
716 } else if (ch == 'C') {
717 Current_color = get_message_num(&message)-1;
718 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
720 } else if (ch == 'F') { // toggle flashing cursor
721 flashing_cursor = !flashing_cursor;
723 while (*message++ != 10)
725 } else if (ch == 'T') {
726 tab_stop = get_message_num(&message);
727 tab_stop*=(1+MenuHires);
728 prev_ch = 10; // read to eoln
729 } else if (ch == 'R') {
730 if (Robot_canv != NULL) {
740 init_spinning_robot();
741 robot_num = get_message_num(&message);
742 while (*message++ != 10)
746 spinRobotName[2]=kludge; // ugly but proud
748 RobotPlaying=InitRobotMovie(spinRobotName);
750 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
754 DoBriefingColorStuff ();
755 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
758 prev_ch = 10; // read to eoln
759 } else if (ch == 'N') {
760 //--grs_bitmap *bitmap_ptr;
761 if (Robot_canv != NULL) {
766 get_message_name(&message, Bitmap_name);
767 strcat(Bitmap_name, "#0");
768 Animating_bitmap_type = 0;
770 } else if (ch == 'O') {
771 if (Robot_canv != NULL) {
776 get_message_name(&message, Bitmap_name);
777 strcat(Bitmap_name, "#0");
778 Animating_bitmap_type = 1;
780 } else if (ch=='A') {
781 LineAdjustment=1-LineAdjustment;
782 } else if (ch=='Z') {
783 //mprintf ((0,"Got a Z!\n"));
785 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
788 if (LineAdjustment==1)
795 while ((fname[i]=*message) != '\n') {
801 while (*message++ != 10) // Get and drop eoln
808 while (fname[i]!='.') {
809 fname2[i] = fname[i];
819 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
820 load_new_briefing_screen (fname2);
822 load_new_briefing_screen (fname);
825 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
827 } else if (ch == 'B') {
828 char bitmap_name[32];
829 grs_bitmap guy_bitmap;
830 ubyte temp_palette[768];
833 if (Robot_canv != NULL) {
838 get_message_name(&message, bitmap_name);
839 strcat(bitmap_name, ".bbm");
840 guy_bitmap.bm_data = NULL;
841 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
842 Assert(iff_error == IFF_NO_ERROR);
843 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
845 show_briefing_bitmap(&guy_bitmap);
846 d_free(guy_bitmap.bm_data);
848 // } else if (ch==EOF) {
850 // } else if (ch == 'B') {
851 // if (Robot_canv != NULL) {
852 // d_free(Robot_canv);
856 // bitmap_num = get_message_num(&message);
857 // if (bitmap_num != -1)
858 // show_briefing_bitmap(Textures[bitmap_num]);
859 // prev_ch = 10; // read to eoln
860 } else if (ch == 'S') {
865 if (printing_channel>-1)
866 digi_stop_sound( printing_channel );
871 start_time = timer_get_fixed_seconds();
872 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
874 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
876 flash_cursor(flashing_cursor);
881 show_spinning_robot_frame(robot_num);
883 if (Bitmap_name[0] != 0)
885 start_time += KEY_DELAY_DEFAULT/2;
889 if (keypress == KEY_BACKSP)
892 if (keypress == KEY_ESC)
897 } else if (ch == 'P') { // New page.
899 Int3(); // Hey ryan!!!! You gotta load a screen before you start
900 // printing to it! You know, $Z !!!
901 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
905 while (*message != 10) {
906 message++; // drop carriage return after special escape sequence
912 } else if (ch == '\t') { // Tab
913 if (Briefing_text_x - bsp->text_ulx < tab_stop)
914 Briefing_text_x = bsp->text_ulx + tab_stop;
915 } else if ((ch == ';') && (prev_ch == 10)) {
916 while (*message++ != 10)
919 } else if (ch == '\\') {
921 } else if (ch == 10) {
922 if (prev_ch != '\\') {
925 Briefing_text_y += (8*(MenuHires+1));
928 Briefing_text_x = bsp->text_ulx;
929 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
930 load_briefing_screen(screen_num);
931 Briefing_text_x = bsp->text_ulx;
932 Briefing_text_y = bsp->text_uly;
935 if (ch == 13) //Can this happen? Above says ch==10
942 Int3(); // Hey ryan!!!! You gotta load a screen before you start
943 // printing to it! You know, $Z !!!
944 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
950 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
954 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
958 // Check for Esc -> abort.
960 key_check=local_key_inkey();
966 _RedrawScreen = FALSE;
967 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
971 if ( key_check == KEY_ESC ) {
976 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
979 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
980 if ((key_check == KEY_ALTED+KEY_ENTER) ||
981 (key_check == KEY_ALTED+KEY_PADENTER))
982 gr_toggle_fullscreen();
985 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
986 Briefing_text_x = bsp->text_ulx;
987 Briefing_text_y += bsp->text_uly;
990 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
996 if (printing_channel>-1)
997 digi_stop_sound( printing_channel );
1002 start_time = timer_get_fixed_seconds();
1003 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1004 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1006 flash_cursor(flashing_cursor);
1009 if (robot_num != -1)
1010 show_spinning_robot_frame(robot_num);
1011 if (Bitmap_name[0] != 0)
1012 show_bitmap_frame();
1013 start_time += KEY_DELAY_DEFAULT/2;
1022 if (keypress == KEY_BACKSP)
1025 if (keypress == KEY_ESC) {
1030 load_briefing_screen(screen_num);
1031 Briefing_text_x = bsp->text_ulx;
1032 Briefing_text_y = bsp->text_uly;
1033 delay_count = KEY_DELAY_DEFAULT;
1042 if (Robot_canv != NULL)
1043 {d_free(Robot_canv); Robot_canv=NULL;}
1046 digi_stop_sound( hum_channel );
1047 if (printing_channel>-1)
1048 digi_stop_sound( printing_channel );
1056 //-----------------------------------------------------------------------------
1057 // Return a pointer to the start of text for screen #screen_num.
1058 char * get_briefing_message(int screen_num)
1060 char *tptr = Briefing_text;
1064 Assert(screen_num >= 0);
1066 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1071 cur_screen = get_message_num(&tptr);
1075 if (screen_num!=cur_screen)
1081 //-----------------------------------------------------------------------------
1082 // Load Descent briefing text.
1083 int load_screen_text(char *filename, char **buf)
1088 int have_binary = 0;
1090 if ((tfile = cfopen(filename,"rb")) == NULL) {
1091 char nfilename[30], *ptr;
1093 strcpy(nfilename, filename);
1094 if ((ptr = strrchr(nfilename, '.')))
1096 strcat(nfilename, ".txb");
1097 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1098 mprintf ((0,"can't open %s!\n",nfilename));
1100 //Error("Cannot open file %s or %s", filename, nfilename);
1103 mprintf ((0,"reading...\n"));
1106 len = cfilelength(ifile);
1107 MALLOC(*buf, char, len+500);
1108 mprintf ((0,"len=%d\n",len));
1109 for (x=0, i=0; i < len; i++, x++) {
1110 cfread (*buf+x,1,1,ifile);
1111 // mprintf ((0,"%c",*(*buf+x)));
1118 len = cfilelength(tfile);
1119 MALLOC(*buf, char, len+500);
1120 for (x=0, i=0; i < len; i++, x++) {
1121 cfread (*buf+x,1,1,tfile);
1122 // mprintf ((0,"%c",*(*buf+x)));
1128 //cfread(*buf, 1, len, tfile);
1133 decode_text(*buf, len);
1138 //-----------------------------------------------------------------------------
1139 // Return true if message got aborted, else return false.
1140 int show_briefing_text(int screen_num)
1144 message_ptr = get_briefing_message
1145 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1147 if (message_ptr==NULL)
1150 DoBriefingColorStuff();
1152 return show_briefing_message(screen_num, message_ptr);
1155 void DoBriefingColorStuff ()
1157 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1158 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1160 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1161 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1163 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1164 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1168 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1169 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1171 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1172 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1174 //Begin D1X addition
1176 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1177 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1180 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1181 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1183 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1184 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1186 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1187 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1189 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1190 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1193 Erase_color = gr_find_closest_color_current(0, 0, 0);
1196 //-----------------------------------------------------------------------------
1197 // Return true if screen got aborted by user, else return false.
1198 int show_briefing_screen( int screen_num, int allow_keys)
1201 //ubyte palette_save[768];
1203 New_pal_254_bash = 0;
1205 if (Skip_briefing_screens) {
1206 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1213 grs_bitmap briefing_bm;
1215 gr_init_bitmap_data(&briefing_bm);
1216 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1218 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1220 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1221 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));
1227 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1228 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1230 //vfx_set_palette_sub( New_pal );
1232 gr_palette_load(New_pal);
1236 gr_set_current_canvas( NULL );
1237 show_fullscr(&briefing_bm);
1240 //added on 9/13/98 by adb to make arch's requiring updates work
1242 //end changes by adb
1245 gr_free_bitmap_data (&briefing_bm);
1248 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1251 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1256 key_close(); // kill the keyboard handler during briefing screens for movies
1258 rval = show_briefing_text(screen_num);
1263 #if defined (MACINTOSH) || defined(WINDOWS)
1264 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1268 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1271 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1273 //d_free(briefing_bm.bm_data);
1279 //-----------------------------------------------------------------------------
1280 void do_briefing_screens(char *filename,int level_num)
1282 int abort_briefing_screens = 0;
1283 int cur_briefing_screen = 0;
1285 if (Skip_briefing_screens) {
1286 mprintf((0, "Skipping all briefing screens.\n"));
1291 return; // no briefing screens at all for demo
1295 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1297 if (!filename || !*filename)
1300 if (!load_screen_text(filename, &Briefing_text))
1304 songs_play_song( SONG_BRIEFING, 1 );
1309 set_screen_mode( SCREEN_MENU );
1311 gr_set_current_canvas(NULL);
1313 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1320 for (i = 0; i < MAX_BRIEFING_SCREENS; i++)
1321 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1323 if (level_num == 1) {
1324 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1325 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1326 cur_briefing_screen++;
1330 if (!abort_briefing_screens) {
1331 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1332 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1333 if (show_briefing_screen(cur_briefing_screen, 0))
1338 show_briefing_screen(level_num,0);
1340 d_free (Briefing_text);
1347 int DefineBriefingBox (char **buf)
1352 n=get_new_message_num (buf);
1354 Assert(n < MAX_BRIEFING_SCREENS);
1356 while (**buf!=' ') {
1361 name[i]='\0'; // slap a delimiter on this guy
1363 strcpy (Briefing_screens[n].bs_name,name);
1364 Briefing_screens[n].level_num=get_new_message_num (buf);
1365 Briefing_screens[n].message_num=get_new_message_num (buf);
1366 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1367 Briefing_screens[n].text_uly=get_new_message_num (buf);
1368 Briefing_screens[n].text_width=get_new_message_num (buf);
1369 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1371 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1372 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1373 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1374 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1379 int get_new_message_num(char **message)
1383 while (**message == ' ')
1386 while ((**message >= '0') && (**message <= '9')) {
1387 num = 10*num + **message-'0';