1 /* $Id: titles.c,v 1.33 2004-10-24 12:46:49 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
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
272 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
273 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
275 briefing_screen Briefing_screens[] = {
276 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
277 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
278 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
279 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
281 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
282 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
283 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
285 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
286 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
288 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
289 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
290 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
293 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
294 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
295 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
296 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
297 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
299 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
300 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
301 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
302 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
303 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
305 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
306 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
307 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
308 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
309 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
311 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
312 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
313 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
314 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
316 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
317 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
318 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
320 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
321 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
322 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
324 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
325 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
326 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
329 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
331 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
332 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
333 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
340 int Briefing_text_x, Briefing_text_y;
342 void init_char_pos(int x, int y)
346 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
349 grs_canvas *Robot_canv = NULL;
350 vms_angvec Robot_angles;
352 char Bitmap_name[32] = "";
353 #define EXIT_DOOR_MAX 14
354 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
355 #define DOOR_DIV_INIT 6
356 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
358 //-----------------------------------------------------------------------------
359 void show_bitmap_frame(void)
362 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
364 grs_canvas *curcanv_save, *bitmap_canv=0;
367 grs_bitmap *bitmap_ptr;
369 // Only plot every nth frame.
370 if (Door_div_count) {
375 Door_div_count = DOOR_DIV_INIT;
377 if (Bitmap_name[0] != 0) {
381 // Set supertransparency color to black
382 if (!New_pal_254_bash) {
383 New_pal_254_bash = 1;
385 New_pal[254*3+1] = 0;
386 New_pal[254*3+2] = 0;
387 gr_palette_load( New_pal );
390 switch (Animating_bitmap_type) {
392 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break,
393 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break
397 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break,
398 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break
401 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
403 Int3(); // Impossible, illegal value for Animating_bitmap_type
407 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
408 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
411 pound_signp = strchr(Bitmap_name, '#');
412 Assert(pound_signp != NULL);
414 dig1 = *(pound_signp+1);
415 dig2 = *(pound_signp+2);
419 num = (dig1-'0')*10 + (dig2-'0');
421 switch (Animating_bitmap_type) {
424 if (num > EXIT_DOOR_MAX) {
427 } else if (num < 0) {
434 if (num > OTHER_THING_MAX)
441 *(pound_signp+1) = (num / 10) + '0';
442 *(pound_signp+2) = (num % 10) + '0';
443 *(pound_signp+3) = 0;
445 *(pound_signp+1) = (num % 10) + '0';
446 *(pound_signp+2) = 0;
451 bi = piggy_find_bitmap(Bitmap_name);
452 bitmap_ptr = &GameBitmaps[bi.index];
456 WIN(DDGRLOCK(dd_grd_curcanv));
457 gr_bitmapm(0, 0, bitmap_ptr);
458 WIN(DDGRUNLOCK(dd_grd_curcanv));
461 dd_grd_curcanv = curcanv_save,
462 grd_curcanv = curcanv_save
466 switch (Animating_bitmap_type) {
468 if (num == EXIT_DOOR_MAX) {
471 } else if (num == 0) {
483 //-----------------------------------------------------------------------------
484 void show_briefing_bitmap(grs_bitmap *bmp)
487 dd_grs_canvas *bitmap_canv, *curcanv_save;
489 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
490 curcanv_save = dd_grd_curcanv;
491 dd_gr_set_current_canvas(bitmap_canv);
492 DDGRLOCK(dd_grd_curcanv);
494 DDGRUNLOCK(dd_grd_curcanv);
495 dd_gr_set_current_canvas(curcanv_save);
497 grs_canvas *curcanv_save, *bitmap_canv;
499 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
500 curcanv_save = grd_curcanv;
501 gr_set_current_canvas(bitmap_canv);
502 gr_bitmapm(0, 0, bmp);
503 gr_set_current_canvas(curcanv_save);
510 //-----------------------------------------------------------------------------
511 void show_spinning_robot_frame(int robot_num)
513 grs_canvas *curcanv_save;
515 if (robot_num != -1) {
516 Robot_angles.h += 150;
518 curcanv_save = grd_curcanv;
519 grd_curcanv = Robot_canv;
520 Assert(Robot_info[robot_num].model_num != -1);
521 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
522 grd_curcanv = curcanv_save;
527 //-----------------------------------------------------------------------------
528 void init_spinning_robot(void) //(int x,int y,int w,int h)
530 //Robot_angles.p += 0;
531 //Robot_angles.b += 0;
532 //Robot_angles.h += 0;
534 int x = rescale_x(138);
535 int y = rescale_y(55);
536 int w = rescale_x(166);
537 int h = rescale_y(138);
539 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
544 //---------------------------------------------------------------------------
545 // Returns char width.
546 // If show_robot_flag set, then show a frame of the spinning robot.
547 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
551 static fix start_time=0;
553 message[0] = the_char;
556 if (start_time==0 && timer_get_fixed_seconds()<0)
557 start_time=timer_get_fixed_seconds();
559 gr_get_string_size(message, &w, &h, &aw );
561 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
563 // Draw cursor if there is some delay and caller says to draw cursor
564 if (cursor_flag && delay) {
565 WIN(DDGRLOCK(dd_grd_curcanv));
566 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
567 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
568 WIN(DDGRUNLOCK(dd_grd_curcanv));
573 delay=fixdiv (F1_0,i2f(15));
575 if ((Bitmap_name[0] != 0) && (delay != 0))
578 if (RobotPlaying && (delay != 0))
581 while (timer_get_fixed_seconds() < (start_time + delay)) {
582 if (RobotPlaying && delay != 0)
586 show_spinning_robot_frame(robot_num);
588 start_time = timer_get_fixed_seconds();
590 WIN(DDGRLOCK(dd_grd_curcanv));
592 if (cursor_flag && delay) {
593 gr_set_fontcolor(Erase_color, -1);
594 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
597 // Draw the character
598 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
599 gr_printf(Briefing_text_x, Briefing_text_y, message );
601 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
602 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
603 WIN(DDGRUNLOCK(dd_grd_curcanv));
605 if (delay) gr_update();
607 // if (the_char != ' ')
608 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
609 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
614 //-----------------------------------------------------------------------------
615 int load_briefing_screen( int screen_num )
621 fname = Briefing_screens[screen_num].bs_name;
623 fname = CurBriefScreenName;
625 WIN(DDGRLOCK(dd_grd_curcanv));
626 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
627 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
628 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);
629 WIN(DDGRUNLOCK(dd_grd_curcanv));
630 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
632 WIN(DDGRUNLOCK(dd_grd_curcanv));
639 int load_new_briefing_screen( char *fname )
643 mprintf ((0,"Loading new briefing <%s>\n",fname));
644 strcpy (CurBriefScreenName,fname);
646 //WIN(DEFINE_SCREEN(CurBriefScreenName));
648 if (gr_palette_fade_out( New_pal, 32, 0 ))
651 WIN(DDGRLOCK(dd_grd_curcanv));
652 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
653 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
654 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);
655 WIN(DDGRUNLOCK(dd_grd_curcanv));
656 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
658 WIN(DDGRUNLOCK(dd_grd_curcanv));
662 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
664 if (gr_palette_fade_in( New_pal, 32, 0 ))
666 DoBriefingColorStuff();
673 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
675 //-----------------------------------------------------------------------------
676 int get_message_num(char **message)
680 while (**message == ' ')
683 while ((**message >= '0') && (**message <= '9')) {
684 num = 10*num + **message-'0';
688 while (*(*message)++ != 10) // Get and drop eoln
694 //-----------------------------------------------------------------------------
695 void get_message_name(char **message, char *result)
697 while (**message == ' ')
700 while ((**message != ' ') && (**message != 10)) {
701 if (**message != '\n')
702 *result++ = **message;
707 while (*(*message)++ != 10) // Get and drop eoln
713 //-----------------------------------------------------------------------------
714 void flash_cursor(int cursor_flag)
716 if (cursor_flag == 0)
719 WIN(DDGRLOCK(dd_grd_curcanv));
720 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
721 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
723 gr_set_fontcolor(Erase_color, -1);
725 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
726 WIN(DDGRUNLOCK(dd_grd_curcanv));
730 extern int InitMovieBriefing();
733 //-----------------------------------------------------------------------------
734 // Return true if message got aborted by user (pressed ESC), else return false.
735 int show_briefing_message(int screen_num, char *message)
739 briefing_screen *bsp;
740 int delay_count = KEY_DELAY_DEFAULT;
744 static int tab_stop=0;
745 int flashing_cursor=0;
746 int new_page=0,GotZ=0;
747 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
751 int hum_channel=-1,printing_channel=-1;
752 int LineAdjustment=1;
753 WIN(int wpage_done=0);
762 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
765 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
766 gr_set_curfont( GAME_FONT );
770 MALLOC(bsp, briefing_screen, 1);
771 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
772 bsp->text_ulx = rescale_x(bsp->text_ulx);
773 bsp->text_uly = rescale_y(bsp->text_uly);
774 bsp->text_width = rescale_x(bsp->text_width);
775 bsp->text_height = rescale_y(bsp->text_height);
776 init_char_pos(bsp->text_ulx, bsp->text_uly);
778 bsp=&Briefing_screens[0];
779 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
787 screen_num=DefineBriefingBox (&message);
788 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
790 bsp = &Briefing_screens[screen_num];
791 init_char_pos(bsp->text_ulx, bsp->text_uly);
793 prev_ch = 10; // read to eoln
794 } else if (ch=='U') {
795 screen_num=get_message_num(&message);
796 bsp = &Briefing_screens[screen_num];
797 init_char_pos(bsp->text_ulx, bsp->text_uly);
798 prev_ch = 10; // read to eoln
799 } else if (ch == 'C') {
800 Current_color = get_message_num(&message)-1;
801 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
803 } else if (ch == 'F') { // toggle flashing cursor
804 flashing_cursor = !flashing_cursor;
806 while (*message++ != 10)
808 } else if (ch == 'T') {
809 tab_stop = get_message_num(&message);
810 tab_stop*=(1+MenuHires);
811 prev_ch = 10; // read to eoln
812 } else if (ch == 'R') {
813 if (Robot_canv != NULL) {
823 init_spinning_robot();
824 robot_num = get_message_num(&message);
825 while (*message++ != 10)
829 spinRobotName[2]=kludge; // ugly but proud
831 RobotPlaying=InitRobotMovie(spinRobotName);
833 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
837 DoBriefingColorStuff ();
838 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
841 prev_ch = 10; // read to eoln
842 } else if (ch == 'N') {
843 //--grs_bitmap *bitmap_ptr;
844 if (Robot_canv != NULL) {
849 get_message_name(&message, Bitmap_name);
850 strcat(Bitmap_name, "#0");
851 Animating_bitmap_type = 0;
853 } else if (ch == 'O') {
854 if (Robot_canv != NULL) {
859 get_message_name(&message, Bitmap_name);
860 strcat(Bitmap_name, "#0");
861 Animating_bitmap_type = 1;
863 } else if (ch=='A') {
864 LineAdjustment=1-LineAdjustment;
865 } else if (ch=='Z') {
866 //mprintf ((0,"Got a Z!\n"));
868 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
871 if (LineAdjustment==1)
878 while ((fname[i]=*message) != '\n') {
884 while (*message++ != 10) // Get and drop eoln
891 while (fname[i]!='.') {
892 fname2[i] = fname[i];
902 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
903 load_new_briefing_screen (fname2);
905 load_new_briefing_screen (fname);
908 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
910 } else if (ch == 'B') {
911 char bitmap_name[32];
912 grs_bitmap guy_bitmap;
913 ubyte temp_palette[768];
916 if (Robot_canv != NULL) {
921 get_message_name(&message, bitmap_name);
922 strcat(bitmap_name, ".bbm");
923 guy_bitmap.bm_data = NULL;
924 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
925 Assert(iff_error == IFF_NO_ERROR);
926 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
928 show_briefing_bitmap(&guy_bitmap);
929 d_free(guy_bitmap.bm_data);
931 // } else if (ch==EOF) {
933 // } else if (ch == 'B') {
934 // if (Robot_canv != NULL) {
935 // d_free(Robot_canv);
939 // bitmap_num = get_message_num(&message);
940 // if (bitmap_num != -1)
941 // show_briefing_bitmap(Textures[bitmap_num]);
942 // prev_ch = 10; // read to eoln
943 } else if (ch == 'S') {
948 if (printing_channel>-1)
949 digi_stop_sound( printing_channel );
961 start_time = timer_get_fixed_seconds();
962 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
965 _RedrawScreen = FALSE;
966 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
972 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
974 flash_cursor(flashing_cursor);
979 show_spinning_robot_frame(robot_num);
981 if (Bitmap_name[0] != 0)
983 start_time += KEY_DELAY_DEFAULT/2;
987 if (keypress == KEY_BACKSP)
990 if (keypress == KEY_ESC)
996 } else if (ch == 'P') { // New page.
998 Int3(); // Hey ryan!!!! You gotta load a screen before you start
999 // printing to it! You know, $Z !!!
1000 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1004 while (*message != 10) {
1005 message++; // drop carriage return after special escape sequence
1011 } else if (ch == '\t') { // Tab
1012 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1013 Briefing_text_x = bsp->text_ulx + tab_stop;
1014 } else if ((ch == ';') && (prev_ch == 10)) {
1015 while (*message++ != 10)
1018 } else if (ch == '\\') {
1020 } else if (ch == 10) {
1021 if (prev_ch != '\\') {
1024 Briefing_text_y += (8*(MenuHires+1));
1027 Briefing_text_x = bsp->text_ulx;
1028 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1029 load_briefing_screen(screen_num);
1030 Briefing_text_x = bsp->text_ulx;
1031 Briefing_text_y = bsp->text_uly;
1034 if (ch == 13) //Can this happen? Above says ch==10
1041 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1042 // printing to it! You know, $Z !!!
1043 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1049 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1053 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1055 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1059 // Check for Esc -> abort.
1061 key_check=local_key_inkey();
1066 if (_RedrawScreen) {
1067 _RedrawScreen = FALSE;
1068 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1069 key_check = KEY_ESC;
1072 if ( key_check == KEY_ESC ) {
1077 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1080 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1081 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1082 (key_check == KEY_ALTED+KEY_PADENTER))
1083 gr_toggle_fullscreen();
1086 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1087 Briefing_text_x = bsp->text_ulx;
1088 Briefing_text_y += bsp->text_uly;
1091 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1097 if (printing_channel>-1)
1098 digi_stop_sound( printing_channel );
1099 printing_channel=-1;
1110 start_time = timer_get_fixed_seconds();
1111 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1113 if (_RedrawScreen) {
1114 _RedrawScreen = FALSE;
1115 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1121 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1123 flash_cursor(flashing_cursor);
1126 if (robot_num != -1)
1127 show_spinning_robot_frame(robot_num);
1128 if (Bitmap_name[0] != 0)
1129 show_bitmap_frame();
1130 start_time += KEY_DELAY_DEFAULT/2;
1139 if (keypress == KEY_BACKSP)
1142 if (keypress == KEY_ESC) {
1147 load_briefing_screen(screen_num);
1148 Briefing_text_x = bsp->text_ulx;
1149 Briefing_text_y = bsp->text_uly;
1150 delay_count = KEY_DELAY_DEFAULT;
1152 WIN(wpage_done = 0);
1161 if (Robot_canv != NULL)
1162 {d_free(Robot_canv); Robot_canv=NULL;}
1165 digi_stop_sound( hum_channel );
1166 if (printing_channel>-1)
1167 digi_stop_sound( printing_channel );
1175 //-----------------------------------------------------------------------------
1176 // Return a pointer to the start of text for screen #screen_num.
1177 char * get_briefing_message(int screen_num)
1179 char *tptr = Briefing_text;
1183 Assert(screen_num >= 0);
1185 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1190 cur_screen = get_message_num(&tptr);
1194 if (screen_num!=cur_screen)
1200 //-----------------------------------------------------------------------------
1201 // Load Descent briefing text.
1202 int load_screen_text(char *filename, char **buf)
1207 int have_binary = 0;
1209 if ((tfile = cfopen(filename,"rb")) == NULL) {
1210 char nfilename[30], *ptr;
1212 strcpy(nfilename, filename);
1213 if ((ptr = strrchr(nfilename, '.')))
1215 strcat(nfilename, ".txb");
1216 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1217 mprintf ((0,"can't open %s!\n",nfilename));
1219 //Error("Cannot open file %s or %s", filename, nfilename);
1222 mprintf ((0,"reading...\n"));
1225 len = cfilelength(ifile);
1226 MALLOC(*buf, char, len+500);
1227 mprintf ((0,"len=%d\n",len));
1228 for (x=0, i=0; i < len; i++, x++) {
1229 cfread (*buf+x,1,1,ifile);
1230 // mprintf ((0,"%c",*(*buf+x)));
1237 len = cfilelength(tfile);
1238 MALLOC(*buf, char, len+500);
1239 for (x=0, i=0; i < len; i++, x++) {
1240 cfread (*buf+x,1,1,tfile);
1241 // mprintf ((0,"%c",*(*buf+x)));
1247 //cfread(*buf, 1, len, tfile);
1254 while ((endline = strchr (ptr, '\n')) != NULL) {
1256 decode_text_line (ptr);
1260 decode_text_line (ptr);
1266 //-----------------------------------------------------------------------------
1267 // Return true if message got aborted, else return false.
1268 int show_briefing_text(int screen_num)
1272 message_ptr = get_briefing_message
1273 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1275 if (message_ptr==NULL)
1278 DoBriefingColorStuff();
1280 return show_briefing_message(screen_num, message_ptr);
1283 void DoBriefingColorStuff ()
1285 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1286 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1288 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1289 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1291 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1292 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1296 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1297 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1299 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1300 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1302 //Begin D1X addition
1304 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1305 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1308 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1309 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1311 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1312 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1314 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1315 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1317 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1318 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1321 Erase_color = gr_find_closest_color_current(0, 0, 0);
1324 //-----------------------------------------------------------------------------
1325 // Return true if screen got aborted by user, else return false.
1326 int show_briefing_screen( int screen_num, int allow_keys)
1329 //ubyte palette_save[768];
1331 New_pal_254_bash = 0;
1333 if (Skip_briefing_screens) {
1334 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1341 grs_bitmap briefing_bm;
1343 gr_init_bitmap_data(&briefing_bm);
1344 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1346 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1348 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1349 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));
1355 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1356 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1358 //vfx_set_palette_sub( New_pal );
1360 gr_palette_load(New_pal);
1364 gr_set_current_canvas( NULL );
1365 show_fullscr(&briefing_bm);
1368 //added on 9/13/98 by adb to make arch's requiring updates work
1370 //end changes by adb
1373 gr_free_bitmap_data (&briefing_bm);
1376 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1379 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1384 key_close(); // kill the keyboard handler during briefing screens for movies
1386 rval = show_briefing_text(screen_num);
1391 #if defined (MACINTOSH) || defined(WINDOWS)
1392 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1397 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1400 DEFINE_SCREEN(NULL);
1401 WIN(DDGRLOCK(dd_grd_curcanv));
1402 gr_clear_canvas (0);
1403 WIN(DDGRUNLOCK(dd_grd_curcanv));
1404 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1408 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1410 //d_free(briefing_bm.bm_data);
1416 //-----------------------------------------------------------------------------
1417 void do_briefing_screens(char *filename,int level_num)
1419 int abort_briefing_screens = 0;
1420 int cur_briefing_screen = 0;
1422 if (Skip_briefing_screens) {
1423 mprintf((0, "Skipping all briefing screens.\n"));
1428 return; // no briefing screens at all for demo
1432 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1437 if (!load_screen_text(filename, &Briefing_text))
1441 songs_play_song( SONG_BRIEFING, 1 );
1446 set_screen_mode( SCREEN_MENU );
1449 dd_gr_set_current_canvas(NULL),
1450 gr_set_current_canvas(NULL)
1453 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1458 if (level_num == 1) {
1459 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1460 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1461 cur_briefing_screen++;
1465 if (!abort_briefing_screens) {
1466 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1467 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1468 if (show_briefing_screen(cur_briefing_screen, 0))
1473 show_briefing_screen(level_num,0);
1475 d_free (Briefing_text);
1482 int DefineBriefingBox (char **buf)
1487 n=get_new_message_num (buf);
1489 Assert(n < MAX_BRIEFING_SCREENS);
1491 while (**buf!=' ') {
1496 name[i]='\0'; // slap a delimiter on this guy
1498 strcpy (Briefing_screens[n].bs_name,name);
1499 Briefing_screens[n].level_num=get_new_message_num (buf);
1500 Briefing_screens[n].message_num=get_new_message_num (buf);
1501 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1502 Briefing_screens[n].text_uly=get_new_message_num (buf);
1503 Briefing_screens[n].text_width=get_new_message_num (buf);
1504 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1506 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1507 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1508 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1509 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1514 int get_new_message_num(char **message)
1518 while (**message == ' ')
1521 while ((**message >= '0') && (**message <= '9')) {
1522 num = 10*num + **message-'0';