2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Routines to display title screens...
50 void DoBriefingColorStuff(void);
51 int get_new_message_num(char **message);
52 int DefineBriefingBox(char **buf);
54 extern unsigned RobSX, RobSY, RobDX, RobDY; // Robot movie coords
59 char CurBriefScreenName[15] = "brief03.pcx";
61 char RobotPlaying = 0;
63 //Begin D1X modification
64 #define MAX_BRIEFING_COLORS 7
65 //End D1X modification
68 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
69 int Skip_briefing_screens=0;
71 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
72 int Current_color = 0;
76 // added by Jan Bobrowski for variable-size menu screen
77 static int rescale_x(int x)
79 return x * GWIDTH / 320;
82 static int rescale_y(int y)
84 return y * GHEIGHT / 200;
88 int local_key_inkey(void)
92 rval = newmenu_inkey();
94 if (rval == KEY_PRINT_SCREEN) {
96 return 0; // say no key pressed
99 if (mouse_button_state(0)) // mouse button pressed?
102 if ( rval == KEY_Q+KEY_COMMAND )
109 void delay_until(fix time)
111 fix t = timer_get_fixed_seconds();
113 timer_delay(time - t);
117 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
122 ubyte palette_save[768];
123 char new_filename[FILENAME_LEN+1] = "";
127 strcpy(new_filename, "\x01"); // only read from hog file
130 strcat(new_filename, filename);
131 filename = new_filename;
133 title_bm.bm_data = NULL;
134 if ((pcx_error = pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal )) != PCX_ERROR_NONE) {
135 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n", filename, pcx_errormsg(pcx_error), pcx_error);
136 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));
137 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", filename, pcx_errormsg(pcx_error), pcx_error);
140 memcpy(palette_save, gr_palette, sizeof(palette_save));
142 //vfx_set_palette_sub( New_pal );
145 gr_set_current_canvas( NULL );
146 gr_bitmap_fullscr(&title_bm);
148 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
150 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
152 gr_palette_load( New_pal );
153 timer = timer_get_fixed_seconds() + i2f(3);
155 if ( local_key_inkey() && allow_keys ) break;
156 if ( timer_get_fixed_seconds() > timer ) break;
158 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
160 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
161 d_free(title_bm.bm_data);
165 int intro_played = 0;
167 void show_titles(void)
170 int played = MOVIE_NOT_PLAYED; // default is not played
172 int song_playing = 0;
175 #define MOVIE_REQUIRED 0
177 #define MOVIE_REQUIRED 1
180 // show bundler screens
182 char filename[FILENAME_LEN];
184 played = MOVIE_NOT_PLAYED; // default is not played
186 played = PlayMovie("pre_i.mve",0);
189 strcpy(filename, MenuHires?"pre_i1b.pcx":"pre_i1.pcx");
191 while (PHYSFS_exists(filename)) {
192 show_title_screen( filename, 1, 0 );
199 init_subtitles("intro.tex");
200 played = PlayMovie("intro.mve", MOVIE_REQUIRED);
204 if (played != MOVIE_NOT_PLAYED)
207 // didn't get intro movie, try titles
208 played = PlayMovie("titles.mve", MOVIE_REQUIRED);
210 if (played == MOVIE_NOT_PLAYED) {
211 char filename[FILENAME_LEN];
213 vid_set_mode(MENU_SCREEN_MODE);
215 set_screen_mode(SCREEN_MENU);
217 con_printf( CON_DEBUG, "\nPlaying title song..." );
218 songs_play_song( SONG_TITLE, 1);
220 con_printf( CON_DEBUG, "\nShowing logo screens..." );
222 strcpy(filename, MenuHires?"iplogo1b.pcx":"iplogo1.pcx"); // OEM
223 if (! cfexist(filename))
224 strcpy(filename, "iplogo1.pcx"); // SHAREWARE
225 if (! cfexist(filename))
226 strcpy(filename, "mplogo.pcx"); // MAC SHAREWARE
227 if (cfexist(filename))
228 show_title_screen(filename, 1, 1);
230 strcpy(filename, MenuHires?"logob.pcx":"logo.pcx"); // OEM
231 if (! cfexist(filename))
232 strcpy(filename, "logo.pcx"); // SHAREWARE
233 if (! cfexist(filename))
234 strcpy(filename, "plogo.pcx"); // MAC SHAREWARE
235 if (cfexist(filename))
236 show_title_screen(filename, 1, 1);
240 // show bundler movie or screens
242 char filename[FILENAME_LEN];
243 PHYSFS_file *movie_handle;
245 played = MOVIE_NOT_PLAYED; // default is not played
247 //check if OEM movie exists, so we don't stop the music if it doesn't
248 movie_handle = PHYSFS_openRead("oem.mve");
250 PHYSFS_close(movie_handle);
251 played = PlayMovie("oem.mve",0);
252 song_playing = 0; // movie will kill sound
257 strcpy(filename, MenuHires?"oem1b.pcx":"oem1.pcx");
259 while (PHYSFS_exists(filename)) {
260 show_title_screen( filename, 1, 0 );
267 songs_play_song( SONG_TITLE, 1);
270 void show_loading_screen(ubyte *title_pal)
272 //grs_bitmap title_bm;
276 strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx");
277 if (! cfexist(filename))
278 strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM
279 if (! cfexist(filename))
280 strcpy(filename, "descentd.pcx"); // SHAREWARE
281 if (! cfexist(filename))
282 strcpy(filename, "descentb.pcx"); // MAC SHAREWARE
284 vid_set_mode(MENU_SCREEN_MODE);
286 set_screen_mode(SCREEN_MENU);
289 FontHires = FontHiresAvailable && MenuHires;
291 if ((pcx_error = pcx_read_fullscr( filename, title_pal )) == PCX_ERROR_NONE) {
292 //vfx_set_palette_sub( title_pal );
294 gr_palette_fade_in( title_pal, 32, 0 );
297 Error( "Couldn't load pcx file '%s', PCX load error: %s\n", filename, pcx_errormsg(pcx_error));
301 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
304 short text_ulx, text_uly; // upper left x,y of text window
305 short text_width, text_height; // width and height of text window
308 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
309 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
311 #define MAX_BRIEFING_SCREENS 60
313 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS] = {
314 {"brief03.pcx", 0, 3, 8, 8, 257, 177 },
317 briefing_screen D1_Briefing_screens[] = {
318 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
319 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
320 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
321 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
323 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
324 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
325 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
327 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
328 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
330 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
331 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
332 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
334 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
335 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
336 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
337 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
338 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
340 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
341 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
342 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
343 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
344 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
346 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
347 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
348 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
349 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
350 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
352 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
353 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
354 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
355 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
357 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
358 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
359 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
361 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
362 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
363 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
365 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
366 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
367 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
369 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
370 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
371 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
372 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
375 #define NUM_D1_BRIEFING_SCREENS (sizeof(D1_Briefing_screens)/sizeof(briefing_screen))
377 int Briefing_text_x, Briefing_text_y;
379 void init_char_pos(int x, int y)
383 mprintf((0, "Setting init x=%d y=%d\n", x, y));
386 grs_canvas *Robot_canv = NULL;
387 vms_angvec Robot_angles;
389 ubyte Bitmap_palette[768];
391 char Bitmap_name[32] = "";
392 #define EXIT_DOOR_MAX 14
393 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
394 #define DOOR_DIV_INIT 3
395 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
397 //-----------------------------------------------------------------------------
398 void show_bitmap_frame(void)
400 grs_canvas *bitmap_canv = 0;
401 grs_bitmap *bitmap_ptr;
403 // Only plot every nth frame.
404 if (Door_div_count) {
409 Door_div_count = DOOR_DIV_INIT;
411 if (Bitmap_name[0] != 0) {
415 // Set supertransparency color to black
416 if (!New_pal_254_bash) {
417 New_pal_254_bash = 1;
419 New_pal[254*3+1] = 0;
420 New_pal[254*3+2] = 0;
421 gr_palette_load( New_pal );
424 switch (Animating_bitmap_type) {
426 bitmap_canv = gr_create_canvas(rescale_y(64), rescale_y(64));
429 bitmap_canv = gr_create_canvas(rescale_y(94), rescale_y(94));
432 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
434 Int3(); // Impossible, illegal value for Animating_bitmap_type
437 pound_signp = strchr(Bitmap_name, '#');
438 Assert(pound_signp != NULL);
440 dig1 = *(pound_signp+1);
441 dig2 = *(pound_signp+2);
445 num = (dig1-'0')*10 + (dig2-'0');
447 switch (Animating_bitmap_type) {
450 if (num > EXIT_DOOR_MAX) {
453 } else if (num < 0) {
460 if (num > OTHER_THING_MAX)
467 *(pound_signp+1) = (num / 10) + '0';
468 *(pound_signp+2) = (num % 10) + '0';
469 *(pound_signp+3) = 0;
471 *(pound_signp+1) = (num % 10) + '0';
472 *(pound_signp+2) = 0;
477 bi = piggy_find_bitmap(Bitmap_name);
478 bitmap_ptr = &GameBitmaps[bi.index];
482 gr_bitmap_scale_to(bitmap_ptr, &bitmap_canv->cv_bitmap);
484 gr_remap_bitmap_good(&bitmap_canv->cv_bitmap, Bitmap_palette, 255, 254);
485 gr_bitmapm(rescale_x(220), rescale_y(45), &bitmap_canv->cv_bitmap);
488 switch (Animating_bitmap_type) {
490 if (num == EXIT_DOOR_MAX) {
493 } else if (num == 0) {
505 //-----------------------------------------------------------------------------
506 void show_briefing_bitmap(grs_bitmap *bmp)
508 grs_canvas *bitmap_canv;
510 bitmap_canv = gr_create_canvas(rescale_y(bmp->bm_w), rescale_y(bmp->bm_h));
511 gr_bitmap_scale_to(bmp, &bitmap_canv->cv_bitmap);
512 gr_bitmapm(rescale_x(220), rescale_y(45), &bitmap_canv->cv_bitmap);
516 //-----------------------------------------------------------------------------
517 void show_spinning_robot_frame(int robot_num)
519 grs_canvas *curcanv_save;
521 if (robot_num != -1) {
522 Robot_angles.h += 150;
524 curcanv_save = grd_curcanv;
525 grd_curcanv = Robot_canv;
526 Assert(Robot_info[robot_num].model_num != -1);
527 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
528 grd_curcanv = curcanv_save;
529 gr_copy_palette(gr_palette, New_pal, sizeof(New_pal));
530 gr_remap_bitmap_good(&Robot_canv->cv_bitmap, Bitmap_palette, 255, 254);
535 //-----------------------------------------------------------------------------
536 void init_spinning_robot(void) //(int x,int y,int w,int h)
538 //Robot_angles.p += 0;
539 //Robot_angles.b += 0;
540 //Robot_angles.h += 0;
542 int x = rescale_x(138);
543 int y = rescale_y(55);
544 int w = rescale_x(166);
545 int h = rescale_y(138);
547 gr_use_palette_table(DEFAULT_LEVEL_PALETTE);
548 memcpy(Bitmap_palette, gr_palette, sizeof(Bitmap_palette));
550 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
554 //---------------------------------------------------------------------------
555 // Returns char width.
556 // If show_robot_flag set, then show a frame of the spinning robot.
557 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
561 static fix start_time=0;
563 message[0] = the_char;
566 if (start_time==0 && timer_get_fixed_seconds()<0)
567 start_time=timer_get_fixed_seconds();
569 gr_get_string_size(message, &w, &h, &aw );
571 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
573 // Draw cursor if there is some delay and caller says to draw cursor
574 if (cursor_flag && delay) {
575 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
576 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
580 if ((Bitmap_name[0] != 0) && (delay != 0))
583 if (RobotPlaying && (delay != 0))
586 if ((robot_num != -1) && (delay != 0))
587 show_spinning_robot_frame(robot_num);
589 while (timer_get_fixed_seconds() < (start_time + delay)) {
592 if (RobotPlaying && delay != 0)
595 if ((robot_num != -1) && (delay != 0))
596 show_spinning_robot_frame(robot_num);
598 if ((Bitmap_name[0] != 0) && (delay != 0))
601 delay_until(start_time + delay/2);
604 start_time = timer_get_fixed_seconds();
607 if (cursor_flag && delay) {
608 gr_set_fontcolor(Erase_color, -1);
609 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
612 // Draw the character
613 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
614 gr_printf(Briefing_text_x, Briefing_text_y, message );
616 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
617 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
619 if (delay) vid_update();
621 // if (the_char != ' ')
622 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
623 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
628 //-----------------------------------------------------------------------------
629 int load_briefing_screen( int screen_num )
634 strcpy (CurBriefScreenName, Briefing_screens[screen_num].bs_name);
636 if ((pcx_error = pcx_read_fullscr(CurBriefScreenName, New_pal)) != PCX_ERROR_NONE)
637 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
642 int load_new_briefing_screen( char *fname )
644 mprintf((0,"Loading new briefing <%s>\n", fname));
645 strcpy (CurBriefScreenName, fname);
648 memcpy(New_pal, gr_palette, sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
651 if (gr_palette_fade_out( New_pal, 32, 0 ))
654 load_briefing_screen(-1);
656 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
658 if (gr_palette_fade_in( New_pal, 32, 0 ))
660 DoBriefingColorStuff();
667 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
669 //-----------------------------------------------------------------------------
670 int get_message_num(char **message)
674 while (**message == ' ')
677 while ((**message >= '0') && (**message <= '9')) {
678 num = 10*num + **message-'0';
682 while (*(*message)++ != 10) // Get and drop eoln
688 //-----------------------------------------------------------------------------
689 void get_message_name(char **message, char *result)
691 while (**message == ' ')
694 while ((**message != ' ') && (**message != 10)) {
695 if (**message != '\n')
696 *result++ = **message;
701 while (*(*message)++ != 10) // Get and drop eoln
707 //-----------------------------------------------------------------------------
708 void flash_cursor(int cursor_flag)
710 if (cursor_flag == 0)
713 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
714 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
716 gr_set_fontcolor(Erase_color, -1);
718 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
722 extern int InitMovieBriefing(void);
724 static int robot_movie_model_map(char kludge)
726 switch (tolower(kludge)) {
727 case 'a': return 24; // bper
728 case 'b': return 25; // smelter
729 case 'c': return 34; // unused?
730 case 'd': return 26; // ice spindle
731 case 'e': return 27; // bulk destroyer
732 case 'f': return 28; // trn racer
733 case 'g': return 29; // fox
734 case 'h': return 30; // sidearm
735 case 'i': return 51; // lou guard
736 case 'j': return 33; // guide bot
737 case 'k': return 36; // itsc
738 case 'l': return 49; // omega defense spawn
739 case 'm': return 37; // itd
740 case 'n': return 38; // pest
741 case 'o': return 50; // sidearm modula
742 case 'p': return 39; // pig
743 case 'q': return 61; // spawn
744 case 'r': return 40; // diamond claw
745 case 's': return 43; // seeker
746 case 't': return 42; // bandit
747 case 'u': return 44; // e-bandit
748 case 'w': return 47; // boarshead
749 case 'x': return 48; // spider
750 case 'y': return 41; // red hornet
751 /* vertigo robots, possibly not constant */
752 case '1': return 70; // smelter ii
753 case '2': return 74; // canary
754 case '3': return 66; // compact lifter
755 case '4': return 69; // class 2 heavy driller
756 case '5': return 73; // logikill
757 case '6': return 71; // max
758 case '7': return 72; // sniper ng
759 case '8': return 68; // fiddler
760 case '9': return 67; // fervid 99
761 case '$': return 77; // spike
762 default: Int3(); return -1;
766 //-----------------------------------------------------------------------------
767 // Return true if message got aborted by user (pressed ESC), else return false.
768 int show_briefing_message(int screen_num, char *message)
772 briefing_screen *bsp;
773 int delay_count = KEY_DELAY_DEFAULT;
777 static int tab_stop = 0;
778 int flashing_cursor = 0;
779 int new_page = 0, GotZ = 0;
780 char spinRobotName[] = "rba.mve", kludge; // matt don't change this!
784 int hum_channel = -1, printing_channel = -1;
785 int LineAdjustment = 1;
793 if (!(EMULATING_D1 || is_SHAREWARE || is_MAC_SHARE))
794 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
796 //mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
797 gr_set_curfont( GAME_FONT );
801 MALLOC(bsp, briefing_screen, 1);
802 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
803 bsp->text_ulx = rescale_x(bsp->text_ulx);
804 bsp->text_uly = rescale_y(bsp->text_uly);
805 bsp->text_width = rescale_x(bsp->text_width);
806 bsp->text_height = rescale_y(bsp->text_height);
807 init_char_pos(bsp->text_ulx, bsp->text_uly);
809 bsp = &Briefing_screens[0];
810 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
818 screen_num = DefineBriefingBox(&message);
819 //load_new_briefing_screen(Briefing_screens[screen_num].bs_name);
821 bsp = &Briefing_screens[screen_num];
822 init_char_pos(bsp->text_ulx, bsp->text_uly);
824 prev_ch = 10; // read to eoln
825 } else if (ch == 'U') {
826 screen_num = get_message_num(&message);
827 bsp = &Briefing_screens[screen_num];
828 init_char_pos(bsp->text_ulx, bsp->text_uly);
829 prev_ch = 10; // read to eoln
830 } else if (ch == 'C') {
831 Current_color = get_message_num(&message)-1;
832 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
834 } else if (ch == 'F') { // toggle flashing cursor
835 flashing_cursor = !flashing_cursor;
837 while (*message++ != 10)
839 } else if (ch == 'T') {
840 tab_stop = get_message_num(&message);
841 tab_stop *= (1+MenuHires);
842 prev_ch = 10; // read to eoln
843 } else if (ch == 'R') {
844 if (Robot_canv != NULL) {
854 init_spinning_robot();
855 robot_num = get_message_num(&message);
856 while (*message++ != 10)
860 spinRobotName[2] = kludge; // ugly but proud
862 RobotPlaying = InitRobotMovie(spinRobotName);
864 //gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
868 DoBriefingColorStuff();
869 mprintf((0, "Robot playing is %d!!!\n", RobotPlaying));
871 init_spinning_robot();
872 robot_num = robot_movie_model_map(kludge);
875 prev_ch = 10; // read to eoln
876 } else if (ch == 'N') {
877 //--grs_bitmap *bitmap_ptr;
878 if (Robot_canv != NULL) {
883 get_message_name(&message, Bitmap_name);
884 strcat(Bitmap_name, "#0");
885 Animating_bitmap_type = 0;
887 } else if (ch == 'O') {
888 if (Robot_canv != NULL) {
893 get_message_name(&message, Bitmap_name);
894 strcat(Bitmap_name, "#0");
895 Animating_bitmap_type = 1;
897 } else if (ch == 'A') {
898 LineAdjustment = 1-LineAdjustment;
899 } else if (ch == 'Z') {
900 //mprintf((0,"Got a Z!\n"));
902 if (LineAdjustment == 1 || is_D2_OEM || is_MAC_SHARE)
908 while ((fname[i] = *message) != '\n') {
914 while (*message++ != 10) // Get and drop eoln
921 while (fname[i] != '.') {
922 fname2[i] = fname[i];
932 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
933 load_new_briefing_screen(fname2);
935 load_new_briefing_screen(fname);
938 //load_new_briefing_screen(MenuHires?"end01b.pcx":"end01.pcx");
940 } else if (ch == 'B') {
941 char bitmap_name[32];
942 grs_bitmap guy_bitmap;
943 ubyte temp_palette[768];
946 if (Robot_canv != NULL) {
951 get_message_name(&message, bitmap_name);
952 strcat(bitmap_name, ".bbm");
953 guy_bitmap.bm_data = NULL;
954 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
955 Assert(iff_error == IFF_NO_ERROR);
956 gr_copy_palette(gr_palette, New_pal, sizeof(New_pal));
957 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
959 show_briefing_bitmap(&guy_bitmap);
960 d_free(guy_bitmap.bm_data);
962 // } else if (ch == EOF) {
964 // } else if (ch == 'B') {
965 // if (Robot_canv != NULL) {
966 // d_free(Robot_canv);
967 // Robot_canv = NULL;
970 // bitmap_num = get_message_num(&message);
971 // if (bitmap_num != -1)
972 // show_briefing_bitmap(Textures[bitmap_num]);
973 // prev_ch = 10; // read to eoln
974 } else if (ch == 'S') {
979 if (printing_channel > -1)
980 digi_stop_sound( printing_channel );
981 printing_channel = -1;
985 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
986 start_time = timer_get_fixed_seconds();
988 flash_cursor(flashing_cursor);
993 show_spinning_robot_frame(robot_num);
995 if (Bitmap_name[0] != 0)
998 delay_until(start_time + KEY_DELAY_DEFAULT/2);
1002 if (keypress == KEY_BACKSP)
1005 if (keypress == KEY_ESC)
1008 flashing_cursor = 0;
1010 } else if (ch == 'P') { // New page.
1012 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1013 // printing to it! You know, $Z !!!
1014 load_new_briefing_screen(MenuHires?"end01b.pcx":"end01.pcx");
1018 while (*message != 10) {
1019 message++; // drop carriage return after special escape sequence
1025 } else if (ch == '\t') { // Tab
1026 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1027 Briefing_text_x = bsp->text_ulx + tab_stop;
1028 } else if ((ch == ';') && (prev_ch == 10)) {
1029 while (*message++ != 10)
1032 } else if (ch == '\\') {
1034 } else if (ch == 10) {
1035 if (prev_ch != '\\') {
1037 if (DumbAdjust == 0)
1039 Briefing_text_y += (8*(MenuHires*1.4+1));
1041 Briefing_text_y += (8*(MenuHires+1));
1044 Briefing_text_x = bsp->text_ulx;
1045 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1046 load_briefing_screen(screen_num);
1047 Briefing_text_x = bsp->text_ulx;
1048 Briefing_text_y = bsp->text_uly;
1051 if (ch == 13) // Can this happen? Above says ch==10
1058 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1059 // printing to it! You know, $Z !!!
1060 load_new_briefing_screen(MenuHires?"end01b.pcx":"end01.pcx");
1065 if (!EMULATING_D1 && !chattering) {
1066 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1070 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1074 // Check for Esc -> abort.
1076 key_check = local_key_inkey();
1081 if (_RedrawScreen) {
1082 _RedrawScreen = FALSE;
1083 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1084 key_check = KEY_ESC;
1087 if ( key_check == KEY_ESC ) {
1092 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1095 #ifdef VID_SUPPORTS_FULLSCREEN_TOGGLE
1096 if ((key_check == KEY_COMMAND+KEY_SHIFTED+KEY_F) ||
1097 (key_check == KEY_ALTED+KEY_ENTER) ||
1098 (key_check == KEY_ALTED+KEY_PADENTER))
1099 vid_toggle_fullscreen();
1102 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1103 Briefing_text_x = bsp->text_ulx;
1104 Briefing_text_y += bsp->text_uly;
1107 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1113 if (printing_channel > -1)
1114 digi_stop_sound( printing_channel );
1115 printing_channel = -1;
1119 start_time = timer_get_fixed_seconds();
1120 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1122 flash_cursor(flashing_cursor);
1125 if (robot_num != -1)
1126 show_spinning_robot_frame(robot_num);
1127 if (Bitmap_name[0] != 0)
1128 show_bitmap_frame();
1129 start_time += KEY_DELAY_DEFAULT/2;
1130 delay_until(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;
1159 if (Robot_canv != NULL) {
1164 if (hum_channel > -1)
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)));
1231 if (*(*buf+x) == 13)
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)));
1242 if (*(*buf+x) == 13)
1247 //cfread(*buf, 1, len, tfile);
1252 decode_text(*buf, len);
1257 //-----------------------------------------------------------------------------
1258 // Return true if message got aborted, else return false.
1259 int show_briefing_text(int screen_num)
1263 message_ptr = get_briefing_message
1264 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1266 if (message_ptr == NULL)
1269 DoBriefingColorStuff();
1271 return show_briefing_message(screen_num, message_ptr);
1274 void DoBriefingColorStuff(void)
1276 Briefing_foreground_colors[0] = gr_find_closest_color_current(0, 40, 0);
1277 Briefing_background_colors[0] = gr_find_closest_color_current(0, 6, 0);
1279 Briefing_foreground_colors[1] = gr_find_closest_color_current(40, 33, 35);
1280 Briefing_background_colors[1] = gr_find_closest_color_current(5, 5, 5);
1282 Briefing_foreground_colors[2] = gr_find_closest_color_current(8, 31, 54);
1283 Briefing_background_colors[2] = gr_find_closest_color_current(1, 4, 7);
1287 Briefing_foreground_colors[0] = gr_find_closest_color_current(0, 54, 0);
1288 Briefing_background_colors[0] = gr_find_closest_color_current(0, 19, 0);
1290 Briefing_foreground_colors[1] = gr_find_closest_color_current(42, 38, 32);
1291 Briefing_background_colors[1] = gr_find_closest_color_current(14, 14, 14);
1293 //Begin D1X addition
1295 Briefing_foreground_colors[2] = gr_find_closest_color_current(63, 0, 0);
1296 Briefing_background_colors[2] = gr_find_closest_color_current(31, 0, 0);
1299 Briefing_foreground_colors[3] = gr_find_closest_color_current(0, 0, 54);
1300 Briefing_background_colors[3] = gr_find_closest_color_current(0, 0, 19);
1302 Briefing_foreground_colors[4] = gr_find_closest_color_current(14, 14, 14);
1303 Briefing_background_colors[4] = gr_find_closest_color_current(0, 0, 0);
1305 Briefing_foreground_colors[5] = gr_find_closest_color_current(54, 54, 0);
1306 Briefing_background_colors[5] = gr_find_closest_color_current(19, 19, 0);
1308 Briefing_foreground_colors[6] = gr_find_closest_color_current(0, 54, 54);
1309 Briefing_background_colors[6] = gr_find_closest_color_current(0, 19, 19);
1312 Erase_color = gr_find_closest_color_current(0, 0, 0);
1316 //-----------------------------------------------------------------------------
1317 // Return true if screen got aborted by user, else return false.
1318 int show_briefing_screen( int screen_num, int allow_keys)
1321 //ubyte palette_save[768];
1323 New_pal_254_bash = 0;
1325 if (Skip_briefing_screens) {
1326 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1331 load_briefing_screen(screen_num);
1335 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1340 key_close(); // kill the keyboard handler during briefing screens for movies
1342 rval = show_briefing_text(screen_num);
1348 memcpy(New_pal, gr_palette, sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1351 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1354 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1356 //d_free(briefing_bm.bm_data);
1362 //-----------------------------------------------------------------------------
1363 void do_briefing_screens(char *filename,int level_num)
1365 int abort_briefing_screens = 0;
1366 int cur_briefing_screen = 0;
1368 if (Skip_briefing_screens) {
1369 mprintf((0, "Skipping all briefing screens.\n"));
1374 return; // no briefing screens at all for demo
1378 mprintf((0, "Trying briefing screen <%s>\n", filename));
1380 if (!filename || !*filename)
1383 if (!load_screen_text(filename, &Briefing_text))
1386 if ( !(EMULATING_D1 || is_SHAREWARE || is_MAC_SHARE) )
1389 set_screen_mode( SCREEN_MENU );
1391 gr_set_current_canvas(NULL);
1393 mprintf((0, "Playing briefing screen <%s>, level %d\n", filename, level_num));
1400 for (i = 0; i < NUM_D1_BRIEFING_SCREENS; i++)
1401 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1403 if (level_num == 1) {
1404 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1405 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1406 cur_briefing_screen++;
1410 if (!abort_briefing_screens) {
1411 for (cur_briefing_screen = 0; cur_briefing_screen < NUM_D1_BRIEFING_SCREENS; cur_briefing_screen++)
1412 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1413 if (show_briefing_screen(cur_briefing_screen, 0))
1418 show_briefing_screen(level_num,0);
1420 d_free (Briefing_text);
1427 int DefineBriefingBox(char **buf)
1432 n = get_new_message_num(buf);
1434 Assert(n < MAX_BRIEFING_SCREENS);
1436 while (**buf != ' ') {
1441 name[i] = '\0'; // slap a delimiter on this guy
1443 strcpy(Briefing_screens[n].bs_name, name);
1444 Briefing_screens[n].level_num = get_new_message_num(buf);
1445 Briefing_screens[n].message_num = get_new_message_num(buf);
1446 Briefing_screens[n].text_ulx = get_new_message_num(buf);
1447 Briefing_screens[n].text_uly = get_new_message_num(buf);
1448 Briefing_screens[n].text_width = get_new_message_num(buf);
1449 Briefing_screens[n].text_height = get_message_num(buf); // NOTICE!!!
1451 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1452 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1453 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1454 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1459 int get_new_message_num(char **message)
1463 while (**message == ' ')
1466 while ((**message >= '0') && (**message <= '9')) {
1467 num = 10*num + **message - '0';
1476 void show_order_form()
1480 unsigned char title_pal[768];
1481 char exit_screen[16];
1483 gr_set_current_canvas( NULL );
1488 strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM
1489 if (! cfexist(exit_screen))
1490 strcpy(exit_screen, MenuHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires
1491 if (! cfexist(exit_screen))
1492 strcpy(exit_screen, MenuHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale
1493 if (! cfexist(exit_screen))
1494 strcpy(exit_screen, MenuHires?"warningb.pcx":"warning.pcx"); // D1
1495 if (! cfexist(exit_screen))
1496 strcpy(exit_screen, MenuHires?"warning.pcx":"warningb.pcx"); // D1, have to rescale
1497 if (! cfexist(exit_screen))
1498 strcpy(exit_screen, "order01.pcx"); // D1 SHAREWARE
1499 if (! cfexist(exit_screen))
1500 return; // D2 registered
1502 if ((pcx_error = pcx_read_fullscr( exit_screen, title_pal )) == PCX_ERROR_NONE) {
1503 //vfx_set_palette_sub( title_pal );
1504 gr_palette_fade_in( title_pal, 32, 0 );
1506 while (!key_inkey() && !mouse_button_state(0)) {} //newmenu_getch();
1507 gr_palette_fade_out( title_pal, 32, 0 );
1509 Int3(); // can't load order screen