1 /* $Id: titles.c,v 1.9 2002-08-06 09:30:24 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 #define SHAREWARE_ENDING_FILENAME "ending.tex"
94 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
95 int Skip_briefing_screens=0;
96 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
97 int Current_color = 0;
100 extern int check_button_press();
103 extern void macintosh_quit(void);
107 static int rescale_x(int x)
109 return x * GWIDTH / 320;
112 static int rescale_y(int y)
114 return y * GHEIGHT / 200;
119 int local_key_inkey(void)
126 DoMessageStuff(&msg);
131 if (rval == KEY_PRINT_SCREEN) {
135 gr_palette_read(gr_palette);
136 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
141 return 0; //say no key pressed
144 if (check_button_press()) //joystick or mouse button pressed?
148 if ( rval == KEY_Q+KEY_COMMAND )
155 int local_key_inkey(void)
160 if (!GetOSEvent(everyEvent, &event))
163 if (event.what != keyDown)
166 rval = (int)((event.message & keyCodeMask) >> 8);
168 if (rval == KEY_PRINT_SCREEN) {
170 return 0; //say no key pressed
173 if (check_button_press()) //joystick or mouse button pressed?
177 if ( rval == KEY_Q+KEY_COMMAND )
185 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
190 ubyte palette_save[768];
191 char new_filename[FILENAME_LEN+1] = "";
195 strcpy(new_filename,"\x01"); //only read from hog file
198 strcat(new_filename,filename);
199 filename = new_filename;
201 title_bm.bm_data=NULL;
202 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
203 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
204 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));
205 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
208 memcpy(palette_save,gr_palette,sizeof(palette_save));
210 #if defined(POLY_ACC)
212 pa_update_clut(New_pal, 0, 256, 0);
215 //vfx_set_palette_sub( New_pal );
217 gr_palette_load( New_pal );
223 dd_gr_set_current_canvas(NULL),
224 gr_set_current_canvas( NULL )
226 WIN(DDGRLOCK(dd_grd_curcanv));
227 show_fullscr(&title_bm);
228 WIN(DDGRUNLOCK(dd_grd_curcanv));
232 #if defined(POLY_ACC)
236 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
238 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
240 gr_palette_load( New_pal );
241 timer = timer_get_fixed_seconds() + i2f(3);
243 if ( local_key_inkey() && allow_keys ) break;
244 if ( timer_get_fixed_seconds() > timer ) break;
246 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
248 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
249 d_free(title_bm.bm_data);
254 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
257 short text_ulx, text_uly; // upper left x,y of text window
258 short text_width, text_height; // width and height of text window
261 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
262 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
264 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
265 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
268 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
270 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
273 #define MAX_BRIEFING_SCREENS 60
275 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
276 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
278 int Briefing_text_x, Briefing_text_y;
280 void init_char_pos(int x, int y)
284 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
287 grs_canvas *Robot_canv = NULL;
288 vms_angvec Robot_angles;
290 char Bitmap_name[32] = "";
291 #define EXIT_DOOR_MAX 14
292 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
293 #define DOOR_DIV_INIT 6
294 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
296 // -----------------------------------------------------------------------------
297 void show_bitmap_frame(void)
300 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
302 grs_canvas *curcanv_save, *bitmap_canv=0;
305 grs_bitmap *bitmap_ptr;
307 // Only plot every nth frame.
308 if (Door_div_count) {
313 Door_div_count = DOOR_DIV_INIT;
315 if (Bitmap_name[0] != 0) {
319 // Set supertransparency color to black
320 if (!New_pal_254_bash) {
321 New_pal_254_bash = 1;
323 New_pal[254*3+1] = 0;
324 New_pal[254*3+2] = 0;
325 gr_palette_load( New_pal );
328 switch (Animating_bitmap_type) {
331 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
332 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
336 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
337 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break
340 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
341 default: Int3(); // Impossible, illegal value for Animating_bitmap_type
345 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
346 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
349 pound_signp = strchr(Bitmap_name, '#');
350 Assert(pound_signp != NULL);
352 dig1 = *(pound_signp+1);
353 dig2 = *(pound_signp+2);
357 num = (dig1-'0')*10 + (dig2-'0');
359 switch (Animating_bitmap_type) {
362 if (num > EXIT_DOOR_MAX) {
365 } else if (num < 0) {
372 if (num > OTHER_THING_MAX)
379 *(pound_signp+1) = (num / 10) + '0';
380 *(pound_signp+2) = (num % 10) + '0';
381 *(pound_signp+3) = 0;
383 *(pound_signp+1) = (num % 10) + '0';
384 *(pound_signp+2) = 0;
389 bi = piggy_find_bitmap(Bitmap_name);
390 bitmap_ptr = &GameBitmaps[bi.index];
394 WIN(DDGRLOCK(dd_grd_curcanv));
395 gr_bitmapm(0, 0, bitmap_ptr);
396 WIN(DDGRUNLOCK(dd_grd_curcanv));
399 dd_grd_curcanv = curcanv_save,
400 grd_curcanv = curcanv_save
404 switch (Animating_bitmap_type) {
406 if (num == EXIT_DOOR_MAX) {
409 } else if (num == 0) {
421 // -----------------------------------------------------------------------------
422 void show_briefing_bitmap(grs_bitmap *bmp)
425 dd_grs_canvas *bitmap_canv, *curcanv_save;
427 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
428 curcanv_save = dd_grd_curcanv;
429 dd_gr_set_current_canvas(bitmap_canv);
430 DDGRLOCK(dd_grd_curcanv);
432 DDGRUNLOCK(dd_grd_curcanv);
433 dd_gr_set_current_canvas(curcanv_save);
435 grs_canvas *curcanv_save, *bitmap_canv;
437 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
438 curcanv_save = grd_curcanv;
439 gr_set_current_canvas(bitmap_canv);
440 gr_bitmapm(0, 0, bmp);
441 gr_set_current_canvas(curcanv_save);
447 #ifndef ROBOT_MOVIES //WINDOWS
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)
474 int x = rescale_x(138);
475 int y = rescale_y(55);
476 int w = rescale_x(166);
477 int h = rescale_y(138);
480 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
485 // -----------------------------------------------------------------------------
486 // Returns char width.
487 // If show_robot_flag set, then show a frame of the spinning robot.
488 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
492 static fix start_time=0;
495 message[0] = the_char;
498 if (start_time==0 && timer_get_fixed_seconds()<0)
499 start_time=timer_get_fixed_seconds();
501 gr_get_string_size(message, &w, &h, &aw );
503 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
505 // Draw cursor if there is some delay and caller says to draw cursor
506 if (cursor_flag && delay) {
507 WIN(DDGRLOCK(dd_grd_curcanv));
508 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
509 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
510 WIN(DDGRUNLOCK(dd_grd_curcanv));
514 delay=fixdiv (F1_0,i2f(15));
520 if (RobotPlaying && (delay != 0))
524 while (timer_get_fixed_seconds() < (start_time + delay)) {
525 if (RobotPlaying && delay != 0)
530 show_spinning_robot_frame(robot_num);
532 start_time = timer_get_fixed_seconds();
534 WIN(DDGRLOCK(dd_grd_curcanv));
536 if (cursor_flag && delay) {
537 gr_set_fontcolor(Erase_color, -1);
538 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
541 // Draw the character
542 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
543 gr_printf(Briefing_text_x, Briefing_text_y, message );
545 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
546 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
547 WIN(DDGRUNLOCK(dd_grd_curcanv));
549 // if (the_char != ' ')
550 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
551 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
556 // -----------------------------------------------------------------------------
557 int load_briefing_screen( int screen_num )
561 WIN(DDGRLOCK(dd_grd_curcanv));
562 if ((pcx_error=pcx_read_fullscr( CurBriefScreenName, New_pal ))!=PCX_ERROR_NONE) {
563 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));
564 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);
565 WIN(DDGRUNLOCK(dd_grd_curcanv));
566 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
568 WIN(DDGRUNLOCK(dd_grd_curcanv));
575 int load_new_briefing_screen( char *fname )
579 mprintf ((0,"Loading new briefing %s!\n",fname));
580 strcpy (CurBriefScreenName,fname);
582 //WIN(DEFINE_SCREEN(CurBriefScreenName));
584 if (gr_palette_fade_out( New_pal, 32, 0 ))
587 WIN(DDGRLOCK(dd_grd_curcanv));
588 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
589 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);
590 WIN(DDGRUNLOCK(dd_grd_curcanv));
591 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
593 WIN(DDGRUNLOCK(dd_grd_curcanv));
597 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
599 if (gr_palette_fade_in( New_pal, 32, 0 ))
601 DoBriefingColorStuff();
608 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
610 // -----------------------------------------------------------------------------
611 int get_message_num(char **message)
615 while (**message == ' ')
618 while ((**message >= '0') && (**message <= '9')) {
619 num = 10*num + **message-'0';
623 while (*(*message)++ != 10) // Get and drop eoln
629 // -----------------------------------------------------------------------------
630 void get_message_name(char **message, char *result)
632 while (**message == ' ')
635 while ((**message != ' ') && (**message != 10)) {
636 if (**message != '\n')
637 *result++ = **message;
642 while (*(*message)++ != 10) // Get and drop eoln
648 // -----------------------------------------------------------------------------
649 void flash_cursor(int cursor_flag)
651 if (cursor_flag == 0)
654 WIN(DDGRLOCK(dd_grd_curcanv));
655 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
656 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
658 gr_set_fontcolor(Erase_color, -1);
660 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
661 WIN(DDGRUNLOCK(dd_grd_curcanv));
664 extern int InitMovieBriefing();
666 // -----------------------------------------------------------------------------
667 // Return true if message got aborted by user (pressed ESC), else return false.
668 int show_briefing_message(int screen_num, char *message)
672 briefing_screen *bsp = &Briefing_screens[screen_num];
673 int delay_count = KEY_DELAY_DEFAULT;
677 static int tab_stop=0;
678 int flashing_cursor=0;
679 int new_page=0,GotZ=0;
681 char *spinRobotName="rba.mve",kludge; // matt don't change this!
686 int hum_channel=-1,printing_channel=-1;
687 int LineAdjustment=0;
688 WIN(int wpage_done=0);
699 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
702 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
703 gr_set_curfont( GAME_FONT );
705 bsp=&Briefing_screens[0];
706 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
714 screen_num=DefineBriefingBox (&message);
715 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
717 bsp = &Briefing_screens[screen_num];
718 init_char_pos(bsp->text_ulx, bsp->text_uly);
720 prev_ch = 10; // read to eoln
724 screen_num=get_message_num(&message);
725 bsp = &Briefing_screens[screen_num];
726 init_char_pos(bsp->text_ulx, bsp->text_uly);
727 prev_ch = 10; // read to eoln
730 else if (ch == 'C') {
731 Current_color = get_message_num(&message)-1;
732 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
734 } else if (ch == 'F') { // toggle flashing cursor
735 flashing_cursor = !flashing_cursor;
737 while (*message++ != 10)
739 } else if (ch == 'T') {
740 tab_stop = get_message_num(&message);
741 tab_stop*=(1+MenuHires);
742 prev_ch = 10; // read to eoln
743 } else if (ch == 'R') {
744 if (Robot_canv != NULL) {
755 spinRobotName[2]=kludge; // ugly but proud
757 RobotPlaying=InitRobotMovie(spinRobotName);
759 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
762 DoBriefingColorStuff ();
763 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
766 init_spinning_robot();
767 robot_num = get_message_num(&message);
769 prev_ch = 10; // read to eoln
770 } else if (ch == 'N') {
771 //--grs_bitmap *bitmap_ptr;
772 if (Robot_canv != NULL)
773 {d_free(Robot_canv); Robot_canv=NULL;}
775 get_message_name(&message, Bitmap_name);
776 strcat(Bitmap_name, "#0");
777 Animating_bitmap_type = 0;
779 } else if (ch == 'O') {
780 if (Robot_canv != NULL)
781 {d_free(Robot_canv); Robot_canv=NULL;}
783 get_message_name(&message, Bitmap_name);
784 strcat(Bitmap_name, "#0");
785 Animating_bitmap_type = 1;
787 } else if (ch=='A') {
788 LineAdjustment=1-LineAdjustment;
789 } else if (ch=='Z') {
790 mprintf ((0,"Got a Z!\n"));
792 #if defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
795 if (LineAdjustment==1)
802 while ((fname[i]=*message) != '\n') {
812 while (fname[i]!='.')
813 fname2[i] = fname[i++];
823 load_new_briefing_screen (cfexist(fname2)?fname2:fname);
825 load_new_briefing_screen (fname);
827 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
829 } else if (ch == 'B') {
830 char bitmap_name[32];
831 grs_bitmap guy_bitmap;
832 ubyte temp_palette[768];
835 if (Robot_canv != NULL)
836 {d_free(Robot_canv); 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); Robot_canv=NULL;}
854 // bitmap_num = get_message_num(&message);
855 // if (bitmap_num != -1)
856 // show_briefing_bitmap(Textures[bitmap_num]);
857 // prev_ch = 10; // read to eoln
858 } else if (ch == 'S') {
863 if (printing_channel>-1)
864 digi_stop_sound( printing_channel );
874 start_time = timer_get_fixed_seconds();
875 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
878 _RedrawScreen = FALSE;
879 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
885 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
887 flash_cursor(flashing_cursor);
890 if (RobotPlaying) RotateRobot ();
892 show_spinning_robot_frame(robot_num);
896 start_time += KEY_DELAY_DEFAULT/2;
900 if (keypress == KEY_BACKSP)
903 if (keypress == KEY_ESC)
909 } else if (ch == 'P') { // New page.
912 Int3(); // Hey ryan!!!! You gotta load a screen before you start
913 // printing to it! You know, $Z !!!
914 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
919 while (*message != 10) {
920 message++; // drop carriage return after special escape sequence
925 } else if (ch == '\t') { // Tab
926 if (Briefing_text_x - bsp->text_ulx < tab_stop)
927 Briefing_text_x = bsp->text_ulx + tab_stop;
928 } else if ((ch == ';') && (prev_ch == 10)) {
929 while (*message++ != 10)
932 } else if (ch == '\\') {
934 } else if (ch == 10) {
935 if (prev_ch != '\\') {
938 Briefing_text_y += (8*(MenuHires+1));
941 Briefing_text_x = bsp->text_ulx;
942 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
943 load_briefing_screen(screen_num);
944 Briefing_text_x = bsp->text_ulx;
945 Briefing_text_y = bsp->text_uly;
948 if (ch == 13) //Can this happen? Above says ch==10
956 Int3(); // Hey ryan!!!! You gotta load a screen before you start
957 // printing to it! You know, $Z !!!
958 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
965 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
969 WIN(if (GRMODEINFO(emul)) delay_count = 0);
971 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
975 // Check for Esc -> abort.
976 key_check = local_key_inkey();
980 _RedrawScreen = FALSE;
981 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
985 if ( key_check == KEY_ESC ) {
990 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
993 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
994 Briefing_text_x = bsp->text_ulx;
995 Briefing_text_y += bsp->text_uly;
998 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1004 if (printing_channel>-1)
1005 digi_stop_sound( printing_channel );
1006 printing_channel=-1;
1017 start_time = timer_get_fixed_seconds();
1018 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1020 if (_RedrawScreen) {
1021 _RedrawScreen = FALSE;
1022 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1028 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1030 flash_cursor(flashing_cursor);
1032 if (RobotPlaying) RotateRobot();
1034 show_spinning_robot_frame(robot_num);
1036 show_bitmap_frame();
1037 start_time += KEY_DELAY_DEFAULT/2;
1041 if (RobotPlaying) DeInitRobotMovie();
1047 if (keypress == KEY_BACKSP)
1050 if (keypress == KEY_ESC) {
1055 load_briefing_screen(screen_num);
1056 Briefing_text_x = bsp->text_ulx;
1057 Briefing_text_y = bsp->text_uly;
1058 delay_count = KEY_DELAY_DEFAULT;
1060 WIN(wpage_done = 0);
1071 if (Robot_canv != NULL)
1072 {d_free(Robot_canv); Robot_canv=NULL;}
1075 digi_stop_sound( hum_channel );
1076 if (printing_channel>-1)
1077 digi_stop_sound( printing_channel );
1082 // -----------------------------------------------------------------------------
1083 // Return a pointer to the start of text for screen #screen_num.
1084 char * get_briefing_message(int screen_num)
1086 char *tptr = Briefing_text;
1090 Assert(screen_num >= 0);
1092 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1097 cur_screen = get_message_num(&tptr);
1101 if (screen_num!=cur_screen)
1107 // -----------------------------------------------------------------------------
1108 // Load Descent briefing text.
1109 int load_screen_text(char *filename, char **buf)
1114 int have_binary = 0;
1116 if ((tfile = cfopen(filename,"rb")) == NULL) {
1117 char nfilename[30], *ptr;
1119 strcpy(nfilename, filename);
1120 ptr = strrchr(nfilename, '.');
1122 strcat(nfilename, ".txb");
1123 if ((ifile = cfopen(nfilename, "rb")) == NULL)
1125 mprintf ((0,"can't open %s!\n",nfilename));
1127 //Error("Cannot open file %s or %s", filename, nfilename);
1130 mprintf ((0,"reading...\n"));
1133 len = cfilelength(ifile);
1134 MALLOC(*buf, char, len+500);
1135 mprintf ((0,"len=%d\n",len));
1136 for (x=0,i=0;i<len;i++,x++)
1138 cfread (*buf+x,1,1,ifile);
1139 // mprintf ((0,"%c",*(*buf+x)));
1146 len = cfilelength(tfile);
1147 MALLOC(*buf, char, len+500);
1148 for (x=0,i=0;i<len;i++,x++)
1150 cfread (*buf+x,1,1,tfile);
1151 // mprintf ((0,"%c",*(*buf+x)));
1157 //cfread(*buf, 1, len, tfile);
1164 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1166 encode_rotate_left(ptr);
1167 *ptr = *ptr ^ BITMAP_TBL_XOR;
1168 encode_rotate_left(ptr);
1176 // -----------------------------------------------------------------------------
1177 // Return true if message got aborted, else return false.
1178 int show_briefing_text(int screen_num)
1182 message_ptr = get_briefing_message(screen_num);
1183 if (message_ptr==NULL)
1186 DoBriefingColorStuff();
1188 return show_briefing_message(screen_num, message_ptr);
1190 void DoBriefingColorStuff ()
1192 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1193 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1195 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1196 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1198 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1199 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1201 Erase_color = gr_find_closest_color_current(0, 0, 0);
1204 // -----------------------------------------------------------------------------
1205 // Return true if screen got aborted by user, else return false.
1206 int show_briefing_screen( int screen_num, int allow_keys)
1209 ubyte palette_save[768];
1211 New_pal_254_bash = 0;
1213 if (Skip_briefing_screens) {
1214 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1218 // briefing_bm.bm_data=NULL;
1219 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1220 // 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));
1225 memcpy(palette_save,gr_palette,sizeof(palette_save));
1226 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1229 // vfx_set_palette_sub( New_pal );
1230 // gr_palette_clear();
1231 // gr_bitmap( 0, 0, &briefing_bm );
1233 gr_palette_load(New_pal);
1236 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1238 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1241 key_close(); // kill the keyboard handler during briefing screens for movies
1243 rval = show_briefing_text(screen_num);
1248 #if defined (MACINTOSH) || defined(WINDOWS)
1249 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1254 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1257 DEFINE_SCREEN(NULL);
1258 WIN(DDGRLOCK(dd_grd_curcanv));
1259 gr_clear_canvas (0);
1260 WIN(DDGRUNLOCK(dd_grd_curcanv));
1261 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1265 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1267 // d_free(briefing_bm.bm_data);
1273 // -----------------------------------------------------------------------------
1274 void do_briefing_screens(char *filename,int level_num)
1279 if (Skip_briefing_screens) {
1280 mprintf((0, "Skipping all briefing screens.\n"));
1285 return; // no briefing screens at all for demo
1288 mprintf ((0,"Trying briefing screen! %s\n",filename));
1293 if (!load_screen_text(filename, &Briefing_text))
1297 songs_play_song( SONG_BRIEFING, 1 );
1302 set_screen_mode( SCREEN_MENU );
1305 dd_gr_set_current_canvas(NULL),
1306 gr_set_current_canvas(NULL)
1309 mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num));
1313 show_briefing_screen(level_num,0);
1315 d_free (Briefing_text);
1322 int DefineBriefingBox (char **buf)
1327 n=get_new_message_num (buf);
1329 Assert(n < MAX_BRIEFING_SCREENS);
1337 name[i]='\0'; // slap a delimiter on this guy
1339 strcpy (Briefing_screens[n].bs_name,name);
1340 Briefing_screens[n].level_num=get_new_message_num (buf);
1341 Briefing_screens[n].message_num=get_new_message_num (buf);
1342 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1343 Briefing_screens[n].text_uly=get_new_message_num (buf);
1344 Briefing_screens[n].text_width=get_new_message_num (buf);
1345 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1349 Briefing_screens[n].text_ulx*=2;
1350 Briefing_screens[n].text_uly*=2.4;
1351 Briefing_screens[n].text_width*=2;
1352 Briefing_screens[n].text_height*=2.4;
1358 int get_new_message_num(char **message)
1362 while (**message == ' ')
1365 while ((**message >= '0') && (**message <= '9')) {
1366 num = 10*num + **message-'0';