1 /* $Id: titles.c,v 1.31 2004-10-09 15:59:28 schaffner Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Routines to display title screens...
37 #include "pa_enabl.h" //$$POLY_ACC
73 void DoBriefingColorStuff ();
74 int get_new_message_num(char **message);
75 int DefineBriefingBox (char **buf);
77 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
82 char CurBriefScreenName[15]="brief03.pcx";
86 //Begin D1X modification
87 #define MAX_BRIEFING_COLORS 7
88 //End D1X modification
90 // Descent 1 briefings
91 char Ending_text_filename[13] = "endreg.txt";
92 char Briefing_text_filename[13] = "briefing.txt";
94 #define SHAREWARE_ENDING_FILENAME "ending.tex"
96 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
97 int Skip_briefing_screens=0;
98 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
99 int Current_color = 0;
102 extern int check_button_press();
105 extern void macintosh_quit(void);
108 // added by Jan Bobrowski for variable-size menu screen
109 static int rescale_x(int x)
111 return x * GWIDTH / 320;
114 static int rescale_y(int y)
116 return y * GHEIGHT / 200;
120 int local_key_inkey(void)
127 DoMessageStuff(&msg);
132 if (rval == KEY_PRINT_SCREEN) {
135 gr_palette_read(gr_palette);
136 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?
145 else if (mouse_button_state(0))
149 if ( rval == KEY_Q+KEY_COMMAND )
156 int local_key_inkey(void)
161 if (!GetOSEvent(everyEvent, &event))
164 if (event.what != keyDown)
167 rval = (int)((event.message & keyCodeMask) >> 8);
169 if (rval == KEY_PRINT_SCREEN) {
171 return 0; //say no key pressed
174 if (check_button_press()) //joystick or mouse button pressed?
178 if ( rval == KEY_Q+KEY_COMMAND )
186 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
191 ubyte palette_save[768];
192 char new_filename[FILENAME_LEN+1] = "";
196 strcpy(new_filename,"\x01"); //only read from hog file
199 strcat(new_filename,filename);
200 filename = new_filename;
202 title_bm.bm_data=NULL;
203 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
204 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
205 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));
206 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
209 memcpy(palette_save,gr_palette,sizeof(palette_save));
211 #if defined(POLY_ACC)
213 pa_update_clut(New_pal, 0, 256, 0);
216 //vfx_set_palette_sub( New_pal );
218 gr_palette_load( New_pal );
224 dd_gr_set_current_canvas(NULL),
225 gr_set_current_canvas( NULL )
227 WIN(DDGRLOCK(dd_grd_curcanv));
228 show_fullscr(&title_bm);
229 WIN(DDGRUNLOCK(dd_grd_curcanv));
233 #if defined(POLY_ACC)
237 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
239 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
241 gr_palette_load( New_pal );
242 timer = timer_get_fixed_seconds() + i2f(3);
244 if ( local_key_inkey() && allow_keys ) break;
245 if ( timer_get_fixed_seconds() > timer ) break;
247 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
249 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
250 d_free(title_bm.bm_data);
255 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
258 short text_ulx, text_uly; // upper left x,y of text window
259 short text_width, text_height; // width and height of text window
262 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
263 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
265 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
266 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
269 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
271 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
274 #define MAX_BRIEFING_SCREENS 60
277 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
278 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
280 briefing_screen Briefing_screens[] = {
281 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
282 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
283 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
284 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
286 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
287 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
288 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
290 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
291 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
293 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
294 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
295 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
298 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
299 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
300 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
301 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
302 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
304 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
305 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
306 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
307 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
308 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
310 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
311 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
312 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
313 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
314 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
316 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
317 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
318 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
319 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
321 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
322 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
323 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
325 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
326 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
327 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
329 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
330 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
331 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
334 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
336 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
337 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
338 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
345 int Briefing_text_x, Briefing_text_y;
347 void init_char_pos(int x, int y)
351 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
354 grs_canvas *Robot_canv = NULL;
355 vms_angvec Robot_angles;
357 char Bitmap_name[32] = "";
358 #define EXIT_DOOR_MAX 14
359 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
360 #define DOOR_DIV_INIT 6
361 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
363 //-----------------------------------------------------------------------------
364 void show_bitmap_frame(void)
367 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
369 grs_canvas *curcanv_save, *bitmap_canv=0;
372 grs_bitmap *bitmap_ptr;
374 // Only plot every nth frame.
375 if (Door_div_count) {
380 Door_div_count = DOOR_DIV_INIT;
382 if (Bitmap_name[0] != 0) {
386 // Set supertransparency color to black
387 if (!New_pal_254_bash) {
388 New_pal_254_bash = 1;
390 New_pal[254*3+1] = 0;
391 New_pal[254*3+2] = 0;
392 gr_palette_load( New_pal );
395 switch (Animating_bitmap_type) {
397 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break,
398 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break
402 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break,
403 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break
406 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
408 Int3(); // Impossible, illegal value for Animating_bitmap_type
412 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
413 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
416 pound_signp = strchr(Bitmap_name, '#');
417 Assert(pound_signp != NULL);
419 dig1 = *(pound_signp+1);
420 dig2 = *(pound_signp+2);
424 num = (dig1-'0')*10 + (dig2-'0');
426 switch (Animating_bitmap_type) {
429 if (num > EXIT_DOOR_MAX) {
432 } else if (num < 0) {
439 if (num > OTHER_THING_MAX)
446 *(pound_signp+1) = (num / 10) + '0';
447 *(pound_signp+2) = (num % 10) + '0';
448 *(pound_signp+3) = 0;
450 *(pound_signp+1) = (num % 10) + '0';
451 *(pound_signp+2) = 0;
456 bi = piggy_find_bitmap(Bitmap_name);
457 bitmap_ptr = &GameBitmaps[bi.index];
461 WIN(DDGRLOCK(dd_grd_curcanv));
462 gr_bitmapm(0, 0, bitmap_ptr);
463 WIN(DDGRUNLOCK(dd_grd_curcanv));
466 dd_grd_curcanv = curcanv_save,
467 grd_curcanv = curcanv_save
471 switch (Animating_bitmap_type) {
473 if (num == EXIT_DOOR_MAX) {
476 } else if (num == 0) {
488 //-----------------------------------------------------------------------------
489 void show_briefing_bitmap(grs_bitmap *bmp)
492 dd_grs_canvas *bitmap_canv, *curcanv_save;
494 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
495 curcanv_save = dd_grd_curcanv;
496 dd_gr_set_current_canvas(bitmap_canv);
497 DDGRLOCK(dd_grd_curcanv);
499 DDGRUNLOCK(dd_grd_curcanv);
500 dd_gr_set_current_canvas(curcanv_save);
502 grs_canvas *curcanv_save, *bitmap_canv;
504 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
505 curcanv_save = grd_curcanv;
506 gr_set_current_canvas(bitmap_canv);
507 gr_bitmapm(0, 0, bmp);
508 gr_set_current_canvas(curcanv_save);
515 //-----------------------------------------------------------------------------
516 void show_spinning_robot_frame(int robot_num)
518 grs_canvas *curcanv_save;
520 if (robot_num != -1) {
521 Robot_angles.h += 150;
523 curcanv_save = grd_curcanv;
524 grd_curcanv = Robot_canv;
525 Assert(Robot_info[robot_num].model_num != -1);
526 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
527 grd_curcanv = curcanv_save;
532 //-----------------------------------------------------------------------------
533 void init_spinning_robot(void) //(int x,int y,int w,int h)
535 //Robot_angles.p += 0;
536 //Robot_angles.b += 0;
537 //Robot_angles.h += 0;
539 int x = rescale_x(138);
540 int y = rescale_y(55);
541 int w = rescale_x(166);
542 int h = rescale_y(138);
544 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
549 //---------------------------------------------------------------------------
550 // Returns char width.
551 // If show_robot_flag set, then show a frame of the spinning robot.
552 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
556 static fix start_time=0;
558 message[0] = the_char;
561 if (start_time==0 && timer_get_fixed_seconds()<0)
562 start_time=timer_get_fixed_seconds();
564 gr_get_string_size(message, &w, &h, &aw );
566 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
568 // Draw cursor if there is some delay and caller says to draw cursor
569 if (cursor_flag && delay) {
570 WIN(DDGRLOCK(dd_grd_curcanv));
571 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
572 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
573 WIN(DDGRUNLOCK(dd_grd_curcanv));
578 delay=fixdiv (F1_0,i2f(15));
580 if ((Bitmap_name[0] != 0) && (delay != 0))
583 if (RobotPlaying && (delay != 0))
586 while (timer_get_fixed_seconds() < (start_time + delay)) {
587 if (RobotPlaying && delay != 0)
591 show_spinning_robot_frame(robot_num);
593 start_time = timer_get_fixed_seconds();
595 WIN(DDGRLOCK(dd_grd_curcanv));
597 if (cursor_flag && delay) {
598 gr_set_fontcolor(Erase_color, -1);
599 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
602 // Draw the character
603 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
604 gr_printf(Briefing_text_x, Briefing_text_y, message );
606 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
607 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
608 WIN(DDGRUNLOCK(dd_grd_curcanv));
610 if (delay) gr_update();
612 // if (the_char != ' ')
613 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
614 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
619 //-----------------------------------------------------------------------------
620 int load_briefing_screen( int screen_num )
626 fname = Briefing_screens[screen_num].bs_name;
628 fname = CurBriefScreenName;
630 WIN(DDGRLOCK(dd_grd_curcanv));
631 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
632 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
633 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);
634 WIN(DDGRUNLOCK(dd_grd_curcanv));
635 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
637 WIN(DDGRUNLOCK(dd_grd_curcanv));
644 int load_new_briefing_screen( char *fname )
648 mprintf ((0,"Loading new briefing <%s>\n",fname));
649 strcpy (CurBriefScreenName,fname);
651 //WIN(DEFINE_SCREEN(CurBriefScreenName));
653 if (gr_palette_fade_out( New_pal, 32, 0 ))
656 WIN(DDGRLOCK(dd_grd_curcanv));
657 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
658 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
659 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);
660 WIN(DDGRUNLOCK(dd_grd_curcanv));
661 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
663 WIN(DDGRUNLOCK(dd_grd_curcanv));
667 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
669 if (gr_palette_fade_in( New_pal, 32, 0 ))
671 DoBriefingColorStuff();
678 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
680 //-----------------------------------------------------------------------------
681 int get_message_num(char **message)
685 while (**message == ' ')
688 while ((**message >= '0') && (**message <= '9')) {
689 num = 10*num + **message-'0';
693 while (*(*message)++ != 10) // Get and drop eoln
699 //-----------------------------------------------------------------------------
700 void get_message_name(char **message, char *result)
702 while (**message == ' ')
705 while ((**message != ' ') && (**message != 10)) {
706 if (**message != '\n')
707 *result++ = **message;
712 while (*(*message)++ != 10) // Get and drop eoln
718 //-----------------------------------------------------------------------------
719 void flash_cursor(int cursor_flag)
721 if (cursor_flag == 0)
724 WIN(DDGRLOCK(dd_grd_curcanv));
725 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
726 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
728 gr_set_fontcolor(Erase_color, -1);
730 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
731 WIN(DDGRUNLOCK(dd_grd_curcanv));
735 extern int InitMovieBriefing();
738 //-----------------------------------------------------------------------------
739 // Return true if message got aborted by user (pressed ESC), else return false.
740 int show_briefing_message(int screen_num, char *message)
744 briefing_screen *bsp;
745 int delay_count = KEY_DELAY_DEFAULT;
749 static int tab_stop=0;
750 int flashing_cursor=0;
751 int new_page=0,GotZ=0;
752 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
756 int hum_channel=-1,printing_channel=-1;
757 int LineAdjustment=1;
758 WIN(int wpage_done=0);
767 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
770 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
771 gr_set_curfont( GAME_FONT );
775 MALLOC(bsp, briefing_screen, 1);
776 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
777 bsp->text_ulx = rescale_x(bsp->text_ulx);
778 bsp->text_uly = rescale_y(bsp->text_uly);
779 bsp->text_width = rescale_x(bsp->text_width);
780 bsp->text_height = rescale_y(bsp->text_height);
781 init_char_pos(bsp->text_ulx, bsp->text_uly);
783 bsp=&Briefing_screens[0];
784 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
792 screen_num=DefineBriefingBox (&message);
793 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
795 bsp = &Briefing_screens[screen_num];
796 init_char_pos(bsp->text_ulx, bsp->text_uly);
798 prev_ch = 10; // read to eoln
799 } else if (ch=='U') {
800 screen_num=get_message_num(&message);
801 bsp = &Briefing_screens[screen_num];
802 init_char_pos(bsp->text_ulx, bsp->text_uly);
803 prev_ch = 10; // read to eoln
804 } else if (ch == 'C') {
805 Current_color = get_message_num(&message)-1;
806 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
808 } else if (ch == 'F') { // toggle flashing cursor
809 flashing_cursor = !flashing_cursor;
811 while (*message++ != 10)
813 } else if (ch == 'T') {
814 tab_stop = get_message_num(&message);
815 tab_stop*=(1+MenuHires);
816 prev_ch = 10; // read to eoln
817 } else if (ch == 'R') {
818 if (Robot_canv != NULL) {
828 init_spinning_robot();
829 robot_num = get_message_num(&message);
830 while (*message++ != 10)
834 spinRobotName[2]=kludge; // ugly but proud
836 RobotPlaying=InitRobotMovie(spinRobotName);
838 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
842 DoBriefingColorStuff ();
843 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
846 prev_ch = 10; // read to eoln
847 } else if (ch == 'N') {
848 //--grs_bitmap *bitmap_ptr;
849 if (Robot_canv != NULL) {
854 get_message_name(&message, Bitmap_name);
855 strcat(Bitmap_name, "#0");
856 Animating_bitmap_type = 0;
858 } else if (ch == 'O') {
859 if (Robot_canv != NULL) {
864 get_message_name(&message, Bitmap_name);
865 strcat(Bitmap_name, "#0");
866 Animating_bitmap_type = 1;
868 } else if (ch=='A') {
869 LineAdjustment=1-LineAdjustment;
870 } else if (ch=='Z') {
871 //mprintf ((0,"Got a Z!\n"));
873 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
876 if (LineAdjustment==1)
883 while ((fname[i]=*message) != '\n') {
889 while (*message++ != 10) // Get and drop eoln
896 while (fname[i]!='.') {
897 fname2[i] = fname[i];
907 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
908 load_new_briefing_screen (fname2);
910 load_new_briefing_screen (fname);
913 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
915 } else if (ch == 'B') {
916 char bitmap_name[32];
917 grs_bitmap guy_bitmap;
918 ubyte temp_palette[768];
921 if (Robot_canv != NULL) {
926 get_message_name(&message, bitmap_name);
927 strcat(bitmap_name, ".bbm");
928 guy_bitmap.bm_data = NULL;
929 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
930 Assert(iff_error == IFF_NO_ERROR);
931 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
933 show_briefing_bitmap(&guy_bitmap);
934 d_free(guy_bitmap.bm_data);
936 // } else if (ch==EOF) {
938 // } else if (ch == 'B') {
939 // if (Robot_canv != NULL) {
940 // d_free(Robot_canv);
944 // bitmap_num = get_message_num(&message);
945 // if (bitmap_num != -1)
946 // show_briefing_bitmap(Textures[bitmap_num]);
947 // prev_ch = 10; // read to eoln
948 } else if (ch == 'S') {
953 if (printing_channel>-1)
954 digi_stop_sound( printing_channel );
966 start_time = timer_get_fixed_seconds();
967 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
970 _RedrawScreen = FALSE;
971 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
977 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
979 flash_cursor(flashing_cursor);
984 show_spinning_robot_frame(robot_num);
986 if (Bitmap_name[0] != 0)
988 start_time += KEY_DELAY_DEFAULT/2;
992 if (keypress == KEY_BACKSP)
995 if (keypress == KEY_ESC)
1000 WIN(wpage_done = 0);
1001 } else if (ch == 'P') { // New page.
1003 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1004 // printing to it! You know, $Z !!!
1005 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1009 while (*message != 10) {
1010 message++; // drop carriage return after special escape sequence
1016 } else if (ch == '\t') { // Tab
1017 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1018 Briefing_text_x = bsp->text_ulx + tab_stop;
1019 } else if ((ch == ';') && (prev_ch == 10)) {
1020 while (*message++ != 10)
1023 } else if (ch == '\\') {
1025 } else if (ch == 10) {
1026 if (prev_ch != '\\') {
1029 Briefing_text_y += (8*(MenuHires+1));
1032 Briefing_text_x = bsp->text_ulx;
1033 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1034 load_briefing_screen(screen_num);
1035 Briefing_text_x = bsp->text_ulx;
1036 Briefing_text_y = bsp->text_uly;
1039 if (ch == 13) //Can this happen? Above says ch==10
1046 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1047 // printing to it! You know, $Z !!!
1048 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1054 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1058 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1060 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1064 // Check for Esc -> abort.
1066 key_check=local_key_inkey();
1071 if (_RedrawScreen) {
1072 _RedrawScreen = FALSE;
1073 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1074 key_check = KEY_ESC;
1077 if ( key_check == KEY_ESC ) {
1082 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1085 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1086 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1087 (key_check == KEY_ALTED+KEY_PADENTER))
1088 gr_toggle_fullscreen();
1091 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1092 Briefing_text_x = bsp->text_ulx;
1093 Briefing_text_y += bsp->text_uly;
1096 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1102 if (printing_channel>-1)
1103 digi_stop_sound( printing_channel );
1104 printing_channel=-1;
1115 start_time = timer_get_fixed_seconds();
1116 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1118 if (_RedrawScreen) {
1119 _RedrawScreen = FALSE;
1120 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1126 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1128 flash_cursor(flashing_cursor);
1131 if (robot_num != -1)
1132 show_spinning_robot_frame(robot_num);
1133 if (Bitmap_name[0] != 0)
1134 show_bitmap_frame();
1135 start_time += KEY_DELAY_DEFAULT/2;
1144 if (keypress == KEY_BACKSP)
1147 if (keypress == KEY_ESC) {
1152 load_briefing_screen(screen_num);
1153 Briefing_text_x = bsp->text_ulx;
1154 Briefing_text_y = bsp->text_uly;
1155 delay_count = KEY_DELAY_DEFAULT;
1157 WIN(wpage_done = 0);
1166 if (Robot_canv != NULL)
1167 {d_free(Robot_canv); Robot_canv=NULL;}
1170 digi_stop_sound( hum_channel );
1171 if (printing_channel>-1)
1172 digi_stop_sound( printing_channel );
1180 //-----------------------------------------------------------------------------
1181 // Return a pointer to the start of text for screen #screen_num.
1182 char * get_briefing_message(int screen_num)
1184 char *tptr = Briefing_text;
1188 Assert(screen_num >= 0);
1190 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1195 cur_screen = get_message_num(&tptr);
1199 if (screen_num!=cur_screen)
1205 //-----------------------------------------------------------------------------
1206 // Load Descent briefing text.
1207 int load_screen_text(char *filename, char **buf)
1212 int have_binary = 0;
1214 if ((tfile = cfopen(filename,"rb")) == NULL) {
1215 char nfilename[30], *ptr;
1217 strcpy(nfilename, filename);
1218 if ((ptr = strrchr(nfilename, '.')))
1220 strcat(nfilename, ".txb");
1221 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1222 mprintf ((0,"can't open %s!\n",nfilename));
1224 //Error("Cannot open file %s or %s", filename, nfilename);
1227 mprintf ((0,"reading...\n"));
1230 len = cfilelength(ifile);
1231 MALLOC(*buf, char, len+500);
1232 mprintf ((0,"len=%d\n",len));
1233 for (x=0, i=0; i < len; i++, x++) {
1234 cfread (*buf+x,1,1,ifile);
1235 // mprintf ((0,"%c",*(*buf+x)));
1242 len = cfilelength(tfile);
1243 MALLOC(*buf, char, len+500);
1244 for (x=0, i=0; i < len; i++, x++) {
1245 cfread (*buf+x,1,1,tfile);
1246 // mprintf ((0,"%c",*(*buf+x)));
1252 //cfread(*buf, 1, len, tfile);
1259 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1261 encode_rotate_left(ptr);
1262 *ptr = *ptr ^ BITMAP_TBL_XOR;
1263 encode_rotate_left(ptr);
1271 //-----------------------------------------------------------------------------
1272 // Return true if message got aborted, else return false.
1273 int show_briefing_text(int screen_num)
1277 message_ptr = get_briefing_message
1278 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1280 if (message_ptr==NULL)
1283 DoBriefingColorStuff();
1285 return show_briefing_message(screen_num, message_ptr);
1288 void DoBriefingColorStuff ()
1290 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1291 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1293 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1294 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1296 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1297 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1301 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1302 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1304 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1305 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1307 //Begin D1X addition
1309 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1310 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1313 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1314 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1316 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1317 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1319 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1320 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1322 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1323 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1326 Erase_color = gr_find_closest_color_current(0, 0, 0);
1329 //-----------------------------------------------------------------------------
1330 // Return true if screen got aborted by user, else return false.
1331 int show_briefing_screen( int screen_num, int allow_keys)
1334 //ubyte palette_save[768];
1336 New_pal_254_bash = 0;
1338 if (Skip_briefing_screens) {
1339 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1346 grs_bitmap briefing_bm;
1348 gr_init_bitmap_data(&briefing_bm);
1349 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1351 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1353 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1354 mprintf((0, "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));
1360 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1361 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1363 //vfx_set_palette_sub( New_pal );
1365 gr_palette_load(New_pal);
1369 gr_set_current_canvas( NULL );
1370 show_fullscr(&briefing_bm);
1373 //added on 9/13/98 by adb to make arch's requiring updates work
1375 //end changes by adb
1378 gr_free_bitmap_data (&briefing_bm);
1381 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1384 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1389 key_close(); // kill the keyboard handler during briefing screens for movies
1391 rval = show_briefing_text(screen_num);
1396 #if defined (MACINTOSH) || defined(WINDOWS)
1397 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1402 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1405 DEFINE_SCREEN(NULL);
1406 WIN(DDGRLOCK(dd_grd_curcanv));
1407 gr_clear_canvas (0);
1408 WIN(DDGRUNLOCK(dd_grd_curcanv));
1409 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1413 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1415 //d_free(briefing_bm.bm_data);
1421 //-----------------------------------------------------------------------------
1422 void do_briefing_screens(char *filename,int level_num)
1424 int abort_briefing_screens = 0;
1425 int cur_briefing_screen = 0;
1427 if (Skip_briefing_screens) {
1428 mprintf((0, "Skipping all briefing screens.\n"));
1433 return; // no briefing screens at all for demo
1437 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1442 if (!load_screen_text(filename, &Briefing_text))
1446 songs_play_song( SONG_BRIEFING, 1 );
1451 set_screen_mode( SCREEN_MENU );
1454 dd_gr_set_current_canvas(NULL),
1455 gr_set_current_canvas(NULL)
1458 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1463 if (level_num == 1) {
1464 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1465 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1466 cur_briefing_screen++;
1470 if (!abort_briefing_screens) {
1471 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1472 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1473 if (show_briefing_screen(cur_briefing_screen, 0))
1478 show_briefing_screen(level_num,0);
1480 d_free (Briefing_text);
1487 int DefineBriefingBox (char **buf)
1492 n=get_new_message_num (buf);
1494 Assert(n < MAX_BRIEFING_SCREENS);
1496 while (**buf!=' ') {
1501 name[i]='\0'; // slap a delimiter on this guy
1503 strcpy (Briefing_screens[n].bs_name,name);
1504 Briefing_screens[n].level_num=get_new_message_num (buf);
1505 Briefing_screens[n].message_num=get_new_message_num (buf);
1506 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1507 Briefing_screens[n].text_uly=get_new_message_num (buf);
1508 Briefing_screens[n].text_width=get_new_message_num (buf);
1509 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1511 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1512 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1513 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1514 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1519 int get_new_message_num(char **message)
1523 while (**message == ' ')
1526 while ((**message >= '0') && (**message <= '9')) {
1527 num = 10*num + **message-'0';