1 /* $Id: titles.c,v 1.12 2002-08-27 04:15:23 btb 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.
33 #include "pa_enabl.h" //$$POLY_ACC
70 extern void RotateRobot();
73 void DoBriefingColorStuff ();
74 int get_new_message_num(char **message);
75 int DefineBriefingBox (char **buf);
77 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
79 extern int MVEPaletteCalls;
84 char CurBriefScreenName[15]="brief03.pcx";
90 #define MAX_BRIEFING_COLORS 3
92 // Descent 1 briefings
93 char Ending_text_filename[13] = "endreg.tex";
94 char Briefing_text_filename[13] = "briefing.tex";
96 #define SHAREWARE_ENDING_FILENAME "ending.tex"
98 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
99 int Skip_briefing_screens=0;
100 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
101 int Current_color = 0;
104 extern int check_button_press();
107 extern void macintosh_quit(void);
111 static int rescale_x(int x)
113 return x * GWIDTH / 320;
116 static int rescale_y(int y)
118 return y * GHEIGHT / 200;
123 int local_key_inkey(void)
130 DoMessageStuff(&msg);
135 if (rval == KEY_PRINT_SCREEN) {
139 gr_palette_read(gr_palette);
140 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
145 return 0; //say no key pressed
148 if (check_button_press()) //joystick or mouse button pressed?
152 if ( rval == KEY_Q+KEY_COMMAND )
159 int local_key_inkey(void)
164 if (!GetOSEvent(everyEvent, &event))
167 if (event.what != keyDown)
170 rval = (int)((event.message & keyCodeMask) >> 8);
172 if (rval == KEY_PRINT_SCREEN) {
174 return 0; //say no key pressed
177 if (check_button_press()) //joystick or mouse button pressed?
181 if ( rval == KEY_Q+KEY_COMMAND )
189 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
194 ubyte palette_save[768];
195 char new_filename[FILENAME_LEN+1] = "";
199 strcpy(new_filename,"\x01"); //only read from hog file
202 strcat(new_filename,filename);
203 filename = new_filename;
205 title_bm.bm_data=NULL;
206 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
207 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
208 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));
209 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
212 memcpy(palette_save,gr_palette,sizeof(palette_save));
214 #if defined(POLY_ACC)
216 pa_update_clut(New_pal, 0, 256, 0);
219 //vfx_set_palette_sub( New_pal );
221 gr_palette_load( New_pal );
227 dd_gr_set_current_canvas(NULL),
228 gr_set_current_canvas( NULL )
230 WIN(DDGRLOCK(dd_grd_curcanv));
231 show_fullscr(&title_bm);
232 WIN(DDGRUNLOCK(dd_grd_curcanv));
236 #if defined(POLY_ACC)
240 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
242 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
244 gr_palette_load( New_pal );
245 timer = timer_get_fixed_seconds() + i2f(3);
247 if ( local_key_inkey() && allow_keys ) break;
248 if ( timer_get_fixed_seconds() > timer ) break;
250 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
252 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
253 d_free(title_bm.bm_data);
258 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
261 short text_ulx, text_uly; // upper left x,y of text window
262 short text_width, text_height; // width and height of text window
265 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
266 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
268 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
269 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
272 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
274 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
277 #define MAX_BRIEFING_SCREENS 60
279 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
280 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
282 int Briefing_text_x, Briefing_text_y;
284 void init_char_pos(int x, int y)
288 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
291 grs_canvas *Robot_canv = NULL;
292 vms_angvec Robot_angles;
294 char Bitmap_name[32] = "";
295 #define EXIT_DOOR_MAX 14
296 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
297 #define DOOR_DIV_INIT 6
298 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
300 // -----------------------------------------------------------------------------
301 void show_bitmap_frame(void)
304 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
306 grs_canvas *curcanv_save, *bitmap_canv=0;
309 grs_bitmap *bitmap_ptr;
311 // Only plot every nth frame.
312 if (Door_div_count) {
317 Door_div_count = DOOR_DIV_INIT;
319 if (Bitmap_name[0] != 0) {
323 // Set supertransparency color to black
324 if (!New_pal_254_bash) {
325 New_pal_254_bash = 1;
327 New_pal[254*3+1] = 0;
328 New_pal[254*3+2] = 0;
329 gr_palette_load( New_pal );
332 switch (Animating_bitmap_type) {
335 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
336 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
340 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
341 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break
344 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
345 default: Int3(); // Impossible, illegal value for Animating_bitmap_type
349 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
350 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
353 pound_signp = strchr(Bitmap_name, '#');
354 Assert(pound_signp != NULL);
356 dig1 = *(pound_signp+1);
357 dig2 = *(pound_signp+2);
361 num = (dig1-'0')*10 + (dig2-'0');
363 switch (Animating_bitmap_type) {
366 if (num > EXIT_DOOR_MAX) {
369 } else if (num < 0) {
376 if (num > OTHER_THING_MAX)
383 *(pound_signp+1) = (num / 10) + '0';
384 *(pound_signp+2) = (num % 10) + '0';
385 *(pound_signp+3) = 0;
387 *(pound_signp+1) = (num % 10) + '0';
388 *(pound_signp+2) = 0;
393 bi = piggy_find_bitmap(Bitmap_name);
394 bitmap_ptr = &GameBitmaps[bi.index];
398 WIN(DDGRLOCK(dd_grd_curcanv));
399 gr_bitmapm(0, 0, bitmap_ptr);
400 WIN(DDGRUNLOCK(dd_grd_curcanv));
403 dd_grd_curcanv = curcanv_save,
404 grd_curcanv = curcanv_save
408 switch (Animating_bitmap_type) {
410 if (num == EXIT_DOOR_MAX) {
413 } else if (num == 0) {
425 // -----------------------------------------------------------------------------
426 void show_briefing_bitmap(grs_bitmap *bmp)
429 dd_grs_canvas *bitmap_canv, *curcanv_save;
431 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
432 curcanv_save = dd_grd_curcanv;
433 dd_gr_set_current_canvas(bitmap_canv);
434 DDGRLOCK(dd_grd_curcanv);
436 DDGRUNLOCK(dd_grd_curcanv);
437 dd_gr_set_current_canvas(curcanv_save);
439 grs_canvas *curcanv_save, *bitmap_canv;
441 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
442 curcanv_save = grd_curcanv;
443 gr_set_current_canvas(bitmap_canv);
444 gr_bitmapm(0, 0, bmp);
445 gr_set_current_canvas(curcanv_save);
451 #ifndef ROBOT_MOVIES //WINDOWS
452 // -----------------------------------------------------------------------------
453 void show_spinning_robot_frame(int robot_num)
455 grs_canvas *curcanv_save;
457 if (robot_num != -1) {
458 Robot_angles.h += 150;
460 curcanv_save = grd_curcanv;
461 grd_curcanv = Robot_canv;
462 Assert(Robot_info[robot_num].model_num != -1);
463 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
464 grd_curcanv = curcanv_save;
469 // -----------------------------------------------------------------------------
470 void init_spinning_robot(void) //(int x,int y,int w,int h)
478 int x = rescale_x(138);
479 int y = rescale_y(55);
480 int w = rescale_x(166);
481 int h = rescale_y(138);
484 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
489 // ---------------------------------------------------------------------------
490 // Returns char width.
491 // If show_robot_flag set, then show a frame of the spinning robot.
492 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
496 static fix start_time=0;
499 message[0] = the_char;
502 if (start_time==0 && timer_get_fixed_seconds()<0)
503 start_time=timer_get_fixed_seconds();
505 gr_get_string_size(message, &w, &h, &aw );
507 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
509 // Draw cursor if there is some delay and caller says to draw cursor
510 if (cursor_flag && delay) {
511 WIN(DDGRLOCK(dd_grd_curcanv));
512 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
513 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
514 WIN(DDGRUNLOCK(dd_grd_curcanv));
518 delay=fixdiv (F1_0,i2f(15));
524 if (RobotPlaying && (delay != 0))
527 while (timer_get_fixed_seconds() < (start_time + delay)) {
528 if (RobotPlaying && delay != 0)
533 show_spinning_robot_frame(robot_num);
536 start_time = timer_get_fixed_seconds();
538 WIN(DDGRLOCK(dd_grd_curcanv));
540 if (cursor_flag && delay) {
541 gr_set_fontcolor(Erase_color, -1);
542 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
545 // Draw the character
546 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
547 gr_printf(Briefing_text_x, Briefing_text_y, message );
549 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
550 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
551 WIN(DDGRUNLOCK(dd_grd_curcanv));
553 if (delay) gr_update();
555 // if (the_char != ' ')
556 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
557 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
562 // -----------------------------------------------------------------------------
563 int load_briefing_screen( int screen_num )
567 WIN(DDGRLOCK(dd_grd_curcanv));
568 if ((pcx_error=pcx_read_fullscr( CurBriefScreenName, New_pal ))!=PCX_ERROR_NONE) {
569 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error));
570 printf( "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);
571 WIN(DDGRUNLOCK(dd_grd_curcanv));
572 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
574 WIN(DDGRUNLOCK(dd_grd_curcanv));
581 int load_new_briefing_screen( char *fname )
585 mprintf ((0,"Loading new briefing %s!\n",fname));
586 strcpy (CurBriefScreenName,fname);
588 //WIN(DEFINE_SCREEN(CurBriefScreenName));
590 if (gr_palette_fade_out( New_pal, 32, 0 ))
593 WIN(DDGRLOCK(dd_grd_curcanv));
594 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
595 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
596 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);
597 WIN(DDGRUNLOCK(dd_grd_curcanv));
598 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
600 WIN(DDGRUNLOCK(dd_grd_curcanv));
604 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
606 if (gr_palette_fade_in( New_pal, 32, 0 ))
608 DoBriefingColorStuff();
615 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
617 // -----------------------------------------------------------------------------
618 int get_message_num(char **message)
622 while (**message == ' ')
625 while ((**message >= '0') && (**message <= '9')) {
626 num = 10*num + **message-'0';
630 while (*(*message)++ != 10) // Get and drop eoln
636 // -----------------------------------------------------------------------------
637 void get_message_name(char **message, char *result)
639 while (**message == ' ')
642 while ((**message != ' ') && (**message != 10)) {
643 if (**message != '\n')
644 *result++ = **message;
649 while (*(*message)++ != 10) // Get and drop eoln
655 // -----------------------------------------------------------------------------
656 void flash_cursor(int cursor_flag)
658 if (cursor_flag == 0)
661 WIN(DDGRLOCK(dd_grd_curcanv));
662 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
663 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
665 gr_set_fontcolor(Erase_color, -1);
667 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
668 WIN(DDGRUNLOCK(dd_grd_curcanv));
671 extern int InitMovieBriefing();
673 // -----------------------------------------------------------------------------
674 // Return true if message got aborted by user (pressed ESC), else return false.
675 int show_briefing_message(int screen_num, char *message)
679 briefing_screen *bsp = &Briefing_screens[screen_num];
680 int delay_count = KEY_DELAY_DEFAULT;
684 static int tab_stop=0;
685 int flashing_cursor=0;
686 int new_page=0,GotZ=0;
688 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
693 int hum_channel=-1,printing_channel=-1;
694 int LineAdjustment=1;
695 WIN(int wpage_done=0);
706 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
709 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
710 gr_set_curfont( GAME_FONT );
712 bsp=&Briefing_screens[0];
713 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
720 screen_num=DefineBriefingBox (&message);
721 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
723 bsp = &Briefing_screens[screen_num];
724 init_char_pos(bsp->text_ulx, bsp->text_uly);
726 prev_ch = 10; // read to eoln
727 } else if (ch=='U') {
728 screen_num=get_message_num(&message);
729 bsp = &Briefing_screens[screen_num];
730 init_char_pos(bsp->text_ulx, bsp->text_uly);
731 prev_ch = 10; // read to eoln
732 } else if (ch == 'C') {
733 Current_color = get_message_num(&message)-1;
734 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
736 } else if (ch == 'F') { // toggle flashing cursor
737 flashing_cursor = !flashing_cursor;
739 while (*message++ != 10)
741 } else if (ch == 'T') {
742 tab_stop = get_message_num(&message);
743 tab_stop*=(1+MenuHires);
744 prev_ch = 10; // read to eoln
745 } else if (ch == 'R') {
746 if (Robot_canv != NULL) {
757 spinRobotName[2]=kludge; // ugly but proud
759 RobotPlaying=InitRobotMovie(spinRobotName);
761 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
764 DoBriefingColorStuff ();
765 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
768 init_spinning_robot();
769 robot_num = get_message_num(&message);
771 prev_ch = 10; // read to eoln
772 } else if (ch == 'N') {
773 //--grs_bitmap *bitmap_ptr;
774 if (Robot_canv != NULL) {
779 get_message_name(&message, Bitmap_name);
780 strcat(Bitmap_name, "#0");
781 Animating_bitmap_type = 0;
783 } else if (ch == 'O') {
784 if (Robot_canv != NULL) {
789 get_message_name(&message, Bitmap_name);
790 strcat(Bitmap_name, "#0");
791 Animating_bitmap_type = 1;
793 } else if (ch=='A') {
794 LineAdjustment=1-LineAdjustment;
795 } else if (ch=='Z') {
796 //mprintf ((0,"Got a Z!\n"));
798 #if defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
801 if (LineAdjustment==1)
808 while ((fname[i]=*message) != '\n') {
818 while (fname[i]!='.')
819 fname2[i] = fname[i++];
829 load_new_briefing_screen (cfexist(fname2)?fname2:fname);
831 load_new_briefing_screen (fname);
833 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
835 } else if (ch == 'B') {
836 char bitmap_name[32];
837 grs_bitmap guy_bitmap;
838 ubyte temp_palette[768];
841 if (Robot_canv != NULL) {
846 get_message_name(&message, bitmap_name);
847 strcat(bitmap_name, ".bbm");
848 guy_bitmap.bm_data = NULL;
849 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
850 Assert(iff_error == IFF_NO_ERROR);
851 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
853 show_briefing_bitmap(&guy_bitmap);
854 d_free(guy_bitmap.bm_data);
856 // } else if (ch==EOF) {
858 // } else if (ch == 'B') {
859 // if (Robot_canv != NULL) {
860 // d_free(Robot_canv);
864 // bitmap_num = get_message_num(&message);
865 // if (bitmap_num != -1)
866 // show_briefing_bitmap(Textures[bitmap_num]);
867 // prev_ch = 10; // read to eoln
868 } else if (ch == 'S') {
873 if (printing_channel>-1)
874 digi_stop_sound( printing_channel );
884 start_time = timer_get_fixed_seconds();
885 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
888 _RedrawScreen = FALSE;
889 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
895 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
897 flash_cursor(flashing_cursor);
903 show_spinning_robot_frame(robot_num);
907 start_time += KEY_DELAY_DEFAULT/2;
911 if (keypress == KEY_BACKSP)
914 if (keypress == KEY_ESC)
920 } else if (ch == 'P') { // New page.
922 Int3(); // Hey ryan!!!! You gotta load a screen before you start
923 // printing to it! You know, $Z !!!
924 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
928 while (*message != 10) {
929 message++; // drop carriage return after special escape sequence
935 } else if (ch == '\t') { // Tab
936 if (Briefing_text_x - bsp->text_ulx < tab_stop)
937 Briefing_text_x = bsp->text_ulx + tab_stop;
938 } else if ((ch == ';') && (prev_ch == 10)) {
939 while (*message++ != 10)
942 } else if (ch == '\\') {
944 } else if (ch == 10) {
945 if (prev_ch != '\\') {
947 if (1) //DumbAdjust==0)
948 Briefing_text_y += (8*(MenuHires+1));
951 Briefing_text_x = bsp->text_ulx;
952 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
953 load_briefing_screen(screen_num);
954 Briefing_text_x = bsp->text_ulx;
955 Briefing_text_y = bsp->text_uly;
958 if (ch == 13) //Can this happen? Above says ch==10
965 Int3(); // Hey ryan!!!! You gotta load a screen before you start
966 // printing to it! You know, $Z !!!
967 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
973 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
977 WIN(if (GRMODEINFO(emul)) delay_count = 0);
979 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
983 // Check for Esc -> abort.
985 key_check=local_key_inkey();
991 _RedrawScreen = FALSE;
992 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
996 if ( key_check == KEY_ESC ) {
1001 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1004 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1005 Briefing_text_x = bsp->text_ulx;
1006 Briefing_text_y += bsp->text_uly;
1009 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1015 if (printing_channel>-1)
1016 digi_stop_sound( printing_channel );
1017 printing_channel=-1;
1028 start_time = timer_get_fixed_seconds();
1029 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1031 if (_RedrawScreen) {
1032 _RedrawScreen = FALSE;
1033 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1039 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1041 flash_cursor(flashing_cursor);
1046 show_spinning_robot_frame(robot_num);
1048 show_bitmap_frame();
1049 start_time += KEY_DELAY_DEFAULT/2;
1060 if (keypress == KEY_BACKSP)
1063 if (keypress == KEY_ESC) {
1068 load_briefing_screen(screen_num);
1069 Briefing_text_x = bsp->text_ulx;
1070 Briefing_text_y = bsp->text_uly;
1071 delay_count = KEY_DELAY_DEFAULT;
1073 WIN(wpage_done = 0);
1084 if (Robot_canv != NULL)
1085 {d_free(Robot_canv); Robot_canv=NULL;}
1088 digi_stop_sound( hum_channel );
1089 if (printing_channel>-1)
1090 digi_stop_sound( printing_channel );
1095 // -----------------------------------------------------------------------------
1096 // Return a pointer to the start of text for screen #screen_num.
1097 char * get_briefing_message(int screen_num)
1099 char *tptr = Briefing_text;
1103 Assert(screen_num >= 0);
1105 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1110 cur_screen = get_message_num(&tptr);
1114 if (screen_num!=cur_screen)
1120 // -----------------------------------------------------------------------------
1121 // Load Descent briefing text.
1122 int load_screen_text(char *filename, char **buf)
1127 int have_binary = 0;
1129 if ((tfile = cfopen(filename,"rb")) == NULL) {
1130 char nfilename[30], *ptr;
1132 strcpy(nfilename, filename);
1133 ptr = strrchr(nfilename, '.');
1135 strcat(nfilename, ".txb");
1136 if ((ifile = cfopen(nfilename, "rb")) == NULL)
1138 mprintf ((0,"can't open %s!\n",nfilename));
1140 //Error("Cannot open file %s or %s", filename, nfilename);
1143 mprintf ((0,"reading...\n"));
1146 len = cfilelength(ifile);
1147 MALLOC(*buf, char, len+500);
1148 mprintf ((0,"len=%d\n",len));
1149 for (x=0,i=0;i<len;i++,x++)
1151 cfread (*buf+x,1,1,ifile);
1152 // mprintf ((0,"%c",*(*buf+x)));
1159 len = cfilelength(tfile);
1160 MALLOC(*buf, char, len+500);
1161 for (x=0,i=0;i<len;i++,x++)
1163 cfread (*buf+x,1,1,tfile);
1164 // mprintf ((0,"%c",*(*buf+x)));
1170 //cfread(*buf, 1, len, tfile);
1177 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1179 encode_rotate_left(ptr);
1180 *ptr = *ptr ^ BITMAP_TBL_XOR;
1181 encode_rotate_left(ptr);
1189 //-----------------------------------------------------------------------------
1190 // Return true if message got aborted, else return false.
1191 int show_briefing_text(int screen_num)
1195 message_ptr = get_briefing_message(screen_num);
1196 if (message_ptr==NULL)
1199 DoBriefingColorStuff();
1201 return show_briefing_message(screen_num, message_ptr);
1204 void DoBriefingColorStuff ()
1206 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1207 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1209 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1210 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1212 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1213 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1215 Erase_color = gr_find_closest_color_current(0, 0, 0);
1218 //-----------------------------------------------------------------------------
1219 // Return true if screen got aborted by user, else return false.
1220 int show_briefing_screen( int screen_num, int allow_keys)
1223 ubyte palette_save[768];
1225 New_pal_254_bash = 0;
1227 if (Skip_briefing_screens) {
1228 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1232 // briefing_bm.bm_data=NULL;
1233 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1234 // mprintf((0, "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n","Brief03.pcx", pcx_errormsg(pcx_error), pcx_error));
1239 memcpy(palette_save,gr_palette,sizeof(palette_save));
1240 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1243 // vfx_set_palette_sub( New_pal );
1244 // gr_palette_clear();
1245 // gr_bitmap( 0, 0, &briefing_bm );
1247 gr_palette_load(New_pal);
1250 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1252 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1255 key_close(); // kill the keyboard handler during briefing screens for movies
1257 rval = show_briefing_text(screen_num);
1262 #if defined (MACINTOSH) || defined(WINDOWS)
1263 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 DEFINE_SCREEN(NULL);
1272 WIN(DDGRLOCK(dd_grd_curcanv));
1273 gr_clear_canvas (0);
1274 WIN(DDGRUNLOCK(dd_grd_curcanv));
1275 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1279 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1281 // d_free(briefing_bm.bm_data);
1287 // -----------------------------------------------------------------------------
1288 void do_briefing_screens(char *filename,int level_num)
1293 if (Skip_briefing_screens) {
1294 mprintf((0, "Skipping all briefing screens.\n"));
1299 return; // no briefing screens at all for demo
1302 mprintf ((0,"Trying briefing screen! %s\n",filename));
1305 filename = Briefing_text_filename[0];
1310 if (!load_screen_text(filename, &Briefing_text))
1314 songs_play_song( SONG_BRIEFING, 1 );
1319 set_screen_mode( SCREEN_MENU );
1322 dd_gr_set_current_canvas(NULL),
1323 gr_set_current_canvas(NULL)
1326 mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num));
1330 show_briefing_screen(level_num,0);
1332 d_free (Briefing_text);
1339 int DefineBriefingBox (char **buf)
1344 n=get_new_message_num (buf);
1346 Assert(n < MAX_BRIEFING_SCREENS);
1354 name[i]='\0'; // slap a delimiter on this guy
1356 strcpy (Briefing_screens[n].bs_name,name);
1357 Briefing_screens[n].level_num=get_new_message_num (buf);
1358 Briefing_screens[n].message_num=get_new_message_num (buf);
1359 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1360 Briefing_screens[n].text_uly=get_new_message_num (buf);
1361 Briefing_screens[n].text_width=get_new_message_num (buf);
1362 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1366 Briefing_screens[n].text_ulx*=2;
1367 Briefing_screens[n].text_uly*=2.4;
1368 Briefing_screens[n].text_width*=2;
1369 Briefing_screens[n].text_height*=2.4;
1375 int get_new_message_num(char **message)
1379 while (**message == ' ')
1382 while ((**message >= '0') && (**message <= '9')) {
1383 num = 10*num + **message-'0';