1 /* $Id: titles.c,v 1.39 2005-11-29 09:44:24 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
304 #define NUM_D1_BRIEFING_SCREENS (sizeof(D1_Briefing_screens)/sizeof(briefing_screen))
306 int Briefing_text_x, Briefing_text_y;
308 void init_char_pos(int x, int y)
312 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
315 grs_canvas *Robot_canv = NULL;
316 vms_angvec Robot_angles;
318 char Bitmap_name[32] = "";
319 #define EXIT_DOOR_MAX 14
320 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
321 #define DOOR_DIV_INIT 6
322 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
324 //-----------------------------------------------------------------------------
325 void show_bitmap_frame(void)
327 grs_canvas *curcanv_save, *bitmap_canv=0;
329 grs_bitmap *bitmap_ptr;
331 // Only plot every nth frame.
332 if (Door_div_count) {
337 Door_div_count = DOOR_DIV_INIT;
339 if (Bitmap_name[0] != 0) {
343 // Set supertransparency color to black
344 if (!New_pal_254_bash) {
345 New_pal_254_bash = 1;
347 New_pal[254*3+1] = 0;
348 New_pal[254*3+2] = 0;
349 gr_palette_load( New_pal );
352 switch (Animating_bitmap_type) {
354 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64);
357 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94);
360 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
362 Int3(); // Impossible, illegal value for Animating_bitmap_type
365 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv;
367 pound_signp = strchr(Bitmap_name, '#');
368 Assert(pound_signp != NULL);
370 dig1 = *(pound_signp+1);
371 dig2 = *(pound_signp+2);
375 num = (dig1-'0')*10 + (dig2-'0');
377 switch (Animating_bitmap_type) {
380 if (num > EXIT_DOOR_MAX) {
383 } else if (num < 0) {
390 if (num > OTHER_THING_MAX)
397 *(pound_signp+1) = (num / 10) + '0';
398 *(pound_signp+2) = (num % 10) + '0';
399 *(pound_signp+3) = 0;
401 *(pound_signp+1) = (num % 10) + '0';
402 *(pound_signp+2) = 0;
407 bi = piggy_find_bitmap(Bitmap_name);
408 bitmap_ptr = &GameBitmaps[bi.index];
412 gr_bitmapm(0, 0, bitmap_ptr);
414 grd_curcanv = curcanv_save;
417 switch (Animating_bitmap_type) {
419 if (num == EXIT_DOOR_MAX) {
422 } else if (num == 0) {
434 //-----------------------------------------------------------------------------
435 void show_briefing_bitmap(grs_bitmap *bmp)
437 grs_canvas *curcanv_save, *bitmap_canv;
439 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
440 curcanv_save = grd_curcanv;
441 gr_set_current_canvas(bitmap_canv);
442 gr_bitmapm(0, 0, bmp);
443 gr_set_current_canvas(curcanv_save);
448 //-----------------------------------------------------------------------------
449 void show_spinning_robot_frame(int robot_num)
451 grs_canvas *curcanv_save;
453 if (robot_num != -1) {
454 Robot_angles.h += 150;
456 curcanv_save = grd_curcanv;
457 grd_curcanv = Robot_canv;
458 Assert(Robot_info[robot_num].model_num != -1);
459 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
460 grd_curcanv = curcanv_save;
465 //-----------------------------------------------------------------------------
466 void init_spinning_robot(void) //(int x,int y,int w,int h)
468 //Robot_angles.p += 0;
469 //Robot_angles.b += 0;
470 //Robot_angles.h += 0;
472 int x = rescale_x(138);
473 int y = rescale_y(55);
474 int w = rescale_x(166);
475 int h = rescale_y(138);
477 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
481 //---------------------------------------------------------------------------
482 // Returns char width.
483 // If show_robot_flag set, then show a frame of the spinning robot.
484 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
488 static fix start_time=0;
490 message[0] = the_char;
493 if (start_time==0 && timer_get_fixed_seconds()<0)
494 start_time=timer_get_fixed_seconds();
496 gr_get_string_size(message, &w, &h, &aw );
498 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
500 // Draw cursor if there is some delay and caller says to draw cursor
501 if (cursor_flag && delay) {
502 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
503 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
508 delay=fixdiv (F1_0,i2f(15));
510 if ((Bitmap_name[0] != 0) && (delay != 0))
513 if (RobotPlaying && (delay != 0))
516 while (timer_get_fixed_seconds() < (start_time + delay)) {
517 if (RobotPlaying && delay != 0)
521 show_spinning_robot_frame(robot_num);
523 start_time = timer_get_fixed_seconds();
526 if (cursor_flag && delay) {
527 gr_set_fontcolor(Erase_color, -1);
528 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
531 // Draw the character
532 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
533 gr_printf(Briefing_text_x, Briefing_text_y, message );
535 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
536 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
538 if (delay) gr_update();
540 // if (the_char != ' ')
541 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
542 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
547 //-----------------------------------------------------------------------------
548 int load_briefing_screen( int screen_num )
554 fname = Briefing_screens[screen_num].bs_name;
556 fname = CurBriefScreenName;
558 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
559 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
560 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);
561 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
567 int load_new_briefing_screen( char *fname )
571 mprintf ((0,"Loading new briefing <%s>\n",fname));
572 strcpy (CurBriefScreenName,fname);
574 if (gr_palette_fade_out( New_pal, 32, 0 ))
577 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
578 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
579 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);
580 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
583 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
585 if (gr_palette_fade_in( New_pal, 32, 0 ))
587 DoBriefingColorStuff();
594 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
596 //-----------------------------------------------------------------------------
597 int get_message_num(char **message)
601 while (**message == ' ')
604 while ((**message >= '0') && (**message <= '9')) {
605 num = 10*num + **message-'0';
609 while (*(*message)++ != 10) // Get and drop eoln
615 //-----------------------------------------------------------------------------
616 void get_message_name(char **message, char *result)
618 while (**message == ' ')
621 while ((**message != ' ') && (**message != 10)) {
622 if (**message != '\n')
623 *result++ = **message;
628 while (*(*message)++ != 10) // Get and drop eoln
634 //-----------------------------------------------------------------------------
635 void flash_cursor(int cursor_flag)
637 if (cursor_flag == 0)
640 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
641 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
643 gr_set_fontcolor(Erase_color, -1);
645 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
649 extern int InitMovieBriefing();
652 //-----------------------------------------------------------------------------
653 // Return true if message got aborted by user (pressed ESC), else return false.
654 int show_briefing_message(int screen_num, char *message)
658 briefing_screen *bsp;
659 int delay_count = KEY_DELAY_DEFAULT;
663 static int tab_stop=0;
664 int flashing_cursor=0;
665 int new_page=0,GotZ=0;
666 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
670 int hum_channel=-1,printing_channel=-1;
671 int LineAdjustment=1;
680 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
683 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
684 gr_set_curfont( GAME_FONT );
688 MALLOC(bsp, briefing_screen, 1);
689 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
690 bsp->text_ulx = rescale_x(bsp->text_ulx);
691 bsp->text_uly = rescale_y(bsp->text_uly);
692 bsp->text_width = rescale_x(bsp->text_width);
693 bsp->text_height = rescale_y(bsp->text_height);
694 init_char_pos(bsp->text_ulx, bsp->text_uly);
696 bsp=&Briefing_screens[0];
697 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
705 screen_num=DefineBriefingBox (&message);
706 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
708 bsp = &Briefing_screens[screen_num];
709 init_char_pos(bsp->text_ulx, bsp->text_uly);
711 prev_ch = 10; // read to eoln
712 } else if (ch=='U') {
713 screen_num=get_message_num(&message);
714 bsp = &Briefing_screens[screen_num];
715 init_char_pos(bsp->text_ulx, bsp->text_uly);
716 prev_ch = 10; // read to eoln
717 } else if (ch == 'C') {
718 Current_color = get_message_num(&message)-1;
719 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
721 } else if (ch == 'F') { // toggle flashing cursor
722 flashing_cursor = !flashing_cursor;
724 while (*message++ != 10)
726 } else if (ch == 'T') {
727 tab_stop = get_message_num(&message);
728 tab_stop*=(1+MenuHires);
729 prev_ch = 10; // read to eoln
730 } else if (ch == 'R') {
731 if (Robot_canv != NULL) {
741 init_spinning_robot();
742 robot_num = get_message_num(&message);
743 while (*message++ != 10)
747 spinRobotName[2]=kludge; // ugly but proud
749 RobotPlaying=InitRobotMovie(spinRobotName);
751 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
755 DoBriefingColorStuff ();
756 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
759 prev_ch = 10; // read to eoln
760 } else if (ch == 'N') {
761 //--grs_bitmap *bitmap_ptr;
762 if (Robot_canv != NULL) {
767 get_message_name(&message, Bitmap_name);
768 strcat(Bitmap_name, "#0");
769 Animating_bitmap_type = 0;
771 } else if (ch == 'O') {
772 if (Robot_canv != NULL) {
777 get_message_name(&message, Bitmap_name);
778 strcat(Bitmap_name, "#0");
779 Animating_bitmap_type = 1;
781 } else if (ch=='A') {
782 LineAdjustment=1-LineAdjustment;
783 } else if (ch=='Z') {
784 //mprintf ((0,"Got a Z!\n"));
786 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
789 if (LineAdjustment==1)
796 while ((fname[i]=*message) != '\n') {
802 while (*message++ != 10) // Get and drop eoln
809 while (fname[i]!='.') {
810 fname2[i] = fname[i];
820 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
821 load_new_briefing_screen (fname2);
823 load_new_briefing_screen (fname);
826 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
828 } else if (ch == 'B') {
829 char bitmap_name[32];
830 grs_bitmap guy_bitmap;
831 ubyte temp_palette[768];
834 if (Robot_canv != NULL) {
839 get_message_name(&message, bitmap_name);
840 strcat(bitmap_name, ".bbm");
841 guy_bitmap.bm_data = NULL;
842 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
843 Assert(iff_error == IFF_NO_ERROR);
844 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
846 show_briefing_bitmap(&guy_bitmap);
847 d_free(guy_bitmap.bm_data);
849 // } else if (ch==EOF) {
851 // } else if (ch == 'B') {
852 // if (Robot_canv != NULL) {
853 // d_free(Robot_canv);
857 // bitmap_num = get_message_num(&message);
858 // if (bitmap_num != -1)
859 // show_briefing_bitmap(Textures[bitmap_num]);
860 // prev_ch = 10; // read to eoln
861 } else if (ch == 'S') {
866 if (printing_channel>-1)
867 digi_stop_sound( printing_channel );
872 start_time = timer_get_fixed_seconds();
873 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
875 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
877 flash_cursor(flashing_cursor);
882 show_spinning_robot_frame(robot_num);
884 if (Bitmap_name[0] != 0)
886 start_time += KEY_DELAY_DEFAULT/2;
890 if (keypress == KEY_BACKSP)
893 if (keypress == KEY_ESC)
898 } else if (ch == 'P') { // New page.
900 Int3(); // Hey ryan!!!! You gotta load a screen before you start
901 // printing to it! You know, $Z !!!
902 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
906 while (*message != 10) {
907 message++; // drop carriage return after special escape sequence
913 } else if (ch == '\t') { // Tab
914 if (Briefing_text_x - bsp->text_ulx < tab_stop)
915 Briefing_text_x = bsp->text_ulx + tab_stop;
916 } else if ((ch == ';') && (prev_ch == 10)) {
917 while (*message++ != 10)
920 } else if (ch == '\\') {
922 } else if (ch == 10) {
923 if (prev_ch != '\\') {
926 Briefing_text_y += (8*(MenuHires+1));
929 Briefing_text_x = bsp->text_ulx;
930 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
931 load_briefing_screen(screen_num);
932 Briefing_text_x = bsp->text_ulx;
933 Briefing_text_y = bsp->text_uly;
936 if (ch == 13) //Can this happen? Above says ch==10
943 Int3(); // Hey ryan!!!! You gotta load a screen before you start
944 // printing to it! You know, $Z !!!
945 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
951 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
955 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
959 // Check for Esc -> abort.
961 key_check=local_key_inkey();
967 _RedrawScreen = FALSE;
968 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
972 if ( key_check == KEY_ESC ) {
977 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
980 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
981 if ((key_check == KEY_ALTED+KEY_ENTER) ||
982 (key_check == KEY_ALTED+KEY_PADENTER))
983 gr_toggle_fullscreen();
986 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
987 Briefing_text_x = bsp->text_ulx;
988 Briefing_text_y += bsp->text_uly;
991 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
997 if (printing_channel>-1)
998 digi_stop_sound( printing_channel );
1003 start_time = timer_get_fixed_seconds();
1004 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1005 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1007 flash_cursor(flashing_cursor);
1010 if (robot_num != -1)
1011 show_spinning_robot_frame(robot_num);
1012 if (Bitmap_name[0] != 0)
1013 show_bitmap_frame();
1014 start_time += KEY_DELAY_DEFAULT/2;
1023 if (keypress == KEY_BACKSP)
1026 if (keypress == KEY_ESC) {
1031 load_briefing_screen(screen_num);
1032 Briefing_text_x = bsp->text_ulx;
1033 Briefing_text_y = bsp->text_uly;
1034 delay_count = KEY_DELAY_DEFAULT;
1043 if (Robot_canv != NULL)
1044 {d_free(Robot_canv); Robot_canv=NULL;}
1047 digi_stop_sound( hum_channel );
1048 if (printing_channel>-1)
1049 digi_stop_sound( printing_channel );
1057 //-----------------------------------------------------------------------------
1058 // Return a pointer to the start of text for screen #screen_num.
1059 char * get_briefing_message(int screen_num)
1061 char *tptr = Briefing_text;
1065 Assert(screen_num >= 0);
1067 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1072 cur_screen = get_message_num(&tptr);
1076 if (screen_num!=cur_screen)
1082 //-----------------------------------------------------------------------------
1083 // Load Descent briefing text.
1084 int load_screen_text(char *filename, char **buf)
1089 int have_binary = 0;
1091 if ((tfile = cfopen(filename,"rb")) == NULL) {
1092 char nfilename[30], *ptr;
1094 strcpy(nfilename, filename);
1095 if ((ptr = strrchr(nfilename, '.')))
1097 strcat(nfilename, ".txb");
1098 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1099 mprintf ((0,"can't open %s!\n",nfilename));
1101 //Error("Cannot open file %s or %s", filename, nfilename);
1104 mprintf ((0,"reading...\n"));
1107 len = cfilelength(ifile);
1108 MALLOC(*buf, char, len+500);
1109 mprintf ((0,"len=%d\n",len));
1110 for (x=0, i=0; i < len; i++, x++) {
1111 cfread (*buf+x,1,1,ifile);
1112 // mprintf ((0,"%c",*(*buf+x)));
1119 len = cfilelength(tfile);
1120 MALLOC(*buf, char, len+500);
1121 for (x=0, i=0; i < len; i++, x++) {
1122 cfread (*buf+x,1,1,tfile);
1123 // mprintf ((0,"%c",*(*buf+x)));
1129 //cfread(*buf, 1, len, tfile);
1134 decode_text(*buf, len);
1139 //-----------------------------------------------------------------------------
1140 // Return true if message got aborted, else return false.
1141 int show_briefing_text(int screen_num)
1145 message_ptr = get_briefing_message
1146 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1148 if (message_ptr==NULL)
1151 DoBriefingColorStuff();
1153 return show_briefing_message(screen_num, message_ptr);
1156 void DoBriefingColorStuff ()
1158 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1159 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1161 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1162 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1164 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1165 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1169 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1170 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1172 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1173 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1175 //Begin D1X addition
1177 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1178 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1181 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1182 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1184 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1185 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1187 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1188 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1190 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1191 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1194 Erase_color = gr_find_closest_color_current(0, 0, 0);
1197 //-----------------------------------------------------------------------------
1198 // Return true if screen got aborted by user, else return false.
1199 int show_briefing_screen( int screen_num, int allow_keys)
1202 //ubyte palette_save[768];
1204 New_pal_254_bash = 0;
1206 if (Skip_briefing_screens) {
1207 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1214 grs_bitmap briefing_bm;
1216 gr_init_bitmap_data(&briefing_bm);
1217 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1219 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1221 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1222 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));
1228 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1229 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1231 //vfx_set_palette_sub( New_pal );
1233 gr_palette_load(New_pal);
1237 gr_set_current_canvas( NULL );
1238 show_fullscr(&briefing_bm);
1241 //added on 9/13/98 by adb to make arch's requiring updates work
1243 //end changes by adb
1246 gr_free_bitmap_data (&briefing_bm);
1249 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1252 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1257 key_close(); // kill the keyboard handler during briefing screens for movies
1259 rval = show_briefing_text(screen_num);
1264 #if defined (MACINTOSH) || defined(WINDOWS)
1265 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1269 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1272 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1274 //d_free(briefing_bm.bm_data);
1280 //-----------------------------------------------------------------------------
1281 void do_briefing_screens(char *filename,int level_num)
1283 int abort_briefing_screens = 0;
1284 int cur_briefing_screen = 0;
1286 if (Skip_briefing_screens) {
1287 mprintf((0, "Skipping all briefing screens.\n"));
1292 return; // no briefing screens at all for demo
1296 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1298 if (!filename || !*filename)
1301 if (!load_screen_text(filename, &Briefing_text))
1305 songs_play_song( SONG_BRIEFING, 1 );
1310 set_screen_mode( SCREEN_MENU );
1312 gr_set_current_canvas(NULL);
1314 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1321 for (i = 0; i < NUM_D1_BRIEFING_SCREENS; i++)
1322 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1324 if (level_num == 1) {
1325 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1326 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1327 cur_briefing_screen++;
1331 if (!abort_briefing_screens) {
1332 for (cur_briefing_screen = 0; cur_briefing_screen < NUM_D1_BRIEFING_SCREENS; cur_briefing_screen++)
1333 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1334 if (show_briefing_screen(cur_briefing_screen, 0))
1339 show_briefing_screen(level_num,0);
1341 d_free (Briefing_text);
1348 int DefineBriefingBox (char **buf)
1353 n=get_new_message_num (buf);
1355 Assert(n < MAX_BRIEFING_SCREENS);
1357 while (**buf!=' ') {
1362 name[i]='\0'; // slap a delimiter on this guy
1364 strcpy (Briefing_screens[n].bs_name,name);
1365 Briefing_screens[n].level_num=get_new_message_num (buf);
1366 Briefing_screens[n].message_num=get_new_message_num (buf);
1367 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1368 Briefing_screens[n].text_uly=get_new_message_num (buf);
1369 Briefing_screens[n].text_width=get_new_message_num (buf);
1370 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1372 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1373 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1374 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1375 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1380 int get_new_message_num(char **message)
1384 while (**message == ' ')
1387 while ((**message >= '0') && (**message <= '9')) {
1388 num = 10*num + **message-'0';