void free_endlevel_data() { gr_free_bitmap_data (&terrain_bm_instance); gr_free_bitmap_data (&satellite_bm_instance); free_light_table(); free_height_array(); }
int automap_handler(window *wind, d_event *event, automap *am) { switch (event->type) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); event_toggle_focus(1); key_toggle_repeat(0); break; case EVENT_WINDOW_DEACTIVATED: event_toggle_focus(0); key_toggle_repeat(1); break; case EVENT_IDLE: case EVENT_JOYSTICK_BUTTON_UP: case EVENT_JOYSTICK_BUTTON_DOWN: case EVENT_JOYSTICK_MOVED: case EVENT_MOUSE_BUTTON_UP: case EVENT_MOUSE_BUTTON_DOWN: case EVENT_MOUSE_MOVED: automap_process_input(wind, event, am); break; case EVENT_KEY_COMMAND: case EVENT_KEY_RELEASE: { int kret = automap_key_command(wind, event, am); if (!kret) automap_process_input(wind, event, am); return kret; } case EVENT_WINDOW_DRAW: draw_automap(am); break; case EVENT_WINDOW_CLOSE: if (!am->pause_game) ConsoleObject->mtype.phys_info.flags |= am->old_wiggle; // Restore wiggle event_toggle_focus(0); key_toggle_repeat(1); #ifdef OGL gr_free_bitmap_data(&am->automap_background); #endif d_free(am->edges); d_free(am->drawingListBright); d_free(am); window_set_visible(Game_wind, 1); Automap_active = 0; return 0; // continue closing break; default: return 0; break; } return 1; }
int show_title_screen( char * filename, int allow_keys ) { fix timer; int pcx_error; grs_bitmap title_bm; gr_init_bitmap_data (&title_bm); if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) { printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error); 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)); Int3(); gr_free_bitmap_data (&title_bm); return 0; } // vfx_set_palette_sub( New_pal ); #ifdef OGL gr_palette_load(New_pal); #else gr_palette_clear(); #endif gr_set_current_canvas( NULL ); show_fullscr(&title_bm); //added on 9/13/98 by adb to make update-needing arch's work gr_update(); //end addition - adb gr_free_bitmap_data (&title_bm); if (allow_keys > 2 || gr_palette_fade_in( New_pal, 32, allow_keys ) || allow_keys > 1) { return 1; } gr_palette_load( New_pal ); timer = timer_get_fixed_seconds() + i2f(3); while (1) { if ( local_key_inkey() && allow_keys ) break; if ( timer_get_fixed_seconds() > timer ) break; } if (gr_palette_fade_out( New_pal, 32, allow_keys )) return 1; return 0; }
void kmatrix_view(int network) { kmatrix_screen *km; window *wind; int i = 0; MALLOC(km, kmatrix_screen, 1); if (!km) return; gr_init_bitmap_data(&km->background); if (pcx_read_bitmap(STARS_BACKGROUND, &km->background, BM_LINEAR, gr_palette) != PCX_ERROR_NONE) { d_free(km); return; } gr_palette_load(gr_palette); km->network = network; km->end_time = -1; km->playing = 0; set_screen_mode( SCREEN_MENU ); game_flush_inputs(); for (i=0;i<MAX_PLAYERS;i++) digi_kill_sound_linked_to_object (Players[i].objnum); wind = window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, (int (*)(window *, d_event *, void *))kmatrix_handler, km); if (!wind) { d_free(km); return; } while (window_exists(wind)) event_process(); gr_free_bitmap_data(&km->background); d_free(km); }
void do_screen_message(char *fmt, ...) { va_list arglist; grs_bitmap background; char msg[1024]; if (Game_mode & GM_MULTI) return; gr_init_bitmap_data(&background); if (pcx_read_bitmap(Menu_pcx_name, &background, BM_LINEAR, gr_palette) != PCX_ERROR_NONE) return; gr_palette_load(gr_palette); va_start(arglist, fmt); vsprintf(msg, fmt, arglist); va_end(arglist); nm_messagebox1(NULL, (int (*)(newmenu *, d_event *, void *))draw_rock, &background, 1, TXT_OK, msg); gr_free_bitmap_data(&background); }
void modex_print_message(int x, int y, char *str) { #ifndef AUTOMAP_DIRECT_RENDER #ifndef AUTOMAP_NO_PAGING int i; for (i=0; i<2; i++ ) { gr_set_current_canvas(&Pages[i]); #else { gr_set_current_canvas(OffscreenPage); #endif #endif modex_printf(x, y, str, GFONT_MEDIUM_1); #ifndef AUTOMAP_DIRECT_RENDER } gr_set_current_canvas(&DrawingPages[current_page]); #endif } extern void GameLoop(int, int ); extern int set_segment_depths(int start_seg, ubyte *segbuf); u_int32_t automap_mode = SM(640,480); int automap_width = 640; int automap_height = 480; int automap_use_game_res=0; int nice_automap=0; void do_automap( int key_code ) { int done=0; vms_matrix tempm; vms_angvec tangles; int leave_mode=0; int first_time=1; // int pcx_error; int c; // char filename[] = "MAP.PCX"; fix entry_time; int pause_game=1; // Set to 1 if everything is paused during automap...No pause during net. fix t1, t2; control_info saved_control_info; grs_bitmap Automap_background; int Max_segments_away = 0; int SegmentLimit = 1; //added on 10/28/98 by adb to fix compile versions #if !defined (NDEBUG) || (!defined(AUTOMAP_NO_PAGING) && !defined(AUTOMAP_DIRECT_RENDER)) int i; #endif key_code = key_code; // disable warning... if ((Game_mode & GM_MULTI) && (Function_mode == FMODE_GAME) && (!Endlevel_sequence)) pause_game = 0; if (pause_game) stop_time(); create_name_canv(); Max_edges = min(MAX_EDGES_FROM_VERTS(Num_vertices),MAX_EDGES); //make maybe smaller than max //Edges = malloc( sizeof(Edge_info)*Max_edges); //if ( Edges == NULL ) { // mprintf((0, "Couldn't get %dK for automap!", sizeof(Edge_info)*Max_edges/1024)); // return; //} //DrawingListBright = malloc( sizeof(short)*Max_edges); //if ( DrawingListBright == NULL ) { // mprintf((0, "Couldn't get %dK for automap!", sizeof(short)*Max_edges/1024)); // return; //} mprintf( (0, "Num_vertices=%d, Max_edges=%d, (MAX:%d)\n", Num_vertices, Max_edges, MAX_EDGES )); mprintf( (0, "Allocated %d K for automap edge list\n", (sizeof(Edge_info)+sizeof(short))*Max_edges/1024 )); //edit 4/23/99 Matt Mueller - don't switch res unless we need to if (grd_curscreen->sc_mode != AUTOMAP_MODE) gr_set_mode( AUTOMAP_MODE ); else gr_set_current_canvas(NULL); //end edit -MM automap_width=grd_curscreen->sc_canvas.cv_bitmap.bm_w; automap_height=grd_curscreen->sc_canvas.cv_bitmap.bm_h; gr_palette_clear(); #ifndef AUTOMAP_DIRECT_RENDER gr_init_sub_canvas(&Pages[0],grd_curcanv,0,0,automap_width,automap_height); #ifndef AUTOMAP_NO_PAGING // NOTICE: should be 0,401! FIXME! gr_init_sub_canvas(&Pages[1],grd_curcanv,0,0,automap_width,automap_height); gr_init_sub_canvas(&DrawingPages[0],&Pages[0],0,0,automap_width,automap_height); gr_init_sub_canvas(&DrawingPages[1],&Pages[1],0,0,automap_width,automap_height); #else OffscreenPage = gr_create_canvas( automap_width,automap_height ); if (!OffscreenPage) { nm_messagebox("No memory for automap", 1, "Ok"); return; } gr_init_sub_canvas(&DrawingPages[0],OffscreenPage,0,0,automap_width,automap_height); #endif #endif gr_init_bitmap_data (&Automap_background); // pcx_error = pcx_read_bitmap(filename,&Automap_background,BM_LINEAR,NULL); // if ( pcx_error != PCX_ERROR_NONE ) { // printf("File %s - PCX error: %s",filename,pcx_errormsg(pcx_error)); // Error("File %s - PCX error: %s",filename,pcx_errormsg(pcx_error)); // return; // } #ifndef AUTOMAP_DIRECT_RENDER #ifndef AUTOMAP_NO_PAGING for (i=0; i<2; i++ ) { gr_set_current_canvas(&Pages[i]); #else { gr_set_current_canvas(OffscreenPage); #endif // gr_bitmap( 0, 0, &Automap_background ); // modex_printf( 40, 22,TXT_AUTOMAP,GFONT_BIG_1); // modex_printf( 70,353,TXT_TURN_SHIP,GFONT_SMALL); // modex_printf( 70,369,TXT_SLIDE_UPDOWN,GFONT_SMALL); // modex_printf( 70,385,TXT_VIEWING_DISTANCE,GFONT_SMALL); } #ifdef AUTOMAP_NO_PAGING //killed 05/17/99 Matt Mueller - this seems to merely copy undefined bytes around.. not needed //--killed-- gr_bm_ubitblt(automap_width,automap_height, 0, 0, 0, 0, &OffscreenPage->cv_bitmap,&Pages[0].cv_bitmap); //end kill -MM #endif gr_free_bitmap_data (&Automap_background); gr_set_current_canvas(&DrawingPages[current_page]); #endif automap_build_edge_list(); if ( ViewDist==0 ) ViewDist = ZOOM_DEFAULT; ViewMatrix = Objects[Players[Player_num].objnum].orient; tangles.p = PITCH_DEFAULT; tangles.h = 0; tangles.b = 0; done = 0; view_target = Objects[Players[Player_num].objnum].pos; t1 = entry_time = timer_get_fixed_seconds(); t2 = t1; //Fill in Automap_visited from Objects[Players[Player_num].objnum].segnum Max_segments_away = set_segment_depths(Objects[Players[Player_num].objnum].segnum, Automap_visited); SegmentLimit = Max_segments_away; adjust_segment_limit(SegmentLimit); while(!done) { if ( leave_mode==0 && Controls.automap_state && (timer_get_fixed_seconds()-entry_time)>LEAVE_TIME) leave_mode = 1; if ( !Controls.automap_state && (leave_mode==1) ) done=1; if (!pause_game) { ushort old_wiggle; saved_control_info = Controls; // Save controls so we can zero them memset(&Controls,0,sizeof(control_info)); // Clear everything... old_wiggle = ConsoleObject->mtype.phys_info.flags & PF_WIGGLE; // Save old wiggle ConsoleObject->mtype.phys_info.flags &= ~PF_WIGGLE; // Turn off wiggle #ifdef NETWORK if (multi_menu_poll()) done = 1; #endif // GameLoop( 0, 0 ); // Do game loop with no rendering and no reading controls. ConsoleObject->mtype.phys_info.flags |= old_wiggle; // Restore wiggle Controls = saved_control_info; } controls_read_all(); if ( Controls.automap_down_count ) { if (leave_mode==0) done = 1; c = 0; } while( (c=key_inkey()) ) { switch( c ) { #ifndef NDEBUG case KEY_BACKSP: Int3(); break; #endif case KEY_PRINT_SCREEN: save_screen_shot(1); break; case KEY_ESC: if (leave_mode==0) done = 1; break; case KEY_ALTED+KEY_F: // Alt+F shows full map, if cheats enabled if (Cheats_enabled) { uint t; t = Players[Player_num].flags; Players[Player_num].flags |= PLAYER_FLAGS_MAP_ALL_CHEAT; automap_build_edge_list(); Players[Player_num].flags=t; } break; #ifndef NDEBUG case KEY_DEBUGGED+KEY_F: { for (i=0; i<=Highest_segment_index; i++ ) Automap_visited[i] = 1; automap_build_edge_list(); Max_segments_away = set_segment_depths(Objects[Players[Player_num].objnum].segnum, Automap_visited); SegmentLimit = Max_segments_away; adjust_segment_limit(SegmentLimit); } break; #endif case KEY_MINUS: if (SegmentLimit > 1) { SegmentLimit--; adjust_segment_limit(SegmentLimit); } break; case KEY_EQUAL: if (SegmentLimit < Max_segments_away) { SegmentLimit++; adjust_segment_limit(SegmentLimit); } break; } } if ( Controls.fire_primary_down_count ) { // Reset orientation ViewDist = ZOOM_DEFAULT; tangles.p = PITCH_DEFAULT; tangles.h = 0; tangles.b = 0; view_target = Objects[Players[Player_num].objnum].pos; } ViewDist -= Controls.forward_thrust_time*ZOOM_SPEED_FACTOR; tangles.p += fixdiv( Controls.pitch_time, ROT_SPEED_DIVISOR ); tangles.h += fixdiv( Controls.heading_time, ROT_SPEED_DIVISOR ); tangles.b += fixdiv( Controls.bank_time, ROT_SPEED_DIVISOR*2 ); if ( Controls.vertical_thrust_time || Controls.sideways_thrust_time ) { vms_angvec tangles1; vms_vector old_vt; old_vt = view_target; tangles1 = tangles; vm_angles_2_matrix(&tempm,&tangles1); vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm); vm_vec_scale_add2( &view_target, &ViewMatrix.uvec, Controls.vertical_thrust_time*SLIDE_SPEED ); vm_vec_scale_add2( &view_target, &ViewMatrix.rvec, Controls.sideways_thrust_time*SLIDE_SPEED ); if ( vm_vec_dist_quick( &view_target, &Objects[Players[Player_num].objnum].pos) > i2f(1000) ) { view_target = old_vt; } } vm_angles_2_matrix(&tempm,&tangles); vm_matrix_x_matrix(&ViewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm); if ( ViewDist < ZOOM_MIN_VALUE ) ViewDist = ZOOM_MIN_VALUE; if ( ViewDist > ZOOM_MAX_VALUE ) ViewDist = ZOOM_MAX_VALUE; draw_automap(); if ( first_time ) { first_time = 0; gr_palette_load( gr_palette ); } t2 = timer_get_fixed_seconds(); while (t2-t1<F1_0/100){//ogl is fast enough that the automap can read the input too fast and you start to turn really slow. So delay a bit (and free up some cpu :) if (nice_automap) d_delay(1); t2 = timer_get_fixed_seconds(); } if (pause_game) FrameTime=t2-t1; t1 = t2; } //free(Edges); //free(DrawingListBright); gr_free_canvas(name_canv); name_canv=NULL; #ifdef AUTOMAP_NO_PAGING gr_free_canvas(OffscreenPage); OffscreenPage = NULL; #endif mprintf( (0, "Automap memory freed\n" )); game_flush_inputs(); if (pause_game) start_time(); } void adjust_segment_limit(int SegmentLimit) { int i,e1; Edge_info * e; mprintf(( 0, "Seglimit: %d\n", SegmentLimit )); for (i=0; i<=Highest_edge_index; i++ ) { e = &Edges[i]; e->flags |= EF_TOO_FAR; for (e1=0; e1<e->num_faces; e1++ ) { if ( Automap_visited[e->segnum[e1]] <= SegmentLimit ) { e->flags &= (~EF_TOO_FAR); break; } } } }
//called for each level to load & setup the exit sequence void load_endlevel_data(int level_num) { char filename[13]; char line[LINE_LEN],*p; CFILE *ifile; int var,segnum,sidenum; int exit_side=0; int have_binary = 0; endlevel_data_loaded = 0; //not loaded yet try_again: ; #ifdef SHAREWARE sprintf(filename,"level%02d.sdl", level_num); #else if (level_num<0) //secret level strcpy(filename,Secret_level_names[-level_num-1]); else //normal level strcpy(filename,Level_names[level_num-1]); #endif if (!convert_ext(filename,"end")) return; ifile = cfopen(filename,"rb"); if (!ifile) { convert_ext(filename,"txb"); if (!strcmp(filename, Briefing_text_filename) || !strcmp(filename, Ending_text_filename)) return; // Don't want to interpret the briefing as an end level sequence! ifile = cfopen(filename,"rb"); if (!ifile) { if (level_num==1) { return; //abort //Error("Cannot load file text of binary version of <%s>",filename); } else { level_num = 1; goto try_again; } } have_binary = 1; } //ok...this parser is pretty simple. It ignores comments, but //everything else must be in the right place var = 0; while (cfgets(line,LINE_LEN,ifile)) { if (have_binary) decode_text_line (line); if ((p=strchr(line,';'))!=NULL) *p = 0; //cut off comment for (p=line+strlen(line)-1;p>line && isspace(*p);*p--=0); for (p=line;isspace(*p);p++); if (!*p) //empty line continue; switch (var) { case 0: { //ground terrain int iff_error; ubyte pal[768]; gr_free_bitmap_data (&terrain_bm_instance); iff_error = iff_read_bitmap(p,&terrain_bm_instance,BM_LINEAR,pal); if (iff_error != IFF_NO_ERROR) { con_printf(CON_DEBUG, "Can't load exit terrain from file %s: IFF error: %s\n", p, iff_errormsg(iff_error)); endlevel_data_loaded = 0; // won't be able to play endlevel sequence cfclose(ifile); return; } terrain_bitmap = &terrain_bm_instance; gr_remap_bitmap_good( terrain_bitmap, pal, iff_transparent_color, -1); break; } case 1: //height map load_terrain(p); break; case 2: sscanf(p,"%d,%d",&exit_point_bmx,&exit_point_bmy); break; case 3: //exit heading exit_angles.h = i2f(atoi(p))/360; break; case 4: { //planet bitmap int iff_error; ubyte pal[768]; gr_free_bitmap_data (&satellite_bm_instance); iff_error = iff_read_bitmap(p,&satellite_bm_instance,BM_LINEAR,pal); if (iff_error != IFF_NO_ERROR) { con_printf(CON_DEBUG, "Can't load exit satellite from file %s: IFF error: %s\n", p, iff_errormsg(iff_error)); endlevel_data_loaded = 0; // won't be able to play endlevel sequence cfclose(ifile); return; } satellite_bitmap = &satellite_bm_instance; gr_remap_bitmap_good( satellite_bitmap, pal, iff_transparent_color, -1); break; } case 5: //earth pos case 7: { //station pos vms_matrix tm; vms_angvec ta; int pitch,head; sscanf(p,"%d,%d",&head,&pitch); ta.h = i2f(head)/360; ta.p = -i2f(pitch)/360; ta.b = 0; vm_angles_2_matrix(&tm,&ta); if (var==5) satellite_pos = tm.fvec; //vm_vec_copy_scale(&satellite_pos,&tm.fvec,SATELLITE_DIST); else station_pos = tm.fvec; break; } case 6: //planet size satellite_size = i2f(atoi(p)); break; } var++; } Assert(var == NUM_VARS); // OK, now the data is loaded. Initialize everything //find the exit sequence by searching all segments for a side with //children == -2 for (segnum=0,exit_segnum=-1;exit_segnum==-1 && segnum<=Highest_segment_index;segnum++) for (sidenum=0;sidenum<6;sidenum++) if (Segments[segnum].children[sidenum] == -2) { exit_segnum = segnum; exit_side = sidenum; break; } Assert(exit_segnum!=-1); compute_segment_center(&mine_exit_point,&Segments[exit_segnum]); extract_orient_from_segment(&mine_exit_orient,&Segments[exit_segnum]); compute_center_point_on_side(&mine_side_exit_point,&Segments[exit_segnum],exit_side); vm_vec_scale_add(&mine_ground_exit_point,&mine_exit_point,&mine_exit_orient.uvec,-i2f(20)); //compute orientation of surface { vms_vector tv; vms_matrix exit_orient,tm; vm_angles_2_matrix(&exit_orient,&exit_angles); vm_transpose_matrix(&exit_orient); vm_matrix_x_matrix(&surface_orient,&mine_exit_orient,&exit_orient); vm_copy_transpose_matrix(&tm,&surface_orient); vm_vec_rotate(&tv,&station_pos,&tm); vm_vec_scale_add(&station_pos,&mine_exit_point,&tv,STATION_DIST); vm_vec_rotate(&tv,&satellite_pos,&tm); vm_vec_scale_add(&satellite_pos,&mine_exit_point,&tv,SATELLITE_DIST); vm_vector_2_matrix(&tm,&tv,&surface_orient.uvec,NULL); vm_vec_copy_scale(&satellite_upvec,&tm.uvec,SATELLITE_HEIGHT); } cfclose(ifile); endlevel_data_loaded = 1; }
int credits_handler(window *wind, d_event *event, credits *cr) { int j, l, y; char * tempp; switch (event->type) { case EVENT_KEY_COMMAND: if (!call_default_handler(event)) // if not print screen, debug etc window_close(wind); return 1; case EVENT_MOUSE_BUTTON_DOWN: case EVENT_MOUSE_BUTTON_UP: if (event_mouse_get_button(event) == MBTN_LEFT || event_mouse_get_button(event) == MBTN_RIGHT) { window_close(wind); return 1; } break; case EVENT_IDLE: if (cr->done>NUM_LINES) { window_close(wind); return 0; } break; case EVENT_WINDOW_DRAW: timer_delay(F1_0/28); if (cr->row == 0) { do { cr->buffer_line = (cr->buffer_line+1) % NUM_LINES; get_line:; if (PHYSFSX_fgets( cr->buffer[cr->buffer_line], 80, cr->file )) { char *p; if (cr->have_bin_file) // is this a binary tbl file decode_text_line (cr->buffer[cr->buffer_line]); p = cr->buffer[cr->buffer_line]; if (p[0] == ';') goto get_line; if (p[0] == '%') { if (p[1] == ALLOWED_CHAR) { int i = 0, len = strlen(p); for (i = 0; i < len; i++) p[i] = p[i+2]; } else goto get_line; } } else { //fseek( file, 0, SEEK_SET); cr->buffer[cr->buffer_line][0] = 0; cr->done++; } } while (cr->extra_inc--); cr->extra_inc = 0; } // cheap but effective: towards end of credits sequence, fade out the music volume if (cr->done >= NUM_LINES-16) { static int curvol = -10; if (curvol == -10) curvol = GameCfg.MusicVolume; if (curvol > (NUM_LINES-cr->done)/2) { curvol = (NUM_LINES-cr->done)/2; songs_set_volume(curvol); } } y = cr->first_line_offset - cr->row; show_fullscr(&cr->backdrop); for (j=0; j<NUM_LINES; j++ ) { char *s; l = (cr->buffer_line + j + 1 ) % NUM_LINES; s = cr->buffer[l]; if ( s[0] == '!' ) { s++; } else if ( s[0] == '$' ) { gr_set_curfont( HUGE_FONT ); s++; } else if ( s[0] == '*' ) { gr_set_curfont( MEDIUM3_FONT ); s++; } else gr_set_curfont( MEDIUM2_FONT ); tempp = strchr( s, '\t' ); if ( !tempp ) { // Wacky Fast Credits thing int w, h, aw; gr_get_string_size( s, &w, &h, &aw); gr_string( 0x8000, y, s ); } y += ROW_SPACING; } cr->row += SHEIGHT/200; if (cr->row >= ROW_SPACING) cr->row = 0; break; case EVENT_WINDOW_CLOSE: gr_free_bitmap_data (&cr->backdrop); PHYSFS_close(cr->file); songs_set_volume(GameCfg.MusicVolume); songs_play_song( SONG_TITLE, 1 ); d_free(cr); break; default: break; } return 0; }
grs_main_canvas::~grs_main_canvas() { gr_free_bitmap_data(cv_bitmap); }
// ----------------------------------------------------------------------------- // Return true if message got aborted by user (pressed ESC), else return false. int show_briefing_message(int screen_num, char *message) { int prev_ch=-1; int ch, done=0; briefing_screen *bsp = &Briefing_screens[screen_num]; int delay_count = KEY_DELAY_DEFAULT; int key_check; int robot_num=-1; int rval=0; int tab_stop=0; int flashing_cursor=0; int new_page=0; int text_ulx = rescale_x(bsp->text_ulx); int text_uly = rescale_y(bsp->text_uly); Bitmap_name[0] = 0; Current_color = 0; // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y)); gr_set_curfont( GAME_FONT ); init_char_pos(text_ulx, text_uly); while (!done) { ch = *message++; if (ch == '$') { ch = *message++; if (ch == 'C') { Current_color = get_message_num(&message)-1; Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS)); prev_ch = 10; } else if (ch == 'F') { // toggle flashing cursor flashing_cursor = !flashing_cursor; prev_ch = 10; while (*message++ != 10) ; } else if (ch == 'T') { tab_stop = get_message_num(&message); prev_ch = 10; // read to eoln } else if (ch == 'R') { if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} init_spinning_robot(); robot_num = get_message_num(&message); prev_ch = 10; // read to eoln } else if (ch == 'N') { //--grs_bitmap *bitmap_ptr; if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); Animating_bitmap_type = 0; prev_ch = 10; } else if (ch == 'O') { if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); Animating_bitmap_type = 1; prev_ch = 10; } else if (ch == 'B') { char bitmap_name[32]; grs_bitmap guy_bitmap; ubyte temp_palette[768]; int iff_error; if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, bitmap_name); strcat(bitmap_name, ".bbm"); gr_init_bitmap_data (&guy_bitmap); iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette); Assert(iff_error == IFF_NO_ERROR); show_briefing_bitmap(&guy_bitmap); gr_free_bitmap_data (&guy_bitmap); prev_ch = 10; // } else if (ch == 'B') { // if (Robot_canv != NULL) // {free(Robot_canv); Robot_canv=NULL;} // // bitmap_num = get_message_num(&message); // if (bitmap_num != -1) // show_briefing_bitmap(Textures[bitmap_num]); // prev_ch = 10; // read to eoln } else if (ch == 'S') { int keypress; fix start_time; fix time_out_value; start_time = timer_get_fixed_seconds(); start_time = timer_get_approx_seconds(); time_out_value = start_time + i2f(60*5); // Wait 1 minute... //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key if ( timer_get_approx_seconds() > time_out_value ) { keypress = 0; break; // Time out after 1 minute.. } while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb start_time += KEY_DELAY_DEFAULT/2; } #ifndef NDEBUG if (keypress == KEY_BACKSP) Int3(); #endif if (keypress == KEY_ESC) rval = 1; flashing_cursor = 0; done = 1; } else if (ch == 'P') { // New page. new_page = 1; while (*message != 10) { message++; // drop carriage return after special escape sequence } message++; prev_ch = 10; //Begin D1X addition } else if (ch == '$' || ch == ';') { // Print a $/; prev_ch = ch; Briefing_text_x += show_char_delay((char) ch, delay_count, robot_num, flashing_cursor); //End D1X addition } } else if (ch == '\t') { // Tab if (Briefing_text_x - text_ulx < tab_stop) Briefing_text_x = text_ulx + tab_stop; } else if ((ch == ';') && (prev_ch == 10)) { while (*message++ != 10) ; prev_ch = 10; } else if (ch == '\\') { prev_ch = ch; } else if (ch == 10) { if (prev_ch != '\\') { prev_ch = ch; Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5; Briefing_text_x = text_ulx; if (Briefing_text_y > text_uly + rescale_y(bsp->text_height)) { load_briefing_screen(screen_num); Briefing_text_x = text_ulx; Briefing_text_y = text_uly; } } else { if (ch == 13) Int3(); prev_ch = ch; } } else { prev_ch = ch; Briefing_text_x += show_char_delay((char) ch, delay_count, robot_num, flashing_cursor); } //added/changed on 9/13/98 by adb to speed up briefings after pressing a key with SDL // Check for Esc -> abort. if(delay_count) key_check=local_key_inkey(); else key_check=0; //end change - adb if ( key_check == KEY_ESC ) { rval = 1; done = 1; } if ( key_check == KEY_ALTED+KEY_F2 ) title_save_game(); if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER)) delay_count = 0; if (Briefing_text_x > text_ulx + rescale_x(bsp->text_width)) { Briefing_text_x = text_ulx; Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5; } if ((new_page) || (Briefing_text_y > text_uly + rescale_y(bsp->text_height))) { fix start_time = 0; fix time_out_value = 0; int keypress; new_page = 0; start_time = timer_get_approx_seconds(); time_out_value = start_time + i2f(60*5); // Wait 1 minute... //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key if ( timer_get_approx_seconds() > time_out_value ) { keypress = 0; break; // Time out after 1 minute.. } while (timer_get_approx_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb start_time += KEY_DELAY_DEFAULT/2; } robot_num = -1; #ifndef NDEBUG if (keypress == KEY_BACKSP) Int3(); #endif if (keypress == KEY_ESC) { rval = 1; done = 1; } load_briefing_screen(screen_num); Briefing_text_x = text_ulx; Briefing_text_y = text_uly; delay_count = KEY_DELAY_DEFAULT; } } if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} return rval; }