From 58eb9b9089b73883bbcbdb0ec98ce59d3d7d72f0 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 7 May 1998 23:14:14 +0000 Subject: [PATCH] Added "D" key binding to set autopilot heading. Made frame rate calculation average out over last 10 frames. Borland C++ floating point exception workaround. Added a --tile-radius=n option. --- Main/GLUTkey.cxx | 16 ++++++++++++---- Main/GLUTmain.cxx | 30 +++++++++++++++++++++++------- Main/fg_init.cxx | 12 ++++++++++++ Main/options.cxx | 17 +++++++++++++++-- Main/runfg.bat.in | 4 ++-- 5 files changed, 64 insertions(+), 15 deletions(-) diff --git a/Main/GLUTkey.cxx b/Main/GLUTkey.cxx index d8a7e8cd5..a542b685b 100644 --- a/Main/GLUTkey.cxx +++ b/Main/GLUTkey.cxx @@ -120,7 +120,9 @@ void GLUTkey(unsigned char k, int x, int y) { case 83: /* S key */ fgAPSetMode(0); return; - + case 68: /* D key */ + fgAPSetHeading(AP_CURRENT_HEADING); + return; } } else { fgPrintf( FG_INPUT, FG_DEBUG, "\n"); @@ -265,10 +267,16 @@ void GLUTspecialkey(int k, int x, int y) { /* $Log$ -/* Revision 1.6 1998/04/28 01:20:20 curt -/* Type-ified fgTIME and fgVIEW. -/* Added a command line option to disable textures. +/* Revision 1.7 1998/05/07 23:14:14 curt +/* Added "D" key binding to set autopilot heading. +/* Made frame rate calculation average out over last 10 frames. +/* Borland C++ floating point exception workaround. +/* Added a --tile-radius=n option. /* + * Revision 1.6 1998/04/28 01:20:20 curt + * Type-ified fgTIME and fgVIEW. + * Added a command line option to disable textures. + * * Revision 1.5 1998/04/25 22:06:29 curt * Edited cvs log messages in source files ... bad bad bad! * diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx index a518a8dca..d5f2344c8 100644 --- a/Main/GLUTmain.cxx +++ b/Main/GLUTmain.cxx @@ -29,6 +29,7 @@ #ifdef HAVE_WINDOWS_H # include +# include #endif #include @@ -542,14 +543,19 @@ static void fgMainLoop( void ) { elapsed, remainder); // Calculate frame rate average - accum = 0.0; - for ( i = FG_FRAME_RATE_HISTORY - 2; i >= 0; i-- ) { - accum += g->frames[i]; - g->frames[i+1] = g->frames[i]; + if ( elapsed > 0.0 ) { + accum = 0.0; + for ( i = FG_FRAME_RATE_HISTORY - 2; i >= 0; i-- ) { + accum += g->frames[i]; + // printf("frame[%d] = %.2f\n", i, g->frames[i]); + g->frames[i+1] = g->frames[i]; + } + g->frames[0] = 1000.0 / (float)elapsed; + // printf("frame[0] = %.2f\n", g->frames[0]); + accum += g->frames[0]; + g->frame_rate = accum / (float)FG_FRAME_RATE_HISTORY; + // printf("ave = %.2f\n", g->frame_rate); } - g->frames[0] = 1000.0 / (float)elapsed; - accum += g->frames[0]; - g->frame_rate = accum / (float)FG_FRAME_RATE_HISTORY; // Calculate model iterations needed for next frame fgPrintf( FG_ALL, FG_DEBUG, @@ -670,6 +676,10 @@ int main( int argc, char **argv ) { f = current_aircraft.flight; +#ifdef HAVE_BC5PLUS + _control87(MCW_EM, MCW_EM); /* defined in float.h */ +#endif + // Initialize the debugging output system fgInitDebug(); @@ -737,6 +747,12 @@ extern "C" { // $Log$ +// Revision 1.12 1998/05/07 23:14:15 curt +// Added "D" key binding to set autopilot heading. +// Made frame rate calculation average out over last 10 frames. +// Borland C++ floating point exception workaround. +// Added a --tile-radius=n option. +// // Revision 1.11 1998/05/06 03:16:23 curt // Added an averaged global frame rate counter. // Added an option to control tile radius. diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx index f670e5cf0..9dd947301 100644 --- a/Main/fg_init.cxx +++ b/Main/fg_init.cxx @@ -169,6 +169,7 @@ int fgInitPosition( void ) { // General house keeping initializations int fgInitGeneral( void ) { fgGENERAL *g; + int i; g = &general; @@ -189,6 +190,11 @@ int fgInitGeneral( void ) { } fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", g->root_dir); + // prime the frame rate counter pump + for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) { + g->frames[i] = 0.0; + } + return ( 1 ); } @@ -381,6 +387,12 @@ int fgInitSubsystems( void ) { // $Log$ +// Revision 1.11 1998/05/07 23:14:15 curt +// Added "D" key binding to set autopilot heading. +// Made frame rate calculation average out over last 10 frames. +// Borland C++ floating point exception workaround. +// Added a --tile-radius=n option. +// // Revision 1.10 1998/05/06 03:16:24 curt // Added an averaged global frame rate counter. // Added an option to control tile radius. diff --git a/Main/options.cxx b/Main/options.cxx index 1d6d725f6..498e1a1c5 100644 --- a/Main/options.cxx +++ b/Main/options.cxx @@ -171,12 +171,19 @@ static int parse_int(char *arg, int min, int max) { while ( (arg[0] != '=') && (arg[0] != '\0') ) { arg++; } - + + if ( arg[0] == '=' ) { + arg++; + } + + printf("parse_int(): arg = %s\n", arg); + result = atoi(arg); if ( result < min ) { result = min; } if ( result > max ) { result = max; } + printf("parse_int(): result = %d\n", result); return(result); } @@ -227,7 +234,7 @@ int fgOPTIONS::parse( int argc, char **argv ) { } else if ( strcmp(argv[i], "--enable-wireframe") == 0 ) { wireframe = 1; } else if ( strncmp(argv[i], "--tile-radius=", 14) == 0 ) { - tile_radius = parse_int(argv[i], 3, 7); + tile_radius = parse_int(argv[i], 3, 9); } else if ( strncmp(argv[i], "--time-offset=", 14) == 0 ) { time_offset = parse_time_offset(argv[i]); } else { @@ -289,6 +296,12 @@ fgOPTIONS::~fgOPTIONS( void ) { // $Log$ +// Revision 1.8 1998/05/07 23:14:16 curt +// Added "D" key binding to set autopilot heading. +// Made frame rate calculation average out over last 10 frames. +// Borland C++ floating point exception workaround. +// Added a --tile-radius=n option. +// // Revision 1.7 1998/05/06 03:16:25 curt // Added an averaged global frame rate counter. // Added an option to control tile radius. diff --git a/Main/runfg.bat.in b/Main/runfg.bat.in index f54990caa..62c7f9569 100755 --- a/Main/runfg.bat.in +++ b/Main/runfg.bat.in @@ -3,7 +3,7 @@ REM @ECHO OFF REM Skip ahead to CONT1 if FG_ROOT has a value IF NOT %FG_ROOT%.==. GOTO CONT1 -SET FG_ROOT=@prefix@ +SET FG_ROOT=. :CONT1 @@ -12,7 +12,7 @@ IF NOT EXIST %FG_ROOT%\BIN\FG.EXE GOTO ERROR1 REM Now that FG_ROOT has been set, run the program ECHO FG_ROOT = %FG_ROOT% -%FG_ROOT%\BIN\FG.EXE +%FG_ROOT%\BIN\FG.EXE %1 %2 %3 %4 %5 %6 %7 %8 %9 GOTO END -- 2.39.2