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.
28 #include "pa_enabl.h" //$$POLY_ACC
62 extern void RotateRobot();
64 void DoBriefingColorStuff ();
65 int get_new_message_num(char **message);
66 int DefineBriefingBox (char **buf);
68 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
70 extern int MVEPaletteCalls;
75 char CurBriefScreenName[15]="brief03.pcx";
79 #define MAX_BRIEFING_COLORS 3
81 #define SHAREWARE_ENDING_FILENAME "ending.tex"
83 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
84 int Skip_briefing_screens=0;
85 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
86 int Current_color = 0;
89 extern int check_button_press();
92 extern void macintosh_quit(void);
96 int local_key_inkey(void)
103 DoMessageStuff(&msg);
108 if (rval == KEY_PRINT_SCREEN) {
111 gr_palette_read(gr_palette);
112 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
116 return 0; //say no key pressed
119 if (check_button_press()) //joystick or mouse button pressed?
123 if ( rval == KEY_Q+KEY_COMMAND )
130 int local_key_inkey(void)
135 if (!GetOSEvent(everyEvent, &event))
138 if (event.what != keyDown)
141 rval = (int)((event.message & keyCodeMask) >> 8);
143 if (rval == KEY_PRINT_SCREEN) {
145 return 0; //say no key pressed
148 if (check_button_press()) //joystick or mouse button pressed?
152 if ( rval == KEY_Q+KEY_COMMAND )
160 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
165 ubyte palette_save[768];
166 char new_filename[FILENAME_LEN+1] = "";
170 strcpy(new_filename,"\x01"); //only read from hog file
173 strcat(new_filename,filename);
174 filename = new_filename;
176 title_bm.bm_data=NULL;
177 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
178 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
179 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));
180 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
183 memcpy(palette_save,gr_palette,sizeof(palette_save));
185 #if defined(POLY_ACC)
187 pa_update_clut(New_pal, 0, 256, 0);
190 //vfx_set_palette_sub( New_pal );
192 gr_palette_load( New_pal );
198 dd_gr_set_current_canvas(NULL),
199 gr_set_current_canvas( NULL )
201 WIN(DDGRLOCK(dd_grd_curcanv));
202 gr_bitmap( 0, 0, &title_bm );
203 WIN(DDGRUNLOCK(dd_grd_curcanv));
207 #if defined(POLY_ACC)
211 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
213 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
215 gr_palette_load( New_pal );
216 timer = timer_get_fixed_seconds() + i2f(3);
218 if ( local_key_inkey() && allow_keys ) break;
219 if ( timer_get_fixed_seconds() > timer ) break;
221 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
223 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
224 d_free(title_bm.bm_data);
229 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
232 short text_ulx, text_uly; // upper left x,y of text window
233 short text_width, text_height; // width and height of text window
236 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
237 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
239 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
240 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
243 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
245 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
248 #define MAX_BRIEFING_SCREENS 60
250 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
251 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
253 int Briefing_text_x, Briefing_text_y;
255 void init_char_pos(int x, int y)
259 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
262 grs_canvas *Robot_canv = NULL;
263 vms_angvec Robot_angles;
265 char Bitmap_name[32] = "";
266 #define EXIT_DOOR_MAX 14
267 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
268 #define DOOR_DIV_INIT 6
269 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
271 // -----------------------------------------------------------------------------
272 void show_bitmap_frame(void)
275 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
277 grs_canvas *curcanv_save, *bitmap_canv=0;
280 grs_bitmap *bitmap_ptr;
282 // Only plot every nth frame.
283 if (Door_div_count) {
288 Door_div_count = DOOR_DIV_INIT;
290 if (Bitmap_name[0] != 0) {
294 // Set supertransparency color to black
295 if (!New_pal_254_bash) {
296 New_pal_254_bash = 1;
298 New_pal[254*3+1] = 0;
299 New_pal[254*3+2] = 0;
300 gr_palette_load( New_pal );
303 switch (Animating_bitmap_type) {
306 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
307 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
311 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
312 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break
315 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
316 default: Int3(); // Impossible, illegal value for Animating_bitmap_type
320 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
321 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
324 pound_signp = strchr(Bitmap_name, '#');
325 Assert(pound_signp != NULL);
327 dig1 = *(pound_signp+1);
328 dig2 = *(pound_signp+2);
332 num = (dig1-'0')*10 + (dig2-'0');
334 switch (Animating_bitmap_type) {
337 if (num > EXIT_DOOR_MAX) {
340 } else if (num < 0) {
347 if (num > OTHER_THING_MAX)
354 *(pound_signp+1) = (num / 10) + '0';
355 *(pound_signp+2) = (num % 10) + '0';
356 *(pound_signp+3) = 0;
358 *(pound_signp+1) = (num % 10) + '0';
359 *(pound_signp+2) = 0;
364 bi = piggy_find_bitmap(Bitmap_name);
365 bitmap_ptr = &GameBitmaps[bi.index];
369 WIN(DDGRLOCK(dd_grd_curcanv));
370 gr_bitmapm(0, 0, bitmap_ptr);
371 WIN(DDGRUNLOCK(dd_grd_curcanv));
374 dd_grd_curcanv = curcanv_save,
375 grd_curcanv = curcanv_save
379 switch (Animating_bitmap_type) {
381 if (num == EXIT_DOOR_MAX) {
384 } else if (num == 0) {
396 // -----------------------------------------------------------------------------
397 void show_briefing_bitmap(grs_bitmap *bmp)
400 dd_grs_canvas *bitmap_canv, *curcanv_save;
402 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
403 curcanv_save = dd_grd_curcanv;
404 dd_gr_set_current_canvas(bitmap_canv);
405 DDGRLOCK(dd_grd_curcanv);
407 DDGRUNLOCK(dd_grd_curcanv);
408 dd_gr_set_current_canvas(curcanv_save);
410 grs_canvas *curcanv_save, *bitmap_canv;
412 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
413 curcanv_save = grd_curcanv;
414 gr_set_current_canvas(bitmap_canv);
415 gr_bitmapm(0, 0, bmp);
416 gr_set_current_canvas(curcanv_save);
423 // -----------------------------------------------------------------------------
424 void show_spinning_robot_frame(int robot_num)
426 grs_canvas *curcanv_save;
428 if (robot_num != -1) {
429 Robot_angles.h += 150;
431 curcanv_save = grd_curcanv;
432 grd_curcanv = Robot_canv;
433 Assert(Robot_info[robot_num].model_num != -1);
434 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
435 grd_curcanv = curcanv_save;
440 // -----------------------------------------------------------------------------
441 void init_spinning_robot(int x,int y,int w,int h)
447 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
452 // -----------------------------------------------------------------------------
453 // Returns char width.
454 // If show_robot_flag set, then show a frame of the spinning robot.
455 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
459 static fix start_time=0;
462 message[0] = the_char;
465 if (start_time==0 && timer_get_fixed_seconds()<0)
466 start_time=timer_get_fixed_seconds();
468 gr_get_string_size(message, &w, &h, &aw );
470 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
472 // Draw cursor if there is some delay and caller says to draw cursor
473 if (cursor_flag && delay) {
474 WIN(DDGRLOCK(dd_grd_curcanv));
475 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
476 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
477 WIN(DDGRUNLOCK(dd_grd_curcanv));
481 delay=fixdiv (F1_0,i2f(15));
486 if (RobotPlaying && (delay != 0))
490 while (timer_get_fixed_seconds() < (start_time + delay))
492 if (RobotPlaying && delay != 0)
496 start_time = timer_get_fixed_seconds();
498 WIN(DDGRLOCK(dd_grd_curcanv));
500 if (cursor_flag && delay) {
501 gr_set_fontcolor(Erase_color, -1);
502 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
505 // Draw the character
506 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
507 gr_printf(Briefing_text_x, Briefing_text_y, message );
509 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
510 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
511 WIN(DDGRUNLOCK(dd_grd_curcanv));
513 // if (the_char != ' ')
514 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
515 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
520 // -----------------------------------------------------------------------------
521 int load_briefing_screen( int screen_num )
525 WIN(DDGRLOCK(dd_grd_curcanv));
526 if ((pcx_error=pcx_read_bitmap( CurBriefScreenName, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
527 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));
528 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);
529 WIN(DDGRUNLOCK(dd_grd_curcanv));
530 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
532 WIN(DDGRUNLOCK(dd_grd_curcanv));
539 int load_new_briefing_screen( char *fname )
543 mprintf ((0,"Loading new briefing %s!\n",fname));
544 strcpy (CurBriefScreenName,fname);
546 // WIN(DEFINE_SCREEN(CurBriefScreenName));
548 if (gr_palette_fade_out( New_pal, 32, 0 ))
551 WIN(DDGRLOCK(dd_grd_curcanv));
552 if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
553 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);
554 WIN(DDGRUNLOCK(dd_grd_curcanv));
555 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
557 WIN(DDGRUNLOCK(dd_grd_curcanv));
561 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
563 if (gr_palette_fade_in( New_pal, 32, 0 ))
565 DoBriefingColorStuff();
572 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
574 // -----------------------------------------------------------------------------
575 int get_message_num(char **message)
579 while (**message == ' ')
582 while ((**message >= '0') && (**message <= '9')) {
583 num = 10*num + **message-'0';
587 while (*(*message)++ != 10) // Get and drop eoln
593 // -----------------------------------------------------------------------------
594 void get_message_name(char **message, char *result)
596 while (**message == ' ')
599 while ((**message != ' ') && (**message != 10)) {
600 if (**message != '\n')
601 *result++ = **message;
606 while (*(*message)++ != 10) // Get and drop eoln
612 // -----------------------------------------------------------------------------
613 void flash_cursor(int cursor_flag)
615 if (cursor_flag == 0)
618 WIN(DDGRLOCK(dd_grd_curcanv));
619 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
620 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
622 gr_set_fontcolor(Erase_color, -1);
624 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
625 WIN(DDGRUNLOCK(dd_grd_curcanv));
628 extern int InitMovieBriefing();
630 // -----------------------------------------------------------------------------
631 // Return true if message got aborted by user (pressed ESC), else return false.
632 int show_briefing_message(int screen_num, char *message)
636 briefing_screen *bsp = &Briefing_screens[screen_num];
637 int delay_count = KEY_DELAY_DEFAULT;
641 static int tab_stop=0;
642 int flashing_cursor=0;
643 int new_page=0,GotZ=0;
644 char *spinRobotName="rba.mve",kludge; // matt don't change this!
648 int hum_channel=-1,printing_channel=-1;
649 int LineAdjustment=0;
650 WIN(int wpage_done=0);
659 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
662 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
663 gr_set_curfont( GAME_FONT );
665 bsp=&Briefing_screens[0];
666 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
674 screen_num=DefineBriefingBox (&message);
675 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
677 bsp = &Briefing_screens[screen_num];
678 init_char_pos(bsp->text_ulx, bsp->text_uly);
680 prev_ch = 10; // read to eoln
684 screen_num=get_message_num(&message);
685 bsp = &Briefing_screens[screen_num];
686 init_char_pos(bsp->text_ulx, bsp->text_uly);
687 prev_ch = 10; // read to eoln
690 else if (ch == 'C') {
691 Current_color = get_message_num(&message)-1;
692 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
694 } else if (ch == 'F') { // toggle flashing cursor
695 flashing_cursor = !flashing_cursor;
697 while (*message++ != 10)
699 } else if (ch == 'T') {
700 tab_stop = get_message_num(&message);
701 tab_stop*=(1+MenuHires);
702 prev_ch = 10; // read to eoln
703 } else if (ch == 'R') {
704 if (Robot_canv != NULL)
716 spinRobotName[2]=kludge; // ugly but proud
718 RobotPlaying=InitRobotMovie(spinRobotName);
720 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
724 DoBriefingColorStuff ();
725 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
728 prev_ch = 10; // read to eoln
729 } else if (ch == 'N') {
730 //--grs_bitmap *bitmap_ptr;
731 if (Robot_canv != NULL)
732 {d_free(Robot_canv); Robot_canv=NULL;}
734 get_message_name(&message, Bitmap_name);
735 strcat(Bitmap_name, "#0");
736 Animating_bitmap_type = 0;
738 } else if (ch == 'O') {
739 if (Robot_canv != NULL)
740 {d_free(Robot_canv); Robot_canv=NULL;}
742 get_message_name(&message, Bitmap_name);
743 strcat(Bitmap_name, "#0");
744 Animating_bitmap_type = 1;
746 } else if (ch=='A') {
747 LineAdjustment=1-LineAdjustment;
748 } else if (ch=='Z') {
749 mprintf ((0,"Got a Z!\n"));
751 #if defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
754 if (LineAdjustment==1)
761 while ((fname[i]=*message) != '\n') {
770 while (fname[i]!='.')
779 load_new_briefing_screen (fname);
782 load_new_briefing_screen (fname);
784 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
786 } else if (ch == 'B') {
787 char bitmap_name[32];
788 grs_bitmap guy_bitmap;
789 ubyte temp_palette[768];
792 if (Robot_canv != NULL)
793 {d_free(Robot_canv); Robot_canv=NULL;}
795 get_message_name(&message, bitmap_name);
796 strcat(bitmap_name, ".bbm");
797 guy_bitmap.bm_data = NULL;
798 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
799 Assert(iff_error == IFF_NO_ERROR);
800 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
802 show_briefing_bitmap(&guy_bitmap);
803 d_free(guy_bitmap.bm_data);
805 // } else if (ch==EOF) {
807 // } else if (ch == 'B') {
808 // if (Robot_canv != NULL)
809 // {d_free(Robot_canv); Robot_canv=NULL;}
811 // bitmap_num = get_message_num(&message);
812 // if (bitmap_num != -1)
813 // show_briefing_bitmap(Textures[bitmap_num]);
814 // prev_ch = 10; // read to eoln
815 } else if (ch == 'S') {
820 if (printing_channel>-1)
821 digi_stop_sound( printing_channel );
831 start_time = timer_get_fixed_seconds();
832 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
835 _RedrawScreen = FALSE;
836 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
842 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
844 flash_cursor(flashing_cursor);
846 if (RobotPlaying) RotateRobot ();
849 start_time += KEY_DELAY_DEFAULT/2;
853 if (keypress == KEY_BACKSP)
856 if (keypress == KEY_ESC)
862 } else if (ch == 'P') { // New page.
865 Int3(); // Hey ryan!!!! You gotta load a screen before you start
866 // printing to it! You know, $Z !!!
867 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
872 while (*message != 10) {
873 message++; // drop carriage return after special escape sequence
878 } else if (ch == '\t') { // Tab
879 if (Briefing_text_x - bsp->text_ulx < tab_stop)
880 Briefing_text_x = bsp->text_ulx + tab_stop;
881 } else if ((ch == ';') && (prev_ch == 10)) {
882 while (*message++ != 10)
885 } else if (ch == '\\') {
887 } else if (ch == 10) {
888 if (prev_ch != '\\') {
891 Briefing_text_y += (8*(MenuHires+1));
894 Briefing_text_x = bsp->text_ulx;
895 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
896 load_briefing_screen(screen_num);
897 Briefing_text_x = bsp->text_ulx;
898 Briefing_text_y = bsp->text_uly;
901 if (ch == 13) //Can this happen? Above says ch==10
909 Int3(); // Hey ryan!!!! You gotta load a screen before you start
910 // printing to it! You know, $Z !!!
911 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
918 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
922 WIN(if (GRMODEINFO(emul)) delay_count = 0);
924 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
928 // Check for Esc -> abort.
929 key_check = local_key_inkey();
933 _RedrawScreen = FALSE;
934 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
938 if ( key_check == KEY_ESC ) {
943 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
946 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
947 Briefing_text_x = bsp->text_ulx;
948 Briefing_text_y += bsp->text_uly;
951 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
957 if (printing_channel>-1)
958 digi_stop_sound( printing_channel );
970 start_time = timer_get_fixed_seconds();
971 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
974 _RedrawScreen = FALSE;
975 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
981 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
983 flash_cursor(flashing_cursor);
985 if (RobotPlaying) RotateRobot();
988 start_time += KEY_DELAY_DEFAULT/2;
991 if (RobotPlaying) DeInitRobotMovie();
996 if (keypress == KEY_BACKSP)
999 if (keypress == KEY_ESC) {
1004 load_briefing_screen(screen_num);
1005 Briefing_text_x = bsp->text_ulx;
1006 Briefing_text_y = bsp->text_uly;
1007 delay_count = KEY_DELAY_DEFAULT;
1009 WIN(wpage_done = 0);
1020 if (Robot_canv != NULL)
1021 {d_free(Robot_canv); Robot_canv=NULL;}
1024 digi_stop_sound( hum_channel );
1025 if (printing_channel>-1)
1026 digi_stop_sound( printing_channel );
1031 // -----------------------------------------------------------------------------
1032 // Return a pointer to the start of text for screen #screen_num.
1033 char * get_briefing_message(int screen_num)
1035 char *tptr = Briefing_text;
1039 Assert(screen_num >= 0);
1041 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1046 cur_screen = get_message_num(&tptr);
1050 if (screen_num!=cur_screen)
1056 // -----------------------------------------------------------------------------
1057 // Load Descent briefing text.
1058 int load_screen_text(char *filename, char **buf)
1063 int have_binary = 0;
1065 if ((tfile = cfopen(filename,"rb")) == NULL) {
1066 char nfilename[30], *ptr;
1068 strcpy(nfilename, filename);
1069 ptr = strrchr(nfilename, '.');
1071 strcat(nfilename, ".txb");
1072 if ((ifile = cfopen(nfilename, "rb")) == NULL)
1074 mprintf ((0,"can't open %s!\n",nfilename));
1076 //Error("Cannot open file %s or %s", filename, nfilename);
1079 mprintf ((0,"reading...\n"));
1082 len = cfilelength(ifile);
1083 MALLOC(*buf, char, len+500);
1084 mprintf ((0,"len=%d\n",len));
1085 for (x=0,i=0;i<len;i++,x++)
1087 cfread (*buf+x,1,1,ifile);
1088 // mprintf ((0,"%c",*(*buf+x)));
1095 len = cfilelength(tfile);
1096 MALLOC(*buf, char, len+500);
1097 for (x=0,i=0;i<len;i++,x++)
1099 cfread (*buf+x,1,1,tfile);
1100 // mprintf ((0,"%c",*(*buf+x)));
1106 //cfread(*buf, 1, len, tfile);
1113 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1115 encode_rotate_left(ptr);
1116 *ptr = *ptr ^ BITMAP_TBL_XOR;
1117 encode_rotate_left(ptr);
1125 // -----------------------------------------------------------------------------
1126 // Return true if message got aborted, else return false.
1127 int show_briefing_text(int screen_num)
1131 message_ptr = get_briefing_message(screen_num);
1132 if (message_ptr==NULL)
1135 DoBriefingColorStuff();
1137 return show_briefing_message(screen_num, message_ptr);
1139 void DoBriefingColorStuff ()
1141 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1142 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1144 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1145 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1147 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1148 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1150 Erase_color = gr_find_closest_color_current(0, 0, 0);
1153 // -----------------------------------------------------------------------------
1154 // Return true if screen got aborted by user, else return false.
1155 int show_briefing_screen( int screen_num, int allow_keys)
1158 ubyte palette_save[768];
1160 New_pal_254_bash = 0;
1162 if (Skip_briefing_screens) {
1163 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1167 // briefing_bm.bm_data=NULL;
1168 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1169 // 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));
1174 memcpy(palette_save,gr_palette,sizeof(palette_save));
1175 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1178 // vfx_set_palette_sub( New_pal );
1179 // gr_palette_clear();
1180 // gr_bitmap( 0, 0, &briefing_bm );
1182 gr_palette_load(New_pal);
1185 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1187 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1190 key_close(); // kill the keyboard handler during briefing screens for movies
1192 rval = show_briefing_text(screen_num);
1197 #if defined (MACINTOSH) || defined(WINDOWS)
1198 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1203 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1206 DEFINE_SCREEN(NULL);
1207 WIN(DDGRLOCK(dd_grd_curcanv));
1208 gr_clear_canvas (0);
1209 WIN(DDGRUNLOCK(dd_grd_curcanv));
1210 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1214 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1216 // d_free(briefing_bm.bm_data);
1222 // -----------------------------------------------------------------------------
1223 void do_briefing_screens(char *filename,int level_num)
1228 if (Skip_briefing_screens) {
1229 mprintf((0, "Skipping all briefing screens.\n"));
1234 return; // no briefing screens at all for demo
1237 mprintf ((0,"Trying briefing screen! %s\n",filename));
1242 if (!load_screen_text(filename, &Briefing_text))
1246 songs_play_song( SONG_BRIEFING, 1 );
1251 set_screen_mode( SCREEN_MENU );
1254 dd_gr_set_current_canvas(NULL),
1255 gr_set_current_canvas(NULL)
1258 mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num));
1262 show_briefing_screen(level_num,0);
1264 d_free (Briefing_text);
1271 int DefineBriefingBox (char **buf)
1276 n=get_new_message_num (buf);
1278 Assert(n < MAX_BRIEFING_SCREENS);
1286 name[i]='\0'; // slap a delimiter on this guy
1288 strcpy (Briefing_screens[n].bs_name,name);
1289 Briefing_screens[n].level_num=get_new_message_num (buf);
1290 Briefing_screens[n].message_num=get_new_message_num (buf);
1291 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1292 Briefing_screens[n].text_uly=get_new_message_num (buf);
1293 Briefing_screens[n].text_width=get_new_message_num (buf);
1294 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1298 Briefing_screens[n].text_ulx*=2;
1299 Briefing_screens[n].text_uly*=2.4;
1300 Briefing_screens[n].text_width*=2;
1301 Briefing_screens[n].text_height*=2.4;
1307 int get_new_message_num(char **message)
1311 while (**message == ' ')
1314 while ((**message >= '0') && (**message <= '9')) {
1315 num = 10*num + **message-'0';