1 /* $Id: titles.c,v 1.36 2005-02-25 09:53:17 chris 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
72 void DoBriefingColorStuff ();
73 int get_new_message_num(char **message);
74 int DefineBriefingBox (char **buf);
76 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
81 char CurBriefScreenName[15]="brief03.pcx";
85 //Begin D1X modification
86 #define MAX_BRIEFING_COLORS 7
87 //End D1X modification
89 #define SHAREWARE_ENDING_FILENAME "ending.tex"
91 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
92 int Skip_briefing_screens=0;
93 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
94 int Current_color = 0;
97 extern int check_button_press();
100 extern void macintosh_quit(void);
103 // added by Jan Bobrowski for variable-size menu screen
104 static int rescale_x(int x)
106 return x * GWIDTH / 320;
109 static int rescale_y(int y)
111 return y * GHEIGHT / 200;
115 int local_key_inkey(void)
122 DoMessageStuff(&msg);
127 if (rval == KEY_PRINT_SCREEN) {
130 gr_palette_read(gr_palette);
131 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
135 return 0; //say no key pressed
138 if (check_button_press()) //joystick or mouse button pressed?
140 else if (mouse_button_state(0))
144 if ( rval == KEY_Q+KEY_COMMAND )
151 int local_key_inkey(void)
156 if (!GetOSEvent(everyEvent, &event))
159 if (event.what != keyDown)
162 rval = (int)((event.message & keyCodeMask) >> 8);
164 if (rval == KEY_PRINT_SCREEN) {
166 return 0; //say no key pressed
169 if (check_button_press()) //joystick or mouse button pressed?
173 if ( rval == KEY_Q+KEY_COMMAND )
181 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
186 ubyte palette_save[768];
187 char new_filename[FILENAME_LEN+1] = "";
191 strcpy(new_filename,"\x01"); //only read from hog file
194 strcat(new_filename,filename);
195 filename = new_filename;
197 title_bm.bm_data=NULL;
198 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
199 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
200 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));
201 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
204 memcpy(palette_save,gr_palette,sizeof(palette_save));
206 #if defined(POLY_ACC)
208 pa_update_clut(New_pal, 0, 256, 0);
211 //vfx_set_palette_sub( New_pal );
213 gr_palette_load( New_pal );
219 dd_gr_set_current_canvas(NULL),
220 gr_set_current_canvas( NULL )
222 WIN(DDGRLOCK(dd_grd_curcanv));
223 show_fullscr(&title_bm);
224 WIN(DDGRUNLOCK(dd_grd_curcanv));
228 #if defined(POLY_ACC)
232 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
234 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
236 gr_palette_load( New_pal );
237 timer = timer_get_fixed_seconds() + i2f(3);
239 if ( local_key_inkey() && allow_keys ) break;
240 if ( timer_get_fixed_seconds() > timer ) break;
242 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
244 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
245 d_free(title_bm.bm_data);
250 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
253 short text_ulx, text_uly; // upper left x,y of text window
254 short text_width, text_height; // width and height of text window
257 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
258 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
260 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
261 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
264 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
266 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
269 #define MAX_BRIEFING_SCREENS 60
271 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
272 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
274 briefing_screen D1_Briefing_screens[] = {
275 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
276 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
277 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
278 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
280 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
281 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
282 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
284 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
285 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
287 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
288 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
289 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
292 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
293 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
294 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
295 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
296 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
298 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
299 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
300 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
301 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
302 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
304 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
305 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
306 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
307 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
308 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
310 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
311 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
312 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
313 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
315 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
316 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
317 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
319 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
320 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
321 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
323 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
324 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
325 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
328 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
330 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
331 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
332 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
338 int Briefing_text_x, Briefing_text_y;
340 void init_char_pos(int x, int y)
344 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
347 grs_canvas *Robot_canv = NULL;
348 vms_angvec Robot_angles;
350 char Bitmap_name[32] = "";
351 #define EXIT_DOOR_MAX 14
352 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
353 #define DOOR_DIV_INIT 6
354 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
356 //-----------------------------------------------------------------------------
357 void show_bitmap_frame(void)
360 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
362 grs_canvas *curcanv_save, *bitmap_canv=0;
365 grs_bitmap *bitmap_ptr;
367 // Only plot every nth frame.
368 if (Door_div_count) {
373 Door_div_count = DOOR_DIV_INIT;
375 if (Bitmap_name[0] != 0) {
379 // Set supertransparency color to black
380 if (!New_pal_254_bash) {
381 New_pal_254_bash = 1;
383 New_pal[254*3+1] = 0;
384 New_pal[254*3+2] = 0;
385 gr_palette_load( New_pal );
388 switch (Animating_bitmap_type) {
390 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break,
391 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break
395 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break,
396 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break
399 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
401 Int3(); // Impossible, illegal value for Animating_bitmap_type
405 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
406 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
409 pound_signp = strchr(Bitmap_name, '#');
410 Assert(pound_signp != NULL);
412 dig1 = *(pound_signp+1);
413 dig2 = *(pound_signp+2);
417 num = (dig1-'0')*10 + (dig2-'0');
419 switch (Animating_bitmap_type) {
422 if (num > EXIT_DOOR_MAX) {
425 } else if (num < 0) {
432 if (num > OTHER_THING_MAX)
439 *(pound_signp+1) = (num / 10) + '0';
440 *(pound_signp+2) = (num % 10) + '0';
441 *(pound_signp+3) = 0;
443 *(pound_signp+1) = (num % 10) + '0';
444 *(pound_signp+2) = 0;
449 bi = piggy_find_bitmap(Bitmap_name);
450 bitmap_ptr = &GameBitmaps[bi.index];
454 WIN(DDGRLOCK(dd_grd_curcanv));
455 gr_bitmapm(0, 0, bitmap_ptr);
456 WIN(DDGRUNLOCK(dd_grd_curcanv));
459 dd_grd_curcanv = curcanv_save,
460 grd_curcanv = curcanv_save
464 switch (Animating_bitmap_type) {
466 if (num == EXIT_DOOR_MAX) {
469 } else if (num == 0) {
481 //-----------------------------------------------------------------------------
482 void show_briefing_bitmap(grs_bitmap *bmp)
485 dd_grs_canvas *bitmap_canv, *curcanv_save;
487 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
488 curcanv_save = dd_grd_curcanv;
489 dd_gr_set_current_canvas(bitmap_canv);
490 DDGRLOCK(dd_grd_curcanv);
492 DDGRUNLOCK(dd_grd_curcanv);
493 dd_gr_set_current_canvas(curcanv_save);
495 grs_canvas *curcanv_save, *bitmap_canv;
497 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
498 curcanv_save = grd_curcanv;
499 gr_set_current_canvas(bitmap_canv);
500 gr_bitmapm(0, 0, bmp);
501 gr_set_current_canvas(curcanv_save);
508 //-----------------------------------------------------------------------------
509 void show_spinning_robot_frame(int robot_num)
511 grs_canvas *curcanv_save;
513 if (robot_num != -1) {
514 Robot_angles.h += 150;
516 curcanv_save = grd_curcanv;
517 grd_curcanv = Robot_canv;
518 Assert(Robot_info[robot_num].model_num != -1);
519 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
520 grd_curcanv = curcanv_save;
525 //-----------------------------------------------------------------------------
526 void init_spinning_robot(void) //(int x,int y,int w,int h)
528 //Robot_angles.p += 0;
529 //Robot_angles.b += 0;
530 //Robot_angles.h += 0;
532 int x = rescale_x(138);
533 int y = rescale_y(55);
534 int w = rescale_x(166);
535 int h = rescale_y(138);
537 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
542 //---------------------------------------------------------------------------
543 // Returns char width.
544 // If show_robot_flag set, then show a frame of the spinning robot.
545 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
549 static fix start_time=0;
551 message[0] = the_char;
554 if (start_time==0 && timer_get_fixed_seconds()<0)
555 start_time=timer_get_fixed_seconds();
557 gr_get_string_size(message, &w, &h, &aw );
559 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
561 // Draw cursor if there is some delay and caller says to draw cursor
562 if (cursor_flag && delay) {
563 WIN(DDGRLOCK(dd_grd_curcanv));
564 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
565 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
566 WIN(DDGRUNLOCK(dd_grd_curcanv));
571 delay=fixdiv (F1_0,i2f(15));
573 if ((Bitmap_name[0] != 0) && (delay != 0))
576 if (RobotPlaying && (delay != 0))
579 while (timer_get_fixed_seconds() < (start_time + delay)) {
580 if (RobotPlaying && delay != 0)
584 show_spinning_robot_frame(robot_num);
586 start_time = timer_get_fixed_seconds();
588 WIN(DDGRLOCK(dd_grd_curcanv));
590 if (cursor_flag && delay) {
591 gr_set_fontcolor(Erase_color, -1);
592 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
595 // Draw the character
596 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
597 gr_printf(Briefing_text_x, Briefing_text_y, message );
599 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
600 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
601 WIN(DDGRUNLOCK(dd_grd_curcanv));
603 if (delay) gr_update();
605 // if (the_char != ' ')
606 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
607 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
612 //-----------------------------------------------------------------------------
613 int load_briefing_screen( int screen_num )
619 fname = Briefing_screens[screen_num].bs_name;
621 fname = CurBriefScreenName;
623 WIN(DDGRLOCK(dd_grd_curcanv));
624 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
625 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
626 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);
627 WIN(DDGRUNLOCK(dd_grd_curcanv));
628 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
630 WIN(DDGRUNLOCK(dd_grd_curcanv));
637 int load_new_briefing_screen( char *fname )
641 mprintf ((0,"Loading new briefing <%s>\n",fname));
642 strcpy (CurBriefScreenName,fname);
644 //WIN(DEFINE_SCREEN(CurBriefScreenName));
646 if (gr_palette_fade_out( New_pal, 32, 0 ))
649 WIN(DDGRLOCK(dd_grd_curcanv));
650 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
651 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
652 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);
653 WIN(DDGRUNLOCK(dd_grd_curcanv));
654 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
656 WIN(DDGRUNLOCK(dd_grd_curcanv));
660 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
662 if (gr_palette_fade_in( New_pal, 32, 0 ))
664 DoBriefingColorStuff();
671 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
673 //-----------------------------------------------------------------------------
674 int get_message_num(char **message)
678 while (**message == ' ')
681 while ((**message >= '0') && (**message <= '9')) {
682 num = 10*num + **message-'0';
686 while (*(*message)++ != 10) // Get and drop eoln
692 //-----------------------------------------------------------------------------
693 void get_message_name(char **message, char *result)
695 while (**message == ' ')
698 while ((**message != ' ') && (**message != 10)) {
699 if (**message != '\n')
700 *result++ = **message;
705 while (*(*message)++ != 10) // Get and drop eoln
711 //-----------------------------------------------------------------------------
712 void flash_cursor(int cursor_flag)
714 if (cursor_flag == 0)
717 WIN(DDGRLOCK(dd_grd_curcanv));
718 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
719 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
721 gr_set_fontcolor(Erase_color, -1);
723 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
724 WIN(DDGRUNLOCK(dd_grd_curcanv));
728 extern int InitMovieBriefing();
731 //-----------------------------------------------------------------------------
732 // Return true if message got aborted by user (pressed ESC), else return false.
733 int show_briefing_message(int screen_num, char *message)
737 briefing_screen *bsp;
738 int delay_count = KEY_DELAY_DEFAULT;
742 static int tab_stop=0;
743 int flashing_cursor=0;
744 int new_page=0,GotZ=0;
745 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
749 int hum_channel=-1,printing_channel=-1;
750 int LineAdjustment=1;
751 WIN(int wpage_done=0);
760 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
763 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
764 gr_set_curfont( GAME_FONT );
768 MALLOC(bsp, briefing_screen, 1);
769 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
770 bsp->text_ulx = rescale_x(bsp->text_ulx);
771 bsp->text_uly = rescale_y(bsp->text_uly);
772 bsp->text_width = rescale_x(bsp->text_width);
773 bsp->text_height = rescale_y(bsp->text_height);
774 init_char_pos(bsp->text_ulx, bsp->text_uly);
776 bsp=&Briefing_screens[0];
777 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
785 screen_num=DefineBriefingBox (&message);
786 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
788 bsp = &Briefing_screens[screen_num];
789 init_char_pos(bsp->text_ulx, bsp->text_uly);
791 prev_ch = 10; // read to eoln
792 } else if (ch=='U') {
793 screen_num=get_message_num(&message);
794 bsp = &Briefing_screens[screen_num];
795 init_char_pos(bsp->text_ulx, bsp->text_uly);
796 prev_ch = 10; // read to eoln
797 } else if (ch == 'C') {
798 Current_color = get_message_num(&message)-1;
799 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
801 } else if (ch == 'F') { // toggle flashing cursor
802 flashing_cursor = !flashing_cursor;
804 while (*message++ != 10)
806 } else if (ch == 'T') {
807 tab_stop = get_message_num(&message);
808 tab_stop*=(1+MenuHires);
809 prev_ch = 10; // read to eoln
810 } else if (ch == 'R') {
811 if (Robot_canv != NULL) {
821 init_spinning_robot();
822 robot_num = get_message_num(&message);
823 while (*message++ != 10)
827 spinRobotName[2]=kludge; // ugly but proud
829 RobotPlaying=InitRobotMovie(spinRobotName);
831 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
835 DoBriefingColorStuff ();
836 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
839 prev_ch = 10; // read to eoln
840 } else if (ch == 'N') {
841 //--grs_bitmap *bitmap_ptr;
842 if (Robot_canv != NULL) {
847 get_message_name(&message, Bitmap_name);
848 strcat(Bitmap_name, "#0");
849 Animating_bitmap_type = 0;
851 } else if (ch == 'O') {
852 if (Robot_canv != NULL) {
857 get_message_name(&message, Bitmap_name);
858 strcat(Bitmap_name, "#0");
859 Animating_bitmap_type = 1;
861 } else if (ch=='A') {
862 LineAdjustment=1-LineAdjustment;
863 } else if (ch=='Z') {
864 //mprintf ((0,"Got a Z!\n"));
866 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
869 if (LineAdjustment==1)
876 while ((fname[i]=*message) != '\n') {
882 while (*message++ != 10) // Get and drop eoln
889 while (fname[i]!='.') {
890 fname2[i] = fname[i];
900 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
901 load_new_briefing_screen (fname2);
903 load_new_briefing_screen (fname);
906 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
908 } else if (ch == 'B') {
909 char bitmap_name[32];
910 grs_bitmap guy_bitmap;
911 ubyte temp_palette[768];
914 if (Robot_canv != NULL) {
919 get_message_name(&message, bitmap_name);
920 strcat(bitmap_name, ".bbm");
921 guy_bitmap.bm_data = NULL;
922 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
923 Assert(iff_error == IFF_NO_ERROR);
924 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
926 show_briefing_bitmap(&guy_bitmap);
927 d_free(guy_bitmap.bm_data);
929 // } else if (ch==EOF) {
931 // } else if (ch == 'B') {
932 // if (Robot_canv != NULL) {
933 // d_free(Robot_canv);
937 // bitmap_num = get_message_num(&message);
938 // if (bitmap_num != -1)
939 // show_briefing_bitmap(Textures[bitmap_num]);
940 // prev_ch = 10; // read to eoln
941 } else if (ch == 'S') {
946 if (printing_channel>-1)
947 digi_stop_sound( printing_channel );
959 start_time = timer_get_fixed_seconds();
960 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
963 _RedrawScreen = FALSE;
964 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
970 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
972 flash_cursor(flashing_cursor);
977 show_spinning_robot_frame(robot_num);
979 if (Bitmap_name[0] != 0)
981 start_time += KEY_DELAY_DEFAULT/2;
985 if (keypress == KEY_BACKSP)
988 if (keypress == KEY_ESC)
994 } else if (ch == 'P') { // New page.
996 Int3(); // Hey ryan!!!! You gotta load a screen before you start
997 // printing to it! You know, $Z !!!
998 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1002 while (*message != 10) {
1003 message++; // drop carriage return after special escape sequence
1009 } else if (ch == '\t') { // Tab
1010 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1011 Briefing_text_x = bsp->text_ulx + tab_stop;
1012 } else if ((ch == ';') && (prev_ch == 10)) {
1013 while (*message++ != 10)
1016 } else if (ch == '\\') {
1018 } else if (ch == 10) {
1019 if (prev_ch != '\\') {
1022 Briefing_text_y += (8*(MenuHires+1));
1025 Briefing_text_x = bsp->text_ulx;
1026 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1027 load_briefing_screen(screen_num);
1028 Briefing_text_x = bsp->text_ulx;
1029 Briefing_text_y = bsp->text_uly;
1032 if (ch == 13) //Can this happen? Above says ch==10
1039 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1040 // printing to it! You know, $Z !!!
1041 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1047 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1051 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1053 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1057 // Check for Esc -> abort.
1059 key_check=local_key_inkey();
1064 if (_RedrawScreen) {
1065 _RedrawScreen = FALSE;
1066 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1067 key_check = KEY_ESC;
1070 if ( key_check == KEY_ESC ) {
1075 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1078 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1079 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1080 (key_check == KEY_ALTED+KEY_PADENTER))
1081 gr_toggle_fullscreen();
1084 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1085 Briefing_text_x = bsp->text_ulx;
1086 Briefing_text_y += bsp->text_uly;
1089 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1095 if (printing_channel>-1)
1096 digi_stop_sound( printing_channel );
1097 printing_channel=-1;
1108 start_time = timer_get_fixed_seconds();
1109 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1111 if (_RedrawScreen) {
1112 _RedrawScreen = FALSE;
1113 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1119 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1121 flash_cursor(flashing_cursor);
1124 if (robot_num != -1)
1125 show_spinning_robot_frame(robot_num);
1126 if (Bitmap_name[0] != 0)
1127 show_bitmap_frame();
1128 start_time += KEY_DELAY_DEFAULT/2;
1137 if (keypress == KEY_BACKSP)
1140 if (keypress == KEY_ESC) {
1145 load_briefing_screen(screen_num);
1146 Briefing_text_x = bsp->text_ulx;
1147 Briefing_text_y = bsp->text_uly;
1148 delay_count = KEY_DELAY_DEFAULT;
1150 WIN(wpage_done = 0);
1159 if (Robot_canv != NULL)
1160 {d_free(Robot_canv); Robot_canv=NULL;}
1163 digi_stop_sound( hum_channel );
1164 if (printing_channel>-1)
1165 digi_stop_sound( printing_channel );
1173 //-----------------------------------------------------------------------------
1174 // Return a pointer to the start of text for screen #screen_num.
1175 char * get_briefing_message(int screen_num)
1177 char *tptr = Briefing_text;
1181 Assert(screen_num >= 0);
1183 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1188 cur_screen = get_message_num(&tptr);
1192 if (screen_num!=cur_screen)
1198 //-----------------------------------------------------------------------------
1199 // Load Descent briefing text.
1200 int load_screen_text(char *filename, char **buf)
1205 int have_binary = 0;
1207 if ((tfile = cfopen(filename,"rb")) == NULL) {
1208 char nfilename[30], *ptr;
1210 strcpy(nfilename, filename);
1211 if ((ptr = strrchr(nfilename, '.')))
1213 strcat(nfilename, ".txb");
1214 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1215 mprintf ((0,"can't open %s!\n",nfilename));
1217 //Error("Cannot open file %s or %s", filename, nfilename);
1220 mprintf ((0,"reading...\n"));
1223 len = cfilelength(ifile);
1224 MALLOC(*buf, char, len+500);
1225 mprintf ((0,"len=%d\n",len));
1226 for (x=0, i=0; i < len; i++, x++) {
1227 cfread (*buf+x,1,1,ifile);
1228 // mprintf ((0,"%c",*(*buf+x)));
1235 len = cfilelength(tfile);
1236 MALLOC(*buf, char, len+500);
1237 for (x=0, i=0; i < len; i++, x++) {
1238 cfread (*buf+x,1,1,tfile);
1239 // mprintf ((0,"%c",*(*buf+x)));
1245 //cfread(*buf, 1, len, tfile);
1250 decode_text(*buf, len);
1255 //-----------------------------------------------------------------------------
1256 // Return true if message got aborted, else return false.
1257 int show_briefing_text(int screen_num)
1261 message_ptr = get_briefing_message
1262 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1264 if (message_ptr==NULL)
1267 DoBriefingColorStuff();
1269 return show_briefing_message(screen_num, message_ptr);
1272 void DoBriefingColorStuff ()
1274 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1275 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1277 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1278 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1280 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1281 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1285 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1286 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1288 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1289 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1291 //Begin D1X addition
1293 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1294 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1297 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1298 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1300 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1301 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1303 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1304 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1306 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1307 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1310 Erase_color = gr_find_closest_color_current(0, 0, 0);
1313 //-----------------------------------------------------------------------------
1314 // Return true if screen got aborted by user, else return false.
1315 int show_briefing_screen( int screen_num, int allow_keys)
1318 //ubyte palette_save[768];
1320 New_pal_254_bash = 0;
1322 if (Skip_briefing_screens) {
1323 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1330 grs_bitmap briefing_bm;
1332 gr_init_bitmap_data(&briefing_bm);
1333 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1335 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1337 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1338 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));
1344 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1345 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1347 //vfx_set_palette_sub( New_pal );
1349 gr_palette_load(New_pal);
1353 gr_set_current_canvas( NULL );
1354 show_fullscr(&briefing_bm);
1357 //added on 9/13/98 by adb to make arch's requiring updates work
1359 //end changes by adb
1362 gr_free_bitmap_data (&briefing_bm);
1365 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1368 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1373 key_close(); // kill the keyboard handler during briefing screens for movies
1375 rval = show_briefing_text(screen_num);
1380 #if defined (MACINTOSH) || defined(WINDOWS)
1381 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1386 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1389 DEFINE_SCREEN(NULL);
1390 WIN(DDGRLOCK(dd_grd_curcanv));
1391 gr_clear_canvas (0);
1392 WIN(DDGRUNLOCK(dd_grd_curcanv));
1393 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1397 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1399 //d_free(briefing_bm.bm_data);
1405 //-----------------------------------------------------------------------------
1406 void do_briefing_screens(char *filename,int level_num)
1408 int abort_briefing_screens = 0;
1409 int cur_briefing_screen = 0;
1411 if (Skip_briefing_screens) {
1412 mprintf((0, "Skipping all briefing screens.\n"));
1417 return; // no briefing screens at all for demo
1421 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1423 if (!filename || !*filename)
1426 if (!load_screen_text(filename, &Briefing_text))
1430 songs_play_song( SONG_BRIEFING, 1 );
1435 set_screen_mode( SCREEN_MENU );
1438 dd_gr_set_current_canvas(NULL),
1439 gr_set_current_canvas(NULL)
1442 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1449 for (i = 0; i < MAX_BRIEFING_SCREENS; i++)
1450 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1452 if (level_num == 1) {
1453 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1454 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1455 cur_briefing_screen++;
1459 if (!abort_briefing_screens) {
1460 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1461 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1462 if (show_briefing_screen(cur_briefing_screen, 0))
1467 show_briefing_screen(level_num,0);
1469 d_free (Briefing_text);
1476 int DefineBriefingBox (char **buf)
1481 n=get_new_message_num (buf);
1483 Assert(n < MAX_BRIEFING_SCREENS);
1485 while (**buf!=' ') {
1490 name[i]='\0'; // slap a delimiter on this guy
1492 strcpy (Briefing_screens[n].bs_name,name);
1493 Briefing_screens[n].level_num=get_new_message_num (buf);
1494 Briefing_screens[n].message_num=get_new_message_num (buf);
1495 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1496 Briefing_screens[n].text_uly=get_new_message_num (buf);
1497 Briefing_screens[n].text_width=get_new_message_num (buf);
1498 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1500 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1501 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1502 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1503 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1508 int get_new_message_num(char **message)
1512 while (**message == ' ')
1515 while ((**message >= '0') && (**message <= '9')) {
1516 num = 10*num + **message-'0';