2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
32 #include "pa_enabl.h" //$$POLY_ACC
69 extern void RotateRobot();
72 void DoBriefingColorStuff ();
73 int get_new_message_num(char **message);
74 int DefineBriefingBox (char **buf);
76 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
78 extern int MVEPaletteCalls;
83 char CurBriefScreenName[15]="brief03.pcx";
89 #define MAX_BRIEFING_COLORS 3
91 #define SHAREWARE_ENDING_FILENAME "ending.tex"
93 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
94 int Skip_briefing_screens=0;
95 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
96 int Current_color = 0;
99 extern int check_button_press();
102 extern void macintosh_quit(void);
106 static int rescale_x(int x)
108 return x * GWIDTH / 320;
111 static int rescale_y(int y)
113 return y * GHEIGHT / 200;
118 int local_key_inkey(void)
125 DoMessageStuff(&msg);
130 if (rval == KEY_PRINT_SCREEN) {
134 gr_palette_read(gr_palette);
135 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
140 return 0; //say no key pressed
143 if (check_button_press()) //joystick or mouse button pressed?
147 if ( rval == KEY_Q+KEY_COMMAND )
154 int local_key_inkey(void)
159 if (!GetOSEvent(everyEvent, &event))
162 if (event.what != keyDown)
165 rval = (int)((event.message & keyCodeMask) >> 8);
167 if (rval == KEY_PRINT_SCREEN) {
169 return 0; //say no key pressed
172 if (check_button_press()) //joystick or mouse button pressed?
176 if ( rval == KEY_Q+KEY_COMMAND )
184 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
189 ubyte palette_save[768];
190 char new_filename[FILENAME_LEN+1] = "";
194 strcpy(new_filename,"\x01"); //only read from hog file
197 strcat(new_filename,filename);
198 filename = new_filename;
200 title_bm.bm_data=NULL;
201 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
202 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
203 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));
204 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
207 memcpy(palette_save,gr_palette,sizeof(palette_save));
209 #if defined(POLY_ACC)
211 pa_update_clut(New_pal, 0, 256, 0);
214 //vfx_set_palette_sub( New_pal );
216 gr_palette_load( New_pal );
222 dd_gr_set_current_canvas(NULL),
223 gr_set_current_canvas( NULL )
225 WIN(DDGRLOCK(dd_grd_curcanv));
226 gr_bitmap( 0, 0, &title_bm );
227 WIN(DDGRUNLOCK(dd_grd_curcanv));
231 #if defined(POLY_ACC)
235 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
237 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
239 gr_palette_load( New_pal );
240 timer = timer_get_fixed_seconds() + i2f(3);
242 if ( local_key_inkey() && allow_keys ) break;
243 if ( timer_get_fixed_seconds() > timer ) break;
245 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
247 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
248 d_free(title_bm.bm_data);
253 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
256 short text_ulx, text_uly; // upper left x,y of text window
257 short text_width, text_height; // width and height of text window
260 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
261 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
263 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
264 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
267 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
269 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
272 #define MAX_BRIEFING_SCREENS 60
274 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
275 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
277 int Briefing_text_x, Briefing_text_y;
279 void init_char_pos(int x, int y)
283 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
286 grs_canvas *Robot_canv = NULL;
287 vms_angvec Robot_angles;
289 char Bitmap_name[32] = "";
290 #define EXIT_DOOR_MAX 14
291 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
292 #define DOOR_DIV_INIT 6
293 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
295 // -----------------------------------------------------------------------------
296 void show_bitmap_frame(void)
299 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
301 grs_canvas *curcanv_save, *bitmap_canv=0;
304 grs_bitmap *bitmap_ptr;
306 // Only plot every nth frame.
307 if (Door_div_count) {
312 Door_div_count = DOOR_DIV_INIT;
314 if (Bitmap_name[0] != 0) {
318 // Set supertransparency color to black
319 if (!New_pal_254_bash) {
320 New_pal_254_bash = 1;
322 New_pal[254*3+1] = 0;
323 New_pal[254*3+2] = 0;
324 gr_palette_load( New_pal );
327 switch (Animating_bitmap_type) {
330 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
331 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
335 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
336 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break
339 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
340 default: Int3(); // Impossible, illegal value for Animating_bitmap_type
344 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
345 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
348 pound_signp = strchr(Bitmap_name, '#');
349 Assert(pound_signp != NULL);
351 dig1 = *(pound_signp+1);
352 dig2 = *(pound_signp+2);
356 num = (dig1-'0')*10 + (dig2-'0');
358 switch (Animating_bitmap_type) {
361 if (num > EXIT_DOOR_MAX) {
364 } else if (num < 0) {
371 if (num > OTHER_THING_MAX)
378 *(pound_signp+1) = (num / 10) + '0';
379 *(pound_signp+2) = (num % 10) + '0';
380 *(pound_signp+3) = 0;
382 *(pound_signp+1) = (num % 10) + '0';
383 *(pound_signp+2) = 0;
388 bi = piggy_find_bitmap(Bitmap_name);
389 bitmap_ptr = &GameBitmaps[bi.index];
393 WIN(DDGRLOCK(dd_grd_curcanv));
394 gr_bitmapm(0, 0, bitmap_ptr);
395 WIN(DDGRUNLOCK(dd_grd_curcanv));
398 dd_grd_curcanv = curcanv_save,
399 grd_curcanv = curcanv_save
403 switch (Animating_bitmap_type) {
405 if (num == EXIT_DOOR_MAX) {
408 } else if (num == 0) {
420 // -----------------------------------------------------------------------------
421 void show_briefing_bitmap(grs_bitmap *bmp)
424 dd_grs_canvas *bitmap_canv, *curcanv_save;
426 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
427 curcanv_save = dd_grd_curcanv;
428 dd_gr_set_current_canvas(bitmap_canv);
429 DDGRLOCK(dd_grd_curcanv);
431 DDGRUNLOCK(dd_grd_curcanv);
432 dd_gr_set_current_canvas(curcanv_save);
434 grs_canvas *curcanv_save, *bitmap_canv;
436 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
437 curcanv_save = grd_curcanv;
438 gr_set_current_canvas(bitmap_canv);
439 gr_bitmapm(0, 0, bmp);
440 gr_set_current_canvas(curcanv_save);
446 #ifndef ROBOT_MOVIES //WINDOWS
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)
473 int x = rescale_x(138);
474 int y = rescale_y(55);
475 int w = rescale_x(166);
476 int h = rescale_y(138);
479 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
484 // -----------------------------------------------------------------------------
485 // Returns char width.
486 // If show_robot_flag set, then show a frame of the spinning robot.
487 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
491 static fix start_time=0;
494 message[0] = the_char;
497 if (start_time==0 && timer_get_fixed_seconds()<0)
498 start_time=timer_get_fixed_seconds();
500 gr_get_string_size(message, &w, &h, &aw );
502 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
504 // Draw cursor if there is some delay and caller says to draw cursor
505 if (cursor_flag && delay) {
506 WIN(DDGRLOCK(dd_grd_curcanv));
507 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
508 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
509 WIN(DDGRUNLOCK(dd_grd_curcanv));
513 delay=fixdiv (F1_0,i2f(15));
519 if (RobotPlaying && (delay != 0))
523 while (timer_get_fixed_seconds() < (start_time + delay)) {
524 if (RobotPlaying && delay != 0)
529 show_spinning_robot_frame(robot_num);
531 start_time = timer_get_fixed_seconds();
533 WIN(DDGRLOCK(dd_grd_curcanv));
535 if (cursor_flag && delay) {
536 gr_set_fontcolor(Erase_color, -1);
537 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
540 // Draw the character
541 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
542 gr_printf(Briefing_text_x, Briefing_text_y, message );
544 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
545 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
546 WIN(DDGRUNLOCK(dd_grd_curcanv));
548 // if (the_char != ' ')
549 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
550 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
555 // -----------------------------------------------------------------------------
556 int load_briefing_screen( int screen_num )
560 WIN(DDGRLOCK(dd_grd_curcanv));
561 if ((pcx_error=pcx_read_bitmap( CurBriefScreenName, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
562 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));
563 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);
564 WIN(DDGRUNLOCK(dd_grd_curcanv));
565 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
567 WIN(DDGRUNLOCK(dd_grd_curcanv));
574 int load_new_briefing_screen( char *fname )
578 mprintf ((0,"Loading new briefing %s!\n",fname));
579 strcpy (CurBriefScreenName,fname);
581 // WIN(DEFINE_SCREEN(CurBriefScreenName));
583 if (gr_palette_fade_out( New_pal, 32, 0 ))
586 WIN(DDGRLOCK(dd_grd_curcanv));
587 if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
588 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);
589 WIN(DDGRUNLOCK(dd_grd_curcanv));
590 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
592 WIN(DDGRUNLOCK(dd_grd_curcanv));
596 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
598 if (gr_palette_fade_in( New_pal, 32, 0 ))
600 DoBriefingColorStuff();
607 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
609 // -----------------------------------------------------------------------------
610 int get_message_num(char **message)
614 while (**message == ' ')
617 while ((**message >= '0') && (**message <= '9')) {
618 num = 10*num + **message-'0';
622 while (*(*message)++ != 10) // Get and drop eoln
628 // -----------------------------------------------------------------------------
629 void get_message_name(char **message, char *result)
631 while (**message == ' ')
634 while ((**message != ' ') && (**message != 10)) {
635 if (**message != '\n')
636 *result++ = **message;
641 while (*(*message)++ != 10) // Get and drop eoln
647 // -----------------------------------------------------------------------------
648 void flash_cursor(int cursor_flag)
650 if (cursor_flag == 0)
653 WIN(DDGRLOCK(dd_grd_curcanv));
654 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
655 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
657 gr_set_fontcolor(Erase_color, -1);
659 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
660 WIN(DDGRUNLOCK(dd_grd_curcanv));
663 extern int InitMovieBriefing();
665 // -----------------------------------------------------------------------------
666 // Return true if message got aborted by user (pressed ESC), else return false.
667 int show_briefing_message(int screen_num, char *message)
671 briefing_screen *bsp = &Briefing_screens[screen_num];
672 int delay_count = KEY_DELAY_DEFAULT;
676 static int tab_stop=0;
677 int flashing_cursor=0;
678 int new_page=0,GotZ=0;
680 char *spinRobotName="rba.mve",kludge; // matt don't change this!
685 int hum_channel=-1,printing_channel=-1;
686 int LineAdjustment=0;
687 WIN(int wpage_done=0);
698 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
701 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
702 gr_set_curfont( GAME_FONT );
704 bsp=&Briefing_screens[0];
705 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
713 screen_num=DefineBriefingBox (&message);
714 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
716 bsp = &Briefing_screens[screen_num];
717 init_char_pos(bsp->text_ulx, bsp->text_uly);
719 prev_ch = 10; // read to eoln
723 screen_num=get_message_num(&message);
724 bsp = &Briefing_screens[screen_num];
725 init_char_pos(bsp->text_ulx, bsp->text_uly);
726 prev_ch = 10; // read to eoln
729 else if (ch == 'C') {
730 Current_color = get_message_num(&message)-1;
731 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
733 } else if (ch == 'F') { // toggle flashing cursor
734 flashing_cursor = !flashing_cursor;
736 while (*message++ != 10)
738 } else if (ch == 'T') {
739 tab_stop = get_message_num(&message);
740 tab_stop*=(1+MenuHires);
741 prev_ch = 10; // read to eoln
742 } else if (ch == 'R') {
743 if (Robot_canv != NULL) {
754 spinRobotName[2]=kludge; // ugly but proud
756 RobotPlaying=InitRobotMovie(spinRobotName);
758 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
761 DoBriefingColorStuff ();
762 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
765 init_spinning_robot();
766 robot_num = get_message_num(&message);
768 prev_ch = 10; // read to eoln
769 } else if (ch == 'N') {
770 //--grs_bitmap *bitmap_ptr;
771 if (Robot_canv != NULL)
772 {d_free(Robot_canv); Robot_canv=NULL;}
774 get_message_name(&message, Bitmap_name);
775 strcat(Bitmap_name, "#0");
776 Animating_bitmap_type = 0;
778 } else if (ch == 'O') {
779 if (Robot_canv != NULL)
780 {d_free(Robot_canv); Robot_canv=NULL;}
782 get_message_name(&message, Bitmap_name);
783 strcat(Bitmap_name, "#0");
784 Animating_bitmap_type = 1;
786 } else if (ch=='A') {
787 LineAdjustment=1-LineAdjustment;
788 } else if (ch=='Z') {
789 mprintf ((0,"Got a Z!\n"));
791 #if defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
794 if (LineAdjustment==1)
801 while ((fname[i]=*message) != '\n') {
810 while (fname[i]!='.')
821 load_new_briefing_screen (fname);
824 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)
835 {d_free(Robot_canv); Robot_canv=NULL;}
837 get_message_name(&message, bitmap_name);
838 strcat(bitmap_name, ".bbm");
839 guy_bitmap.bm_data = NULL;
840 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
841 Assert(iff_error == IFF_NO_ERROR);
842 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
844 show_briefing_bitmap(&guy_bitmap);
845 d_free(guy_bitmap.bm_data);
847 // } else if (ch==EOF) {
849 // } else if (ch == 'B') {
850 // if (Robot_canv != NULL)
851 // {d_free(Robot_canv); Robot_canv=NULL;}
853 // bitmap_num = get_message_num(&message);
854 // if (bitmap_num != -1)
855 // show_briefing_bitmap(Textures[bitmap_num]);
856 // prev_ch = 10; // read to eoln
857 } else if (ch == 'S') {
862 if (printing_channel>-1)
863 digi_stop_sound( printing_channel );
873 start_time = timer_get_fixed_seconds();
874 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
877 _RedrawScreen = FALSE;
878 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
884 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
886 flash_cursor(flashing_cursor);
889 if (RobotPlaying) RotateRobot ();
891 show_spinning_robot_frame(robot_num);
895 start_time += KEY_DELAY_DEFAULT/2;
899 if (keypress == KEY_BACKSP)
902 if (keypress == KEY_ESC)
908 } else if (ch == 'P') { // New page.
911 Int3(); // Hey ryan!!!! You gotta load a screen before you start
912 // printing to it! You know, $Z !!!
913 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
918 while (*message != 10) {
919 message++; // drop carriage return after special escape sequence
924 } else if (ch == '\t') { // Tab
925 if (Briefing_text_x - bsp->text_ulx < tab_stop)
926 Briefing_text_x = bsp->text_ulx + tab_stop;
927 } else if ((ch == ';') && (prev_ch == 10)) {
928 while (*message++ != 10)
931 } else if (ch == '\\') {
933 } else if (ch == 10) {
934 if (prev_ch != '\\') {
937 Briefing_text_y += (8*(MenuHires+1));
940 Briefing_text_x = bsp->text_ulx;
941 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
942 load_briefing_screen(screen_num);
943 Briefing_text_x = bsp->text_ulx;
944 Briefing_text_y = bsp->text_uly;
947 if (ch == 13) //Can this happen? Above says ch==10
955 Int3(); // Hey ryan!!!! You gotta load a screen before you start
956 // printing to it! You know, $Z !!!
957 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
964 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
968 WIN(if (GRMODEINFO(emul)) delay_count = 0);
970 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
974 // Check for Esc -> abort.
975 key_check = local_key_inkey();
979 _RedrawScreen = FALSE;
980 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
984 if ( key_check == KEY_ESC ) {
989 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
992 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
993 Briefing_text_x = bsp->text_ulx;
994 Briefing_text_y += bsp->text_uly;
997 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1003 if (printing_channel>-1)
1004 digi_stop_sound( printing_channel );
1005 printing_channel=-1;
1016 start_time = timer_get_fixed_seconds();
1017 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1019 if (_RedrawScreen) {
1020 _RedrawScreen = FALSE;
1021 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1027 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1029 flash_cursor(flashing_cursor);
1031 if (RobotPlaying) RotateRobot();
1033 show_spinning_robot_frame(robot_num);
1035 show_bitmap_frame();
1036 start_time += KEY_DELAY_DEFAULT/2;
1040 if (RobotPlaying) DeInitRobotMovie();
1046 if (keypress == KEY_BACKSP)
1049 if (keypress == KEY_ESC) {
1054 load_briefing_screen(screen_num);
1055 Briefing_text_x = bsp->text_ulx;
1056 Briefing_text_y = bsp->text_uly;
1057 delay_count = KEY_DELAY_DEFAULT;
1059 WIN(wpage_done = 0);
1070 if (Robot_canv != NULL)
1071 {d_free(Robot_canv); Robot_canv=NULL;}
1074 digi_stop_sound( hum_channel );
1075 if (printing_channel>-1)
1076 digi_stop_sound( printing_channel );
1081 // -----------------------------------------------------------------------------
1082 // Return a pointer to the start of text for screen #screen_num.
1083 char * get_briefing_message(int screen_num)
1085 char *tptr = Briefing_text;
1089 Assert(screen_num >= 0);
1091 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1096 cur_screen = get_message_num(&tptr);
1100 if (screen_num!=cur_screen)
1106 // -----------------------------------------------------------------------------
1107 // Load Descent briefing text.
1108 int load_screen_text(char *filename, char **buf)
1113 int have_binary = 0;
1115 if ((tfile = cfopen(filename,"rb")) == NULL) {
1116 char nfilename[30], *ptr;
1118 strcpy(nfilename, filename);
1119 ptr = strrchr(nfilename, '.');
1121 strcat(nfilename, ".txb");
1122 if ((ifile = cfopen(nfilename, "rb")) == NULL)
1124 mprintf ((0,"can't open %s!\n",nfilename));
1126 //Error("Cannot open file %s or %s", filename, nfilename);
1129 mprintf ((0,"reading...\n"));
1132 len = cfilelength(ifile);
1133 MALLOC(*buf, char, len+500);
1134 mprintf ((0,"len=%d\n",len));
1135 for (x=0,i=0;i<len;i++,x++)
1137 cfread (*buf+x,1,1,ifile);
1138 // mprintf ((0,"%c",*(*buf+x)));
1145 len = cfilelength(tfile);
1146 MALLOC(*buf, char, len+500);
1147 for (x=0,i=0;i<len;i++,x++)
1149 cfread (*buf+x,1,1,tfile);
1150 // mprintf ((0,"%c",*(*buf+x)));
1156 //cfread(*buf, 1, len, tfile);
1163 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1165 encode_rotate_left(ptr);
1166 *ptr = *ptr ^ BITMAP_TBL_XOR;
1167 encode_rotate_left(ptr);
1175 // -----------------------------------------------------------------------------
1176 // Return true if message got aborted, else return false.
1177 int show_briefing_text(int screen_num)
1181 message_ptr = get_briefing_message(screen_num);
1182 if (message_ptr==NULL)
1185 DoBriefingColorStuff();
1187 return show_briefing_message(screen_num, message_ptr);
1189 void DoBriefingColorStuff ()
1191 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1192 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1194 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1195 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1197 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1198 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1200 Erase_color = gr_find_closest_color_current(0, 0, 0);
1203 // -----------------------------------------------------------------------------
1204 // Return true if screen got aborted by user, else return false.
1205 int show_briefing_screen( int screen_num, int allow_keys)
1208 ubyte palette_save[768];
1210 New_pal_254_bash = 0;
1212 if (Skip_briefing_screens) {
1213 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1217 // briefing_bm.bm_data=NULL;
1218 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1219 // 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));
1224 memcpy(palette_save,gr_palette,sizeof(palette_save));
1225 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1228 // vfx_set_palette_sub( New_pal );
1229 // gr_palette_clear();
1230 // gr_bitmap( 0, 0, &briefing_bm );
1232 gr_palette_load(New_pal);
1235 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1237 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1240 key_close(); // kill the keyboard handler during briefing screens for movies
1242 rval = show_briefing_text(screen_num);
1247 #if defined (MACINTOSH) || defined(WINDOWS)
1248 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1253 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1256 DEFINE_SCREEN(NULL);
1257 WIN(DDGRLOCK(dd_grd_curcanv));
1258 gr_clear_canvas (0);
1259 WIN(DDGRUNLOCK(dd_grd_curcanv));
1260 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1264 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1266 // d_free(briefing_bm.bm_data);
1272 // -----------------------------------------------------------------------------
1273 void do_briefing_screens(char *filename,int level_num)
1278 if (Skip_briefing_screens) {
1279 mprintf((0, "Skipping all briefing screens.\n"));
1284 return; // no briefing screens at all for demo
1287 mprintf ((0,"Trying briefing screen! %s\n",filename));
1292 if (!load_screen_text(filename, &Briefing_text))
1296 songs_play_song( SONG_BRIEFING, 1 );
1301 set_screen_mode( SCREEN_MENU );
1304 dd_gr_set_current_canvas(NULL),
1305 gr_set_current_canvas(NULL)
1308 mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num));
1312 show_briefing_screen(level_num,0);
1314 d_free (Briefing_text);
1321 int DefineBriefingBox (char **buf)
1326 n=get_new_message_num (buf);
1328 Assert(n < MAX_BRIEFING_SCREENS);
1336 name[i]='\0'; // slap a delimiter on this guy
1338 strcpy (Briefing_screens[n].bs_name,name);
1339 Briefing_screens[n].level_num=get_new_message_num (buf);
1340 Briefing_screens[n].message_num=get_new_message_num (buf);
1341 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1342 Briefing_screens[n].text_uly=get_new_message_num (buf);
1343 Briefing_screens[n].text_width=get_new_message_num (buf);
1344 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1348 Briefing_screens[n].text_ulx*=2;
1349 Briefing_screens[n].text_uly*=2.4;
1350 Briefing_screens[n].text_width*=2;
1351 Briefing_screens[n].text_height*=2.4;
1357 int get_new_message_num(char **message)
1361 while (**message == ' ')
1364 while ((**message >= '0') && (**message <= '9')) {
1365 num = 10*num + **message-'0';