/* * pinewood.h * * Include file to pull everything together. */ #ifndef PINEWOOD_DEFINED #define PINEWOOD_DEFINED /*** *** Common lint comments ***/ /*lint -e579 */ /*lint -esym(534,cputs,fgets,cprintf) */ /*lint -esym(750,K_F8,K_F9,K_F10) */ /*lint -esym(755,K_F8,K_F9,K_F10,NHEATS,IO_PORT) */ /*lint -efile(766,c:\borlandc\include\_nfile.h) */ /*lint -efile(764,c:\borlandc\include\ctype.h) */ /*lint -efile(766,c:\borlandc\include\ctype.h) */ /*lint -efile(766,c:\borlandc\include\stdlib.h) */ /*lint -efile(766,c:\borlandc\include\string.h) */ /*lint -efile(766,pragmas.h) */ /*** *** Tunable constants ***/ #define DATABASE "pinewood.dat" /* Name of the database */ #define HELPFILE "pinewood.hlp" /* Name of help file */ #define RANKFILE "rank.dat" /* Name of rank file */ #define RACESCHED "race.dat" /* Race schedule file */ //#define PRINTER "printer" /* Name of print device, normally LPT1 */ #define PRINTER "com1" //#define KB_INTERFACE 1 /* Define for the keyboard interface for testing */ #define NHEATS 2 /* Number of times each car races */ #define NLANES 4 /* Number of cars on the track */ #define NRACES 20 /* Maximum number of runs */ #define NUSERS 200 /* Maximum number of cars */ #define NSIZE 30 /* Size of name */ #define CSIZE 2 /* Size of car number */ #define NLINES 25 /* Number of lines on the display */ #define NDATAL (NLINES-2) /* Number of user lines */ #define NRANKS 10 /* Number of race categories */ #define MAXTIME 9 /* Maximum time to race */ #define IO_PORT 0x378 /* I/O port for the parallel port */ /* Columns for edit fields */ #define C_NAME 0 /* Starting column for name */ #define C_CAR NSIZE /* Starting column for car # */ #define C_TIME (C_CAR+CSIZE) /* Starting column for time fields */ #define EQ(str1, str2) (strcmp(str1, str2) == 0) #define EQn(str1, str2) (strncmp(str1, str2, strlen(str2)) == 0) /*** *** Local types ***/ typedef int bool_t; /* Boolean data type */ #define TRUE 1 #define FALSE 0 /*** *** Track definitions ***/ #define BIT_LANE_4 0x80 /* Bit for lane 4 */ #define BIT_LANE_3 0x40 /* Bit for lane 3 */ #define BIT_LANE_2 0x20 /* Bit for lane 2 */ #define BIT_LANE_1 0x10 /* Bit for lane 1 */ #define BIT_START 0x08 /* Starting signal */ /* * keyboard definitions */ /* Keypad keys */ #define K_HOME 0x4700 #define K_UP 0x4800 #define K_PGUP 0x4900 #define K_LEFT 0x4B00 #define K_RIGHT 0x4D00 #define K_END 0x4F00 #define K_DOWN 0x5000 #define K_PGDN 0x5100 #define K_INSERT 0x5200 #define K_DELETE 0x5300 /* Standard function keys */ #define K_F1 0x3B00 #define K_F2 0x3C00 #define K_F3 0x3D00 #define K_F4 0x3E00 #define K_F5 0x3F00 #define K_F6 0x4000 #define K_F7 0x4100 #define K_F8 0x4200 #define K_F9 0x4300 #define K_F10 0x4400 #define K_ESC 0x001B /* * cmd table for displaying commands */ struct cmd { char *title; /* Prompt for command */ void (*fn)(void); /* Function to run if selected */ }; /* * The database entry */ struct db { char name[NSIZE+1]; /* The name of the user */ char car[CSIZE+1]; /* Car # (Den # in tens digit) */ long run[NRACES]; /* Runtime (in microseconds) */ int lane[NRACES]; /* Lane number used */ int racenum; /* Race number for this car */ bool_t scanned; /* User has been scanned in search */ int in_race; /* This car is in the race */ long average; /* Snapshot of average */ int rank; /* Which rank this car attains */ }; /* * The rank table */ struct rank { char *name; /* Name of rank */ int dens[10]; /* Dens of the given rank (term with -1) */ }; /*** *** Global variables ***/ /*lint -esym(767,X) */ #ifdef MAIN #define X #else #define X extern #endif X struct db Database[NUSERS]; /* The incore database */ X bool_t Database_dirty; /* TRUE if the database needs to be written */ X unsigned int Kb_interface; /* Keyboard interface vector */ X int Nranks; /* Number of ranks */ X int Nusers; /* Current number of users */ X struct rank Ranks[NRANKS]; /* Rank table */ /*** *** Function prototypes ***/ void big_display(int x, int y, char *str); /* Display big text */ void big_modify(void); /* Change character table */ void clear_results(void); /* Clear all current results */ void delete_database(void); /* Delete the database */ void edit_data(void); /* Edit the database */ void exit_program(void); /* Exit the program */ unsigned int get_track_sensors(void); /* Get track sensors */ unsigned int getxch(void); /* Get an extended character */ void print_race_schedule(void); void print_results(void); void print_roster(void); void print_standings(void); /* Print the current standings */ void print_user(FILE *fp, int user, int fields); #ifdef KB_INTERFACE bool_t process_keyboard(unsigned int ch); /* Keyboard interface */ #else #define process_keyboard(x) #endif /* KB_INTERFACE */ void process_table(struct cmd *cmd); /* Process a menu */ void run_heat(void); /* Run the next heat */ bool_t run_race(char *labels[NLANES], int rank[NLANES], long int *times, int racenum); void show_information(void); /* Show a help file */ void test_run(void); /* Test run */ /* log.h */ void xfclose(FILE *printer); FILE * xfopen(char *fname, char *mode); void xfprintf(FILE *printer, char *fmt, ...); void xreprint(void); /* utility.h */ long int average(int user); int count_races(int user); int find_rank(long int times[], int car); char * format_time(long int time_val); void init_db(int user, bool_t full); void read_database(void); void read_ranks(void); void save_database(void); void write_database(void); void xstrncpy(char *dest, char *src, size_t len); /*** *** Pmon definitions ***/ typedef struct { unsigned long tick; unsigned int timer; /* unsigned char stat; */ } US_TIME; unsigned long delta_us(US_TIME *s_us_time, US_TIME *e_us_time); void calib_pmon(void); void get_time(US_TIME *us_time); #endif /* PINEWOOD_DEFINED */