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.
30 #include "pa_enabl.h" //$$POLY_ACC
64 extern void RotateRobot();
66 void DoBriefingColorStuff ();
67 int get_new_message_num(char **message);
68 int DefineBriefingBox (char **buf);
70 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
72 extern int MVEPaletteCalls;
77 char CurBriefScreenName[15]="brief03.pcx";
81 #define MAX_BRIEFING_COLORS 3
83 #define SHAREWARE_ENDING_FILENAME "ending.tex"
85 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
86 int Skip_briefing_screens=0;
87 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
88 int Current_color = 0;
91 extern int check_button_press();
94 extern void macintosh_quit(void);
98 int local_key_inkey(void)
105 DoMessageStuff(&msg);
110 if (rval == KEY_PRINT_SCREEN) {
113 gr_palette_read(gr_palette);
114 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
118 return 0; //say no key pressed
121 if (check_button_press()) //joystick or mouse button pressed?
125 if ( rval == KEY_Q+KEY_COMMAND )
132 int local_key_inkey(void)
137 if (!GetOSEvent(everyEvent, &event))
140 if (event.what != keyDown)
143 rval = (int)((event.message & keyCodeMask) >> 8);
145 if (rval == KEY_PRINT_SCREEN) {
147 return 0; //say no key pressed
150 if (check_button_press()) //joystick or mouse button pressed?
154 if ( rval == KEY_Q+KEY_COMMAND )
162 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
167 ubyte palette_save[768];
168 char new_filename[FILENAME_LEN+1] = "";
172 strcpy(new_filename,"\x01"); //only read from hog file
175 strcat(new_filename,filename);
176 filename = new_filename;
178 title_bm.bm_data=NULL;
179 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
180 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
181 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));
182 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
185 memcpy(palette_save,gr_palette,sizeof(palette_save));
187 #if defined(POLY_ACC)
189 pa_update_clut(New_pal, 0, 256, 0);
192 //vfx_set_palette_sub( New_pal );
194 gr_palette_load( New_pal );
200 dd_gr_set_current_canvas(NULL),
201 gr_set_current_canvas( NULL )
203 WIN(DDGRLOCK(dd_grd_curcanv));
204 gr_bitmap( 0, 0, &title_bm );
205 WIN(DDGRUNLOCK(dd_grd_curcanv));
209 #if defined(POLY_ACC)
213 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
215 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
217 gr_palette_load( New_pal );
218 timer = timer_get_fixed_seconds() + i2f(3);
220 if ( local_key_inkey() && allow_keys ) break;
221 if ( timer_get_fixed_seconds() > timer ) break;
223 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
225 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
226 d_free(title_bm.bm_data);
231 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
234 short text_ulx, text_uly; // upper left x,y of text window
235 short text_width, text_height; // width and height of text window
238 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
239 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
241 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
242 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
245 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
247 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
250 #define MAX_BRIEFING_SCREENS 60
252 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
253 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
255 int Briefing_text_x, Briefing_text_y;
257 void init_char_pos(int x, int y)
261 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
264 grs_canvas *Robot_canv = NULL;
265 vms_angvec Robot_angles;
267 char Bitmap_name[32] = "";
268 #define EXIT_DOOR_MAX 14
269 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
270 #define DOOR_DIV_INIT 6
271 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
273 // -----------------------------------------------------------------------------
274 void show_bitmap_frame(void)
277 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
279 grs_canvas *curcanv_save, *bitmap_canv=0;
282 grs_bitmap *bitmap_ptr;
284 // Only plot every nth frame.
285 if (Door_div_count) {
290 Door_div_count = DOOR_DIV_INIT;
292 if (Bitmap_name[0] != 0) {
296 // Set supertransparency color to black
297 if (!New_pal_254_bash) {
298 New_pal_254_bash = 1;
300 New_pal[254*3+1] = 0;
301 New_pal[254*3+2] = 0;
302 gr_palette_load( New_pal );
305 switch (Animating_bitmap_type) {
308 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
309 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
313 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
314 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break
317 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
318 default: Int3(); // Impossible, illegal value for Animating_bitmap_type
322 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
323 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
326 pound_signp = strchr(Bitmap_name, '#');
327 Assert(pound_signp != NULL);
329 dig1 = *(pound_signp+1);
330 dig2 = *(pound_signp+2);
334 num = (dig1-'0')*10 + (dig2-'0');
336 switch (Animating_bitmap_type) {
339 if (num > EXIT_DOOR_MAX) {
342 } else if (num < 0) {
349 if (num > OTHER_THING_MAX)
356 *(pound_signp+1) = (num / 10) + '0';
357 *(pound_signp+2) = (num % 10) + '0';
358 *(pound_signp+3) = 0;
360 *(pound_signp+1) = (num % 10) + '0';
361 *(pound_signp+2) = 0;
366 bi = piggy_find_bitmap(Bitmap_name);
367 bitmap_ptr = &GameBitmaps[bi.index];
371 WIN(DDGRLOCK(dd_grd_curcanv));
372 gr_bitmapm(0, 0, bitmap_ptr);
373 WIN(DDGRUNLOCK(dd_grd_curcanv));
376 dd_grd_curcanv = curcanv_save,
377 grd_curcanv = curcanv_save
381 switch (Animating_bitmap_type) {
383 if (num == EXIT_DOOR_MAX) {
386 } else if (num == 0) {
398 // -----------------------------------------------------------------------------
399 void show_briefing_bitmap(grs_bitmap *bmp)
402 dd_grs_canvas *bitmap_canv, *curcanv_save;
404 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
405 curcanv_save = dd_grd_curcanv;
406 dd_gr_set_current_canvas(bitmap_canv);
407 DDGRLOCK(dd_grd_curcanv);
409 DDGRUNLOCK(dd_grd_curcanv);
410 dd_gr_set_current_canvas(curcanv_save);
412 grs_canvas *curcanv_save, *bitmap_canv;
414 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
415 curcanv_save = grd_curcanv;
416 gr_set_current_canvas(bitmap_canv);
417 gr_bitmapm(0, 0, bmp);
418 gr_set_current_canvas(curcanv_save);
425 // -----------------------------------------------------------------------------
426 void show_spinning_robot_frame(int robot_num)
428 grs_canvas *curcanv_save;
430 if (robot_num != -1) {
431 Robot_angles.h += 150;
433 curcanv_save = grd_curcanv;
434 grd_curcanv = Robot_canv;
435 Assert(Robot_info[robot_num].model_num != -1);
436 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
437 grd_curcanv = curcanv_save;
442 // -----------------------------------------------------------------------------
443 void init_spinning_robot(int x,int y,int w,int h)
449 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
454 // -----------------------------------------------------------------------------
455 // Returns char width.
456 // If show_robot_flag set, then show a frame of the spinning robot.
457 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
461 static fix start_time=0;
464 message[0] = the_char;
467 if (start_time==0 && timer_get_fixed_seconds()<0)
468 start_time=timer_get_fixed_seconds();
470 gr_get_string_size(message, &w, &h, &aw );
472 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
474 // Draw cursor if there is some delay and caller says to draw cursor
475 if (cursor_flag && delay) {
476 WIN(DDGRLOCK(dd_grd_curcanv));
477 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
478 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
479 WIN(DDGRUNLOCK(dd_grd_curcanv));
483 delay=fixdiv (F1_0,i2f(15));
488 if (RobotPlaying && (delay != 0))
492 while (timer_get_fixed_seconds() < (start_time + delay))
494 if (RobotPlaying && delay != 0)
498 start_time = timer_get_fixed_seconds();
500 WIN(DDGRLOCK(dd_grd_curcanv));
502 if (cursor_flag && delay) {
503 gr_set_fontcolor(Erase_color, -1);
504 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
507 // Draw the character
508 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
509 gr_printf(Briefing_text_x, Briefing_text_y, message );
511 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
512 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
513 WIN(DDGRUNLOCK(dd_grd_curcanv));
515 // if (the_char != ' ')
516 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
517 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
522 // -----------------------------------------------------------------------------
523 int load_briefing_screen( int screen_num )
527 WIN(DDGRLOCK(dd_grd_curcanv));
528 if ((pcx_error=pcx_read_bitmap( CurBriefScreenName, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
529 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));
530 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);
531 WIN(DDGRUNLOCK(dd_grd_curcanv));
532 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
534 WIN(DDGRUNLOCK(dd_grd_curcanv));
541 int load_new_briefing_screen( char *fname )
545 mprintf ((0,"Loading new briefing %s!\n",fname));
546 strcpy (CurBriefScreenName,fname);
548 // WIN(DEFINE_SCREEN(CurBriefScreenName));
550 if (gr_palette_fade_out( New_pal, 32, 0 ))
553 WIN(DDGRLOCK(dd_grd_curcanv));
554 if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
555 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);
556 WIN(DDGRUNLOCK(dd_grd_curcanv));
557 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
559 WIN(DDGRUNLOCK(dd_grd_curcanv));
563 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
565 if (gr_palette_fade_in( New_pal, 32, 0 ))
567 DoBriefingColorStuff();
574 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
576 // -----------------------------------------------------------------------------
577 int get_message_num(char **message)
581 while (**message == ' ')
584 while ((**message >= '0') && (**message <= '9')) {
585 num = 10*num + **message-'0';
589 while (*(*message)++ != 10) // Get and drop eoln
595 // -----------------------------------------------------------------------------
596 void get_message_name(char **message, char *result)
598 while (**message == ' ')
601 while ((**message != ' ') && (**message != 10)) {
602 if (**message != '\n')
603 *result++ = **message;
608 while (*(*message)++ != 10) // Get and drop eoln
614 // -----------------------------------------------------------------------------
615 void flash_cursor(int cursor_flag)
617 if (cursor_flag == 0)
620 WIN(DDGRLOCK(dd_grd_curcanv));
621 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
622 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
624 gr_set_fontcolor(Erase_color, -1);
626 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
627 WIN(DDGRUNLOCK(dd_grd_curcanv));
630 extern int InitMovieBriefing();
632 // -----------------------------------------------------------------------------
633 // Return true if message got aborted by user (pressed ESC), else return false.
634 int show_briefing_message(int screen_num, char *message)
638 briefing_screen *bsp = &Briefing_screens[screen_num];
639 int delay_count = KEY_DELAY_DEFAULT;
643 static int tab_stop=0;
644 int flashing_cursor=0;
645 int new_page=0,GotZ=0;
646 char *spinRobotName="rba.mve",kludge; // matt don't change this!
650 int hum_channel=-1,printing_channel=-1;
651 int LineAdjustment=0;
652 WIN(int wpage_done=0);
661 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
664 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
665 gr_set_curfont( GAME_FONT );
667 bsp=&Briefing_screens[0];
668 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
676 screen_num=DefineBriefingBox (&message);
677 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
679 bsp = &Briefing_screens[screen_num];
680 init_char_pos(bsp->text_ulx, bsp->text_uly);
682 prev_ch = 10; // read to eoln
686 screen_num=get_message_num(&message);
687 bsp = &Briefing_screens[screen_num];
688 init_char_pos(bsp->text_ulx, bsp->text_uly);
689 prev_ch = 10; // read to eoln
692 else if (ch == 'C') {
693 Current_color = get_message_num(&message)-1;
694 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
696 } else if (ch == 'F') { // toggle flashing cursor
697 flashing_cursor = !flashing_cursor;
699 while (*message++ != 10)
701 } else if (ch == 'T') {
702 tab_stop = get_message_num(&message);
703 tab_stop*=(1+MenuHires);
704 prev_ch = 10; // read to eoln
705 } else if (ch == 'R') {
706 if (Robot_canv != NULL)
718 spinRobotName[2]=kludge; // ugly but proud
720 RobotPlaying=InitRobotMovie(spinRobotName);
722 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
726 DoBriefingColorStuff ();
727 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
730 prev_ch = 10; // read to eoln
731 } else if (ch == 'N') {
732 //--grs_bitmap *bitmap_ptr;
733 if (Robot_canv != NULL)
734 {d_free(Robot_canv); Robot_canv=NULL;}
736 get_message_name(&message, Bitmap_name);
737 strcat(Bitmap_name, "#0");
738 Animating_bitmap_type = 0;
740 } else if (ch == 'O') {
741 if (Robot_canv != NULL)
742 {d_free(Robot_canv); Robot_canv=NULL;}
744 get_message_name(&message, Bitmap_name);
745 strcat(Bitmap_name, "#0");
746 Animating_bitmap_type = 1;
748 } else if (ch=='A') {
749 LineAdjustment=1-LineAdjustment;
750 } else if (ch=='Z') {
751 mprintf ((0,"Got a Z!\n"));
753 #if defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
756 if (LineAdjustment==1)
763 while ((fname[i]=*message) != '\n') {
772 while (fname[i]!='.')
781 load_new_briefing_screen (fname);
784 load_new_briefing_screen (fname);
786 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
788 } else if (ch == 'B') {
789 char bitmap_name[32];
790 grs_bitmap guy_bitmap;
791 ubyte temp_palette[768];
794 if (Robot_canv != NULL)
795 {d_free(Robot_canv); Robot_canv=NULL;}
797 get_message_name(&message, bitmap_name);
798 strcat(bitmap_name, ".bbm");
799 guy_bitmap.bm_data = NULL;
800 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
801 Assert(iff_error == IFF_NO_ERROR);
802 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
804 show_briefing_bitmap(&guy_bitmap);
805 d_free(guy_bitmap.bm_data);
807 // } else if (ch==EOF) {
809 // } else if (ch == 'B') {
810 // if (Robot_canv != NULL)
811 // {d_free(Robot_canv); Robot_canv=NULL;}
813 // bitmap_num = get_message_num(&message);
814 // if (bitmap_num != -1)
815 // show_briefing_bitmap(Textures[bitmap_num]);
816 // prev_ch = 10; // read to eoln
817 } else if (ch == 'S') {
822 if (printing_channel>-1)
823 digi_stop_sound( printing_channel );
833 start_time = timer_get_fixed_seconds();
834 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
837 _RedrawScreen = FALSE;
838 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
844 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
846 flash_cursor(flashing_cursor);
848 if (RobotPlaying) RotateRobot ();
851 start_time += KEY_DELAY_DEFAULT/2;
855 if (keypress == KEY_BACKSP)
858 if (keypress == KEY_ESC)
864 } else if (ch == 'P') { // New page.
867 Int3(); // Hey ryan!!!! You gotta load a screen before you start
868 // printing to it! You know, $Z !!!
869 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
874 while (*message != 10) {
875 message++; // drop carriage return after special escape sequence
880 } else if (ch == '\t') { // Tab
881 if (Briefing_text_x - bsp->text_ulx < tab_stop)
882 Briefing_text_x = bsp->text_ulx + tab_stop;
883 } else if ((ch == ';') && (prev_ch == 10)) {
884 while (*message++ != 10)
887 } else if (ch == '\\') {
889 } else if (ch == 10) {
890 if (prev_ch != '\\') {
893 Briefing_text_y += (8*(MenuHires+1));
896 Briefing_text_x = bsp->text_ulx;
897 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
898 load_briefing_screen(screen_num);
899 Briefing_text_x = bsp->text_ulx;
900 Briefing_text_y = bsp->text_uly;
903 if (ch == 13) //Can this happen? Above says ch==10
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");
920 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
924 WIN(if (GRMODEINFO(emul)) delay_count = 0);
926 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
930 // Check for Esc -> abort.
931 key_check = local_key_inkey();
935 _RedrawScreen = FALSE;
936 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
940 if ( key_check == KEY_ESC ) {
945 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
948 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
949 Briefing_text_x = bsp->text_ulx;
950 Briefing_text_y += bsp->text_uly;
953 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
959 if (printing_channel>-1)
960 digi_stop_sound( printing_channel );
972 start_time = timer_get_fixed_seconds();
973 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
976 _RedrawScreen = FALSE;
977 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
983 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
985 flash_cursor(flashing_cursor);
987 if (RobotPlaying) RotateRobot();
990 start_time += KEY_DELAY_DEFAULT/2;
993 if (RobotPlaying) DeInitRobotMovie();
998 if (keypress == KEY_BACKSP)
1001 if (keypress == KEY_ESC) {
1006 load_briefing_screen(screen_num);
1007 Briefing_text_x = bsp->text_ulx;
1008 Briefing_text_y = bsp->text_uly;
1009 delay_count = KEY_DELAY_DEFAULT;
1011 WIN(wpage_done = 0);
1022 if (Robot_canv != NULL)
1023 {d_free(Robot_canv); Robot_canv=NULL;}
1026 digi_stop_sound( hum_channel );
1027 if (printing_channel>-1)
1028 digi_stop_sound( printing_channel );
1033 // -----------------------------------------------------------------------------
1034 // Return a pointer to the start of text for screen #screen_num.
1035 char * get_briefing_message(int screen_num)
1037 char *tptr = Briefing_text;
1041 Assert(screen_num >= 0);
1043 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1048 cur_screen = get_message_num(&tptr);
1052 if (screen_num!=cur_screen)
1058 // -----------------------------------------------------------------------------
1059 // Load Descent briefing text.
1060 int load_screen_text(char *filename, char **buf)
1065 int have_binary = 0;
1067 if ((tfile = cfopen(filename,"rb")) == NULL) {
1068 char nfilename[30], *ptr;
1070 strcpy(nfilename, filename);
1071 ptr = strrchr(nfilename, '.');
1073 strcat(nfilename, ".txb");
1074 if ((ifile = cfopen(nfilename, "rb")) == NULL)
1076 mprintf ((0,"can't open %s!\n",nfilename));
1078 //Error("Cannot open file %s or %s", filename, nfilename);
1081 mprintf ((0,"reading...\n"));
1084 len = cfilelength(ifile);
1085 MALLOC(*buf, char, len+500);
1086 mprintf ((0,"len=%d\n",len));
1087 for (x=0,i=0;i<len;i++,x++)
1089 cfread (*buf+x,1,1,ifile);
1090 // mprintf ((0,"%c",*(*buf+x)));
1097 len = cfilelength(tfile);
1098 MALLOC(*buf, char, len+500);
1099 for (x=0,i=0;i<len;i++,x++)
1101 cfread (*buf+x,1,1,tfile);
1102 // mprintf ((0,"%c",*(*buf+x)));
1108 //cfread(*buf, 1, len, tfile);
1115 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1117 encode_rotate_left(ptr);
1118 *ptr = *ptr ^ BITMAP_TBL_XOR;
1119 encode_rotate_left(ptr);
1127 // -----------------------------------------------------------------------------
1128 // Return true if message got aborted, else return false.
1129 int show_briefing_text(int screen_num)
1133 message_ptr = get_briefing_message(screen_num);
1134 if (message_ptr==NULL)
1137 DoBriefingColorStuff();
1139 return show_briefing_message(screen_num, message_ptr);
1141 void DoBriefingColorStuff ()
1143 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1144 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1146 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1147 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1149 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1150 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1152 Erase_color = gr_find_closest_color_current(0, 0, 0);
1155 // -----------------------------------------------------------------------------
1156 // Return true if screen got aborted by user, else return false.
1157 int show_briefing_screen( int screen_num, int allow_keys)
1160 ubyte palette_save[768];
1162 New_pal_254_bash = 0;
1164 if (Skip_briefing_screens) {
1165 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1169 // briefing_bm.bm_data=NULL;
1170 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1171 // 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));
1176 memcpy(palette_save,gr_palette,sizeof(palette_save));
1177 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1180 // vfx_set_palette_sub( New_pal );
1181 // gr_palette_clear();
1182 // gr_bitmap( 0, 0, &briefing_bm );
1184 gr_palette_load(New_pal);
1187 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1189 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1192 key_close(); // kill the keyboard handler during briefing screens for movies
1194 rval = show_briefing_text(screen_num);
1199 #if defined (MACINTOSH) || defined(WINDOWS)
1200 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1205 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1208 DEFINE_SCREEN(NULL);
1209 WIN(DDGRLOCK(dd_grd_curcanv));
1210 gr_clear_canvas (0);
1211 WIN(DDGRUNLOCK(dd_grd_curcanv));
1212 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1216 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1218 // d_free(briefing_bm.bm_data);
1224 // -----------------------------------------------------------------------------
1225 void do_briefing_screens(char *filename,int level_num)
1230 if (Skip_briefing_screens) {
1231 mprintf((0, "Skipping all briefing screens.\n"));
1236 return; // no briefing screens at all for demo
1239 mprintf ((0,"Trying briefing screen! %s\n",filename));
1244 if (!load_screen_text(filename, &Briefing_text))
1248 songs_play_song( SONG_BRIEFING, 1 );
1253 set_screen_mode( SCREEN_MENU );
1256 dd_gr_set_current_canvas(NULL),
1257 gr_set_current_canvas(NULL)
1260 mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num));
1264 show_briefing_screen(level_num,0);
1266 d_free (Briefing_text);
1273 int DefineBriefingBox (char **buf)
1278 n=get_new_message_num (buf);
1280 Assert(n < MAX_BRIEFING_SCREENS);
1288 name[i]='\0'; // slap a delimiter on this guy
1290 strcpy (Briefing_screens[n].bs_name,name);
1291 Briefing_screens[n].level_num=get_new_message_num (buf);
1292 Briefing_screens[n].message_num=get_new_message_num (buf);
1293 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1294 Briefing_screens[n].text_uly=get_new_message_num (buf);
1295 Briefing_screens[n].text_width=get_new_message_num (buf);
1296 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1300 Briefing_screens[n].text_ulx*=2;
1301 Briefing_screens[n].text_uly*=2.4;
1302 Briefing_screens[n].text_width*=2;
1303 Briefing_screens[n].text_height*=2.4;
1309 int get_new_message_num(char **message)
1313 while (**message == ' ')
1316 while ((**message >= '0') && (**message <= '9')) {
1317 num = 10*num + **message-'0';