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]!='.')
783 load_new_briefing_screen (fname);
786 load_new_briefing_screen (fname);
788 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
790 } else if (ch == 'B') {
791 char bitmap_name[32];
792 grs_bitmap guy_bitmap;
793 ubyte temp_palette[768];
796 if (Robot_canv != NULL)
797 {d_free(Robot_canv); Robot_canv=NULL;}
799 get_message_name(&message, bitmap_name);
800 strcat(bitmap_name, ".bbm");
801 guy_bitmap.bm_data = NULL;
802 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
803 Assert(iff_error == IFF_NO_ERROR);
804 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
806 show_briefing_bitmap(&guy_bitmap);
807 d_free(guy_bitmap.bm_data);
809 // } else if (ch==EOF) {
811 // } else if (ch == 'B') {
812 // if (Robot_canv != NULL)
813 // {d_free(Robot_canv); Robot_canv=NULL;}
815 // bitmap_num = get_message_num(&message);
816 // if (bitmap_num != -1)
817 // show_briefing_bitmap(Textures[bitmap_num]);
818 // prev_ch = 10; // read to eoln
819 } else if (ch == 'S') {
824 if (printing_channel>-1)
825 digi_stop_sound( printing_channel );
835 start_time = timer_get_fixed_seconds();
836 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
839 _RedrawScreen = FALSE;
840 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
846 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
848 flash_cursor(flashing_cursor);
850 if (RobotPlaying) RotateRobot ();
853 start_time += KEY_DELAY_DEFAULT/2;
857 if (keypress == KEY_BACKSP)
860 if (keypress == KEY_ESC)
866 } else if (ch == 'P') { // New page.
869 Int3(); // Hey ryan!!!! You gotta load a screen before you start
870 // printing to it! You know, $Z !!!
871 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
876 while (*message != 10) {
877 message++; // drop carriage return after special escape sequence
882 } else if (ch == '\t') { // Tab
883 if (Briefing_text_x - bsp->text_ulx < tab_stop)
884 Briefing_text_x = bsp->text_ulx + tab_stop;
885 } else if ((ch == ';') && (prev_ch == 10)) {
886 while (*message++ != 10)
889 } else if (ch == '\\') {
891 } else if (ch == 10) {
892 if (prev_ch != '\\') {
895 Briefing_text_y += (8*(MenuHires+1));
898 Briefing_text_x = bsp->text_ulx;
899 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
900 load_briefing_screen(screen_num);
901 Briefing_text_x = bsp->text_ulx;
902 Briefing_text_y = bsp->text_uly;
905 if (ch == 13) //Can this happen? Above says ch==10
913 Int3(); // Hey ryan!!!! You gotta load a screen before you start
914 // printing to it! You know, $Z !!!
915 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
922 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
926 WIN(if (GRMODEINFO(emul)) delay_count = 0);
928 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
932 // Check for Esc -> abort.
933 key_check = local_key_inkey();
937 _RedrawScreen = FALSE;
938 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
942 if ( key_check == KEY_ESC ) {
947 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
950 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
951 Briefing_text_x = bsp->text_ulx;
952 Briefing_text_y += bsp->text_uly;
955 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
961 if (printing_channel>-1)
962 digi_stop_sound( printing_channel );
974 start_time = timer_get_fixed_seconds();
975 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
978 _RedrawScreen = FALSE;
979 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
985 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
987 flash_cursor(flashing_cursor);
989 if (RobotPlaying) RotateRobot();
992 start_time += KEY_DELAY_DEFAULT/2;
995 if (RobotPlaying) DeInitRobotMovie();
1000 if (keypress == KEY_BACKSP)
1003 if (keypress == KEY_ESC) {
1008 load_briefing_screen(screen_num);
1009 Briefing_text_x = bsp->text_ulx;
1010 Briefing_text_y = bsp->text_uly;
1011 delay_count = KEY_DELAY_DEFAULT;
1013 WIN(wpage_done = 0);
1024 if (Robot_canv != NULL)
1025 {d_free(Robot_canv); Robot_canv=NULL;}
1028 digi_stop_sound( hum_channel );
1029 if (printing_channel>-1)
1030 digi_stop_sound( printing_channel );
1035 // -----------------------------------------------------------------------------
1036 // Return a pointer to the start of text for screen #screen_num.
1037 char * get_briefing_message(int screen_num)
1039 char *tptr = Briefing_text;
1043 Assert(screen_num >= 0);
1045 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1050 cur_screen = get_message_num(&tptr);
1054 if (screen_num!=cur_screen)
1060 // -----------------------------------------------------------------------------
1061 // Load Descent briefing text.
1062 int load_screen_text(char *filename, char **buf)
1067 int have_binary = 0;
1069 if ((tfile = cfopen(filename,"rb")) == NULL) {
1070 char nfilename[30], *ptr;
1072 strcpy(nfilename, filename);
1073 ptr = strrchr(nfilename, '.');
1075 strcat(nfilename, ".txb");
1076 if ((ifile = cfopen(nfilename, "rb")) == NULL)
1078 mprintf ((0,"can't open %s!\n",nfilename));
1080 //Error("Cannot open file %s or %s", filename, nfilename);
1083 mprintf ((0,"reading...\n"));
1086 len = cfilelength(ifile);
1087 MALLOC(*buf, char, len+500);
1088 mprintf ((0,"len=%d\n",len));
1089 for (x=0,i=0;i<len;i++,x++)
1091 cfread (*buf+x,1,1,ifile);
1092 // mprintf ((0,"%c",*(*buf+x)));
1099 len = cfilelength(tfile);
1100 MALLOC(*buf, char, len+500);
1101 for (x=0,i=0;i<len;i++,x++)
1103 cfread (*buf+x,1,1,tfile);
1104 // mprintf ((0,"%c",*(*buf+x)));
1110 //cfread(*buf, 1, len, tfile);
1117 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1119 encode_rotate_left(ptr);
1120 *ptr = *ptr ^ BITMAP_TBL_XOR;
1121 encode_rotate_left(ptr);
1129 // -----------------------------------------------------------------------------
1130 // Return true if message got aborted, else return false.
1131 int show_briefing_text(int screen_num)
1135 message_ptr = get_briefing_message(screen_num);
1136 if (message_ptr==NULL)
1139 DoBriefingColorStuff();
1141 return show_briefing_message(screen_num, message_ptr);
1143 void DoBriefingColorStuff ()
1145 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1146 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1148 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1149 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1151 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1152 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1154 Erase_color = gr_find_closest_color_current(0, 0, 0);
1157 // -----------------------------------------------------------------------------
1158 // Return true if screen got aborted by user, else return false.
1159 int show_briefing_screen( int screen_num, int allow_keys)
1162 ubyte palette_save[768];
1164 New_pal_254_bash = 0;
1166 if (Skip_briefing_screens) {
1167 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1171 // briefing_bm.bm_data=NULL;
1172 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1173 // 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));
1178 memcpy(palette_save,gr_palette,sizeof(palette_save));
1179 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1182 // vfx_set_palette_sub( New_pal );
1183 // gr_palette_clear();
1184 // gr_bitmap( 0, 0, &briefing_bm );
1186 gr_palette_load(New_pal);
1189 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1191 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1194 key_close(); // kill the keyboard handler during briefing screens for movies
1196 rval = show_briefing_text(screen_num);
1201 #if defined (MACINTOSH) || defined(WINDOWS)
1202 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1207 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1210 DEFINE_SCREEN(NULL);
1211 WIN(DDGRLOCK(dd_grd_curcanv));
1212 gr_clear_canvas (0);
1213 WIN(DDGRUNLOCK(dd_grd_curcanv));
1214 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1218 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1220 // d_free(briefing_bm.bm_data);
1226 // -----------------------------------------------------------------------------
1227 void do_briefing_screens(char *filename,int level_num)
1232 if (Skip_briefing_screens) {
1233 mprintf((0, "Skipping all briefing screens.\n"));
1238 return; // no briefing screens at all for demo
1241 mprintf ((0,"Trying briefing screen! %s\n",filename));
1246 if (!load_screen_text(filename, &Briefing_text))
1250 songs_play_song( SONG_BRIEFING, 1 );
1255 set_screen_mode( SCREEN_MENU );
1258 dd_gr_set_current_canvas(NULL),
1259 gr_set_current_canvas(NULL)
1262 mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num));
1266 show_briefing_screen(level_num,0);
1268 d_free (Briefing_text);
1275 int DefineBriefingBox (char **buf)
1280 n=get_new_message_num (buf);
1282 Assert(n < MAX_BRIEFING_SCREENS);
1290 name[i]='\0'; // slap a delimiter on this guy
1292 strcpy (Briefing_screens[n].bs_name,name);
1293 Briefing_screens[n].level_num=get_new_message_num (buf);
1294 Briefing_screens[n].message_num=get_new_message_num (buf);
1295 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1296 Briefing_screens[n].text_uly=get_new_message_num (buf);
1297 Briefing_screens[n].text_width=get_new_message_num (buf);
1298 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1302 Briefing_screens[n].text_ulx*=2;
1303 Briefing_screens[n].text_uly*=2.4;
1304 Briefing_screens[n].text_width*=2;
1305 Briefing_screens[n].text_height*=2.4;
1311 int get_new_message_num(char **message)
1315 while (**message == ' ')
1318 while ((**message >= '0') && (**message <= '9')) {
1319 num = 10*num + **message-'0';