// // COCKPIT.C - Source Code Module // // (c)Copyright 1995-1998 Steve Eschweiler. All Rights Reserved. // #include "fly.h" #include "tmr_snd.h" #include "sound.h" #include <math.h> //#define BUFFER_BLAST // Also in FLY.C #define WINDOW_OFF 0 #define WINDOW_YELLOW 1 #define WINDOW_GREEN 2 #define WINDOW_STROBE_GREEN 3 #define WINDOW_STROBE_RED 4 int current_window; int pipper_x, pipper_y, bomb_x, bomb_y; #define SC_INDEX 0x03c4 // Sequence Controller Index #define SC_DATA 0x03c5 // Sequence Controller Data Register char *vidmem; extern int cockpit_green_off_index, cockpit_green_on_index, cockpit_yellow_off_index, cockpit_yellow_on_index, cockpit_red_off_index, cockpit_red_on_index; int old_my_plane_brake, old_my_plane_gear, old_my_plane_flaps, old_my_plane_stall; extern char bitmap_light_aa[100]; extern char bitmap_light_sam[100]; extern char bitmap_light_lock[100]; extern char bitmap_light_nada[100]; extern char bitmap_light_stall[100]; extern char bitmap_light_fuel[100]; extern char bitmap_light_radar[100]; extern char bitmap_light_fail[100]; extern char bitmap_light_ctrl[100]; extern char bitmap_light_hyd[100]; extern char bitmap_light_fire[100]; extern char bitmap_light_engl[100]; extern char bitmap_light_engr[100]; extern char bitmap_light_brake[100]; extern char bitmap_light_gear[100]; extern char bitmap_light_flaps[100]; extern char bitmap_shoot[95]; extern short Syaw, Spitch, Sroll; // Same as PHYSICS.C #define MY_PLANE_MASS 1140 #define MY_PLANE_WEIGHT 36710 // #define MY_PLANE_MASS 716 // #define MY_PLANE_WEIGHT 23050 int ils; extern char CFP_g_force[90][251]; extern long Lstall_speed[90]; // Used by target view extern short Syaw_angle_of_head, Spitch_angle_of_head, Sroll_angle_of_head; long infrared_view_x, infrared_view_y, infrared_view_z, infrared_target_x, infrared_target_z, infrared_target_distance, infrared_wme, infrared_wmet; void Update_DDIs(void); void Draw_Threat(int on_left); void Draw_Target_Info(int on_left); void Draw_Radar(int on_left); void Draw_Radar_Blip(int DRB_sim_plane_element); void Draw_Missle_Radar_Blip(int DMRB_element); void Draw_Stores(int on_left); void Draw_Waypoints(int on_left); void Draw_Infrared(int on_left); void Calculate_Ground_Target_View(long view_distance); void disp_ddi_text(int disp_ddi_text_x, int disp_ddi_text_y, unsigned char *string, int string_len); void draw_ddi_station(int num, int draw_ddi_station_x, int draw_ddi_station_y); int update_stores_display; long Lx1, Ly1, Lx2, Ly2, Lx3, Ly3, Lx4, Ly4, Lx5, Ly5, Lx6, Ly6; /* Used by pitch ladder */ short Swaypoint_angle; #define LADDER_MINX 129 #define LADDER_MAXX 191 #define LADDER_MINY 30 #define LADDER_MAXY 100 #define HUD_COLOR 243 // new #define MAP_COLOR 140 //? #define DISPLAY_BK_COLOR 240 // new #define DISPLAY_DIM_COLOR 241 // new #define DISPLAY_FG_COLOR 242 // new /* #define MAP_MINX 135 #define MAP_MAXX 184 #define MAP_MINY 189 #define MAP_MAXY 238 #define MAP_CENTER_X 160 #define MAP_CENTER_Y 213 */ #define MAP_MINX 132 #define MAP_MAXX 185 #define MAP_MINY 200 #define MAP_MAXY 239 #define MAP_CENTER_X 159 #define MAP_CENTER_Y 227 int last_center_element, last_map_heading_x, map_heading_x, last_map_heading_z, map_heading_z, last_map_waypoint_x, map_waypoint_x, last_map_waypoint_z, map_waypoint_z; /* Used by map display */ extern long Lcenter_element; extern const short drawing_sequence_lookup[961]; long map_center_element; extern char *weapon_digit_ptr[10]; extern char weapon_digit_0[15]; extern char weapon_digit_1[15]; extern char weapon_digit_2[15]; extern char weapon_digit_3[15]; extern char weapon_digit_4[15]; extern char weapon_digit_5[15]; extern char weapon_digit_6[15]; extern char weapon_digit_7[15]; extern char weapon_digit_8[15]; extern char weapon_digit_9[15]; int MACH[90] = { 1116, 1113, 1109, 1105, 1101, 1097, 1093, 1089, 1085, 1081, 1077, 1073, 1069, 1065, 1061, 1057, 1053, 1049, 1045, 1041, 1037, 1033, 1029, 1025, 1020, 1016, 1012, 1008, 1003, 1000, 995, 991, 986, 982, 978, 973, 969, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, 968, }; void Update_Cockpit(void) { int loop_var; short Sgen, Sgen2; int Igen, Igen2, Igen3; long Lgen, Lgen2, Lgen3; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; if (cockpit_on_screen==NO || view_point!=LOOK_FOREWARD) return; Update_Lights(); // Alright, this is the plan. // We update all lights and everything pertaining to the cockpit // in this ONE function!!!!! // // The 2 DDI backgrounds are drawn on the hidden page. // The 2 DDI background are blited to the visual page. // All remaining DDI information is updated in real time. // // The map info is updated only as needed. // When the map changes, we store on the hidden page, and we // blit it to the active and visual pages and we're done and we // forget about it until it needs to be updated again. /* fg_restore(51,269,116,196); copy0( (char *)(0x000a0000+(page*20480)) ); copy1( (char *)(0x000a0000+(page*20480)) ); copy2( (char *)(0x000a0000+(page*20480)) ); copy3( (char *)(0x000a0000+(page*20480)) ); */ // Draw it FAST Please! // vidmem=(char *)0x000a0000+(page*20480); outp(SC_INDEX, 0x02); outp(SC_DATA, 0x01); copy1_cockpit((char *)(0x000a0000 + (page * 20480))); // Rippin' fast asm bitplane 1 blit outp(SC_DATA, 0x02); copy2_cockpit((char *)(0x000a0000 + (page * 20480))); // Rippin' fast asm bitplane 2 blit outp(SC_DATA, 0x04); copy3_cockpit((char *)(0x000a0000 + (page * 20480))); // Rippin' fast asm bitplane 3 blit outp(SC_DATA, 0x08); copy4_cockpit((char *)(0x000a0000 + (page * 20480))); // Rippin' fast asm bitplane 4 blit fg_restore(82, 238, 105, 119); fg_restore(49, 271, 120, 154); fg_restore(26, 294, 155, 196); fg_restore(58, 108, 197, 200); // Bottom of Left DDI fg_restore(210, 260, 197, 200); // Bottom of Left DDI // Let's paint an x marks the closest direction of travel to the // current target. if (gpt_selected && gpt_visable==NO && beginner_mode) { fg_setclip(0, 319, 1, 239); Lx = gpt_x - Lmy_plane_x; Lz = gpt_z - Lmy_plane_z; Syaw = Satan2(Lx, Lz); Lcos(Syaw, Lcyaw); Lsin(Syaw, Lsyaw); if (Lx<-32767 || Lx>32767 || Lz<-32767 || Lz>32767) { Lcyaw >>= SHIFT_HI_LO; Lsyaw >>= SHIFT_HI_LO; Spitch = Satan2(Lmy_plane_y - gpt_y, (LLabs(Lx * Lsyaw) + LLabs(Lz * Lcyaw) >> SHIFT_LO)); } else Spitch = Satan2(Lmy_plane_y - gpt_y, (LLabs(Lx * Lsyaw) + LLabs(Lz * Lcyaw) >> SHIFT_HI)); Sangle = Satan2((long)((short)(Syaw - Smy_plane_yaw)), (long)((short)(Spitch - Smy_plane_pitch))); Lsin(Sangle, Lsine); Lcos(Sangle, Lcosine); Lsxa = 256L * Lsine >> SHIFT_HI; Lsya = 256L * -Lcosine >> SHIFT_HI; Lsxb = Lsxa * Lmy_plane_croll + Lsya * Lmy_plane_sroll >> SHIFT_HI; Lsyb = Lsxa * -Lmy_plane_sroll + Lsya * Lmy_plane_croll >> SHIFT_HI; Lsxa = X_OFFSET; Lsya = y_offset; Lsxb += X_OFFSET; Lsyb += y_offset; // OK, we gotta find the intersection with the edge of the // screen. In other words, clip it. Lxa = 4L; // MINX //if (beginner_mode) Lya = 13L; // MINY //else // Lya=4L; // MINY Lxb = 315L; // MAXX if (y_offset==SMALL_SCREEN_CENTER_Y) Lyb = 99L; // MAXY else Lyb = 236L; // MAXY if (Lsxb<Lxa) { INTERPOLATE(Lsyb, Lsxb, Lsya, Lsxa, Lxa, Lsyb); Lsxb = Lxa; } if (Lsxb>Lxb) { INTERPOLATE(Lsya, Lsxa, Lsyb, Lsxb, Lxb, Lsyb); Lsxb = Lxb; } if (Lsyb<Lya) { INTERPOLATE(Lsxb, Lsyb, Lsxa, Lsya, Lya, Lsxb); Lsyb = Lya; } if (Lsyb>Lyb) { INTERPOLATE(Lsxa, Lsya, Lsxb, Lsyb, Lyb, Lsxb); Lsyb = Lyb; } fg_setcolor(HUD_COLOR); fg_point(Lsxb - 1, Lsyb - 1); fg_point(Lsxb - 1, Lsyb + 1); fg_point(Lsxb - 2, Lsyb - 2); fg_point(Lsxb - 2, Lsyb + 2); fg_point(Lsxb, Lsyb); fg_point(Lsxb + 1, Lsyb - 1); fg_point(Lsxb + 1, Lsyb + 1); fg_point(Lsxb + 2, Lsyb - 2); fg_point(Lsxb + 2, Lsyb + 2); } /* HUD area is: */ fg_setclip(118, 202, 19, 100); fg_setcolor(HUD_COLOR); /* Draw HUD weapon stuff*/ if (ils || station_type[current_station]==M61A1 || station_type[current_station]==MK82 || station_type[current_station]==MK83 || station_type[current_station]==MK84) { /* 40 frame per second maximum limitation */ if (pipper_counter==39) pipper_counter = 0; else pipper_counter++; Lpipper_tick[pipper_counter] = current_tick; Spipper_pitch[pipper_counter] = Smy_plane_pitch; Spipper_yaw[pipper_counter] = Smy_plane_yaw; /* convert distance to number of seconds ago */ /* 4096 max distance... seconds ago = distance / 4096 ticks ago = seconds ago * 1024 -or- ticks ago = (distance << 10L) / 4096 -or- ticks ago = (distance << 10L) >> 12L -or- ticks ago = distance >> 2L */ /* ticks ago */ ULgen = (TIMER_HZ * 2L) >> 2L; // 2048 /* Actual clock tick to use */ ULgen = Lpipper_tick[pipper_counter] - ULgen; ULgen2 = 0L; for (Igen = 0;Igen<40;Igen++) { if (Lpipper_tick[Igen]<ULgen && Lpipper_tick[Igen]>ULgen2) { ULgen2 = Lpipper_tick[Igen]; Igen2 = Igen; } } /* Igen2 now contains the farthest value * and Igen2+1 is the nearest value. * * Igen2+1 always exists and is safe to * use because it is always at least equal to pipper_counter * which is shown above. However, it must be in range from * 0-39. */ if (Igen2 + 1==40) Igen3 = 0; else Igen3 = Igen2 + 1; /* Now we'll extrapolate the pitch and yaw. The ratio between the * two clock ticks: * * Lpipper_tick[Igen2] * Lpipper_tick[Igen3] * * is what we use for the extrapolation factor. This ratio is * stored in Lgen as a FPL of 10 bits * precision. 10 bits equals 1024 which is exactly equal to * the clock tick precision of one second. If we were * calculating a smaller distance then 1024 ticks away, it * would be even more accurate! */ ULgen2 = (long)(Lpipper_tick[Igen3] - Lpipper_tick[Igen2]); if (ULgen2==0) ULgen2 = 1; Lgen = (long)(((ULgen - Lpipper_tick[Igen2]) << 10L) / ULgen2); /* PITCH */ /* Find difference or angle between the two */ Sangle = Spipper_pitch[Igen3] - Spipper_pitch[Igen2]; Lgen2 = (long)Sangle; /* Multiply by ratio */ Lgen2 = (Lgen2 * Lgen) >> 10L; Sangle = (int)Lgen2; /* Add result to first angle */ Sangle += Spipper_pitch[Igen2]; /* YAW */ /* Find difference or angle between the two */ Sangle_2 = Spipper_yaw[Igen3] - Spipper_yaw[Igen2]; Lgen2 = (long)Sangle_2; /* Multiply by ratio */ Lgen2 = (Lgen2 * Lgen) >> 10L; Sangle_2 = (int)Lgen2; /* Add result to first angle */ Sangle_2 += Spipper_yaw[Igen2]; // Ltravel_distance=to radar distance? // If so, remember that we are using this formula for the // velocity vector used by the MK80 series cockpit HUD display so we // should make sure that this distance is set to 2048 when displaying // the MK80 series HUD display. if (gpt_selected && gpt_visable && gpt_distance<4096L && !ils) { Ltravel_distance = gpt_distance; fg_move(189, 100); fg_drwimage(HUD_in_rng, 11, 12); } else Ltravel_distance = 2048L; /* The stalling part of the velocity vector */ if (ils || station_type[current_station]==MK82 || station_type[current_station]==MK83 || station_type[current_station]==MK84) { if (!my_plane_touchdown) { if (Lmy_plane_velocity<Lstall_speed[-Lmy_plane_y/1000L]) { // -45 degree aoa at 0 ft/sec and -15 aoa at stall INTERPOLATE(-8192L, 0L, -2731L, Lstall_speed[-Lmy_plane_y/1000L], Lmy_plane_velocity, Lgen); Sangle += Lgen; } else if (Lmy_plane_velocity<Lstall_speed[-Lmy_plane_y/1000L] + 51L) { // -15 degree aoa at stall INTERPOLATE(0L, Lstall_speed[-Lmy_plane_y/1000L] + 51L, -2731L, Lstall_speed[-Lmy_plane_y/1000L], Lmy_plane_velocity, Lgen); Sangle += Lgen; } } else { Sangle = 0; } } Lcos(Sangle, Lcosine); Lsin(Sangle, Lsine); Lxa = Ltravel_distance * Lcosine >> SHIFT_HI; Lya = Ltravel_distance * Lsine >> SHIFT_HI; Lcos(Sangle_2, Lcosine); Lsin(Sangle_2, Lsine); Lz = Lmy_plane_z + (Lxa * Lcosine >> SHIFT_HI); Lx = Lmy_plane_x + (Lxa * Lsine >> SHIFT_HI); Ly = Lmy_plane_y - Lya; Lxa = Lx - Lview_x; Lya = Ly - Lview_y; Lza = Lz - Lview_z; Lxb = Lxa * T00 + Lya * T01 + Lza * T02; /* >>SHIFT_LO; */ Lyb = Lxa * T10 + Lya * T11 + Lza * T12; /* >>SHIFT_LO; */ Lzb = Lxa * T20 + Lya * T21 + Lza * T22; /* >>SHIFT_LO; */ /* if (Lzb==0L) Lzb=1L; Will never be a Divide by zero here because pipper is always far in front and always 2048 away in front */ if (Lzb==0L) Lzb = 1L; // With ILS and GP-BOMB it can! Isxa = (int)(DEPTH * Lxb / Lzb); Isya = (int)(DEPTH * Lyb / Lzb); if (station_type[current_station]==M61A1 && ils==OFF) { fg_move(Isxa + X_OFFSET, Isya + y_offset); fg_point(Isxa + X_OFFSET, Isya + y_offset); // fg_circle(10); fg_point(Isxa + X_OFFSET - 10, Isya + y_offset); fg_point(Isxa + X_OFFSET + 10, Isya + y_offset); fg_point(Isxa + X_OFFSET, Isya + y_offset - 10); fg_point(Isxa + X_OFFSET, Isya + y_offset + 10); fg_point(Isxa + X_OFFSET - 10, Isya + y_offset - 3); fg_point(Isxa + X_OFFSET - 10, Isya + y_offset + 3); fg_point(Isxa + X_OFFSET + 10, Isya + y_offset - 3); fg_point(Isxa + X_OFFSET + 10, Isya + y_offset + 3); fg_point(Isxa + X_OFFSET - 3, Isya + y_offset - 10); fg_point(Isxa + X_OFFSET + 3, Isya + y_offset - 10); fg_point(Isxa + X_OFFSET - 3, Isya + y_offset + 10); fg_point(Isxa + X_OFFSET + 3, Isya + y_offset + 10); fg_point(Isxa + X_OFFSET - 8, Isya + y_offset - 6); fg_point(Isxa + X_OFFSET - 6, Isya + y_offset - 8); fg_point(Isxa + X_OFFSET + 8, Isya + y_offset - 6); fg_point(Isxa + X_OFFSET + 6, Isya + y_offset - 8); fg_point(Isxa + X_OFFSET + 8, Isya + y_offset + 6); fg_point(Isxa + X_OFFSET + 6, Isya + y_offset + 8); fg_point(Isxa + X_OFFSET - 8, Isya + y_offset + 6); fg_point(Isxa + X_OFFSET - 6, Isya + y_offset + 8); fg_point(157, SMALL_SCREEN_CENTER_Y); fg_point(158, SMALL_SCREEN_CENTER_Y); fg_point(162, SMALL_SCREEN_CENTER_Y); fg_point(163, SMALL_SCREEN_CENTER_Y); } } else if (station_type[current_station]==AIM7M) { fg_move(X_OFFSET, SMALL_SCREEN_CENTER_Y); fg_circle(21); fg_point(157, SMALL_SCREEN_CENTER_Y); fg_point(158, SMALL_SCREEN_CENTER_Y); fg_point(159, SMALL_SCREEN_CENTER_Y + 1); fg_point(160, SMALL_SCREEN_CENTER_Y); fg_point(161, SMALL_SCREEN_CENTER_Y + 1); fg_point(162, SMALL_SCREEN_CENTER_Y); fg_point(163, SMALL_SCREEN_CENTER_Y); } else if (station_type[current_station]==AIM9M) { fg_move(X_OFFSET, SMALL_SCREEN_CENTER_Y); fg_circle(17); fg_point(157, SMALL_SCREEN_CENTER_Y); fg_point(158, SMALL_SCREEN_CENTER_Y); fg_point(159, SMALL_SCREEN_CENTER_Y + 1); fg_point(160, SMALL_SCREEN_CENTER_Y); fg_point(161, SMALL_SCREEN_CENTER_Y + 1); fg_point(162, SMALL_SCREEN_CENTER_Y); fg_point(163, SMALL_SCREEN_CENTER_Y); } else if (station_type[current_station]==AGM88A || station_type[current_station]==AGM65F || station_type[current_station]==M151 || station_type[current_station]==MK5) { // Draw Center Cross Hairs fg_point(156, SMALL_SCREEN_CENTER_Y); fg_point(157, SMALL_SCREEN_CENTER_Y); fg_point(163, SMALL_SCREEN_CENTER_Y); fg_point(164, SMALL_SCREEN_CENTER_Y); fg_point(160, SMALL_SCREEN_CENTER_Y - 4); fg_point(160, SMALL_SCREEN_CENTER_Y - 3); fg_point(160, SMALL_SCREEN_CENTER_Y + 3); fg_point(160, SMALL_SCREEN_CENTER_Y + 4); } if (ils) { // Isxa, Isya were defined using the pipper location. // We'll use it for a velocity vector. fg_point(Isxa + 3 + X_OFFSET, Isya + y_offset); fg_point(Isxa - 3 + X_OFFSET, Isya + y_offset); fg_point(Isxa + X_OFFSET, Isya - 3 + y_offset); fg_move(Isxa + X_OFFSET, Isya + y_offset); fg_circle(2); // The AOA Bracket fg_move(155, 96); fg_drwimage(aoa_bracket, 2, 17); // ILS fg_move(189, 100); fg_drwimage(ILS_bitmap, 11, 5); // If within 60x60 mile grid or 30+ miles to runway, then // we draw deviation bars // ...But if in runway world map element box, then no // elevation bars are drawn. Lz = Lmy_plane_z - Lwaypoint_z[num_waypoints-1]; Lx = Lmy_plane_x - Lwaypoint_x[num_waypoints-1]; if (Lx>-158400L && Lx<158400L && Lz>-158400L && Lz<158400L && Lcurrent_element!=XZ_TO_ELEMENT(Lwaypoint_x[num_waypoints-1], Lwaypoint_z[num_waypoints-1])) { // OK, let's find the line for the ILS if (Lmy_plane_z>Lwaypoint_z[num_waypoints-1]) { // landing on runway 18 // Calculate Vertical Deviation Bar Lgen = (Lmy_plane_x - Lwaypoint_x[num_waypoints-1]) / 100L; // Calculate Horizontal Deviation Bar INTERPOLATE(0L, Lwaypoint_z[num_waypoints-1] + 2560L, -30000L, Lwaypoint_z[num_waypoints-1] + 2560L + 158400L, Lmy_plane_z, Lgen2); } else { // landing on runway 00 // Calculate Vertical Deviation Bar Lgen = (Lmy_plane_x - Lwaypoint_x[num_waypoints-1]) / -100L; // Calculate Horizontal Deviation Bar INTERPOLATE(0L, Lwaypoint_z[num_waypoints-1] - 2560L, -30000L, Lwaypoint_z[num_waypoints-1] - 2560L - 158400L, Lmy_plane_z, Lgen2); } // Draw Vertical Deviation Bar if (Lgen<-12) Lgen = -12; if (Lgen>12) Lgen = 12; // Line Style - 3333h = 0011 0011 0011 0011b = first 2 pixels off! fg_move(160 + Lgen, 75); fg_dash(160 + Lgen, 51, 0xAAAA); // Draw Horizontal Deviation Bar Lgen2 = Lmy_plane_y - Lgen2; Lgen2 /= -100L; if (Lgen2<-12) Lgen2 = -12; if (Lgen2>12) Lgen2 = 12; fg_move(148, 63 + Lgen2); fg_dash(172, 63 + Lgen2, 0xAAAA); } else { // The center of HUD thingy - Watermark? fg_move(160, 60); fg_draw(160, 66); fg_move(157, 63); fg_draw(163, 63); } } else if (station_type[current_station]==MK82 || station_type[current_station]==MK83 || station_type[current_station]==MK84) { // Calculate and display impact location on earth Lsin(Smy_plane_pitch, Lspitch); Lcos(Smy_plane_pitch, Lcpitch); Lsin(Smy_plane_roll, Lsroll); Lcos(Smy_plane_roll, Lcroll); // Calculate vertical velocity in ft/sec Fgen3 = (float)(Lmy_plane_velocity * -Lspitch >> SHIFT_HI); Fgen = Fgen3 * Fgen3; Fgen2 = 64.4F * (float)(-Lmy_plane_y); Lgen = (long)sqrt((double)(Fgen + Fgen2)); // Calculate time from release to impact Fgen = (float)(Lgen + (Lmy_plane_velocity * Lspitch >> SHIFT_HI)) / 32.2F; // Calculate total distance forward to hit impact zone // we don't divide by two here cause there is no foreward // accelleration formula involved! Lgen3 = (long)((float)(Lmy_plane_velocity * Lcpitch >> SHIFT_HI) * Fgen); // Translate earth impact coordinates to plane system for projection // Since the yaw can be completely and safely avoided, we will not // use it for our rotation matrix. TLtemp_00 = Lcroll; TLtemp_01 = Lsroll * Lcpitch >> SHIFT_HI; TLtemp_02 = Lsroll * Lspitch >> SHIFT_HI; TLtemp_10 = -Lsroll; TLtemp_11 = Lcroll * Lcpitch >> SHIFT_HI; TLtemp_12 = Lcroll * Lspitch >> SHIFT_HI; TLtemp_20 = 0L; TLtemp_21 = -Lspitch; TLtemp_22 = Lcpitch; TLtemp_00 >>= SHIFT_HI_LO; TLtemp_01 >>= SHIFT_HI_LO; TLtemp_02 >>= SHIFT_HI_LO; TLtemp_10 >>= SHIFT_HI_LO; TLtemp_11 >>= SHIFT_HI_LO; TLtemp_12 >>= SHIFT_HI_LO; TLtemp_20 >>= SHIFT_HI_LO; TLtemp_21 >>= SHIFT_HI_LO; TLtemp_22 >>= SHIFT_HI_LO; // Lxa = 0*TLtemp_00 + -Lmy_plane_y*TLtemp_01 + Lgen3*TLtemp_02 >>SHIFT_LO; // Lya = 0*TLtemp_10 + -Lmy_plane_y*TLtemp_11 + Lgen3*TLtemp_12 >>SHIFT_LO; // Lza = 0*TLtemp_20 + -Lmy_plane_y*TLtemp_21 + Lgen3*TLtemp_22 >>SHIFT_LO; Lxa = -Lmy_plane_y * TLtemp_01 + Lgen3 * TLtemp_02 >> SHIFT_LO; Lya = -Lmy_plane_y * TLtemp_11 + Lgen3 * TLtemp_12 >> SHIFT_LO; Lza = -Lmy_plane_y * TLtemp_21 + Lgen3 * TLtemp_22 >> SHIFT_LO; // Isxa, Isya were defined using the pipper location. // We'll use it for a velocity vector. /* Isxa>>=2; Isya>>=2; */ fg_point(Isxa + 3 + X_OFFSET, Isya + y_offset); fg_point(Isxa - 3 + X_OFFSET, Isya + y_offset); fg_point(Isxa + X_OFFSET, Isya - 3 + y_offset); fg_move(Isxa + X_OFFSET, Isya + y_offset); fg_circle(2); // if (Lza<1) Lza=1; if (Lza==0L) Lza = 1; else if (Lza<0L) Lza = -Lza; // Save it. bomb_x = (DEPTH * Lxa / Lza) + X_OFFSET; bomb_y = (DEPTH * Lya / Lza) + SMALL_SCREEN_CENTER_Y; fg_draw(bomb_x, bomb_y); // fg_circle(3); fg_moverel(-2, -2); fg_drawrel(4, 4); fg_moverel(0, -4); fg_drawrel(-4, 4); fg_point(X_OFFSET - 3, SMALL_SCREEN_CENTER_Y); fg_point(X_OFFSET - 2, SMALL_SCREEN_CENTER_Y); fg_point(X_OFFSET + 2, SMALL_SCREEN_CENTER_Y); fg_point(X_OFFSET + 3, SMALL_SCREEN_CENTER_Y); } // If we got a target, we'll add the stuff to the HUD if (gpt_visable) { // Draw the target designator box fg_box(gpt_sx - 4L + X_OFFSET, gpt_sx + 4L + X_OFFSET, gpt_sy - 4L + SMALL_SCREEN_CENTER_Y, gpt_sy + 4L + SMALL_SCREEN_CENTER_Y); // Display shoot also! // Save it. pipper_x = Isxa + X_OFFSET; pipper_y = Isya + y_offset; if (current_window==WINDOW_STROBE_GREEN) // Need to display SHOOT { if (page==0) { // Display SHOOT at bottom of HUD fg_move(151, 100); fg_drwimage(bitmap_shoot, 19, 5); } } // Draw the target designator box directional line // (gpt_sx+X_OFFSET)-X_OFFSET, (gpt_sy+SMALL_SCREEN_CENTER_Y)-30 Sangle = Satan2(gpt_sx, gpt_sy + SMALL_SCREEN_CENTER_Y - 30L); Lsin(Sangle, Lsine); Lcos(Sangle, Lcosine); Lsxa = 12 * Lsine >> SHIFT_HI; Lsya = 12 * Lcosine >> SHIFT_HI; fg_move(X_OFFSET, 30); fg_drawrel(Lsxa, Lsya); if (gpt_in_rng && !ils) { fg_move(189, 100); fg_drwimage(HUD_in_rng, 11, 12); } if (gpt_lockable) { fg_move(gpt_sx + X_OFFSET, gpt_sy + SMALL_SCREEN_CENTER_Y - 5L); fg_drawrel(5, 5); fg_drawrel(-5, 5); fg_drawrel(-5, -5); fg_drawrel(5, -5); } } /* Full Screen Access Now */ fg_setclip(0, 319, 0, 239); if (ils) { // Calculate if within 10 degrees to runway center Sangle = Satan2(Lwaypoint_x[num_waypoints-1] - Lmy_plane_x, Lwaypoint_z[num_waypoints-1] - Lmy_plane_z); if ((Sangle>=(-10 * 182) && Sangle<=(10 * 182)) || (Sangle>=(170 * 182) || Sangle<=(-170 * 182))) { // Calculate feet to runway center Fgen = (float)(Lmy_plane_x - Lwaypoint_x[num_waypoints-1]) * (float)(Lmy_plane_x - Lwaypoint_x[num_waypoints-1]); Fgen2 = (float)(Lmy_plane_z - Lwaypoint_z[num_waypoints-1]) * (float)(Lmy_plane_z - Lwaypoint_z[num_waypoints-1]); Lgen = (long)sqrt((double)(Fgen + Fgen2)); if (Lgen<2860L) // 256*10 = edge of runway + 300 { // 300 feet from edge of runway fg_setcolor(cockpit_green_on_index); fg_rect(100, 103, 123, 124); } else if (Lgen<6560L) // 256*10 = edge of runway + 4000 { // Middle one is lit fg_setcolor(cockpit_yellow_on_index); fg_rect(100, 103, 128, 129); } else if (Lgen<65920L) // 256*10 = edge of runway + 12 miles { // Bottom one is lit fg_setcolor(cockpit_red_on_index); fg_rect(100, 103, 133, 134); } } } fg_setpage(2); if (update_RPM) { if (update_RPM==STAGE_2) update_RPM = NO; else update_RPM = STAGE_2; if (my_plane_eng_1_AFB) fg_transfer(108, 123, 0, 4, 212, 125, 2, 2); else { // RPM% fg_move(212, 125); fg_putimage(cockpit_digit_ptr[(my_plane_eng_1_RPM/100)%10], 3, 5); fg_move(216, 125); fg_putimage(cockpit_digit_ptr[(my_plane_eng_1_RPM/10)%10], 3, 5); fg_move(220, 125); fg_putimage(cockpit_digit_ptr[my_plane_eng_1_RPM%10], 3, 5); fg_transfer(40, 42, 6, 10, 224, 125, 2, 2); // Redisplay that % sign } } fg_setpage(page); /* Display Pounds of Fuel Of Current Fuel Tank */ if (current_fuel_tank==INTERNAL) Lgen = (long)Imy_plane_int_fuel_weight; else Lgen = (long)Imy_plane_ext_fuel_weight; fg_move(208, 131); fg_putimage(cockpit_digit_ptr[(Lgen/10000)%10], 3, 5); fg_move(212, 131); fg_putimage(cockpit_digit_ptr[(Lgen/1000)%10], 3, 5); fg_move(216, 131); fg_putimage(cockpit_digit_ptr[(Lgen/100)%10], 3, 5); fg_move(220, 131); fg_putimage(cockpit_digit_ptr[(Lgen/10)%10], 3, 5); fg_move(224, 131); fg_putimage(cockpit_digit_ptr[Lgen%10], 3, 5); Lmy_plane_weight = MY_PLANE_EMPTY_WEIGHT + Imy_plane_int_fuel_weight + Imy_plane_ext_fuel_weight + Lweight_stations_not_ext_fuel; /* HUD area is: */ fg_setclip(118, 202, 19, 100); fg_setcolor(HUD_COLOR); /* MACH indicator */ Igen = (int)(Lmy_plane_velocity * 100L) / MACH[-Lmy_plane_y/1000L]; /* Decimal point */ fg_point(129, 86); if (Igen>99) { fg_move(125, 86); fg_drwimage(HUD_digit_ptr[(Igen/100)%10], 3, 5); } fg_move(131, 86); fg_drwimage(HUD_digit_ptr[(Igen/10)%10], 3, 5); fg_move(135, 86); fg_drwimage(HUD_digit_ptr[Igen%10], 3, 5); // Draw the M for MACH and G for G force, on the HUD fg_move(120, 93); fg_drwimage(HUD_m_g, 3, 12); /* G indicator */ // Well, our flight model is innaccurate, so let's say that // IFP_current_g_force will not display anything greater than 9.0! if (IFP_current_g_force>90) IFP_current_g_force = 90; if (IFP_current_g_force<0) { /* Negative sign */ fg_point(126, 91); fg_point(127, 91); Igen = -IFP_current_g_force; } else Igen = IFP_current_g_force; /* Decimal point */ fg_point(133, 93); fg_move(129, 93); fg_drwimage(HUD_digit_ptr[(Igen/10)%10], 3, 5); fg_move(135, 93); fg_drwimage(HUD_digit_ptr[Igen%10], 3, 5); /* Altitude */ Lgen = -(Lmy_plane_y + 6L); //Lgen=Lmy_plane_calibrated_altitude; if (Lgen>9999L) { fg_move(185, 58); fg_drwimage(HUD_digit_ptr[(Lgen/10000)%10], 3, 5); } if (Lgen>999L) { fg_move(189, 58); fg_drwimage(HUD_digit_ptr[(Lgen/1000)%10], 3, 5); } if (Lgen>99L) { fg_move(193, 58); fg_drwimage(HUD_digit_ptr[(Lgen/100)%10], 3, 5); } if (Lgen>9L) { fg_move(197, 58); fg_drwimage(HUD_digit_ptr[(Lgen/10)%10], 3, 5); } fg_move(201, 58); fg_drwimage(HUD_digit_ptr[Lgen%10], 3, 5); /* KNOTS */ Igen = (int)(Lmy_plane_velocity * 4857L >> 13L); if (Igen<0) Igen = 0; Igen2 = 118; if (Igen>999) { fg_move(118, 58); Igen2 += 4; fg_drwimage(HUD_digit_ptr[(Igen/1000)%10], 3, 5); } if (Igen>99) { fg_move(Igen2, 58); Igen2 += 4; fg_drwimage(HUD_digit_ptr[(Igen/100)%10], 3, 5); } if (Igen>9) { fg_move(Igen2, 58); Igen2 += 4; fg_drwimage(HUD_digit_ptr[(Igen/10)%10], 3, 5); } fg_move(Igen2, 58); fg_drwimage(HUD_digit_ptr[Igen%10], 3, 5); /* VSI: Vertical Speed Indicator */ fg_point(129, 100); /* Decimal point */ if (IFP_VSI<0) { /* Negitive sign and first charcter placement on the x axis */ IFP_VSI = -IFP_VSI; fg_point(118, 98); fg_point(119, 98); } if (IFP_VSI>999) { fg_move(121, 100); fg_drwimage(HUD_digit_ptr[(IFP_VSI/1000)%10], 3, 5); } fg_move(125, 100); fg_drwimage(HUD_digit_ptr[(IFP_VSI/100)%10], 3, 5); fg_move(131, 100); fg_drwimage(HUD_digit_ptr[(IFP_VSI/10)%10], 3, 5); fg_move(135, 100); fg_drwimage(HUD_digit_ptr[IFP_VSI%10], 3, 5); /* HUD Pitch Ladder Limits */ fg_setclip(LADDER_MINX, LADDER_MAXX, LADDER_MINY, LADDER_MAXY); // Make drawing of 0 pitch rungs look nice at small variations in roll if (Smy_plane_roll>-364 && Smy_plane_roll<364) { Lsroll = 0L; Lcroll = 16384L; } else { Lsin(Smy_plane_roll, Lsroll); Lcos(Smy_plane_roll, Lcroll); } // From 'center' of HUD to beginning of line Lsxa = (-5L * Lcroll >> SHIFT_HI) + X_OFFSET; Lsya = (5L * Lsroll >> SHIFT_HI) + y_offset; Lsxb = (5L * Lcroll >> SHIFT_HI) + X_OFFSET; Lsyb = (-5L * Lsroll >> SHIFT_HI) + y_offset; // Hash marks - relative Isxa = 3L * Lsroll >> SHIFT_HI; Isya = 3L * Lcroll >> SHIFT_HI; // Calculate relative location of a digit after Isxa, Isya // Left positive numbers Lx3 = (-4L * Lcroll >> SHIFT_HI) - 1L; Ly3 = (-4L * -Lsroll >> SHIFT_HI) + 2L; // Right positive numbers Lx4 = (4L * Lcroll >> SHIFT_HI) - 1L; Ly4 = (4L * -Lsroll >> SHIFT_HI) + 2L; // Left negative numbers Lx5 = (-6L * Lcroll >> SHIFT_HI) - 2L; Ly5 = (-6L * -Lsroll >> SHIFT_HI) + 2L; // Right negative numbers Lx6 = (6L * Lcroll >> SHIFT_HI) - 2L; Ly6 = (6L * -Lsroll >> SHIFT_HI) + 2L; // A little pre-calc for nanosecond time savings and less code Lxc = -9 * Lcroll; Lyc = -9 * -Lsroll; Lxd = 9 * Lcroll; Lyd = 9 * -Lsroll; /* +80 */ Sgen = Smy_plane_pitch - 14564; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + (Lsroll << 4L) >> SHIFT_HI; Ly1 = Lyc + (Lcroll << 4L) >> SHIFT_HI; Lx2 = Lxd + (Lsroll << 4L) >> SHIFT_HI; Ly2 = Lyd + (Lcroll << 4L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_8, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_8, 3, 5); } /* +70 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + 14 * Lsroll >> SHIFT_HI; Ly1 = Lyc + 14 * Lcroll >> SHIFT_HI; Lx2 = Lxd + 14 * Lsroll >> SHIFT_HI; Ly2 = Lyd + 14 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_7, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_7, 3, 5); } /* +60 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + 12 * Lsroll >> SHIFT_HI; Ly1 = Lyc + 12 * Lcroll >> SHIFT_HI; Lx2 = Lxd + 12 * Lsroll >> SHIFT_HI; Ly2 = Lyd + 12 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_6, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_6, 3, 5); } /* +50 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + 10 * Lsroll >> SHIFT_HI; Ly1 = Lyc + 10 * Lcroll >> SHIFT_HI; Lx2 = Lxd + 10 * Lsroll >> SHIFT_HI; Ly2 = Lyd + 10 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_5, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_5, 3, 5); } /* +40 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + (Lsroll << 3L) >> SHIFT_HI; Ly1 = Lyc + (Lcroll << 3L) >> SHIFT_HI; Lx2 = Lxd + (Lsroll << 3L) >> SHIFT_HI; Ly2 = Lyd + (Lcroll << 3L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_4, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_4, 3, 5); } /* +30 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + 6 * Lsroll >> SHIFT_HI; Ly1 = Lyc + 6 * Lcroll >> SHIFT_HI; Lx2 = Lxd + 6 * Lsroll >> SHIFT_HI; Ly2 = Lyd + 6 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_3, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_3, 3, 5); } /* +20 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + (Lsroll << 2L) >> SHIFT_HI; Ly1 = Lyc + (Lcroll << 2L) >> SHIFT_HI; Lx2 = Lxd + (Lsroll << 2L) >> SHIFT_HI; Ly2 = Lyd + (Lcroll << 2L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_2, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_2, 3, 5); } /* +10 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc + (Lsroll << 2L) >> SHIFT_HI; Ly1 = Lyc + (Lcroll << 2L) >> SHIFT_HI; Lx2 = Lxd + (Lsroll << 2L) >> SHIFT_HI; Ly2 = Lyd + (Lcroll << 2L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_1, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_1, 3, 5); } /* 0 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc >> SHIFT_HI; Ly1 = Lyc >> SHIFT_HI; Lx2 = Lxd >> SHIFT_HI; Ly2 = Lyd >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_drawrel(Lx1, Ly1); fg_drawrel(Isxa, Isya); fg_moverel(Lx3, Ly3); fg_clpimage(HUD_digit_0, 3, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_drawrel(Lx2, Ly2); fg_drawrel(Isxa, Isya); fg_moverel(Lx4, Ly4); fg_clpimage(HUD_digit_0, 3, 5); } /* -10 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - (Lsroll << 2L) >> SHIFT_HI; Ly1 = Lyc - (Lcroll << 2L) >> SHIFT_HI; Lx2 = Lxd - (Lsroll << 2L) >> SHIFT_HI; Ly2 = Lyd - (Lcroll << 2L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_1, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_1, 6, 5); } /* -20 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - (Lsroll << 2L) >> SHIFT_HI; Ly1 = Lyc - (Lcroll << 2L) >> SHIFT_HI; Lx2 = Lxd - (Lsroll << 2L) >> SHIFT_HI; Ly2 = Lyd - (Lcroll << 2L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_2, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_2, 6, 5); } /* -30 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - 6 * Lsroll >> SHIFT_HI; Ly1 = Lyc - 6 * Lcroll >> SHIFT_HI; Lx2 = Lxd - 6 * Lsroll >> SHIFT_HI; Ly2 = Lyd - 6 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_3, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_3, 6, 5); } /* -40 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - (Lsroll << 3L) >> SHIFT_HI; Ly1 = Lyc - (Lcroll << 3L) >> SHIFT_HI; Lx2 = Lxd - (Lsroll << 3L) >> SHIFT_HI; Ly2 = Lyd - (Lcroll << 3L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_4, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_4, 6, 5); } /* -50 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - 10 * Lsroll >> SHIFT_HI; Ly1 = Lyc - 10 * Lcroll >> SHIFT_HI; Lx2 = Lxd - 10 * Lsroll >> SHIFT_HI; Ly2 = Lyd - 10 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_5, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_5, 6, 5); } /* -60 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - 12 * Lsroll >> SHIFT_HI; Ly1 = Lyc - 12 * Lcroll >> SHIFT_HI; Lx2 = Lxd - 12 * Lsroll >> SHIFT_HI; Ly2 = Lyd - 12 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_6, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_6, 6, 5); } /* -70 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - 14 * Lsroll >> SHIFT_HI; Ly1 = Lyc - 14 * Lcroll >> SHIFT_HI; Lx2 = Lxd - 14 * Lsroll >> SHIFT_HI; Ly2 = Lyd - 14 * Lcroll >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_7, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_7, 6, 5); } /* -80 */ Sgen += 1820; if (Sgen>-3640 && Sgen<3640) { // Calculate center offset of pitch ladder rung based on // pitch and roll Lsin(Sgen, Lspitch); Lcos(Sgen, Lcpitch); if (Lcpitch==0L) Lcpitch = 1L; // Avoid divide by zero Lxa = DEPTH * (Lsroll * Lspitch >> SHIFT_HI) / Lcpitch; Lya = DEPTH * (Lcroll * Lspitch >> SHIFT_HI) / Lcpitch; // Calculate rung bend locations for this pitch angle Lx1 = Lxc - (Lsroll << 4L) >> SHIFT_HI; Ly1 = Lyc - (Lcroll << 4L) >> SHIFT_HI; Lx2 = Lxd - (Lsroll << 4L) >> SHIFT_HI; Ly2 = Lyd - (Lcroll << 4L) >> SHIFT_HI; // Draw those lines fg_move(Lsxa + Lxa, Lsya + Lya); fg_dashrel(Lx1, Ly1, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx5, Ly5); fg_clpimage(HUD_neg_digit_8, 6, 5); fg_move(Lsxb + Lxa, Lsyb + Lya); fg_dashrel(Lx2, Ly2, 0x3333); fg_drawrel(Isxa, Isya); fg_moverel(Lx6, Ly6); fg_clpimage(HUD_neg_digit_8, 6, 5); } /* HUD area is: Heading Slide Rule type thing. */ fg_setclip(118, 202, 19, 100); // Find the relative yaw angle to the nearest 10 degree marker. // For example, we are facing 30 yaw and want to find 20 degrees, // so 20 degree's relative to 30 is -10 degree's. We use -10 for // the following formula. 20-30=-10. Also 30 degree's is 0 relative // to center of our slide rule thingy. If we were facing 31 degree's, // then our relative position to 30 degree's would be -1. If we // were facing 29 degree's, then our relative position to 30 degree's // would be 1. OK, last, but not least, we need to keep track of // what directional points are what, so we can add numbers to the // points. This is simple! Sgen, below, contians, // our relative angle and so we add this to our "nearest to center" // angle. // To find out how far an exact replication of 5 degree is, we do // this: DEPTH*sin(5)/cos(5) - DEPTH*sin(0)/cos(0) // 160 * 0.0871557427477/0.9961946980917 = 13.998179 or 14 // Find our yaw of 0 - 359 if (Smy_plane_yaw>0) Igen = Smy_plane_yaw / 182; else Igen = (((long)Smy_plane_yaw + 65536L) / 182L); Igen %= 360; // 0-355 at 5 degree increments. However, when // Igen is originally at 4, we get 0. This is OK, // and makes for simpler equations. 3 on the left and 4 on the right Sgen = (short)((Igen / 5) * 5); Sgen2 = (Sgen * 182) - Smy_plane_yaw; // OK, now we find the X offset based on our nearest 5 increment yaw. Lsin(Sgen2, Lsyaw); Lcos(Sgen2, Lcyaw); if (Lcyaw==0L) Lcyaw = 1L; // Avoid divide by zero Lxa = DEPTH * Lsyaw / Lcyaw + X_OFFSET; /* When Perspective DEPTH is 160 Lxa+=14 When Perspective DEPTH is 200 Lxa+=17.5 When Perspective DEPTH is 240 Lxa+=21 When Perspective DEPTH is 320 Lxa+=28 */ Sgen -= 5; if (Sgen==-10) Sgen = 350; Lxa -= 17; fg_point(Lxa, 28); fg_point(Lxa, 27); if (!(Sgen & 1)) // Draw digits above 10 degree marks only { fg_move(Lxa - 3, 25); fg_clpimage(HUD_digit_ptr[(Sgen/100)%10], 3, 5); fg_moverel(4, 0); fg_drwimage(HUD_digit_ptr[(Sgen/10)%10], 3, 5); } // 0 Sgen += 5; if (Sgen==360) Sgen = 0; Lxa += 17; fg_point(Lxa, 28); fg_point(Lxa, 27); if (!(Sgen & 1)) // Draw digits above 10 degree marks only { fg_move(Lxa - 3, 25); fg_drwimage(HUD_digit_ptr[(Sgen/100)%10], 3, 5); fg_moverel(4, 0); fg_drwimage(HUD_digit_ptr[(Sgen/10)%10], 3, 5); } // 5 Sgen += 5; if (Sgen==360) Sgen = 0; Lxa += 17; fg_point(Lxa, 28); fg_point(Lxa, 27); if (!(Sgen & 1)) // Draw digits above 10 degree marks only { fg_move(Lxa - 3, 25); fg_drwimage(HUD_digit_ptr[(Sgen/100)%10], 3, 5); fg_moverel(4, 0); fg_drwimage(HUD_digit_ptr[(Sgen/10)%10], 3, 5); } // 10 Sgen += 5; if (Sgen==360) Sgen = 0; // else if (Sgen==370) Sgen=10; Lxa += 17; fg_point(Lxa, 28); fg_point(Lxa, 27); if (!(Sgen & 1)) // Draw digits above 10 degree marks only { fg_move(Lxa - 3, 25); fg_drwimage(HUD_digit_ptr[(Sgen/100)%10], 3, 5); fg_moverel(4, 0); fg_drwimage(HUD_digit_ptr[(Sgen/10)%10], 3, 5); } // Current Heading Marker fg_point(X_OFFSET, 29); fg_point(X_OFFSET - 1, 30); fg_point(X_OFFSET + 1, 30); fg_point(X_OFFSET, 31); // Waypoint Marker Sgen = Swaypoint_angle - Smy_plane_yaw; Lsin(Sgen, Lsyaw); Lcos(Sgen, Lcyaw); if (Lcyaw==0L) Lcyaw = 1L; // Avoid divide by zero Lxa = DEPTH * Lsyaw / Lcyaw + X_OFFSET; if (Sgen<0) { // NOTE: Lxa<=118 comes last if (Sgen<-4096 || Lxa<=118) { fg_point(118, 27); fg_point(119, 28); fg_point(120, 27); } else { fg_point(Lxa - 1, 27); fg_point(Lxa, 28); fg_point(Lxa + 1, 27); } } else { // NOTE: Lxa>=202 comes last if (Sgen>4096 || Lxa>=202) { fg_point(200, 27); fg_point(201, 28); fg_point(202, 27); } else { fg_point(Lxa - 1, 27); fg_point(Lxa, 28); fg_point(Lxa + 1, 27); } } // Map Time Swaypoint_angle = Satan2(Lwaypoint_x[current_waypoint] - Lmy_plane_x, Lwaypoint_z[current_waypoint] - Lmy_plane_z); // Just remember that Swaypoint_angle is only correct when the // cockpit is currently displayed on the screen Lsin(Swaypoint_angle, Lsine); Lcos(Swaypoint_angle, Lcosine); map_waypoint_x = 15 * Lsine >> SHIFT_HI; map_waypoint_z = -15 * Lcosine >> SHIFT_HI; map_heading_x = 7 * Lsyaw_T >> SHIFT_HI; map_heading_z = -7 * Lcyaw_T >> SHIFT_HI; if (map_heading_x!=last_map_heading_x || map_heading_z!=last_map_heading_z || map_waypoint_x!=last_map_waypoint_x || map_waypoint_z!=last_map_waypoint_z) { last_map_waypoint_x = map_waypoint_x; last_map_waypoint_z = map_waypoint_z; last_map_heading_x = map_heading_x; last_map_heading_z = map_heading_z; update_map_heading = YES; } if (last_center_element!=Lcenter_element) { last_center_element = Lcenter_element; update_map = YES; } if (update_map) { update_map_heading = update_map = NO; fg_setclip(MAP_MINX, MAP_MAXX, MAP_MINY, MAP_MAXY); // We already got Lcenter_element from the previous // frame which was calculated in Draw_World. // map_center_element = Lcenter_element; // Check the stats of map_x and map_z to see if they are feasable map_center_element += (map_x * 2); map_center_element += (map_z * 510); // Clear the entire map display // OBSOLETE fg_setcolor(120); fg_setcolor(DISPLAY_BK_COLOR); fg_rect(MAP_MINX, MAP_MAXX, MAP_MINY, MAP_MAXY); // 17*17 map grid and 3 pixels per box. 961-(17*17)=672 for (loop_var = 672;loop_var<961;loop_var++) { // Current scenery object at proper location. Lx = (long)(drawing_sequence_lookup[loop_var] % 31); // Avoid drawing un-wanted scenery on the X axis if (map_x + (Lview_x / 8192L) - 15L + Lx<0L || map_x + (Lview_x / 8192L) - 15L + Lx>126L) continue; Lz = (long)(drawing_sequence_lookup[loop_var] / 31); Lcurrent_element = map_center_element - ((15L - Lx) << 1L) - ((15L - Lz) * 510L); // Avoid drawing un-wanted scenery on the Z axis if (Lcurrent_element<256L || Lcurrent_element>64768L) continue; // Move to location of scenery box on the map Lx -= 15; Lz -= 15; Lx *= 3; Lz *= 3; Lx += MAP_CENTER_X; Lz += MAP_CENTER_Y; // Move to MAP offset of scenery box fg_move(Lx, Lz); // MOUNTAIN if (world_map[Lcurrent_element]<32) { if (world_map[Lcurrent_element] & AA) { // OBSOLETE fg_setcolor( (int)world_map[Lcurrent_element-1]+100 ); /* Igen=(int)world_map[Lcurrent_element-1]; if ( ((Igen/2)&1) ) fg_setcolor(DISPLAY_BK_COLOR); else fg_setcolor(DISPLAY_DIM_COLOR); */ fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx - 1, Lz - 1); // fg_point(Lx-1,Lz); fg_point(Lx - 1, Lz + 1); // fg_point(Lx,Lz-1); fg_point(Lx, Lz); fg_point(Lx + 1, Lz - 1); } if (world_map[Lcurrent_element] & BB) { // OBSOLETE fg_setcolor( (int)world_map[Lcurrent_element+1]+100 ); /* Igen=(int)world_map[Lcurrent_element+1]; if ( ((Igen/2)&1) ) fg_setcolor(DISPLAY_BK_COLOR); else fg_setcolor(DISPLAY_DIM_COLOR); */ fg_setcolor(DISPLAY_DIM_COLOR); // fg_point(Lx,Lz+1); // fg_point(Lx+1,Lz); fg_point(Lx + 1, Lz + 1); } if (world_map[Lcurrent_element] & CC) { // OBSOLETE fg_setcolor( (int)world_map[Lcurrent_element+255]+100 ); /* Igen=(int)world_map[Lcurrent_element+255]; if ( ((Igen/2)&1) ) fg_setcolor(DISPLAY_BK_COLOR); else fg_setcolor(DISPLAY_DIM_COLOR); */ fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx - 1, Lz - 1); // fg_point(Lx-1,Lz); fg_point(Lx - 1, Lz + 1); fg_point(Lx, Lz); // fg_point(Lx,Lz+1); fg_point(Lx + 1, Lz + 1); } if (world_map[Lcurrent_element] & DD) { // OBSOLETE fg_setcolor( (int)world_map[Lcurrent_element-255]+100 ); /* Igen=(int)world_map[Lcurrent_element-255]; if ( ((Igen/2)&1) ) fg_setcolor(DISPLAY_BK_COLOR); else fg_setcolor(DISPLAY_DIM_COLOR); */ fg_setcolor(DISPLAY_DIM_COLOR); // fg_point(Lx,Lz-1); fg_point(Lx + 1, Lz - 1); // fg_point(Lx+1,Lz); } } // LAKE else if (world_map[Lcurrent_element]<37) { // OBSOLETE fg_setcolor( 138 ); fg_setcolor(DISPLAY_DIM_COLOR); if (world_map[Lcurrent_element]==LAKEA) { fg_point(Lx - 1, Lz - 1); fg_point(Lx - 1, Lz); fg_point(Lx - 1, Lz + 1); fg_point(Lx, Lz - 1); fg_point(Lx, Lz); fg_point(Lx + 1, Lz - 1); } if (world_map[Lcurrent_element]==LAKEB) { fg_point(Lx, Lz + 1); fg_point(Lx + 1, Lz); fg_point(Lx + 1, Lz + 1); } if (world_map[Lcurrent_element]==LAKEC) { fg_point(Lx - 1, Lz - 1); fg_point(Lx - 1, Lz); fg_point(Lx - 1, Lz + 1); fg_point(Lx, Lz); fg_point(Lx, Lz + 1); fg_point(Lx + 1, Lz + 1); } if (world_map[Lcurrent_element]==LAKED) { fg_point(Lx, Lz - 1); fg_point(Lx + 1, Lz - 1); fg_point(Lx + 1, Lz); } if (world_map[Lcurrent_element]==LAKEBOX) { fg_clprect(Lx - 1, Lx + 1, Lz - 1, Lz + 1); } } // NSBRIDGE else if (world_map[Lcurrent_element]==NSBRIDGE) { // OBSOLETE fg_setcolor(138); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx - 1, Lz); fg_point(Lx + 1, Lz); // OBSOLETE fg_setcolor(137); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx, Lz - 1); fg_point(Lx, Lz); fg_point(Lx, Lz + 1); } // WEBRIDGE else if (world_map[Lcurrent_element]==WEBRIDGE) { // OBSOLETE fg_setcolor(138); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx, Lz - 1); fg_point(Lx, Lz + 1); // OBSOLETE fg_setcolor(137); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx - 1, Lz); fg_point(Lx, Lz); fg_point(Lx + 1, Lz); } // ROAD else if ((world_map[Lcurrent_element]>45 && world_map[Lcurrent_element]<63) || (world_map[Lcurrent_element]==WEAPONS_FACTORY) || (world_map[Lcurrent_element]==CHEMICAL_FACTORY)) { // OBSOLETE fg_setcolor(137); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx, Lz); if (world_map[Lcurrent_element]==ROAD3 || world_map[Lcurrent_element]==ROAD5 || world_map[Lcurrent_element]==ROAD9 || world_map[Lcurrent_element]==ROAD12 || world_map[Lcurrent_element]==ROAD13 || world_map[Lcurrent_element]==ROAD14 || world_map[Lcurrent_element]==ROAD15 || world_map[Lcurrent_element]==WEAPONS_FACTORY) fg_point(Lx, Lz - 1); if (world_map[Lcurrent_element]==ROAD2 || world_map[Lcurrent_element]==ROAD8 || world_map[Lcurrent_element]==ROAD16) fg_point(Lx + 1, Lz - 1); if (world_map[Lcurrent_element]==ROAD4 || world_map[Lcurrent_element]==ROAD5 || world_map[Lcurrent_element]==ROAD6 || world_map[Lcurrent_element]==ROAD9 || world_map[Lcurrent_element]==ROAD10 || world_map[Lcurrent_element]==ROAD11 || world_map[Lcurrent_element]==ROAD12 || world_map[Lcurrent_element]==CHEMICAL_FACTORY) fg_point(Lx + 1, Lz); if (world_map[Lcurrent_element]==ROAD1 || world_map[Lcurrent_element]==ROAD13 || world_map[Lcurrent_element]==ROAD17) fg_point(Lx + 1, Lz + 1); if (world_map[Lcurrent_element]==ROAD3 || world_map[Lcurrent_element]==ROAD5 || world_map[Lcurrent_element]==ROAD6 || world_map[Lcurrent_element]==ROAD7 || world_map[Lcurrent_element]==ROAD8 || world_map[Lcurrent_element]==ROAD9 || world_map[Lcurrent_element]==ROAD15 || world_map[Lcurrent_element]==WEAPONS_FACTORY) fg_point(Lx, Lz + 1); if (world_map[Lcurrent_element]==ROAD2 || world_map[Lcurrent_element]==ROAD11 || world_map[Lcurrent_element]==ROAD14) fg_point(Lx - 1, Lz + 1); if (world_map[Lcurrent_element]==ROAD4 || world_map[Lcurrent_element]==ROAD5 || world_map[Lcurrent_element]==ROAD6 || world_map[Lcurrent_element]==ROAD12 || world_map[Lcurrent_element]==ROAD15 || world_map[Lcurrent_element]==ROAD16 || world_map[Lcurrent_element]==ROAD17 || world_map[Lcurrent_element]==CHEMICAL_FACTORY) fg_point(Lx - 1, Lz); if (world_map[Lcurrent_element]==ROAD1 || world_map[Lcurrent_element]==ROAD7 || world_map[Lcurrent_element]==ROAD10) fg_point(Lx - 1, Lz - 1); } // RIVER else if (world_map[Lcurrent_element]>64 && world_map[Lcurrent_element]<77) { // OBSOLETE fg_setcolor(138); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx, Lz); if (world_map[Lcurrent_element]==RIVER3 || world_map[Lcurrent_element]==RIVER9 || world_map[Lcurrent_element]==RIVER10) fg_point(Lx, Lz - 1); if (world_map[Lcurrent_element]==RIVER2 || world_map[Lcurrent_element]==RIVER6 || world_map[Lcurrent_element]==RIVER11) fg_point(Lx + 1, Lz - 1); if (world_map[Lcurrent_element]==RIVER4 || world_map[Lcurrent_element]==RIVER7 || world_map[Lcurrent_element]==RIVER8) fg_point(Lx + 1, Lz); if (world_map[Lcurrent_element]==RIVER1 || world_map[Lcurrent_element]==RIVER9 || world_map[Lcurrent_element]==RIVER12) fg_point(Lx + 1, Lz + 1); if (world_map[Lcurrent_element]==RIVER3 || world_map[Lcurrent_element]==RIVER5 || world_map[Lcurrent_element]==RIVER6) fg_point(Lx, Lz + 1); if (world_map[Lcurrent_element]==RIVER2 || world_map[Lcurrent_element]==RIVER8 || world_map[Lcurrent_element]==RIVER10) fg_point(Lx - 1, Lz + 1); if (world_map[Lcurrent_element]==RIVER4 || world_map[Lcurrent_element]==RIVER11 || world_map[Lcurrent_element]==RIVER12) fg_point(Lx - 1, Lz); if (world_map[Lcurrent_element]==RIVER1 || world_map[Lcurrent_element]==RIVER5 || world_map[Lcurrent_element]==RIVER7) fg_point(Lx - 1, Lz - 1); } else if (world_map[Lcurrent_element]==FRIENDLY_AIRPORT) { // OBSOLETE fg_setcolor(139); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx, Lz); fg_point(Lx - 1, Lz - 1); fg_point(Lx - 1, Lz + 1); fg_point(Lx + 1, Lz + 1); fg_point(Lx + 1, Lz - 1); // OBSOLETE fg_setcolor(137); fg_setcolor(DISPLAY_DIM_COLOR); fg_point(Lx - 1, Lz); fg_point(Lx + 1, Lz); fg_point(Lx, Lz - 1); fg_point(Lx, Lz + 1); } } fg_setcolor(DISPLAY_FG_COLOR + 1); fg_tcxfer(240, 284, 0, 34, 136, 239, 2, page); // Your current location circle thingy fg_move(MAP_CENTER_X, MAP_CENTER_Y); fg_circle(4); // Save the map to hidden page fg_save(MAP_MINX, MAP_MAXX, MAP_MINY, MAP_MAXY); // Welp, since we changed the map, we gotta draw the // heading markers as well BUT AFTER we save the above // configuration to the hidden page. // // Draw the current heading indicator fg_move(MAP_CENTER_X + map_heading_x, MAP_CENTER_Y + map_heading_z); fg_drawrel(map_heading_x, map_heading_z); // Draw the current waypoint indicator fg_move(MAP_CENTER_X + map_waypoint_x, MAP_CENTER_Y + map_waypoint_z); fg_circle(1); // Transfer this screen to the other one. fg_transfer(MAP_MINX, MAP_MAXX, MAP_MINY, MAP_MAXY, MAP_MINX, MAP_MAXY, page, 1 - page); } // Update the heading info if we have to if (update_map_heading) { fg_setcolor(DISPLAY_FG_COLOR + 1); fg_setclip(MAP_MINX, MAP_MAXX, MAP_MINY, MAP_MAXY); update_map_heading = NO; // Restore the area of the INTERIOR OF THE COMPASS to the // extents of the directional lines fg_restore(142, 176, 210, 239); // Draw the current heading indicator // OBSOLETE fg_setcolor(MAP_COLOR); fg_move(MAP_CENTER_X + map_heading_x, MAP_CENTER_Y + map_heading_z); fg_drawrel(map_heading_x, map_heading_z); // Draw the current waypoint indicator fg_move(MAP_CENTER_X + map_waypoint_x, MAP_CENTER_Y + map_waypoint_z); fg_circle(1); // Transfer this altered screen to the other one. fg_transfer(142, 176, 210, 239, 142, 239, page, 1 - page); } Update_DDIs(); } void Update_Weapon_Status(void) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; update_stores_display = YES; if (station_number[current_station]==0) { // OK, let's see if there are any other stations available // of the same type and switch current_station if so. for (loop_var = 1;loop_var<10;loop_var++) { if (station_type[loop_var]==station_type[current_station] && station_number[loop_var]!=0) { current_station = (int)loop_var; break; } } } if (station_type[current_station]==NONE || station_type[current_station]==EXTERNAL_FUEL) current_station_type = NONE; else if (station_type[current_station]==AIM9M || station_type[current_station]==AIM7M || station_type[current_station]==M61A1) current_station_type = A_A; else current_station_type = A_G; /* Weight of stations */ Lweight_stations_not_ext_fuel = 0L; for (loop_var = 1;loop_var<=9;loop_var++) { if (station_type[loop_var]==NONE) continue; if (station_type[loop_var]==AIM9M) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_AIM9M); if (station_type[loop_var]==AIM7M) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_AIM7M); if (station_type[loop_var]==AGM65F) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_AGM65F); if (station_type[loop_var]==AGM88A) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_AGM88A); if (station_type[loop_var]==MK82) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_MK82); if (station_type[loop_var]==MK83) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_MK83); if (station_type[loop_var]==MK84) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_MK84); if (station_type[loop_var]==M151) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_M151); if (station_type[loop_var]==MK5) Lweight_stations_not_ext_fuel += (station_number[loop_var] * WEIGHT_MK5); // We don't compute EXTERNAL_FUEL weight for this variable! // if (station_type[loop_var]==EXTERNAL_FUEL) Lweight_stations_not_ext_fuel+=(station_number[loop_var]*Imy_plane_ext_fuel_weight); } // OK, this is where we copy the current weapon type and number info // to the cockpit... to the hidden page! // Calc number of weapons of current type on board and store in // Igen2 Igen2 = 0; for (Igen = 1;Igen<10;Igen++) { if (station_type[Igen]==station_type[current_station]) { Igen2 += station_number[Igen]; } } if (station_type[current_station]==M61A1) { /* if (current_weapon_mode==A_A) fg_transfer(0,50,24,28, 132,115, 2,2); else fg_transfer(0,50,24,28, 132,115, 2,2); */ fg_transfer(0, 50, 24, 28, 132, 115, 2, 2); fg_setpage(2); fg_move(152, 115); fg_putimage(weapon_digit_ptr[(station_number[current_station]/100)%10], 3, 5); fg_move(156, 115); fg_putimage(weapon_digit_ptr[(station_number[current_station]/10)%10], 3, 5); fg_move(160, 115); fg_putimage(weapon_digit_ptr[station_number[current_station]%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==AIM9M) { // Problem! fg_transfer(23,73,29,33, 135,129, 2,2); fg_transfer(0, 50, 30, 34, 132, 115, 2, 2); fg_setpage(2); fg_move(160, 115); //fg_putimage(weapon_digit_ptr[station_number[current_station]%10],3,5); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==AIM7M) { // Problem! fg_transfer(23,73,35,39, 135,129, 2,2); fg_transfer(0, 50, 36, 40, 132, 115, 2, 2); fg_setpage(2); fg_move(160, 115); //fg_putimage(weapon_digit_ptr[station_number[current_station]%10],3,5); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==AGM65F) { // Problem! fg_transfer(23,73,41,45, 135,129, 2,2); fg_transfer(0, 50, 42, 46, 132, 115, 2, 2); fg_setpage(2); fg_move(164, 115); //fg_putimage(weapon_digit_ptr[station_number[current_station]%10],3,5); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==AGM88A) { // Problem! fg_transfer(23,73,47,51, 135,129, 2,2); fg_transfer(0, 50, 48, 52, 132, 115, 2, 2); fg_setpage(2); fg_move(164, 115); //fg_putimage(weapon_digit_ptr[station_number[current_station]%10],3,5); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==MK82) { // Problem! fg_transfer(23,73,53,57, 135,129, 2,2); fg_transfer(0, 50, 54, 58, 132, 115, 2, 2); fg_setpage(2); fg_move(156, 115); fg_putimage(weapon_digit_ptr[(Igen2/10)%10], 3, 5); fg_move(160, 115); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==MK83) { // Problem! fg_transfer(23,73,59,63, 135,129, 2,2); fg_transfer(0, 50, 60, 64, 132, 115, 2, 2); fg_setpage(2); fg_move(156, 115); fg_putimage(weapon_digit_ptr[(Igen2/10)%10], 3, 5); fg_move(160, 115); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==MK84) { // Problem! fg_transfer(23,73,65,69, 135,129, 2,2); fg_transfer(0, 50, 66, 70, 132, 115, 2, 2); fg_setpage(2); fg_move(156, 115); fg_putimage(weapon_digit_ptr[(Igen2/10)%10], 3, 5); fg_move(160, 115); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==M151) { // Problem! fg_transfer(23,73,71,75, 135,129, 2,2); fg_transfer(0, 50, 72, 76, 132, 115, 2, 2); fg_setpage(2); fg_move(156, 115); fg_putimage(weapon_digit_ptr[(Igen2/10)%10], 3, 5); fg_move(160, 115); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==MK5) { // Problem! fg_transfer(23,73,77,81, 135,129, 2,2); fg_transfer(0, 50, 78, 82, 132, 115, 2, 2); fg_setpage(2); fg_move(152, 115); fg_putimage(weapon_digit_ptr[(Igen2/10)%10], 3, 5); fg_move(156, 115); fg_putimage(weapon_digit_ptr[Igen2%10], 3, 5); fg_setpage(page); } else if (station_type[current_station]==NONE || station_type[current_station]==EXTERNAL_FUEL) { // Problem! fg_transfer(23,73,17,21, 135,129, 2,2); // OBSOLETE SINCE WE DON'T PICK STATIONS ANYMORE - Just weapons } } void Init_DDI(int on_left) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; fg_setpage(2); fg_setcolor(DISPLAY_BK_COLOR); if (on_left==YES) { fg_setclip(58, 108, 154, 200); fg_rect(58, 108, 154, 200); ddi_center_x = 83; } else { fg_setclip(210, 260, 154, 200); fg_rect(210, 260, 154, 200); ddi_center_x = 235; } if ((on_left && left_ddi==RADAR) || (on_left==NO && right_ddi==RADAR)) { // Cursor in middle of DDI fg_setcolor(DISPLAY_FG_COLOR); /* Nada fg_point(ddi_center_x-2,DDI_CENTER_Y-1); fg_point(ddi_center_x-2,DDI_CENTER_Y); fg_point(ddi_center_x-2,DDI_CENTER_Y+1); fg_point(ddi_center_x+2,DDI_CENTER_Y-1); fg_point(ddi_center_x+2,DDI_CENTER_Y); fg_point(ddi_center_x+2,DDI_CENTER_Y+1); */ // Don't change color yet, we'll add range marks now fg_point(ddi_center_x + 24, DDI_CENTER_Y - 22); fg_point(ddi_center_x + 24, DDI_CENTER_Y - 11); fg_point(ddi_center_x + 24, DDI_CENTER_Y); fg_point(ddi_center_x + 24, DDI_CENTER_Y + 10); fg_point(ddi_center_x + 24, DDI_CENTER_Y + 20); // Still don't change color, we'll add 30 degree elevation // marks now fg_point(ddi_center_x - 25, DDI_CENTER_Y - 14); fg_point(ddi_center_x - 24, DDI_CENTER_Y - 14); fg_point(ddi_center_x - 25, DDI_CENTER_Y); fg_point(ddi_center_x - 24, DDI_CENTER_Y); fg_point(ddi_center_x - 25, DDI_CENTER_Y + 13); fg_point(ddi_center_x - 24, DDI_CENTER_Y + 13); // Now we'll add the 30 degree azimuth marks fg_setcolor(DISPLAY_DIM_COLOR); fg_move(ddi_center_x - 14, DDI_CENTER_Y - 22); fg_draw(ddi_center_x - 14, DDI_CENTER_Y + 20); fg_move(ddi_center_x, DDI_CENTER_Y - 22); fg_draw(ddi_center_x, DDI_CENTER_Y + 20); fg_move(ddi_center_x + 14, DDI_CENTER_Y - 22); fg_draw(ddi_center_x + 14, DDI_CENTER_Y + 20); // Now we'll add the range line fg_move(ddi_center_x + 25, DDI_CENTER_Y - 22); fg_draw(ddi_center_x + 25, DDI_CENTER_Y + 20); sprintf(buffer, "%2d", radar_range); disp_ddi_text(ddi_center_x + 16, DDI_CENTER_Y - 20, buffer, 2); } if ((on_left && left_ddi==WAYPOINTS) || (on_left==NO && right_ddi==WAYPOINTS)) { if (num_waypoints==1) { disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, " 1 WAYPOINT", 11); // disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y-13, ?, 11); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 6, "HEADING:", 8); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y + 8, "1: HOMEBASE", 11); } else { sprintf(buffer, "%2d WAYPOINTS", num_waypoints); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 12); // disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y-13, ?, 11); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 6, "HEADING:", 8); } } if ((on_left && left_ddi==THREAT) || (on_left==NO && right_ddi==THREAT)) { // The circles and lines fg_setcolor(DISPLAY_FG_COLOR); fg_move(ddi_center_x, DDI_CENTER_Y); fg_circle(20); fg_circle(10); fg_move(ddi_center_x, DDI_CENTER_Y - 20); fg_drawrel(0, 40); fg_move(ddi_center_x - 20, DDI_CENTER_Y); fg_drawrel(40, 0); } if ((on_left && left_ddi==STORES) || (on_left==NO && right_ddi==STORES)) { // Draw triangle line fg_setcolor(DISPLAY_DIM_COLOR); fg_move(ddi_center_x - 24, DDI_CENTER_Y + 9); fg_draw(ddi_center_x, DDI_CENTER_Y - 15); fg_draw(ddi_center_x + 24, DDI_CENTER_Y + 9); fg_move(ddi_center_x - 25, DDI_CENTER_Y + 12); // Draw station armament draw_ddi_station(1, ddi_center_x - 25, DDI_CENTER_Y + 12); draw_ddi_station(2, ddi_center_x - 19, DDI_CENTER_Y + 6); draw_ddi_station(3, ddi_center_x - 13, DDI_CENTER_Y); draw_ddi_station(4, ddi_center_x - 7, DDI_CENTER_Y - 6); draw_ddi_station(5, ddi_center_x - 1, DDI_CENTER_Y - 11); draw_ddi_station(6, ddi_center_x + 5, DDI_CENTER_Y - 6); draw_ddi_station(7, ddi_center_x + 11, DDI_CENTER_Y); draw_ddi_station(8, ddi_center_x + 17, DDI_CENTER_Y + 6); draw_ddi_station(9, ddi_center_x + 23, DDI_CENTER_Y + 12); // Draw A-A or A-G or nothing fg_setcolor(DISPLAY_FG_COLOR); if (station_type[current_station]==AIM9M || station_type[current_station]==AIM7M) { disp_ddi_text(ddi_center_x + 16, DDI_CENTER_Y - 20, "A", 1); fg_point(ddi_center_x + 20, DDI_CENTER_Y - 22); fg_point(ddi_center_x + 21, DDI_CENTER_Y - 22); disp_ddi_text(ddi_center_x + 23, DDI_CENTER_Y - 20, "A", 1); } else if (station_type[current_station]!=M61A1 && station_type[current_station]!=NONE && station_type[current_station]!=EXTERNAL_FUEL) { disp_ddi_text(ddi_center_x + 16, DDI_CENTER_Y - 20, "A", 1); fg_point(ddi_center_x + 20, DDI_CENTER_Y - 22); fg_point(ddi_center_x + 21, DDI_CENTER_Y - 22); disp_ddi_text(ddi_center_x + 23, DDI_CENTER_Y - 20, "G", 1); } // Draw CHF and FLR stuff disp_ddi_text(ddi_center_x - 23, DDI_CENTER_Y + 22, "CHF", 3); disp_ddi_text(ddi_center_x - 12, DDI_CENTER_Y + 22, ":", 1); sprintf(buffer, "%2d ", my_plane_num_chaffs); disp_ddi_text(ddi_center_x - 9, DDI_CENTER_Y + 22, buffer, 2); disp_ddi_text(ddi_center_x + 3, DDI_CENTER_Y + 22, "FLR", 3); disp_ddi_text(ddi_center_x + 14, DDI_CENTER_Y + 22, ":", 1); sprintf(buffer, "%2d ", my_plane_num_flares); disp_ddi_text(ddi_center_x + 17, DDI_CENTER_Y + 22, buffer, 2); // Calc number of weapons of current type on board and store // in Igen2 Igen2 = 0; for (Igen = 0;Igen<10;Igen++) { if (station_type[Igen]==station_type[current_station]) { Igen2 += station_number[Igen]; } } // Draw armament designation and number remaining if neccessary if (station_type[current_station]==NONE) { disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, "---", 3); } else if (station_type[current_station]==M61A1) { sprintf(buffer, "M61:%-3d ", station_number[current_station]); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==AIM9M) { //sprintf(buffer,"AIM9M:%-3d ",station_number[current_station]); sprintf(buffer, "AIM9M:%-3d ", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==AIM7M) { //sprintf(buffer,"AIM7M:%-3d ",station_number[current_station]); sprintf(buffer, "AIM7M:%-3d ", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==AGM65F) { //sprintf(buffer,"AGM65F:%-3d",station_number[current_station]); sprintf(buffer, "AGM65F:%-3d", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==AGM88A) { //sprintf(buffer,"AGM88A:%-3d",station_number[current_station]); sprintf(buffer, "AGM88A:%-3d", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==MK82) { //sprintf(buffer,"MK82:%-3d ",station_number[current_station]); sprintf(buffer, "MK82:%-3d ", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==MK83) { //sprintf(buffer,"MK83:%-3d ",station_number[current_station]); sprintf(buffer, "MK83:%-3d ", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==MK84) { //sprintf(buffer,"MK84:%-3d ",station_number[current_station]); sprintf(buffer, "MK84:%-3d ", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==M151) { //sprintf(buffer,"M151:%-3d ",station_number[current_station]); sprintf(buffer, "M151:%-3d ", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==MK5) { //sprintf(buffer,"MK5:%-3d ",station_number[current_station]); sprintf(buffer, "MK5:%-3d ", Igen2); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, buffer, 10); } else if (station_type[current_station]==EXTERNAL_FUEL) { disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, "EXT FUEL ", 10); } } if ((on_left && left_ddi==TARGET) || (on_left==NO && right_ddi==TARGET)) { safe_to_average_closure_rate = average_closure_rate_counter = 0; } if ((on_left && left_ddi==INFRARED) || (on_left==NO && right_ddi==INFRARED)) { fg_setcolor(DISPLAY_FG_COLOR); fg_move(ddi_center_x - 20, DDI_CENTER_Y); fg_drawrel(19, 0); fg_moverel(2, 0); fg_drawrel(19, 0); fg_move(ddi_center_x, DDI_CENTER_Y - 20); fg_drawrel(0, 19); fg_moverel(0, 2); fg_drawrel(0, 19); } fg_setpage(page); } void Update_DDIs(void) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; if (left_ddi==STORES) Draw_Stores(YES); else if (left_ddi==RADAR) Draw_Radar(YES); else if (left_ddi==THREAT) Draw_Threat(YES); else if (left_ddi==WAYPOINTS) Draw_Waypoints(YES); else if (left_ddi==TARGET) Draw_Target_Info(YES); if (right_ddi==STORES) Draw_Stores(NO); else if (right_ddi==RADAR) Draw_Radar(NO); else if (right_ddi==THREAT) Draw_Threat(NO); else if (right_ddi==WAYPOINTS) Draw_Waypoints(NO); else if (right_ddi==TARGET) Draw_Target_Info(NO); // We do this last because the previous displays rely on an unaltered // state from Set_View(). However, Draw_Infrared() changes these // states. if (left_ddi==INFRARED) Draw_Infrared(YES); if (right_ddi==INFRARED) Draw_Infrared(NO); } void Draw_Radar(int on_left) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; if (on_left==YES) { fg_setclip(58, 108, 154, 200); ddi_center_x = 83; } else { fg_setclip(210, 260, 154, 200); ddi_center_x = 235; } fg_setcolor(DISPLAY_FG_COLOR); // if gpt_selected and on radar... draw sinlge blip, set "TRAK", // and draw static elevation and azimuth indicators. // // To do this right, draw the blip first and check Lsxa, Lsya as // set by Draw_Radar_Blip() Lsxa = Lsya = -1000; if (gpt_selected && current_weapon_mode==A_A) { if (sim_plane[gpt_aircraft_index].exist && sim_plane[gpt_aircraft_index].distance_to_my_plane<=radar_range * 6080L && Check_Gimbal(sim_plane[gpt_aircraft_index].Lx, sim_plane[gpt_aircraft_index].Ly, sim_plane[gpt_aircraft_index].Lz, Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) { Draw_Radar_Blip(gpt_aircraft_index); if (Lsxa>=ddi_center_x - 25 && Lsxa<=ddi_center_x + 25 && Lsya>=DDI_CENTER_Y - 25 && Lsya<=DDI_CENTER_Y + 25) { // Set "TRAK", draw static elevation and azimuth indicators // and get lost. fg_point(ddi_center_x + (int)Lsxa, DDI_CENTER_Y + 21); fg_point(ddi_center_x + (int)Lsxa - 1, DDI_CENTER_Y + 22); fg_point(ddi_center_x + (int)Lsxa + 1, DDI_CENTER_Y + 22); fg_point(ddi_center_x - 23, DDI_CENTER_Y + (int)Lsya - 1); fg_point(ddi_center_x - 22, DDI_CENTER_Y + (int)Lsya - 1 - 1); fg_point(ddi_center_x - 22, DDI_CENTER_Y + (int)Lsya + 1 - 1); disp_ddi_text(ddi_center_x - 21, DDI_CENTER_Y - 20, "TRAK", 4); return; } } } disp_ddi_text(ddi_center_x - 21, DDI_CENTER_Y - 20, "SCAN", 4); // Let's draw them bogies and friendlies blips if needed if (sim_plane[0].exist && sim_plane[0].distance_to_my_plane<=radar_range * 6080L && Check_Gimbal(sim_plane[0].Lx, sim_plane[0].Ly, sim_plane[0].Lz, Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Radar_Blip(0); if (sim_plane[1].exist && sim_plane[1].distance_to_my_plane<=radar_range * 6080L && Check_Gimbal(sim_plane[1].Lx, sim_plane[1].Ly, sim_plane[1].Lz, Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Radar_Blip(1); if (sim_plane[2].exist && sim_plane[2].distance_to_my_plane<=radar_range * 6080L && Check_Gimbal(sim_plane[2].Lx, sim_plane[2].Ly, sim_plane[2].Lz, Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Radar_Blip(2); if (sim_plane[3].exist && sim_plane[3].distance_to_my_plane<=radar_range * 6080L && Check_Gimbal(sim_plane[3].Lx, sim_plane[3].Ly, sim_plane[3].Lz, Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Radar_Blip(3); if (sim_plane[4].exist && sim_plane[4].distance_to_my_plane<=radar_range * 6080L && Check_Gimbal(sim_plane[4].Lx, sim_plane[4].Ly, sim_plane[4].Lz, Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Radar_Blip(4); // Let's draw our missles blips if (missle_stats[0] && Check_Gimbal(Lmissle_x[0], Lmissle_y[0], Lmissle_z[0], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(0); if (missle_stats[1] && Check_Gimbal(Lmissle_x[1], Lmissle_y[1], Lmissle_z[1], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(1); if (missle_stats[2] && Check_Gimbal(Lmissle_x[2], Lmissle_y[2], Lmissle_z[2], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(2); if (missle_stats[3] && Check_Gimbal(Lmissle_x[3], Lmissle_y[3], Lmissle_z[3], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(3); if (missle_stats[4] && Check_Gimbal(Lmissle_x[4], Lmissle_y[4], Lmissle_z[4], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(4); if (missle_stats[5] && Check_Gimbal(Lmissle_x[5], Lmissle_y[5], Lmissle_z[5], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(5); if (missle_stats[6] && Check_Gimbal(Lmissle_x[6], Lmissle_y[6], Lmissle_z[6], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(6); if (missle_stats[7] && Check_Gimbal(Lmissle_x[7], Lmissle_y[7], Lmissle_z[7], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(7); if (missle_stats[8] && Check_Gimbal(Lmissle_x[8], Lmissle_y[8], Lmissle_z[8], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(8); if (missle_stats[9] && Check_Gimbal(Lmissle_x[9], Lmissle_y[9], Lmissle_z[9], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(9); if (missle_stats[10] && Check_Gimbal(Lmissle_x[10], Lmissle_y[10], Lmissle_z[10], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(10); if (missle_stats[11] && Check_Gimbal(Lmissle_x[11], Lmissle_y[11], Lmissle_z[11], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(11); if (missle_stats[12] && Check_Gimbal(Lmissle_x[12], Lmissle_y[12], Lmissle_z[12], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(12); if (missle_stats[13] && Check_Gimbal(Lmissle_x[13], Lmissle_y[13], Lmissle_z[13], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(13); if (missle_stats[14] && Check_Gimbal(Lmissle_x[14], Lmissle_y[14], Lmissle_z[14], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(14); if (missle_stats[15] && Check_Gimbal(Lmissle_x[15], Lmissle_y[15], Lmissle_z[15], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z, Smy_plane_yaw, Smy_plane_pitch)) Draw_Missle_Radar_Blip(15); // OK, let's draw the radar elevation and azimuth indicators // // We'll say that it takes 1/2 second from left to right and // vice-versa // // Also, we'll say that it takes 3 seconds from top to bottom Lgen = (long)current_tick; fg_setcolor(DISPLAY_FG_COLOR); // Half second if ((Lgen % TIMER_HZ)<(TIMER_HZ / 2)) { Lgen2 = (Lgen % TIMER_HZ); // Lgen2 is between 0 and 63 Lgen2 -= (TIMER_HZ / 4); // Lgen2 is between -32 and +31 // We need -24 to +24, so multilpy by .75 Lgen2 = ((Lgen2 * 75L) / 100L); // OK, draw it fg_point(ddi_center_x + (int)Lgen2, DDI_CENTER_Y + 21); fg_point(ddi_center_x + (int)Lgen2 - 1, DDI_CENTER_Y + 22); fg_point(ddi_center_x + (int)Lgen2 + 1, DDI_CENTER_Y + 22); } else { Lgen2 = (Lgen % TIMER_HZ); // Lgen2 is between 64 and 127 Lgen2 -= (TIMER_HZ / 2); Lgen2 -= (TIMER_HZ / 4); Lgen2 = -Lgen2; // Lgen2 is between -31 and +32 // We need +24 to -24, so multilpy by .75 Lgen2 = ((Lgen2 * 75L) / 100L); // OK, draw it fg_point(ddi_center_x + (int)Lgen2, DDI_CENTER_Y + 21); fg_point(ddi_center_x + (int)Lgen2 - 1, DDI_CENTER_Y + 22); fg_point(ddi_center_x + (int)Lgen2 + 1, DDI_CENTER_Y + 22); } // 3 seconds if ((Lgen % (TIMER_HZ * 3))<((TIMER_HZ * 3) / 2)) { Lgen2 = (Lgen % (TIMER_HZ * 3)); // Lgen2 is between 0 and 191 Lgen2 -= ((TIMER_HZ * 3) / 4); // Lgen2 is between -96 and +95 // We need -22-1 to +22-1, so multilpy by .229166 Lgen2 = ((Lgen2 * 229L) / 1000L); // OK, draw it fg_point(ddi_center_x - 23, DDI_CENTER_Y + (int)Lgen2 - 1); fg_point(ddi_center_x - 22, DDI_CENTER_Y + (int)Lgen2 - 1 - 1); fg_point(ddi_center_x - 22, DDI_CENTER_Y + (int)Lgen2 + 1 - 1); } else { Lgen2 = (Lgen % (TIMER_HZ * 3)); // Lgen2 is between 192 and 383 Lgen2 -= ((TIMER_HZ * 3) / 2); Lgen2 -= ((TIMER_HZ * 3) / 4); Lgen2 = -Lgen2; // Lgen2 is between -96 and +95 // We need +22-1 to -22-1, so multilpy by .229166 Lgen2 = ((Lgen2 * 229L) / 1000L); // OK, draw it fg_point(ddi_center_x - 23, DDI_CENTER_Y + (int)Lgen2 - 1); fg_point(ddi_center_x - 22, DDI_CENTER_Y + (int)Lgen2 - 1 - 1); fg_point(ddi_center_x - 22, DDI_CENTER_Y + (int)Lgen2 + 1 - 1); } } void Draw_Radar_Blip(int DRB_sim_plane_element) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; // Do translation Lxb = sim_plane[DRB_sim_plane_element].Lx - Lmy_plane_x; Lzb = sim_plane[DRB_sim_plane_element].Lz - Lmy_plane_z; // Scale it so it fits our integer math Lxb >>= 4L; Lzb >>= 4L; // Do rotation of the missle target if ((Lza = Lxb * Lmy_plane_syaw + Lzb * Lmy_plane_cyaw >> SHIFT_HI)<1L) return; Lxa = Lxb * Lmy_plane_cyaw + Lzb * -Lmy_plane_syaw >> SHIFT_HI; // Make sure translated and yaw rotated world x is within gimbal // if (Labs(Lxa)>Labs(Lza)) return; It already is, isn't it? Lsxa = 25L * Lxa / Lza + ddi_center_x; Lsya = sim_plane[DRB_sim_plane_element].distance_to_my_plane / (radar_range * -122) + DDI_CENTER_Y + 25L; // if (Lsya<-50) return; fg_point(Lsxa - 1L, Lsya - 1L); fg_point(Lsxa, Lsya - 1L); fg_point(Lsxa + 1L, Lsya - 1L); fg_point(Lsxa - 1L, Lsya); fg_point(Lsxa, Lsya); fg_point(Lsxa + 1L, Lsya); /* HYPHEN fg_point(Lsxa-1L,Lsya+1L); fg_point(Lsxa ,Lsya+1L); fg_point(Lsxa+1L,Lsya+1L); */ // Add graphical aspect angle Sgen = sim_plane[DRB_sim_plane_element].Syaw - Satan2(Lxb, Lzb); // Sgen=sim_plane[DRB_sim_plane_element].Syaw-Smy_plane_yaw; Lsin(Sgen, Lsyaw); Lcos(Sgen, Lcyaw); fg_move(Lsxa, Lsya); Lsxb = 5 * Lsyaw >> SHIFT_HI; Lsyb = -5 * Lcyaw >> SHIFT_HI; fg_drawrel(Lsxb, Lsyb); } void Draw_Missle_Radar_Blip(int DMRB_element) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; // Do translation Lxb = Lmissle_x[DMRB_element] - Lmy_plane_x; Lzb = Lmissle_z[DMRB_element] - Lmy_plane_z; // Scale it so it fits our integer math Lxb >>= 4L; Lzb >>= 4L; // Do rotation of the missle target if ((Lza = Lxb * Lmy_plane_syaw + Lzb * Lmy_plane_cyaw >> SHIFT_HI)<1L) return; Lxa = Lxb * Lmy_plane_cyaw + Lzb * -Lmy_plane_syaw >> SHIFT_HI; // Make sure translated and yaw rotated world x is within gimbal // if (Labs(Lxa)>Labs(Lza)) return; It already is, isn't it? Lsxa = 25L * Lxa / Lza + ddi_center_x; Lsya = CALC_DISTANCE(Lmissle_x[DMRB_element], Lmissle_y[DMRB_element], Lmissle_z[DMRB_element], Lmy_plane_x, Lmy_plane_y, Lmy_plane_z) / (radar_range * -122) + DDI_CENTER_Y + 25L; // if (Lsya<-50) return; fg_point(Lsxa - 1L, Lsya); fg_point(Lsxa + 1L, Lsya); fg_point(Lsxa, Lsya - 1L); fg_point(Lsxa, Lsya + 1L); // Add graphical aspect angle Sgen = Smissle_yaw[DMRB_element] - Satan2(Lxb, Lzb); // Sgen=Smissle_yaw[DMRB_element]-Smy_plane_yaw; Lsin(Sgen, Lsyaw); Lcos(Sgen, Lcyaw); fg_move(Lsxa, Lsya); Lsxa = 5 * Lsyaw >> SHIFT_HI; Lsya = -5 * Lcyaw >> SHIFT_HI; fg_drawrel(Lsxa, Lsya); } void Draw_Threat(int on_left) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; if (!rad_light) return; // Nothing is on our radar so get lost if (on_left==YES) { fg_setclip(58, 108, 154, 200); ddi_center_x = 83; } else { fg_setclip(210, 260, 154, 200); ddi_center_x = 235; } fg_setcolor(DISPLAY_FG_COLOR); // OK, SAMs, Radar Sites and Aircraft will emit radar signatures. for (loop_var = 0;loop_var<num_active_radars;loop_var++) { if (Lrelative_radar_x[loop_var]>-158400L && Lrelative_radar_x[loop_var]<158400L && Lrelative_radar_z[loop_var]>-158400L && Lrelative_radar_z[loop_var]<158400L) { // 158400/20=7920 Lsxa = Lrelative_radar_x[loop_var] / 7920L; Lsya = -Lrelative_radar_z[loop_var] / 7920L; // Now we'll rotate the threat blip according to // our yaw angle Lsxb = (Lsxa * Lmy_plane_cyaw + Lsya * Lmy_plane_syaw >> SHIFT_HI) + ddi_center_x; Lsyb = (Lsxa * -Lmy_plane_syaw + Lsya * Lmy_plane_cyaw >> SHIFT_HI) + DDI_CENTER_Y; fg_point(Lsxb - 1L, Lsyb - 1L); fg_point(Lsxb, Lsyb - 1L); fg_point(Lsxb + 1L, Lsyb - 1L); fg_point(Lsxb - 1L, Lsyb); fg_point(Lsxb, Lsyb); fg_point(Lsxb + 1L, Lsyb); fg_point(Lsxb - 1L, Lsyb + 1L); fg_point(Lsxb, Lsyb + 1L); fg_point(Lsxb + 1L, Lsyb + 1L); } } } void Draw_Stores(int on_left) { if (update_stores_display) { Init_DDI(on_left); update_stores_display = NO; } } void Draw_Waypoints(int on_left) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; if (on_left==YES) { fg_setclip(58, 108, 154, 200); ddi_center_x = 83; } else { fg_setclip(210, 260, 154, 200); ddi_center_x = 235; } fg_setcolor(DISPLAY_FG_COLOR); // Calculate nautical miles (6080 ft per NM) to the next waypoint Fgen = (float)(Lmy_plane_x - Lwaypoint_x[current_waypoint]) * (float)(Lmy_plane_x - Lwaypoint_x[current_waypoint]); Fgen2 = (float)(Lmy_plane_z - Lwaypoint_z[current_waypoint]) * (float)(Lmy_plane_z - Lwaypoint_z[current_waypoint]); Lgen = (long)sqrt((double)(Fgen + Fgen2)) / 6080L; // Lgen=(long)(sqrt( (double)((Lmy_plane_x-Lwaypoint_x[current_waypoint])*(Lmy_plane_x-Lwaypoint_x[current_waypoint]) + (Lmy_plane_z-Lwaypoint_z[current_waypoint])*(Lmy_plane_z-Lwaypoint_z[current_waypoint]))) *.0001644); if (Smy_plane_yaw>0) Igen = Smy_plane_yaw / 182; else Igen = (((long)Smy_plane_yaw + 65536L) / 182L); Igen %= 360; if (Swaypoint_angle>0) Igen2 = Swaypoint_angle / 182; else Igen2 = (((long)Swaypoint_angle + 65536L) / 182L); Igen2 %= 360; sprintf(buffer, "%-d` ", Igen); disp_ddi_text(ddi_center_x + 11, DDI_CENTER_Y - 6, buffer, 4); sprintf(buffer, "%d NM ", Lgen); disp_ddi_text(ddi_center_x - 9, DDI_CENTER_Y + 15, buffer, 6); sprintf(buffer, "%-d` ", Igen2); disp_ddi_text(ddi_center_x - 9, DDI_CENTER_Y + 22, buffer, 4); if (num_waypoints>1) { sprintf(buffer, "%2d:", current_waypoint + 1); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y + 8, buffer, 3); disp_ddi_text(ddi_center_x - 9, DDI_CENTER_Y + 8, waypoint_names[current_waypoint], 8); } } void Draw_Target_Info(int on_left) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; if (on_left==YES) { fg_setclip(58, 108, 154, 200); ddi_center_x = 83; } else { fg_setclip(210, 260, 154, 200); ddi_center_x = 235; } fg_setcolor(DISPLAY_FG_COLOR); if (!gpt_selected || (gpt_selected && !gpt_visable)) { disp_ddi_text(ddi_center_x - 17, DDI_CENTER_Y - 20, "NO TARGET", 9); return; } if (gpt_y==0L) { // Display "MISSION TARGET" if it's a mission target. if (world_map[mission_wme]==NSBRIDGE) Lgen = WME_NSBRIDGE; else if (world_map[mission_wme]==WEBRIDGE) Lgen = WME_WEBRIDGE; else Lgen = world_map[mission_wme] - 75L; if (Lgen==gpt_wme) disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y - 20, "MISSION TRGT:", 13); else disp_ddi_text(ddi_center_x - 21, DDI_CENTER_Y - 20, "GRND TRGT:", 10); // Distance sprintf(buffer, "%-d NM ", gpt_distance / 6080L); disp_ddi_text(ddi_center_x - 17, DDI_CENTER_Y - 6, buffer, 5); // Bearing Sgen = (Satan2(gpt_x - Lmy_plane_x, gpt_z - Lmy_plane_z) - Smy_plane_yaw) / 182; sprintf(buffer, "%-d` ", Sgen); disp_ddi_text(ddi_center_x - 17, DDI_CENTER_Y + 1, buffer, 5); return; } if (gpt_aircraft_index<2) disp_ddi_text(ddi_center_x - 21, DDI_CENTER_Y - 20, "F/A-18:", 7); else disp_ddi_text(ddi_center_x - 21, DDI_CENTER_Y - 20, "MIG-29:", 7); // Distance sprintf(buffer, "%-d NM ", gpt_distance / 6080L); disp_ddi_text(ddi_center_x - 17, DDI_CENTER_Y - 13, buffer, 5); // Bearing Sgen = (Satan2(gpt_x - Lmy_plane_x, gpt_z - Lmy_plane_z) - Smy_plane_yaw) / 182; sprintf(buffer, "%-d` ", Sgen); disp_ddi_text(ddi_center_x - 17, DDI_CENTER_Y - 6, buffer, 5); // Closure Rate In Knots // OK, the bottom line is that the closure rate changes rapidly by a // few knots (+ or -) every frame. We need a run time average of the // closure rate based on the last few frames in order for this to be // a more precise, and less jumpy, reading. We'll use the last 10 // frames for our average. // Find location of target after one second Lxa = sim_plane[gpt_aircraft_index].Lvelocity * sim_plane[gpt_aircraft_index].Lcpitch >> SHIFT_HI; Lya = sim_plane[gpt_aircraft_index].Lvelocity * sim_plane[gpt_aircraft_index].Lspitch >> SHIFT_HI; Lzc = sim_plane[gpt_aircraft_index].Lz + (Lxa * sim_plane[gpt_aircraft_index].Lcyaw >> SHIFT_HI); Lxc = sim_plane[gpt_aircraft_index].Lx + (Lxa * sim_plane[gpt_aircraft_index].Lsyaw >> SHIFT_HI); Lyc = sim_plane[gpt_aircraft_index].Ly - Lya; // Find location of my plane after one second Lxa = Lmy_plane_velocity * Lmy_plane_cpitch >> SHIFT_HI; Lya = Lmy_plane_velocity * Lmy_plane_spitch >> SHIFT_HI; Lzd = Lmy_plane_z + (Lxa * Lmy_plane_cyaw >> SHIFT_HI); Lxd = Lmy_plane_x + (Lxa * Lmy_plane_syaw >> SHIFT_HI); Lyd = Lmy_plane_y - Lya; Lgen = (gpt_distance - CALC_DISTANCE(Lxc, Lyc, Lzc, Lxd, Lyd, Lzd)) * 19428L >> 15L; // Average result if needed Laverage_closure_rate[average_closure_rate_counter++] = Lgen; if (average_closure_rate_counter==10) { safe_to_average_closure_rate = YES; average_closure_rate_counter = 0; } if (safe_to_average_closure_rate) { Lgen = (Laverage_closure_rate[0] + Laverage_closure_rate[1] + Laverage_closure_rate[2] + Laverage_closure_rate[3] + Laverage_closure_rate[4] + Laverage_closure_rate[5] + Laverage_closure_rate[6] + Laverage_closure_rate[7] + Laverage_closure_rate[8] + Laverage_closure_rate[9]) / 10L; } sprintf(buffer, "%-d KNOTS ", Lgen); disp_ddi_text(ddi_center_x - 17, DDI_CENTER_Y + 1, buffer, 11); // Enemy Altitude sprintf(buffer, "%-d FT ", -gpt_y); disp_ddi_text(ddi_center_x - 13, DDI_CENTER_Y + 8, buffer, 8); // Enemy Speed in Knots sprintf(buffer, "%-d KNOTS ", sim_plane[gpt_aircraft_index].Lvelocity * 19428L >> 15L); disp_ddi_text(ddi_center_x - 13, DDI_CENTER_Y + 15, buffer, 9); // Enemy Heading if (sim_plane[gpt_aircraft_index].Syaw>0) Sgen = sim_plane[gpt_aircraft_index].Syaw / 182; else Sgen = (short)(((long)sim_plane[gpt_aircraft_index].Syaw + 65536L) / 182L); Sgen %= 360; sprintf(buffer, "%-d` ", Sgen); disp_ddi_text(ddi_center_x - 13, DDI_CENTER_Y + 22, buffer, 4); /* disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y-20, "", ); disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y-13, "", ); disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y-6, "", ); disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y+1, "", ); disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y+8, "", ); disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y+15, "", ); disp_ddi_text(ddi_center_x-25, DDI_CENTER_Y+22, "", ); */ } void Draw_Infrared(int on_left) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; if (station_type[current_station]!=AGM65F) return; if (last_65F_launch_missle_element==-1) { if (gpt_lockable) { infrared_view_x = Lmy_plane_x; infrared_view_y = Lmy_plane_y; infrared_view_z = Lmy_plane_z; infrared_target_x = gpt_x; infrared_target_z = gpt_z; infrared_wme = gpt_wme; infrared_wmet = gpt_wmet; infrared_target_distance = gpt_distance / 6080L; } // No missles left and none flying. Don't display anything. else return; } // Missle is flying and is locked else if (missle_lock_status[last_65F_launch_missle_element]) { infrared_view_x = Lmissle_x[last_65F_launch_missle_element]; infrared_view_y = Lmissle_y[last_65F_launch_missle_element]; infrared_view_z = Lmissle_z[last_65F_launch_missle_element]; infrared_target_x = Lmissle_target_x[last_65F_launch_missle_element]; infrared_target_z = Lmissle_target_z[last_65F_launch_missle_element]; infrared_wme = Lmissle_target_wme[last_65F_launch_missle_element]; infrared_wmet = Lmissle_target_wmet[last_65F_launch_missle_element]; infrared_target_distance = Lmissle_locked_target_distance[last_65F_launch_missle_element] / 6080L; } // Missle is flying but is not locked. Don't display anything. else return; if (on_left==YES) { fg_setclip(58, 108, 154, 200); ddi_center_x = 83; } else { fg_setclip(210, 260, 154, 200); ddi_center_x = 235; } display_on_ddi = YES; // It's very important that we set Lcurrent_element because for // instance, the bridge drawing scenery relies on this to be set // in order to draw properly. Lcurrent_element = XZ_TO_ELEMENT(infrared_target_x, infrared_target_z); if (infrared_wme==WME_NSBRIDGE) { Calculate_Ground_Target_View(DEPTH * 2048L / 160L); Draw_North_South_Bridge(); } else if (infrared_wme==WME_WEBRIDGE) { Calculate_Ground_Target_View(DEPTH * 2048L / 160L); Draw_West_East_Bridge(); } else if (infrared_wme==WME_FRIENDLY_AIRPORT && infrared_wmet<2) { Calculate_Ground_Target_View(DEPTH * 512L / 160L); Draw_Hanger(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z, LTGoffset_x, LTGoffset_z); } else if (infrared_wme==WME_FRIENDLY_AIRPORT && infrared_wmet<4) { Calculate_Ground_Target_View(DEPTH * 512L / 160L); Draw_Hanger_45_Degrees(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z); } else if (infrared_wme==WME_FRIENDLY_AIRPORT && infrared_wmet==4) { Calculate_Ground_Target_View(DEPTH * 512L / 160L); Draw_Control_Tower(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z, LTGoffset_x, LTGoffset_z); } else if (infrared_wme==WME_GECKO) { Calculate_Ground_Target_View(DEPTH * 64L / 160L); Draw_Gecko(); } else if (infrared_wme==WME_GROUND_TRAINING_TARGET) { Calculate_Ground_Target_View(DEPTH * 512L / 160L); Draw_Training_Ground_Target(); } else if (infrared_wme==WME_FUEL_DUMPS) { Calculate_Ground_Target_View(DEPTH * 640L / 160L); Draw_Fuel_Tank(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z, LTGoffset_x, LTGoffset_z); } else if (infrared_wme==WME_RADAR_STATION && infrared_wmet==0) { Calculate_Ground_Target_View(DEPTH * 512L / 160L); Draw_Radar_Building_And_Dish(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z, LTGoffset_x, LTGoffset_z); } else if ((infrared_wme==WME_RADAR_STATION && infrared_wmet==1) || (infrared_wme==WME_COMMAND_CONTROL && infrared_wmet==0) || (infrared_wme==WME_COMMUNICATION && infrared_wmet==0)) { Calculate_Ground_Target_View(DEPTH * 1280L / 160L); Draw_Communication_Tower(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z); } else if ((infrared_wme==WME_COMMUNICATION && infrared_wmet==1) || (infrared_wme==WME_WEAPONS_FACTORY && infrared_wmet==1) || (infrared_wme==WME_POWER_PLANT && infrared_wmet==0) || (infrared_wme==WME_CHEMICAL_FACTORY && infrared_wmet==0) || (infrared_wme==WME_COMMAND_CONTROL && infrared_wmet==1) || (infrared_wme==WME_NUCLEAR_RESEARCH) || (infrared_wme==WME_ARMY_BARRACKS && infrared_wmet<3)) { Calculate_Ground_Target_View(DEPTH * 512L / 160L); Draw_Barracks(GREEN_CAMOUFLAGE, LTRGoffset_x, LTRGoffset_y, LTRGoffset_z, LTGoffset_x, LTGoffset_z); } else if ((infrared_wme==WME_WEAPONS_FACTORY && infrared_wmet==0) || (infrared_wme==WME_POWER_PLANT && infrared_wmet>0) || (infrared_wme==WME_CHEMICAL_FACTORY && infrared_wmet==1)) { Calculate_Ground_Target_View(DEPTH * 1536L / 160L); Draw_Smoke_Stack(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z); } else if ((infrared_wme==WME_TANK_CONVOY) || (infrared_wme==WME_WEAPON_STORAGE && (infrared_wmet<3 || infrared_wmet>4))) { Calculate_Ground_Target_View(DEPTH * 64L / 160L); Draw_Tank(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z, LTGoffset_x, LTGoffset_z); } else if (infrared_wme==WME_ARMY_BARRACKS && infrared_wmet>2) { Calculate_Ground_Target_View(DEPTH * 450L / 160L); Draw_Building_A(LTRGoffset_x, LTRGoffset_y, LTRGoffset_z, LTGoffset_x, LTGoffset_z); } else if (infrared_wme==WME_MOBILE_SCUD) { Calculate_Ground_Target_View(DEPTH * 100L / 160L); Draw_SCUD_Launcher(); } else if (infrared_wme==WME_WEAPON_STORAGE && (infrared_wmet==3 || infrared_wmet==4)) { Calculate_Ground_Target_View(DEPTH * 64L / 160L); Draw_Truck(0, LTGoffset_x, -Lview_y, LTGoffset_z); } // Display distance to target in nautical miles. /* Who needs this anyway? fg_setcolor(DISPLAY_BK_COLOR); fg_rect( ddi_center_x-22, ddi_center_x-5, DDI_CENTER_Y+20, DDI_CENTER_Y+22 ); */ sprintf(buffer, "%2d NM ", infrared_target_distance); disp_ddi_text(ddi_center_x - 25, DDI_CENTER_Y + 22, buffer, 5); // Draw Cross Hairs fg_setcolor(DISPLAY_FG_COLOR); fg_move(ddi_center_x - 20, DDI_CENTER_Y); fg_drawrel(19, 0); fg_moverel(2, 0); fg_drawrel(19, 0); fg_move(ddi_center_x, DDI_CENTER_Y - 20); fg_drawrel(0, 19); fg_moverel(0, 2); fg_drawrel(0, 19); display_on_ddi = NO; } void Calculate_Ground_Target_View(long view_distance) { int loop_var; short Sgen; int Igen, Igen2, Igen3; long Lgen, Lgen2; unsigned long ULgen, ULgen2; float Fgen, Fgen2, Fgen3; // Used by ddi version of polyfill_3d() y_offset = LARGE_SCREEN_CENTER_Y; // polyoff_miny=-160L; OBSOLETE // polyoff_maxy=160L; OBSOLETE Ltravel_distance = (long)sqrt((double)((float)(infrared_view_x - infrared_target_x) * (float)(infrared_view_x - infrared_target_x)) + (double)((float)(infrared_view_z - infrared_target_z) * (float)(infrared_view_z - infrared_target_z))); Spitch_angle_of_head = Satan2(infrared_view_y, Ltravel_distance); Syaw_angle_of_head = Satan2(infrared_target_x - infrared_view_x, infrared_target_z - infrared_view_z); Lsin(Syaw_angle_of_head, Lsyaw_T); Lcos(Syaw_angle_of_head, Lcyaw_T); Lsin(Spitch_angle_of_head, Lspitch_T); Lcos(Spitch_angle_of_head, Lcpitch_T); Lsroll_T = 0L; Lcroll_T = 16384L; THI00 = Lcyaw_T; THI01 = 0L; THI02 = -Lsyaw_T; THI10 = Lspitch_T * Lsyaw_T >> SHIFT_HI; THI11 = Lcpitch_T; THI12 = Lspitch_T * Lcyaw_T >> SHIFT_HI; THI20 = Lcpitch_T * Lsyaw_T >> SHIFT_HI; THI21 = -Lspitch_T; THI22 = Lcpitch_T * Lcyaw_T >> SHIFT_HI; T00 = THI00 >> SHIFT_HI_LO; T01 = THI01 >> SHIFT_HI_LO; T02 = THI02 >> SHIFT_HI_LO; T10 = THI10 >> SHIFT_HI_LO; T11 = THI11 >> SHIFT_HI_LO; T12 = THI12 >> SHIFT_HI_LO; T20 = THI20 >> SHIFT_HI_LO; T21 = THI21 >> SHIFT_HI_LO; T22 = THI22 >> SHIFT_HI_LO; // Avoid all those potential errors. if (Lcpitch_T==0L) Lcpitch_T = 1L; /* Lets rotate all preset possible points for all possible * object offset locations FAST 3D speed! * * After this, to calculate a point is just a matter of addition * to the rotated offset followed by projection. * * Remember, all points have a precision to 1/64 ft. * Offsets must have the same precision. */ Rotate_Possible_Points(); /* View distance to target can vary */ Lview_x = infrared_target_x; Lview_y = 0; Lview_z = infrared_target_z; Lxa = -view_distance * Lcpitch_T >> SHIFT_HI; Lya = -view_distance * Lspitch_T >> SHIFT_HI; Lview_z += (Lxa * Lcyaw_T >> SHIFT_HI); Lview_x += (Lxa * Lsyaw_T >> SHIFT_HI); Lview_y -= Lya; // Do translation of target world coordinates LTGoffset_x = infrared_target_x - Lview_x; LTGoffset_z = infrared_target_z - Lview_z; // Do rotation of target world coordinates into 1/64 precision LTRGoffset_x = LTGoffset_x * T00 + -Lview_y * T01 + LTGoffset_z * T02 >> 4L; LTRGoffset_y = LTGoffset_x * T10 + -Lview_y * T11 + LTGoffset_z * T12 >> 4L; LTRGoffset_z = LTGoffset_x * T20 + -Lview_y * T21 + LTGoffset_z * T22 >> 4L; } void disp_ddi_text(int disp_ddi_text_x, int disp_ddi_text_y, unsigned char *string, int string_len) { int loop_var; fg_move(disp_ddi_text_x, disp_ddi_text_y); for (loop_var = 0;loop_var<string_len;loop_var++) { fg_putimage(&ddi_ascii_bitmaps[string[loop_var]][0], 3, 5); fg_moverel(4, 0); } } void draw_ddi_station(int num, int draw_ddi_station_x, int draw_ddi_station_y) { if (station_type[num]==NONE || station_number[num]==0) { // Just draw a thin line. if (current_station==num) fg_setcolor(DISPLAY_FG_COLOR); else fg_setcolor(DISPLAY_DIM_COLOR); fg_move(draw_ddi_station_x + 1, draw_ddi_station_y); fg_drawrel(0, -6); } else { // Highlight all weapons of the same type fg_move(draw_ddi_station_x, draw_ddi_station_y); //if (current_station==num) fg_putimage(ddi_highlighted_missle,3,7); //else fg_putimage(ddi_dithered_missle,3,7); if (station_type[num]==station_type[current_station]) fg_putimage(ddi_highlighted_missle, 3, 7); else fg_putimage(ddi_dithered_missle, 3, 7); } } void Update_Lights(void) { int Igen1, Igen2, loop_var; long Lgen; fg_setpage(2); if (old_aa_lck_light!=aa_lck_light || old_aa_fox1_light!=aa_fox1_light || old_aa_fox2_light!=aa_fox2_light || old_sam_lck_light!=sam_lck_light || old_sam_fox1_light!=sam_fox1_light || old_sam_fox2_light!=sam_fox2_light || old_fuel_light!=fuel_light || old_rad_light!=rad_light || old_my_plane_stall!=my_plane_stall || old_fail_light!=fail_light || old_ctrl_light!=ctrl_light || old_hyd_light!=hyd_light || old_fire_light!=fire_light || old_eng1_light!=eng1_light || old_eng2_light!=eng2_light || old_my_plane_brake!=my_plane_brake || old_my_plane_gear!=my_plane_gear || old_my_plane_flaps!=my_plane_flaps) { // Gotta do some updating old_aa_lck_light = aa_lck_light; old_aa_fox1_light = aa_fox1_light; old_aa_fox2_light = aa_fox2_light; old_sam_lck_light = sam_lck_light; old_sam_fox1_light = sam_fox1_light; old_sam_fox2_light = sam_fox2_light; old_fuel_light = fuel_light; old_rad_light = rad_light; old_my_plane_stall = my_plane_stall; old_fail_light = fail_light; old_ctrl_light = ctrl_light; old_hyd_light = hyd_light; old_fire_light = fire_light; old_eng1_light = eng1_light; old_eng2_light = eng2_light; old_my_plane_brake = my_plane_brake; old_my_plane_gear = my_plane_gear; old_my_plane_flaps = my_plane_flaps; // Row 1 fg_move(169, 140); if (aa_fox1_light || aa_fox2_light) fg_putimage(bitmap_light_aa, 20, 5); else if (sam_fox1_light || sam_fox2_light) fg_putimage(bitmap_light_sam, 20, 5); else if (aa_lck_light || sam_lck_light) fg_putimage(bitmap_light_lock, 20, 5); else fg_putimage(bitmap_light_nada, 20, 5); // Row 2 fg_move(169, 150); if (my_plane_stall && !my_plane_touchdown) fg_putimage(bitmap_light_stall, 20, 5); else if (fuel_light) fg_putimage(bitmap_light_fuel, 20, 5); else if (rad_light) fg_putimage(bitmap_light_radar, 20, 5); else fg_putimage(bitmap_light_nada, 20, 5); // Row 3 fg_move(169, 159); if (fail_light) fg_putimage(bitmap_light_fail, 20, 5); else if (ctrl_light) fg_putimage(bitmap_light_ctrl, 20, 5); else if (hyd_light) fg_putimage(bitmap_light_hyd, 20, 5); else fg_putimage(bitmap_light_nada, 20, 5); // Row 4 fg_move(169, 169); if (fire_light) fg_putimage(bitmap_light_fire, 20, 5); else if (eng1_light) fg_putimage(bitmap_light_engl, 20, 5); else if (eng2_light) fg_putimage(bitmap_light_engr, 20, 5); else fg_putimage(bitmap_light_nada, 20, 5); // Row 5 fg_move(169, 178); if (my_plane_brake) fg_putimage(bitmap_light_brake, 20, 5); else if (my_plane_gear) fg_putimage(bitmap_light_gear, 20, 5); else if (my_plane_flaps) fg_putimage(bitmap_light_flaps, 20, 5); else fg_putimage(bitmap_light_nada, 20, 5); // Now we'll do the other lights if (my_plane_flaps) fg_setcolor(cockpit_yellow_on_index); else fg_setcolor(cockpit_yellow_off_index); fg_rect(108, 111, 123, 126); if (my_plane_gear) fg_setcolor(cockpit_green_on_index); else fg_setcolor(cockpit_green_off_index); fg_rect(108, 111, 131, 134); if (my_plane_brake) fg_setcolor(cockpit_red_on_index); else fg_setcolor(cockpit_red_off_index); fg_rect(108, 111, 139, 142); } // OK, first we'll see what type of weapon the enemy has Igen1 = Igen2 = 0; for (loop_var = 2;loop_var<=4;loop_var++) { if (sim_plane[loop_var].Ipursuing==-1) { // -1 is me // Irrelevant, right? // if (sim_plane[loop_var].Imissle_locked_onto==-1) // -1 is me if (sim_plane[loop_var].missle_type==AIM9M) { Igen2 = 1; // Fox 2 } else { Igen1 = 1; // Fox 1 } } } Lgen = current_tick; // Fox 2 is A-A only! if (aa_fox2_light) { if (page) fg_setcolor(cockpit_red_off_index); else fg_setcolor(cockpit_red_on_index); fg_rect(208, 211, 135, 137); } else if (aa_lck_light && Igen2) { fg_setcolor(cockpit_yellow_on_index); fg_rect(208, 211, 135, 137); } else { fg_setcolor(cockpit_yellow_off_index); fg_rect(208, 211, 135, 137); } if (aa_fox1_light || sam_fox1_light) { if (page) fg_setcolor(cockpit_red_off_index); else fg_setcolor(cockpit_red_on_index); fg_rect(208, 211, 139, 141); } else if ((aa_lck_light && Igen1) || sam_lck_light) { fg_setcolor(cockpit_yellow_on_index); fg_rect(208, 211, 139, 141); } else { fg_setcolor(cockpit_yellow_off_index); fg_rect(208, 211, 139, 141); } // WINDOWS if (gpt_selected && gpt_visable) { if (station_type[current_station]==M61A1) { if (gpt_aircraft_index<2) current_window = WINDOW_STROBE_RED; else if (gpt_distance<4096L && pipper_x>=(gpt_sx - 4L + X_OFFSET) && pipper_x<=(gpt_sx + 4L + X_OFFSET) && pipper_y>=(gpt_sy - 4L + SMALL_SCREEN_CENTER_Y) && pipper_y<=(gpt_sy + 4L + SMALL_SCREEN_CENTER_Y)) { current_window = WINDOW_STROBE_GREEN; } else if (gpt_distance<4096L) current_window = WINDOW_GREEN; else current_window = WINDOW_YELLOW; } else if (station_type[current_station]==AIM9M || station_type[current_station]==AIM7M) { if (gpt_aircraft_index<2) current_window = WINDOW_STROBE_RED; else if (gpt_in_rng && gpt_lockable) current_window = WINDOW_STROBE_GREEN; else if (gpt_in_rng) current_window = WINDOW_GREEN; else current_window = WINDOW_YELLOW; } else if (station_type[current_station]==AGM65F || station_type[current_station]==AGM88A) { if (gpt_in_rng && gpt_lockable) current_window = WINDOW_STROBE_GREEN; else if (gpt_in_rng) current_window = WINDOW_GREEN; else current_window = WINDOW_YELLOW; } else if (station_type[current_station]==MK82 || station_type[current_station]==MK83 || station_type[current_station]==MK84) { if (bomb_x>=(gpt_sx - 4L + X_OFFSET) && bomb_x<=(gpt_sx + 4L + X_OFFSET) && bomb_y>=(gpt_sy - 4L + SMALL_SCREEN_CENTER_Y) && bomb_y<=(gpt_sy + 4L + SMALL_SCREEN_CENTER_Y)) { current_window = WINDOW_STROBE_GREEN; } else current_window = WINDOW_YELLOW; } else if (station_type[current_station]==M151 || station_type[current_station]==MK5) { /* OK, it's gotta be right on the money! if (X_OFFSET>=(gpt_sx-4L+X_OFFSET) && X_OFFSET<=(gpt_sx+4L+X_OFFSET) && y_offset>=(gpt_sy-4L+SMALL_SCREEN_CENTER_Y) && y_offset<=(gpt_sy+4L+SMALL_SCREEN_CENTER_Y) ) */ if (X_OFFSET==(gpt_sx + X_OFFSET) && y_offset==(gpt_sy + SMALL_SCREEN_CENTER_Y)) { current_window = WINDOW_STROBE_GREEN; } else current_window = WINDOW_YELLOW; } } else current_window = WINDOW_OFF; if (current_window==WINDOW_OFF) { fg_transfer(130, 130 + 6, 73 - 7, 73, 78, 130, 2, 2); fg_transfer(130, 130 + 6, 84 - 7, 84, 234, 129, 2, 2); } else if (current_window==WINDOW_YELLOW) { fg_transfer(142, 142 + 6, 73 - 7, 73, 78, 130, 2, 2); fg_transfer(142, 142 + 6, 84 - 7, 84, 234, 129, 2, 2); } else if (current_window==WINDOW_GREEN) { fg_transfer(154, 154 + 6, 73 - 7, 73, 78, 130, 2, 2); fg_transfer(154, 154 + 6, 84 - 7, 84, 234, 129, 2, 2); } else if (current_window==WINDOW_STROBE_GREEN) { if (page) { fg_transfer(154, 154 + 6, 73 - 7, 73, 78, 130, 2, 2); fg_transfer(154, 154 + 6, 84 - 7, 84, 234, 129, 2, 2); } else { fg_transfer(130, 130 + 6, 73 - 7, 73, 78, 130, 2, 2); fg_transfer(130, 130 + 6, 84 - 7, 84, 234, 129, 2, 2); } } else if (current_window==WINDOW_STROBE_RED) { if (page) { fg_transfer(166, 166 + 6, 73 - 7, 73, 78, 130, 2, 2); fg_transfer(166, 166 + 6, 84 - 7, 84, 234, 129, 2, 2); } else { fg_transfer(130, 130 + 6, 73 - 7, 73, 78, 130, 2, 2); fg_transfer(130, 130 + 6, 84 - 7, 84, 234, 129, 2, 2); } } // WARNING if (fire_light || structural_failure || structural_limit) { // Flash that warning light // First a big, red, fast drawn, rectangle if (page) fg_setcolor(245); else fg_setcolor(244); fg_rect(131, 183, 110, 116); // Copy only the word "WARNING" if (page) fg_transfer(144, 170, 89, 93, 144, 115, 2, 2); } else { // Gotta black it out first! fg_setcolor(244); fg_rect(131, 183, 110, 116); // Restore weapons display stuff Update_Weapon_Status(); } fg_setpage(page); }