home *** CD-ROM | disk | FTP | other *** search
- #define VERSION 2.1
-
- /*
- ** User interface code for BYTE DOS benchmarks.
- ** BYTE Lab, 3/90.
- **
- ** This module contains the main routine. The actual benchmark routines are in
- ** benchcod.c ... they are accessed in this module through the benchhook
- ** call.
- **
- ** Revision History:
- ** 2.0:
- ** 5/14 - Fixed machine name update bug.- Steve.
- ** 5/17 - Changed format dumped by /b switch. - Steve.
- ** 5/22 - Fixed 8088/8086 display bug. - Steve.
- ** 7/31 - Fixed shift-s bug in veiw results mode. - Steve.
- ** 8/9 - Fixed overflow bug in miscsubs/getmhz - Steve.
- ** 8/15 - Changed format dumped by /b switch (vendor and product). - Steve.
- ** 8/24 - Fixed throughput elapsed time calculation in benchcod.c - RG & SA.
- ** 2.1: Released 8/31/90
- **
- **
- */
- #include <stdio.h>
- #include <math.h>
- #include <fcntl.h>
- #include <sys\stat.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <time.h>
- #include <io.h>
- #include <ctype.h>
- #include <string.h>
- #include <conio.h>
-
- #include "win.h" /* contains window definitions */
- #include "db.h" /* contains database structure definitions */
- #include "iface.h" /* contains array definitions for menus */
- #include "benchdefs.h" /* global for both interface and benchmarks */
-
- /* a useful macro */
- /* value of field -- uses offset into listptr, fieldname, additional offset*/
- #define vf(off,f) \
- *((double*)((char*)(*(lp+off))+((unsigned int)(&(((db_rec*)0)->f)))))
-
- /* other global variables */
-
- int timeradjust; /* For hires timer */
-
- int oldlen; /* For sliding bar */
-
- int staleflag=0; /* for results */
- int graphstale=0; /* for graphs*/
-
- int durmin; /* duration absolute minimums and maximums */
- int durmax=999;
-
- win_handle field, help, cpuwin, cpu2win; /* global windows */
- win_handle fpuwin, diskwin, vidwin, textreswin;
- win_handle bswin;
-
- struct help_handle helptext;
- int act_h_h;
- int help_base;
-
- int oldcurse; /* old cursor */
-
- char tres_ary[TEXTRESSIZE]; /* results to be printed and displayed */
- int ac_t_h; /* actual array height, after filled in */
-
- /* default filename for results */
- char dumpfname[80];
-
- /* default filename for textdb */
- char dbtxname[80];
-
- /* default machine name */
- char machname[80];
-
- /* struct to contain machine parameters */
- struct mcfig machine_config;
-
- /* array of pointers to db fields; this constitutes the database */
- db_rec *comparison_data[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- char recs_in_db;
-
- /* test defaults ... 0 means don't do test */
-
- int tdef[14] = { 60, /* sieve duration */
- 60, /* sort duration */
- 60, /* imath duration */
- 60, /* move duration */
- 60, /* fourbang duration */
- 60, /* fourier duration */
- 60, /* fio duration */
- 3, /* logical drive for fio (a=1)*/
- 1, /* do low-level disk? */
- 0, /* hard disk to test */
- 60, /* text duration */
- 60, /* graphics duration */
- 1, /* repetitions */
- 1 /* sound? */
- };
-
- int lastproc; /* kludge to keep graphs consistent; needed by batchgraph*/
-
- /* for command line */
- unsigned char options[9] = {0,0,0,0,0,0,0,0,0};
- char valchar[9] = {'b','n','r','c','f','d','v','a','h'};
- char * strargs[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
-
- /* benchmark subroutine prototypes (benchcod.c)*/
- extern sieve(win_handle*,unsigned int, unsigned int actime[], \
- unsigned int *);
- extern sort(win_handle*,unsigned int, unsigned int actime[], \
- unsigned int *);
- extern ifourbang(win_handle*,unsigned int, unsigned int, \
- unsigned int actime[], unsigned int *);
- extern movetest(win_handle *, unsigned int, unsigned int, \
- unsigned int acttime[][3], unsigned int iters[]);
- extern ffourbang (win_handle *,unsigned int, \
- unsigned int actime[],unsigned int *);
- extern fourier(win_handle *,unsigned int, \
- unsigned int actime[],unsigned int *);
- extern do_fileio(win_handle *, unsigned int, unsigned long *, \
- unsigned long *,unsigned int accrtime[], unsigned int accwtime[], \
- unsigned long);
- extern ll_hdthru(unsigned int, unsigned int, double *);
- extern ll_diskseek(unsigned int, double, double*);
- extern textbench(unsigned int, unsigned int, double *);
- extern tscroll(unsigned int, unsigned int, double *);
- extern graph_bench(unsigned int, double *);
- extern double timetodouble(unsigned int *);
- extern void adjust_bar(win_handle*, int, int);
-
- /* misc subroutine prototypes (miscsubs.asm) */
- extern void strip0s (char*, int); /* fast 0 to space routine */
- extern void machine_detect (struct mcfig*); /* gets machine parameters */
- extern int disk_check(int, int);
- extern int get_default(void);
- extern void set_default(int);
- extern void getpath(int, char*);
- extern void click(void);
- extern int cdir(char *);
-
- /* window prototypes (winsubs.asm)*/
- extern win_handle *mk_window( win_handle *, char *, int, int, int, int,
- int, int, int, int, int, int);
- extern void kill_window (win_handle *);
- extern void hide_window (win_handle *);
- extern int new_cursor (int);
- extern void win_set_curpos (win_handle *, int, int);
- extern void clearscreen (void);
- extern int link_array (win_handle *, char *, int, int, int, int);
- extern int scroll(win_handle *, int);
- extern int chattr (win_handle *, int, int, int, int, int, int);
- extern int winputch (win_handle *, int, int, char);
- extern void win_erase_region(win_handle *, int, int, int, int);
- extern int winstrlen(win_handle *, int, int);
- extern int cgainit (void);
-
- /* these are local and explained at their definitions */
- int optparse(unsigned char *, char *, char **, unsigned int, int, char**);
- int ffcopy( char * , char *) ;
- void read_defs( char *, int *, int);
- void limcheck(int *, int);
- int winprintstring( win_handle*, int, int, char*);
- int get_resp_line ( win_handle*, int, int, int, int, int *, int);
- int guess3(int*, void**, int);
- int graph (char*, win_handle *, char, char, char, void**, int, char*);
- void execute( int, int, int, int, void **);
- void benchhook( win_handle *, double *, int);
- int dump_defs( char *, int *, int);
- void calc_indexes (void**, int, int, int);
- void make_textres (void**, char*, int, int);
- void reviewmode(void **);
- void dump_array (char *, int, int, int);
- int alert_box( char*, int, int, int);
- int mod_default_box(char*, int, char*);
- int edit_string (win_handle *, int, int, int, char *, int, int);
- void controls_menu (void **);
- void ts_config (void);
- void sys_setup (void);
- int validpath(char *);
- int validfname(char *);
- struct help_handle *make_helpspace(char *, struct help_handle *);
- void kill_helpspace(struct help_handle *);
- int display_help (struct help_handle *, int);
- void edit_data(void**);
- char* dbrec2string( db_rec* , char *);
- void machtodb(db_rec **, char, struct mcfig *);
- int makeixgraphs(win_handle *, void**, int);
- int get_filename(int *, char *);
- void filedb(db_rec **);
- int batchgraph (void **, int);
- void switchlist(void);
- int delimres(void**);
-
- void main (int argc, char **argv)
- {
-
- /* local data */
- unsigned int acttime[3]; /* Elapsed time */
- int resp;
- int escflag=0;
- int i;
- int diskstat, breakflag;
-
- win_handle logo, menu;
-
- /*********************** real start ********************************/
-
- /* get command line args */
- strargs[0] = machname;
- strargs[1] = machname;
- strargs[2] = dumpfname;
-
- if (!optparse(options, valchar, strargs, 9, argc, argv)){
- printf(USAGESTRING);
- exit(0);
- }
-
- if(options[8]){
- switchlist();
- exit(0);
- }
-
- /* weed out bad switches */
- if((options[0]||options[1]) && !(strlen(machname))){
- printf(USAGESTRING);
- exit(0);
- }
- if(options[2] && (strlen(dumpfname))){
- if (!validpath(dumpfname)){
- printf(USAGESTRING);
- exit(0);
- }
- if (!validfname(dumpfname)){
- printf(USAGESTRING);
- exit(0);
- }
- }
-
- /* detect machine type and set parameters*/
- machine_detect(&machine_config);
- machine_config.dosnowplow=0;
- cgainit();
- if(machine_config.MHz > 16) durmin=FASTLIMIT;
- else{
- if (machine_config.MHz >8) durmin=MEDLIMIT;
- else durmin=SLOWLIMIT;
- }
-
- /* adjust timer */
- timeradjust=0;
- start_timer();
- stop_timer(acttime);
- timeradjust=acttime[0];
-
- /* set defaults */
- if(options[0] || options[1]){
- machname[14]=0;
- }
- else strcpy(machname,NAMEDEF);
-
- if(options[0]) options[2]=1;
-
- for(i=0;i<80;i++)
- dbtxname[i]=0;
- dbtxname[0]=(get_default()+'A');
- strcpy(dbtxname+1,":\\");
- getpath((int)(dbtxname[0]-'A'), dbtxname+3);
- if(dbtxname[strlen(dbtxname)-1]=='\\')
- dbtxname[strlen(dbtxname)-1]=0;
- if( !(options[2] && (strlen(dumpfname)) ) ){
- strcpy(dumpfname, dbtxname);
- strcat(dumpfname, "\\RESULTS");
- }
- strcat(dbtxname, "\\COMPAR.TBL");
-
- read_defs("bbdef.dat", tdef, 14);
-
- /* initialize comparison data */
- recs_in_db=init_db(18, comparison_data, "bbcomp.dat");
- strcpy(machine_config.machine_name,machname);
- recs_in_db=add_entry_db(18, recs_in_db, comparison_data, \
- machine_config.machine_name);
- machtodb(comparison_data, recs_in_db, &machine_config);
-
- /* initialize windows */
- field.made=logo.made=menu.made=help.made=0;
- cpuwin.made=cpu2win.made=fpuwin.made=diskwin.made=vidwin.made=0;
- textreswin.made=0;bswin.made=0;
-
- /* zap cursor */
- clearscreen();
- oldcurse=new_cursor(BLANK_CURSE);
-
- /* initialize help */
- make_helpspace("bbhelp.dat", &helptext);
-
- /* immediate runs? */
- if(options[7]||options[0])
- options[3]=options[4]=options[5]=options[6]=1;
- if(machine_config.fpu_type==0) options[4]=0;
- if(options[3]||options[4]||options[5]||options[6]){
- execute(options[3],options[4],options[5],options[6], \
- (void**) comparison_data);
- }
-
- /* make windows */
- mk_window(&field, NULL, 0, 0, 80, 26, BLUE, WHITE,
- BLUE, WHITE, 0, 1);
- mk_window(&logo, NULL, 41, 13, 76, 24, BLUE, WHITE,
- BLUE, GRAY, 0, 1);
- link_array(&logo, logoarray, 34, 9, 0, 0);
- mk_window(&menu, "Main Menu", 42, 1, 75, 14, CYAN, WHITE,
- CYAN, BLUE, 1, 1);
- winprintstring(&menu, 7, 0, " Run All Tests");
- winprintstring(&menu, 7, 2, " Run CPU Tests");
- winprintstring(&menu, 7, 4, " Run FPU Tests");
- winprintstring(&menu, 7, 6, " Run Disk Tests");
- winprintstring(&menu, 7, 8, " Run Video Tests");
- winprintstring(&menu, 7, 10, " Controls Menu ...");
- menu.num_valid=main_num_valid;
- menu.valid_lines=main_valid_lines;
- mk_window(&help, "Information", 5, 1, 37, 22, GREEN, WHITE,
- BLACK, GRAY, 1, 1);
-
- chattr(&field,0,23,78,1,WHITE,BLACK);
- winprintstring(&field, 5, 23, MENKEYLISTSTRING);
-
- /****** go into big loop ********/
- help_base=0;
- while(TRUE){
- display_help(&helptext,0);
- resp=get_resp_line(&menu, 0, 7, BLUE, WHITE, 0, 1);
- switch(resp){
- case -1: escflag=1;
- break;
- case 0:
- if(!(CPUSPECD||FPUSPECD||DISKSPECD||VIDSPECD)){
- alert_box(NTSTRING, 0, 0, 2);
- break;
- }
- BLANKSCREEN;
- execute(1, 1, 1, 1, \
- (void**) comparison_data);
- UNBLANKSCREEN;
- break;
- case 1:
- if(!CPUSPECD){
- alert_box(NTSTRING, 0, 0, 2);
- break;
- }
- BLANKSCREEN;
- execute(1, 0, 0, 0, \
- (void**) comparison_data);
- UNBLANKSCREEN;
- break;
- case 2:
- if(!FPUSPECD){
- alert_box(NTSTRING, 0, 0, 2);
- break;
- }
- if(machine_config.fpu_type!=0){
- BLANKSCREEN;
- execute(0, 1, 0, 0, \
- (void**) comparison_data);
- UNBLANKSCREEN;
- }
- else
- alert_box( \
- "Can't run tests. FPU Required.", \
- 0,0,3);
- break;
- case 3:
- if(!DISKSPECD){
- alert_box(NTSTRING, 0, 0, 2);
- break;
- }
- if(tdef[6]){ /* file i/o?*/
- breakflag=0;
- diskstat=disk_check(tdef[7], 1);
- while(diskstat==-1){
- if(!alert_box(DERRSTRING, \
- YESNO, 1, 3))
- breakflag=1;
- else
- diskstat=disk_check(tdef[7],1);
- if (breakflag) break;
- }
- if (breakflag) break;
- if(diskstat==0){
- if(!alert_box(IDSSTRING, \
- YESNO, 1, 3))
- break;
- if(!tdef[8]){
- alert_box(NTSTRING,0,0,2);
- break;
- }
- }
- }
- BLANKSCREEN;
- execute(0, 0, 1, 0, \
- (void**) comparison_data);
- UNBLANKSCREEN;
- break;
- case 4:
- if(!VIDSPECD){
- alert_box(NTSTRING, 0, 0,2);
- break;
- }
- BLANKSCREEN;
- execute(0, 0, 0, 1, \
- (void**) comparison_data);
- UNBLANKSCREEN;
- break;
- case 5:
- controls_menu((void**)comparison_data);
- winprintstring(&field, 5, 23,
- MENKEYLISTSTRING);
- break;
- }
- if(escflag) break;
- }
-
- /* close help */
-
- kill_helpspace(&helptext);
-
- /* close database */
- free_db(recs_in_db, comparison_data);
-
- /* put cursor back */
-
- clearscreen();
- new_cursor(oldcurse);
- }
-
- void benchhook( win_handle * winptr, double *resarray, int which)
- {
-
- unsigned int time[5][3];
- unsigned int iters[5];
- double temparray[5] = {0, 0, 0, 0, 0};
- unsigned long bytesr, bytesw;
- unsigned long testbytes;
- char passmess[13];
-
- int olddrive;
- int i, j, k;
-
- /* clear parameter arrays, and results array */
- for (i=0;i<5;i++){
- iters[i]=0;
- *(resarray+i)=0;
- for(j=0;j<3;j++)
- time[i][j]=0;
- }
-
-
- /* big loop number of repeat times */
-
- for(k=0;k<tdef[12];k++){
-
- oldlen=0; /* initialize the slidey bar */
-
- /* put up pass message */
- if((tdef[12]>1) && (which<10)){
- sprintf(passmess, "Pass %u", (k+1));
- win_erase_region(winptr, 72, 23, 7, 1);
- winprintstring(winptr, 72, 23, passmess);
- winprintstring(winptr, 39, 23, BARSTRING );
- chattr(winptr, 39, 23, 20, 1, BLACK, GREEN);
- }
-
- /* which test? */
-
- switch(which){
- case 0: /* sieve */
- sieve (winptr,tdef[which],time[0],iters);
- break;
- case 1: /* sort */
- sort (winptr,tdef[which],time[0],iters);
- break;
- case 2: /* imath */
- ifourbang (winptr,tdef[which],NIOPS, \
- time[0],iters);
- break;
- case 3: /* move */
- movetest(winptr, tdef[which],NKTOMOVE, \
- time, iters);
- break;
- case 4: /* fourbang */
- ffourbang (winptr,tdef[which],time[0],iters);
- break;
- case 5: /* fourier */
- fourier(winptr, tdef[which],time[0],iters);
- break;
- case 6: /* file i/o */
- testbytes=disk_check(tdef[7], 1);
- testbytes*=1024; /* convert to bytes */
-
- olddrive=get_default();
- set_default(tdef[7]-1);
-
- do_fileio(winptr,tdef[which],&bytesr, \
- &bytesw, time[0], time[1], \
- testbytes);
- temparray[0]=timetodouble(time[0]);
- temparray[0]=bytesr/(temparray[0]);
- temparray[0]/=1024; /* kbytes*/
- temparray[1]=timetodouble(time[1]);
- temparray[1]=bytesw/(temparray[1]);
- temparray[1]/=1024; /* kbytes*/
-
- set_default(olddrive);
-
- break;
-
- case 8: /* low level disk */
- ll_hdthru(tdef[9],HDTHITERS,temparray);
- adjust_bar(winptr, 1, 2);
- ll_diskseek(tdef[9], \
- temparray[0],temparray+1);
- adjust_bar(winptr, 2, 2);
- temparray[0]/=1024; /*kbytes*/
- temparray[1]*=1000; /*milliseconds */
- break;
-
- case 10: /* text */
- textbench(tdef[which],NTXCHARS,temparray);
- tscroll(tdef[which],NSCCHARS,temparray+1);
- break;
-
- case 11: /* graphics */
- graph_bench(tdef[which], temparray);
- if(temparray[0]==0)
- alert_box(MDASTRING, 0, 0,3);
- break;
- }
-
- /* test-specific adjustments */
- /* for cpu and fpu, convert to doubles, then iters per second */
- if(which<6){
- for(i=0;i<5;i++){
- if(iters[i]!=0){
- temparray[i]=timetodouble(time[i]);
- if(temparray[i]!=0)
- temparray[i]=iters[i]/(temparray[i]);
- }
- else
- temparray[i]=0;
- }
- }
- if(which==2)
- temparray[0] *= NIOPS;
-
- if(which==4)
- temparray[0] *= FFITERS;
-
- /* running average storage */
-
- for(i=0;i<5;i++){
- *(resarray+i)+=temparray[i];
- }
- }
-
- /* average */
-
- for(i=0;i<5;i++){
- *(resarray+i)/=tdef[12];
- }
-
- return;
-
- }
-
-
- winprintstring( win_handle* wpshand, int wpsx, int wpsy, char *wpsstring)
- /* window based string printer. given asciiz string, prints as many
- ** characters as will fit in window. returns number written.
- */
- {
-
- int i;
- char wpsch;
-
- for(i=0;1;i++,wpsx++){
- wpsch=*(wpsstring+i);
- if (wpsch==0) break;
- if (winputch (wpshand, wpsx, wpsy, wpsch)==0) break;
- }
-
- return i;
- }
-
- int get_resp_line ( win_handle* grlhand, int defaultline, int textoff,
- int grlbgc, int grlfgc, int *selecttype, int dohelp)
- /* get response line. given handle, returns user's selected line.
- ** default line is used first. -2 on error, -1 on escape.
- ** sellecttype determines whether the function returns intermediate
- ** results. sellecttype = null on input means don't return; if
- ** sellectype contains a non-null pointer, this function puts a type code ** in it.
- */
- {
-
- int i;
- int barlen;
- char grlch;
-
- if(defaultline>=(grlhand->num_valid)) return -2;
-
-
- /* clear all valid lines in window and determine def positions*/
- for(i=0; i!=grlhand->num_valid; i++){
- barlen=winstrlen(grlhand, textoff, \
- *((grlhand->valid_lines)+i));
- chattr(grlhand, textoff, *((grlhand->valid_lines)+i), \
- barlen, 1,0,0);
- }
-
- /* go into loop */
-
- i=defaultline;
- barlen=winstrlen(grlhand, textoff, *((grlhand->valid_lines)+i));
- chattr(grlhand, textoff, (int) *((grlhand->valid_lines)+i), \
- barlen, 1, grlbgc, grlfgc);
-
- while(TRUE){
- grlch=0;
- /* get a valid keystroke */
- do{
- barlen=winstrlen(grlhand, textoff, \
- *((grlhand->valid_lines)+i));
- grlch=getch();
- switch(grlch){
- case ENTER: /* These are the exits*/
- chattr(grlhand, textoff, \
- *((grlhand->valid_lines)+i), \
- barlen,1,0,0);
- if(selecttype!=NULL)
- *(selecttype)=1;
- return i;
- case ESC: if(selecttype!=NULL)
- *(selecttype)=1;
- return -1; /* exit 2 */
- case TAB: grlch=DOWNARROW;
- break;
- case CTRLW:
- case CTRLS:
- case CTRLD:
- if(selecttype==NULL) break;
- *(selecttype)=grlch;
- return i;
- case 0: grlch=getch();
- switch(grlch){
- case UPARROW:
- case DOWNARROW:
- case LEFTARROW:
- case RIGHTARROW:
- case CTRLRA:
- case CTRLLA:
- case INS:
- case DEL:
- case PGUP:
- case PGDOWN: break;
-
- default: grlch=0;
- break;
- }
- break;
-
- default: grlch=0;
- break;
- }
- } while(!grlch);
-
- switch(grlch){
-
- case PGUP:
- case PGDOWN:
- if (dohelp)
- scroll(&help, (int)(grlch==PGUP));
- break;
- case UPARROW:
- case DOWNARROW:
- chattr(grlhand, textoff, \
- (int)*((grlhand->valid_lines)+i), \
- barlen, 1,0,0);
-
- if(grlch==UPARROW)
- i=(i==0)? (grlhand->num_valid)-1 : --i;
- else
- i=(i==((grlhand->num_valid)-1))? 0: ++i;
- barlen=winstrlen(grlhand, textoff, \
- *((grlhand->valid_lines)+i));
- chattr(grlhand, textoff, \
- (int)*((grlhand->valid_lines)+i), \
- barlen, 1, grlbgc, grlfgc);
- if(dohelp)
- display_help(&helptext, help_base+i);
- break;
- /* intermediate*/ case LEFTARROW:
- /* exits */ case RIGHTARROW:
- case CTRLRA:
- case CTRLLA:
- case INS:
- case DEL:
- if(selecttype==NULL) break;
- *(selecttype)=grlch;
- return i;
- }
- }
-
- return 0; /* keeps the compiler happy */
- }
-
- int guess3(int* res_array, void** listptr, int s_off)
- /*
- ** function returns four offsets in array; best baseline, next two, current.
- ** if three comparisons are unavailable, puts -1 in place.
- ** s_off is the offset within structure of the test to guess on (test
- ** values are always stored as doubles). returns new current value.
- */
- {
- int curroff;
- int baseline;
- int pick[2];
- int bascrit;
- int i,j;
-
- /* check if current machine has values for this test */
- curroff=lin_search_db(0, recs_in_db-1, listptr, \
- offset_in_struc(db_rec,currflag), INTCODE, 1);
-
- if(*((double*)((char*)(*(listptr+curroff))+s_off))!=0){
- /* sort on this test */
- sort_db(recs_in_db, listptr, s_off, FLOATCODE);
- }
- else{
- /* sort on processor */
- sort_db(recs_in_db, listptr, offset_in_struc(db_rec, proc), \
- INTCODE);
- }
-
- /* relocate current pointer */
-
- curroff=lin_search_db(0, recs_in_db-1, listptr, \
- offset_in_struc(db_rec,currflag), INTCODE, 1);
-
- /* find nearest baseline */
-
- bascrit=(machine_config.proc_type>286)? 3 : 2;
- baseline=lin_search_db(0, recs_in_db-1, listptr, \
- offset_in_struc(db_rec,basenum), INTCODE, bascrit);
-
- pick[0]=lin_search_db(0, recs_in_db-1, listptr, \
- offset_in_struc(db_rec,comp), INTCODE, 1);
- pick[1]=lin_search_db(0, recs_in_db-1, listptr, \
- offset_in_struc(db_rec,comp), INTCODE, 2);
-
- /* find nearest two that have run test */
-
- if(pick[1]<0){
- for(i=curroff+1, j=curroff-1; (i<(int)recs_in_db)||(j>=0); \
- i++, j--){
- if((i<(int)recs_in_db) && i!=baseline){
- if(*((double*)((char *)(*(listptr+i))+s_off))!=0){
- if(pick[0]!=-1){
- pick[1]=i;
- break;
- }
- pick[0]=i;
- }
- }
- if((j>=0) && j!=baseline){
- if(*((double*)((char *)(*(listptr+j))+s_off))!=0){
- if(pick[0]!=-1){
- pick[1]=j;
- break;
- }
- pick[0]=j;
- }
- }
- }
- }
-
- /* avoid stupidity */
-
- pick[0]= (pick[0]==curroff)? -1 : pick[0];
- pick[1]= (pick[1]==curroff)? -1 : pick[1];
- pick[0]= (pick[0]==baseline)? -1 : pick[0];
- pick[1]= (pick[1]==baseline)? -1 : pick[1];
-
- pick[1]= (pick[0]==pick[1]) ? -1 : pick[1];
-
- if(pick[0]==-1){
- pick[0]=pick[1];
- pick[1]=-1;
- }
-
- *(res_array)=curroff;
- *(res_array+1)=pick[0];
- *(res_array+2)=pick[1];
- *(res_array+3)=baseline;
-
- return curroff;
- }
-
- int graph (char* tname, win_handle *winname, char xoff, char yoff, char w, \
- void** listptr,int s_off, char* leglabel)
- /*
- ** draws a four line graph at xoff, yoff, w chars wide. s_off is the
- ** structure offset of the test in *listptr. Returns current offset.
- */
- {
- int retval;
- int i, j, k;
- int ns_off;
- int umultlog;
- double linval[4];
- double graffact, umult;
- double linelen;
-
- int decpos, signpos;
-
- char linlab[6];
- char *tempstring;
- char umstring[7];
- int lincolor[4];
- int bar[4];
-
- /* do guess */
- retval=guess3(bar, listptr, s_off);
-
- /* define colors */
-
- lincolor[0]=LT_CYAN;
- lincolor[1]=PINK;
- lincolor[2]=YELLOW;
- lincolor[3]=LT_GREEN;
-
- /* clear graph region */
- win_erase_region(winname,(int)xoff,(int)yoff,(int) w+1,10);
-
- /* truncate test name and legend label if too big */
- if(strlen(tname)>(size_t)(w-(NAMESPACE+1)))
- *(tname+(w-NAMESPACE))=0;
- if(strlen(leglabel)>(size_t)(w-7))
- *(leglabel+(w-6))=0;
-
- /* print out name of test*/
- winprintstring(winname, xoff+NAMESPACE+1, yoff, tname);
-
- /* write names of machines, get linevalues */
- ns_off=offset_in_struc(db_rec,name);
- i=yoff+1;
- graffact=0;
-
- for(j=0;j<4;j++){
- if(*(bar+j)!=-1){
- winprintstring(winname, \
- xoff+NAMESPACE- \
- strlen(((char*)(*(listptr+(*(bar+j))))+ns_off)), \
- i, ((char*)(*(listptr+(*(bar+j))))+ns_off));
- linval[j]=*((double *) \
- ((char *)(*(listptr+(*(bar+j))))+s_off));
- graffact=(graffact>linval[j])?graffact:linval[j];
- i+=2;
- }
- }
-
- /* figure units conversion */
- umult=1;
- umultlog=0;
-
- /* unruly units? */
- if((graffact>=1000) || (graffact<1)){
-
- /* make scientific notation */
- while (graffact>=10){
- graffact/=10;
- umult*=10;
- umultlog++;
- }
- while ((graffact<1) && (graffact>0)){
- graffact*=10;
- umult/=10;
- umultlog--;
- }
- for(j=0;j<4;j++)
- linval[j]/=umult;
- }
- if(umultlog==0) strcpy(umstring, " ");
- else sprintf(umstring, "x10^%d", umultlog);
-
- /* draw axis line */
- for(j=yoff+1; j<=(i-2); j++)
- winputch(winname, xoff+NAMESPACE, j, 0x0b4);
-
- /* create labels, draw graphs */
-
- i=yoff+1;
- for(j=0;j<4;j++){
- if(*(bar+j)!=-1){
-
- if(linval[j]<=0){
- winprintstring(winname, xoff+NAMESPACE+1, \
- i, " N/A");
- i+=2;
- continue;
- }
- tempstring=fcvt(linval[j], 6, &decpos, &signpos);
-
- if(decpos<0){
- *(linlab)='.';
- for(k=1;(k<=(-decpos))&&(k<5);k++)
- *(linlab+k)='0';
- for(;k<5;k++,tempstring++)
- *(linlab+k)=*(tempstring);
- }
- else{
- strncpy(linlab, tempstring, decpos);
- *(linlab+decpos)='.';
- for(k=decpos+1;k<5;k++)
- *(linlab+k)=*(tempstring+(k-1));
- *(linlab+k)=0;
- }
-
- linelen = floor((w-(NAMESPACE+6))*linval[j]);
- if(graffact) linelen/=graffact;
- for(k=1;k<=(int)linelen;k++)
- winputch(winname, xoff+NAMESPACE+k, i, 0x0db);
- chattr(winname, xoff+NAMESPACE+1,i, (int)linelen,1,
- BLACK, lincolor[j]);
- winprintstring(winname, xoff+NAMESPACE+k, i, linlab);
- i+=2;
- }
- }
-
- winprintstring(winname, xoff+1, i, leglabel);
- winprintstring(winname, xoff+1+strlen(leglabel), i, umstring);
-
- return retval;
-
- }
-
- void read_defs ( char * defilname, int * defarray, int numtests)
- /*
- ** Looks for default settings file on disk. Reads results into defarray
- ** if found.
- */
- {
- int deffh;
-
- deffh=open(defilname, O_BINARY|O_RDONLY);
-
- if(deffh==-1)
- return;
-
- read(deffh, (char*) defarray, numtests*(sizeof(int)));
- limcheck(defarray, numtests-1);
-
- close(deffh);
- return;
- }
- int dump_defs ( char * defilname, int * defarray, int numtests)
- /*
- ** writes defarray to defilname. Returns zero on error.
- */
- {
- int deffh;
-
- deffh=open(defilname, O_TRUNC|O_WRONLY|O_BINARY|O_CREAT, S_IWRITE);
-
- numtests*=sizeof(int);
-
- if (deffh==-1)
- return 0;
- if( write(deffh, (char *) defarray, numtests) < numtests){
- close(deffh);
- return 0;
- }
-
- close(deffh);
- return 1;
- }
-
- void limcheck(int * d_a, int numtests)
- /*
- ** fixes limits according to speed
- ** if less than minimum, go to zero.
- */
- {
- int i;
- int imin, imax;
- int minval;
-
-
- for(i=0;i<numtests;i++){
- switch(i){
- case 6: imin=60;
- imax=durmax;
- if(*(d_a+i)==1)
- minval=imin;
- else minval=0;
- break;
- case 7: imin=minval=1;
- imax=26;
- break;
- case 8: imin=minval=0;
- imax=1;
- break;
- case 9: imin=minval=-1;
- imax=(machine_config.num_hard-1);
- break;
- case 12: imin=minval=1;
- imax=durmax;
- break;
- default: imin=durmin;
- imax=durmax;
- if(*(d_a+i)==1)
- minval=imin;
- else minval=0;
- }
- *(d_a+i)=(*(d_a+i)<imin) ? minval : *(d_a+i);
- *(d_a+i)=(*(d_a+i)>imax) ? imax : *(d_a+i);
- }
-
- /* if invalid hard disk, no hard disk tests */
- if (*(d_a+9) < 0) *(d_a+8)=0;
- }
-
- void execute( int docpu, int dofpu, int dodisk, int dovideo, \
- void** listptr)
- /* Executes benchmarks. Parameters passed in are flags for the
- ** tests to do. Execute builds display windows, hides them, and chains
- ** to review_mode when done.
- */
-
- {
- double tval[5];
- int curval;
- unsigned long tm0, tm1;
-
-
- /* first update the current name */
- curval=lin_search_db(0, recs_in_db-1,listptr, \
- offset_in_struc(db_rec,currflag), INTCODE, 1);
- update_db(curval, listptr, offset_in_struc(db_rec, name), \
- CHARPTRCODE, (int) machine_config.machine_name);
-
- /* update processor record */
- lastproc=machine_config.proc_type;
-
- if(docpu&& CPUSPECD){
- kill_window(&cpuwin);
- mk_window(&cpuwin,"CPU Tests", 0, 0, 82, 27, BLACK, WHITE,
- BLACK, WHITE, 0, 0);
-
- /* guess and graph the screens */
- curval=batchgraph(listptr, 1);
-
- if(tdef[0]){
- win_erase_region(&cpuwin, 0, 23, 79, 1);
- winprintstring(&cpuwin, 40-strlen("Running Sieve: "), \
- 23, "Running Sieve: ");
- winprintstring(&cpuwin, 39, 23, BARSTRING );
- chattr(&cpuwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&cpuwin, tval, 0);
-
- update_db(curval,listptr, offset_in_struc(db_rec, sieveres), \
- FLOATCODE, tval[0]);
- curval= \
- graph("BYTE Sieve",&cpuwin, 0, 1, 39, listptr, \
- offset_in_struc(db_rec, sieveres), \
- "Iterations per second ");
- }
-
- if(tdef[1]){
- win_erase_region(&cpuwin, 0, 23, 79, 1);
- winprintstring(&cpuwin, 40-strlen("Running Sort: "), \
- 23, "Running Sort: ");
- winprintstring(&cpuwin, 39, 23, BARSTRING );
- chattr(&cpuwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&cpuwin, tval, 1);
-
- update_db(curval,listptr, offset_in_struc(db_rec, sortres), \
- FLOATCODE, tval[0]);
- curval= \
- graph("BYTE Sort",&cpuwin, 40, 1, 39, listptr, \
- offset_in_struc(db_rec, sortres), \
- "Iterations per second ");
- }
- if(tdef[2]){
- win_erase_region(&cpuwin, 0, 23, 79, 1);
- winprintstring(&cpuwin, 40-strlen("Running Int. Math: "), \
- 23, "Running Int. Math: ");
- winprintstring(&cpuwin, 39, 23, BARSTRING );
- chattr(&cpuwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&cpuwin, tval, 2);
-
- update_db(curval,listptr, offset_in_struc(db_rec, imathres), \
- FLOATCODE, tval[0]);
- curval= \
- graph("BYTE Int. Math",&cpuwin, 0, 12, 39, listptr, \
- offset_in_struc(db_rec, imathres), \
- "Iterations per second ");
- }
- if(tdef[3]){
- win_erase_region(&cpuwin, 0, 23, 79, 1);
- winprintstring(&cpuwin, 40-strlen("Running String Move: "), \
- 23, "Running String Move: ");
- winprintstring(&cpuwin, 39, 23, BARSTRING );
- chattr(&cpuwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&cpuwin, tval, 3);
-
- update_db(curval,listptr, offset_in_struc(db_rec, movbres), \
- FLOATCODE, tval[0]);
- update_db(curval,listptr, offset_in_struc(db_rec, movwores), \
- FLOATCODE, tval[1]);
- update_db(curval,listptr, offset_in_struc(db_rec, movweres), \
- FLOATCODE, tval[2]);
- update_db(curval,listptr, offset_in_struc(db_rec, movdores), \
- FLOATCODE, tval[3]);
- update_db(curval,listptr, offset_in_struc(db_rec, movderes), \
- FLOATCODE, tval[4]);
-
- curval=\
- graph("BYTE Byte-wide Move",&cpuwin, 40, 12, 39, listptr, \
- offset_in_struc(db_rec, movbres), \
- "Iterations per second ");
- }
- hide_window(&cpuwin);
- }
-
- if(docpu&& SMOVESPECD){
- kill_window(&cpu2win);
- mk_window(&cpu2win,"String Move Tests", 0, 0, 82, 27, BLACK, WHITE,
- BLACK, WHITE, 0, 0);
-
- /* graph the second batch of screens */
-
- win_erase_region(&cpu2win, 0, 23, 79, 1);
- winprintstring(&cpu2win, 40-(strlen(WINPAUSESTRING)>>1), \
- 23, WINPAUSESTRING);
- chattr(&cpu2win, 10, 23, 50, 1, BLACK, CYAN);
-
- curval=batchgraph(listptr, 2);
-
- /* to keep from being so jarring */
- tm0=clock();
- do{
- tm1=clock();
- } while((tm1-tm0)<(5*CLK_TCK));
-
-
- hide_window(&cpu2win);
- }
-
-
- if(dofpu&& FPUSPECD &&(machine_config.fpu_type!=0)){
- kill_window(&fpuwin);
- mk_window(&fpuwin,"FPU Tests", 0, 0, 82, 27, BLACK, WHITE,
- BLACK, WHITE, 0, 0);
-
- /* guess and graph the screens */
-
- curval=batchgraph(listptr,3);
-
- if(tdef[4]){
- win_erase_region(&fpuwin, 0, 23, 79, 1);
- winprintstring(&fpuwin, 40-strlen("Running Fmath: "), \
- 23, "Running Fmath: ");
- winprintstring(&fpuwin, 39, 23, BARSTRING );
- chattr(&fpuwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&fpuwin, tval, 4);
-
- update_db(curval,listptr,offset_in_struc(db_rec,fourbangres),
- FLOATCODE, tval[0]);
- curval= \
- graph("BYTE Fmath",&fpuwin, 0, 1, 78, listptr, \
- offset_in_struc(db_rec, fourbangres), \
- "Iterations per second ");
- }
-
- if(tdef[5]){
- win_erase_region(&fpuwin, 0, 23, 79, 1);
- winprintstring(&fpuwin, 40-strlen("Running Fourier: "), \
- 23, "Running Fourier: ");
- winprintstring(&fpuwin, 39, 23, BARSTRING );
- chattr(&fpuwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&fpuwin, tval, 5);
-
- update_db(curval,listptr, offset_in_struc(db_rec, forres), \
- FLOATCODE, tval[0]);
- curval= \
- graph("BYTE Fourier",&fpuwin, 0, 12, 78, listptr, \
- offset_in_struc(db_rec, forres), \
- "Iterations per second ");
- }
- hide_window(&fpuwin);
- }
-
- if(dodisk && DISKSPECD && (tdef[8] || (disk_check(tdef[7], 1)>0) ) ){
- kill_window(&diskwin);
- mk_window(&diskwin,"Disk Tests", 0, 0, 82, 27, BLACK, WHITE,
- BLACK, WHITE, 0, 0);
-
- /* guess and graph the screens */
- curval=batchgraph(listptr, 4);
-
-
- if(tdef[6]){
- win_erase_region(&diskwin, 0, 23, 79, 1);
- winprintstring(&diskwin, 40-strlen("Running File I/O: "), \
- 23, "Running File I/O: ");
- winprintstring(&diskwin, 39, 23, BARSTRING );
- chattr(&diskwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&diskwin, tval, 6);
-
- update_db(curval,listptr,offset_in_struc(db_rec,fiorres),
- FLOATCODE, tval[0]);
- update_db(curval,listptr,offset_in_struc(db_rec,fiowres),
- FLOATCODE, tval[1]);
- graph("BYTE File I/O Read",&diskwin, 0, 1, 39, listptr, \
- offset_in_struc(db_rec, fiorres), \
- "Kilobytes per second ");
- curval= \
- graph("BYTE File I/O Write",&diskwin, 40, 1, 39, listptr, \
- offset_in_struc(db_rec, fiowres), \
- "Kilobytes per second ");
- }
-
- if(tdef[8]){
- win_erase_region(&diskwin, 0, 23, 79, 1);
- winprintstring(&diskwin, 40-strlen("Running Low-Levels: "), \
- 23, "Running Low-Levels: ");
- winprintstring(&diskwin, 39, 23, BARSTRING );
- chattr(&diskwin, 39, 23, 20, 1, BLACK, GREEN);
-
- benchhook(&diskwin, tval, 8);
-
- update_db(curval,listptr,offset_in_struc(db_rec, tpres), \
- FLOATCODE, tval[0]);
- update_db(curval,listptr,offset_in_struc(db_rec, seekres), \
- FLOATCODE, tval[1]);
-
- graph("BYTE Throughput",&diskwin, 0, 12, 39, listptr, \
- offset_in_struc(db_rec, tpres), \
- "Kilobytes per second ");
- curval= \
- graph("BYTE Seek Test",&diskwin, 40, 12, 39, listptr, \
- offset_in_struc(db_rec, seekres), \
- "Milliseconds ");
- }
- hide_window(&diskwin);
- }
-
- if(dovideo && VIDSPECD){
-
- curval=lin_search_db(0, recs_in_db-1, listptr, \
- offset_in_struc(db_rec,currflag), INTCODE, 1);
-
- if(tdef[10]){
- benchhook(&vidwin, tval, 10);
- update_db(curval,listptr, offset_in_struc(db_rec, txposres), \
- FLOATCODE, tval[0]);
- update_db(curval,listptr,offset_in_struc(db_rec,txscrollres),
- FLOATCODE, tval[1]);
- }
- if(tdef[11]){
- benchhook(&vidwin, tval, 11);
- update_db(curval,listptr, offset_in_struc(db_rec, graphres), \
- FLOATCODE, tval[0]);
- }
-
- /* clean up after video tests*/
- clearscreen();
- new_cursor(BLANK_CURSE);
-
- kill_window(&vidwin);
- mk_window(&vidwin,"Video Tests", 0, 0, 82, 27, BLACK, WHITE,
- BLACK, WHITE, 0, 0);
-
- win_erase_region(&vidwin, 0, 23, 79, 1);
- winprintstring(&vidwin, 40-(strlen(WINPAUSESTRING)>>1), \
- 23, WINPAUSESTRING);
- chattr(&vidwin, 10, 23, 50, 1, BLACK, CYAN);
-
- /* guess and graph the screens */
- curval=batchgraph(listptr, 5);
-
- /* to keep from being so jarring */
- tm0=clock();
- do{
- tm1=clock();
- } while((tm1-tm0)<(5*CLK_TCK));
-
- hide_window(&vidwin);
- }
-
- if(options[0]) delimres(listptr);
-
- staleflag=1;
- reviewmode(listptr);
- }
-
- void make_textres (void** lp, char* aryptr, int trh, int trw)
-
- /*
- ** Creates text array (suitable for file-dumping) in memory. This
- ** routine is hard-wired for the current structure definition. Any
- ** changes to the record structure will make modifying this routine
- ** neccesary.
- */
- {
-
- #define linmem(col,string) sprintf((aryptr+a_off)+col, string);a_off+=trw
- #define prinmem(col,string) sprintf((aryptr+a_off)+col, string)
- #define linvmem(col,str,val) if(val) sprintf((aryptr+a_off)+col,str,val); else sprintf((aryptr+a_off)+col," N/A");a_off+=trw
-
- int co, i286off, i386off, curo;
- int comps[4];
- int c1off;
- int c2off;
-
- int a_off, offcol, cl, i;
-
- /* find two suitable compares, and current */
- co=guess3(comps, lp, offset_in_struc(db_rec, proc));
-
- c1off=c2off=-1;
-
- /* get two unique, non -1 compares */
- for(i=1;i<4;i++){
- if(comps[i] <0) continue;
- c1off=comps[i];
- break;
- }
- for(i++ ; i<4; i++){
- if(comps[i] <0) continue;
- c2off=comps[i];
- break;
- }
-
- /* find 286 baseline */
- i286off=lin_search_db(0, recs_in_db-1, lp, \
- offset_in_struc(db_rec,basenum), INTCODE, 2);
-
- /* find 386 baseline */
- i386off=lin_search_db(0, recs_in_db-1, lp, \
- offset_in_struc(db_rec,basenum), INTCODE, 3);
-
- /* calculate indices */
- calc_indexes (lp, co, i286off, i386off);
-
- /****** print report to memory ******/
- /* clear array*/
- for(i=0;i<(trw*trh);i++)
- *(aryptr+i)=0;
-
- /* heading column */
- a_off=0;
- linmem(1,DOUBBAR);
- linmem(1,"BYTE DOS Benchmarks -- Version 2.1");
- linmem(1,DOUBBAR);
- linmem(1," ");
- linmem(1," ");
-
- if(cpuwin.made){
- linmem(0," ");
- linmem(1, "CPU Tests");
- if( vf(co,sieveres) ){
- prinmem(1, " Sieve:");
- linmem(70, "ips.");
- }
- if( vf(co,sortres) ){
- prinmem(1, " Sort:");
- linmem(70, "ips.");
- }
- if( vf(co,imathres) ){
- prinmem(1, " Integer Math:");
- linmem(70, "ips.");
- }
- if( vf(co,movbres) ){
- prinmem(1, " Move (byte):");
- linmem(70, "ips.");
- }
- if( vf(co,movwores) ){
- prinmem(1, " Move (word-odd):");
- linmem(70, "ips.");
- }
- if( vf(co,movweres) ){
- prinmem(1, " Move (word-even):");
- linmem(70, "ips.");
- }
- if( vf(co,movdores) ){
- prinmem(1, " Move (Dword-odd):");
- linmem(70, "ips.");
- }
- if( vf(co,movderes) ){
- prinmem(1, "Move (Dword-even):");
- linmem(70, "ips.");
- }
- linmem(1,SINGBAR);
- if(i286off>=0){
- linmem(1, "CPU Index (AT Class):");
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linmem(1, "CPU Index (386 Class):");
- }
- linmem(1,SINGBAR);
- }
- if(fpuwin.made){
- linmem(0," ");
- linmem(1, "FPU Tests");
- if( vf(co,fourbangres) ){
- prinmem(1, " Fmath:");
- linmem(70, "ips.");
- }
- if( vf(co,forres) ){
- prinmem(1, " Fourier:");
- linmem(70, "ips.");
- }
- linmem(1,SINGBAR);
- if(i286off>=0){
- linmem(1, "FPU Index (AT Class):");
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linmem(1, "FPU Index (386 Class):");
- }
- linmem(1,SINGBAR);
- }
- if(diskwin.made){
- linmem(0," ");
- linmem(1, "Disk Tests");
- if( vf(co,fiorres) ){
- prinmem(1, " File I/O Read:");
- linmem(69, "KBps.");
- }
- if( vf(co,fiowres) ){
- prinmem(1, " File I/O Write:");
- linmem(69, "KBps.");
- }
- if( vf(co,tpres) ){
- prinmem(1, " Throughput Test:");
- linmem(69, "KBps.");
- }
- if( vf(co,seekres) ){
- prinmem(1, " Seek Time:");
- linmem(70, " ms.");
- }
- linmem(1,SINGBAR);
- if(i286off>=0){
- linmem(1, "Disk Index (AT Class):");
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linmem(1, "Disk Index (386 Class):");
- }
- linmem(1,SINGBAR);
- }
- if(vidwin.made){
- linmem(0," ");
- linmem(1, "Video Tests");
- if( vf(co,txposres) ){
- prinmem(1, " Text Display:");
- linmem(70, "ips.");
- }
- if( vf(co,txscrollres) ){
- prinmem(1, " Scroll:");
- linmem(70, "ips.");
- }
- if( vf(co,graphres) ){
- prinmem(1, " Graphics:");
- linmem(70, "ips.");
- }
- linmem(1,SINGBAR);
- if(i286off>=0){
- linmem(1, "Video Index (AT Class):");
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linmem(1, "Video Index (386 Class):");
- }
- linmem(1,SINGBAR);
- }
-
- /* footnote */
- linmem(1, " ");
- if(vf(co, seekres)){
- linmem(1,"NOTE: For all tests except disk seek time,");
- }
- else {
- linmem(1,"NOTE: For all tests and all indexes,");
- }
- linmem(1, "higher numbers indicate better performance.");
- linmem(1, " ");
- linmem(1, "AT Class indexes show performance relative to an");
- prinmem(1, "8 MHz IBM PC-AT.");
- if(machine_config.proc_type>286){
- linmem(19, "386-Class indexes are calculated");
- linmem(1, "relative to a Compaq 386/20.");
- }
- else{
- linmem(19, " ");
- }
- linmem(1, " ");
- prinmem(1, "Key:");
- if(cpuwin.made || fpuwin.made || vidwin.made){
- linmem(7,"ips.=iterations per second");
- }
- if(diskwin.made){
- linmem(7,"KBps.=kilobytes per second");
- }
- if(vf(co, seekres)){
- linmem(7,"ms.=milliseconds ");
- }
-
- /* now calculate actual array height*/
- ac_t_h=a_off/trw;
-
- /* print results columns */
-
- for(i=0;i<3;i++){
- /**** test machine pass *****/
- if(i==0){
- cl=30; curo=co;
- }
- /**** first compare pass *****/
- if(i==1){
- if(c1off<0) continue;
- cl=45; curo=c1off;
- }
- /**** second compare pass *****/
- if(i==2){
- if(c2off<0) continue;
- cl=60; curo=c2off;
- }
-
- /** the following is a sort-of macro for printing these columns */
-
- /* print name */
- a_off=trw*4;
- offcol=cl-strlen(((char *)(*(lp+curo)) \
- +offset_in_struc(db_rec,name)))/2;
- strcpy((aryptr+a_off+offcol), \
- ((char*)(*(lp+curo))+offset_in_struc(db_rec,name)));
- a_off+=trw;
-
- offcol=cl-2;
-
- if(cpuwin.made){
- a_off+=trw<<1;
- if(vf(co, sieveres)){
- linvmem(offcol, "%6.2f", vf(curo, sieveres));
- }
- if(vf(co, sortres)){
- linvmem(offcol, "%6.2f", vf(curo, sortres));
- }
- if(vf(co, imathres)){
- linvmem(offcol, "%6.2f", vf(curo, imathres));
- }
- if(vf(co, movbres)){
- linvmem(offcol, "%6.2f", vf(curo, movbres));
- }
- if(vf(co, movwores)){
- linvmem(offcol, "%6.2f", vf(curo, movwores));
- }
- if(vf(co, movweres)){
- linvmem(offcol, "%6.2f", vf(curo, movweres));
- }
- if(vf(co, movdores)){
- linvmem(offcol, "%6.2f", vf(curo, movdores));
- }
- if(vf(co, movderes)){
- linvmem(offcol, "%6.2f", vf(curo, movderes));
- }
- a_off+=trw;
- if(i286off>=0){
- linvmem(offcol, "%6.2f", vf(curo, cpuat));
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linvmem(offcol, "%6.2f", vf(curo, cpu386));
- }
- a_off+=trw;
- }
-
- if(fpuwin.made){
- a_off+=trw<<1;
- if(vf(co, fourbangres)){
- linvmem(offcol, "%6.2f", vf(curo, fourbangres));
- }
- if(vf(co, forres)){
- linvmem(offcol, "%6.2f", vf(curo, forres));
- }
- a_off+=trw;
- if(i286off>=0){
- linvmem(offcol, "%6.2f", vf(curo, fpuat));
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linvmem(offcol, "%6.2f", vf(curo, fpu386));
- }
- a_off+=trw;
- }
-
- if(diskwin.made){
- a_off+=trw<<1;
- if(vf(co, fiorres)){
- linvmem(offcol, "%6.2f", vf(curo, fiorres));
- }
- if(vf(co, fiowres)){
- linvmem(offcol, "%6.2f", vf(curo, fiowres));
- }
- if(vf(co, tpres)){
- linvmem(offcol, "%6.2f", vf(curo, tpres));
- }
- if(vf(co, seekres)){
- linvmem(offcol, "%6.2f", vf(curo, seekres));
- }
- a_off+=trw;
- if(i286off>=0){
- linvmem(offcol, "%6.2f", vf(curo, diskat));
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linvmem(offcol, "%6.2f", vf(curo, disk386));
- }
- a_off+=trw;
- }
-
- if(vidwin.made){
- a_off+=trw<<1;
- if(vf(co, txposres)){
- linvmem(offcol, "%6.2f", vf(curo, txposres));
- }
- if(vf(co, txscrollres)){
- linvmem(offcol, "%6.2f", vf(curo, txscrollres));
- }
- if(vf(co, graphres)){
- linvmem(offcol, "%6.2f", vf(curo, graphres));
- }
- a_off+=trw;
- if(i286off>=0){
- linvmem(offcol, "%6.2f", vf(curo, videoat));
- }
- if((machine_config.proc_type>286) && (i386off>=0)){
- linvmem(offcol, "%6.2f", vf(curo, video386));
- }
- a_off+=trw;
-
- }
- }
-
- }
-
- void calc_indexes (void** lp, int co, int i286_off, int i386_off)
- /*
- ** Calculates indexes. base_off is the location of the baseline in the
- ** database. co is the subject. This routine also updates the database.
- */
- {
- double cpuindex,fpuindex,diskindex,videoindex;
- double k,x;
- int i,j;
- int l;
- int base_off;
-
- /* see if 386 is appropriate */
- if(machine_config.proc_type<386) i386_off=-1;
-
- /* Indexes are calculated by normalizing the results of
- each test against the corresponding baseline test, then
- taking the geometric mean of these normalized results in
- each category (cpu, fpu, etc.) */
-
- /* calculate */
- l=-1;
- while(l<1){
- l++;
- if(l) base_off=i386_off;
- else base_off=i286_off;
-
- if(base_off<0) continue;
-
- cpuindex=0;
- if(cpuwin.made){
- /* cpu */
- for(i=0, j=0;i<8;i++){
- k=*((double*)((char*)(*(lp+co))+ \
- (offset_in_struc(db_rec,sieveres) \
- +(sizeof(double)*i))));
- x=*((double*)((char*)(*(lp+base_off))+ \
- (offset_in_struc(db_rec,sieveres) \
- +((sizeof(double))*i))));
- if(k&&x){ /*x could be zero if this is a 286**/
- j++;
- cpuindex+=log10(k/x);
- }
- }
- cpuindex=pow(10,(cpuindex/j));
- }
-
- fpuindex=0;
- if(fpuwin.made){
- /* fpu */
- for(i=0, j=0;i<2;i++){
- k=*((double*)((char*)(*(lp+co))+ \
- (offset_in_struc(db_rec,fourbangres)+ \
- ((sizeof(double))*i))));
- x=*((double*)((char*)(*(lp+base_off))+ \
- (offset_in_struc(db_rec,fourbangres)+ \
- ((sizeof(double))*i))));
- if(k){
- j++;
- fpuindex+=log10(k/x);
- }
- }
- fpuindex=pow(10,(fpuindex/j));
- }
-
- diskindex=0;
- if(diskwin.made){
- /* disk */
- for(i=0, j=0;i<4;i++){
- k=*((double *)((char*)(*(lp+co))+ \
- (offset_in_struc(db_rec,fiorres)+ \
- ((sizeof(double))*i))));
- x=*((double *)((char*)(*(lp+base_off))+ \
- (offset_in_struc(db_rec,fiorres)+ \
- ((sizeof(double))*i))));
- if(k){
- j++;
- if(i!=3)
- diskindex+=log10(k/x);
- else /* seek time: lower is better */
- diskindex+=log10(x/k);
- }
- }
- diskindex=pow(10,(diskindex/j));
- }
-
- videoindex=0;
- if(vidwin.made){
- /* video */
- for(i=0, j=0;i<3;i++){
- k=*((double*)((char*)(*(lp+co))+ \
- (offset_in_struc(db_rec,txposres)+ \
- ((sizeof(double))*i))));
- x=*((double*)((char*)(*(lp+base_off))+ \
- (offset_in_struc(db_rec,txposres)+ \
- ((sizeof(double))*i))));
- if(k){
- j++;
- videoindex+=log10(k/x);
- }
- }
- videoindex=pow(10,(videoindex/j));
- }
-
-
- if(l){
- update_db(co,lp, offset_in_struc(db_rec, cpu386), \
- FLOATCODE, cpuindex);
- update_db(co,lp, offset_in_struc(db_rec, fpu386), \
- FLOATCODE, fpuindex);
- update_db(co,lp, offset_in_struc(db_rec, disk386), \
- FLOATCODE, diskindex);
- update_db(co,lp, offset_in_struc(db_rec, video386), \
- FLOATCODE, videoindex);
- }
- else{
- update_db(co,lp, offset_in_struc(db_rec, cpuat), \
- FLOATCODE, cpuindex);
- update_db(co,lp, offset_in_struc(db_rec, fpuat), \
- FLOATCODE, fpuindex);
- update_db(co,lp, offset_in_struc(db_rec, diskat), \
- FLOATCODE, diskindex);
- update_db(co,lp, offset_in_struc(db_rec, videoat), \
- FLOATCODE, videoindex);
- }
- }
- return;
-
- }
-
- void reviewmode (void** lp)
- /* flips between hidden windows
- **
- **
- */
- {
- int i;
-
- win_handle smallkeylist;
- win_handle ix286, ix386;
-
- win_handle *valwindows[8];
- int localstales[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-
- int curwindex, curwinmax;
- char rmch;
-
- /* Build new results array */
- if (staleflag) {
- make_textres (lp, tres_ary, \
- TEXTRESHIGH, TEXTRESWIDE);
- }
-
- if(options[2]){
- dump_array(tres_ary, TEXTRESWIDE,ac_t_h, 1);
- options[2]=0;
- }
-
- smallkeylist.made=ix286.made=ix386.made=0;
- mk_window(&smallkeylist, NULL, 0, 23, 80, 26, \
- BLACK,BLACK,BLACK,YELLOW, 0, 0);
- winprintstring(&smallkeylist, 1, 0, SKEYLISTSTRING);
-
- if(textreswin.made)
- unhide_window(&textreswin);
- else
- mk_window(&textreswin, "Results Table", \
- 0, 0, 80, 24, GREEN, WHITE,BLACK, GRAY, 1, 0);
- link_array(&textreswin, tres_ary, TEXTRESWIDE, ac_t_h, 0, 0);
-
- /* determine valid windows */
- curwindex=0;
- valwindows[curwindex] = &textreswin;
- curwindex++;
- valwindows[curwindex] = &ix286;
- curwindex++;
- if(machine_config.proc_type>286){
- valwindows[curwindex]=&ix386;
- curwindex++;
- }
- if(cpuwin.made){
- valwindows[curwindex]=&cpuwin;
- if(graphstale) localstales[curwindex]=1;
- curwindex++;
- }
- if(cpu2win.made){
- valwindows[curwindex]=&cpu2win;
- if(graphstale) localstales[curwindex]=2;
- curwindex++;
- }
- if(fpuwin.made){
- valwindows[curwindex]=&fpuwin;
- if(graphstale) localstales[curwindex]=3;
- curwindex++;
- }
- if(diskwin.made){
- valwindows[curwindex]=&diskwin;
- if(graphstale) localstales[curwindex]=4;
- curwindex++;
- }
- if(vidwin.made){
- valwindows[curwindex]=&vidwin;
- if(graphstale) localstales[curwindex]=5;
- curwindex++;
- }
- curwinmax = --curwindex;
-
- curwindex=0;
- rmch=0;
- /* get a keystroke */
- do{
- switch(getch()){
- case ESC: /* exits */
- hide_window(valwindows[curwindex]);
- kill_window(&ix286);
- kill_window(&ix386);
- kill_window(&smallkeylist);
- staleflag=0;
- /* graphs are fresh only if all fresh*/
- graphstale=0;
- for(i=0;i<8;i++)
- graphstale&=localstales[i];
- return;
-
- case CTRLW: /* dumps file */
- if (curwindex!=0) break;
- winprintstring(&smallkeylist, 0, 0, \
- BLANKSTRING);
- dump_array(tres_ary, TEXTRESWIDE,ac_t_h, 0);
- winprintstring(&smallkeylist, 1, 0, \
- SKEYLISTSTRING);
- break;
-
- case TAB: /*pop next window*/
- if (curwindex==0){
- hide_window(valwindows[curwindex]);
- hide_window(&smallkeylist);
- curwindex++;
- if(!(valwindows[curwindex]->made)){
- /* must be an ungraphed 286*/
- makeixgraphs(&ix286, \
- lp,0);
- }
- else{
- unhide_window(valwindows[curwindex]);
- if(localstales[curwindex]){
- batchgraph(lp, \
- localstales[curwindex]);
- localstales[curwindex]=0;
- }
- }
- win_erase_region( \
- valwindows[curwindex],0,23,78,1);
- winprintstring(valwindows[curwindex],\
- 0, 23, GRAPHKLSTRING);
- break;
- }
- if (curwindex==curwinmax){
- hide_window(valwindows[curwindex]);
- curwindex=0;
- unhide_window(&smallkeylist);
- unhide_window(valwindows[curwindex]);
- if(localstales[curwindex]){
- batchgraph(lp, \
- localstales[curwindex]);
- localstales[curwindex]=0;
- }
- break;
- }
- hide_window(valwindows[curwindex]);
- curwindex++;
- if(!(valwindows[curwindex]->made)){
- /* must be an ungraphed 386*/
- makeixgraphs(&ix386, \
- lp, 1);
- }
- else{
- unhide_window(valwindows[curwindex]);
- if(localstales[curwindex]){
- batchgraph(lp, \
- localstales[curwindex]);
- localstales[curwindex]=0;
- }
- }
- win_erase_region( \
- valwindows[curwindex],0,23,78,1);
- winprintstring(valwindows[curwindex],\
- 0, 23, GRAPHKLSTRING);
- break;
-
- case 0: /* scroll, maybe */
- rmch=getch();
- switch(rmch){
- case UPARROW:
- rmch=PGUP;
- case PGUP:
- case PGDOWN:
- case DOWNARROW:
- if(curwindex==0){
- scroll(&textreswin, \
- (int)(rmch==PGUP));
- }
- break;
-
- default: break;
- }
- break;
-
- default: break;
- }
- } while(TRUE);
- }
-
-
- void dump_array(char *aryptr, int aw, int ah, int noask)
- /* dumps array to file.
- ** If noask is not set, Asks about overwriting. fails if edit box fails.
- */
- {
- int dafh;
- unsigned int asize, i;
- char crlfbuf[2];
-
- crlfbuf[0]=CR;
- crlfbuf[1]=LF;
-
- if(noask){
- if((dafh=open(dumpfname, O_WRONLY| \
- O_BINARY|O_CREAT|O_TRUNC,S_IWRITE))==-1){
- alert_box("File Write Error", 0, 1,3);
- return;
- }
- }
- else
- if (!get_filename(&dafh, dumpfname)) return;
-
- /* dafh is now a legitimate file handle */
-
- asize=aw*ah;
- strip0s(aryptr, asize);
- for(i=0; i<asize; i+=aw){
- if(write(dafh, aryptr+i, aw)< aw){
- close (dafh);
- alert_box("File Write Error", 0, 1,3);
- return;
- }
- write(dafh, crlfbuf, 2);
- }
-
- close (dafh);
- return;
- }
-
- int alert_box(char *message, int yesnocode, int beepflag, int severity)
- /* puts up an appropriately sized alert box; returns y/n responses
- ** if yesnocode is set to YESNO
- ** Beeps if beepflag is set.
- ** severity decides the color scheme.
- */
- {
- win_handle abox;
- int boxw;
- char abch=-1;
- unsigned long tm0, tm1;
- int background;
- int frame;
- int text;
-
- switch(severity){
- case 3: background=RED; frame=WHITE; text=YELLOW; break;
- case 2: background=BLACK; frame=YELLOW; text=YELLOW; break;
- default: background=CYAN; frame=WHITE; text=BLUE; break;
- }
-
- abox.made=0;
- boxw=(strlen(message)>8)? strlen(message)+4: 12;
-
- mk_window(&abox, "Alert", (40-(boxw>>1)), 10, (40+(boxw>>1)) , 13, \
- background, frame, background, text, 1, 0);
-
- winprintstring(&abox, ((abox.w-2)-strlen(message))>>1, 0, message);
-
- if (beepflag && tdef[13]) putchar(0x07);
-
- if(yesnocode==YESNO){
- while((abch!='Y') && (abch!='N')){
- if(abch==0)
- getch(); /*filter function keys*/
- abch=toupper(getch());
- }
- kill_window(&abox);
- return (abch=='Y')? 1:0;
- }
-
- /* leave it up for a second */
-
- tm0=clock();
- do{
- tm1=clock();
- } while((tm1-tm0)<CLK_TCK);
- kill_window(&abox);
- return 0;
- }
-
- int mod_default_box(char* defstring, int dsmax, char* message)
- /* puts up an editable box which modifies default names
- ** dsmax is the storage allocated to defstring. Returns zero
- ** and leaves value unchanged on escape.
- */
- {
- win_handle edwin;
- int boxw;
- int baseloc, baselen;
- int retval;
-
- /* initialize */
- edwin.made=0;
-
- /* determine width -- between 20 and 40,wider of strings plus 8 */
- boxw=(strlen(message)>(strlen(defstring)))? \
- strlen(message)+8:strlen(defstring)+8;
- boxw=(boxw>20)?boxw:20;
- boxw=(boxw<40)?boxw:40;
-
- mk_window(&edwin, "Edit", (40-(boxw>>1)), 10, (40+(boxw>>1)) , 14, \
- BLUE, GRAY, BLUE, WHITE, 1, 0);
-
- /* put up messages */
- winprintstring(&edwin,((edwin.w-2)-strlen(message))>>1,0,message);
- baseloc=((edwin.w-2)-(dsmax-1))>>1;
- baseloc=(baseloc>1)?baseloc:1;
-
- baselen=(edwin.w-4<dsmax-1)? edwin.w-4: dsmax-1;
-
- /* edit string */
- retval=edit_string(&edwin, baseloc, 1, baselen, \
- defstring, dsmax, 0);
-
- /* close and exit */
- kill_window(&edwin);
- return (retval) ? 1 : 0;
- }
-
- int edit_string(win_handle *win, int x, int y, int edlen, char * edstring, \
- int edstrlen, int arrowflag)
- /*
- ** window based text input. Leaves string unchanged and returns zero on
- ** escape. Otherwise returns keystroke which finished arrows are
- ** accepted if arrowflag is set, else only enter.
- */
-
- {
- int i, o;
- char *j;
- char edch=-1;
- char scratch[100];
- char savchar;
- int izeroflag;
- int breakflag=0;
-
- /* bad string check */
- if (edstrlen>100) return 0;
-
- /* initialize */
- for(i=0;i<100;i++)
- scratch[i]=0;
-
- strcpy(scratch, edstring);
- *(scratch+99)=0;
-
- /* big loop */
- i=0;
- o=0;
- new_cursor(oldcurse);
- while(TRUE){
- win_erase_region(win, x, y, edlen,1);
- chattr(win,x,y, edlen, 1, WHITE,BLACK);
-
- if ((i+o)==edstrlen-1) new_cursor(BLANK_CURSE);
- else new_cursor(oldcurse);
-
- /* print only edlen trick */
- savchar=(*(scratch+o+edlen));
- *(scratch+o+edlen)=0;
- winprintstring(win, x, y, scratch+o);
- *(scratch+o+edlen)=savchar;
-
- win_set_curpos(win,x+i,y);
- edch=getch();
- switch(edch){
- case ESC:
- new_cursor(BLANK_CURSE);
- return 0;
- case 0:
- edch=getch();
- switch(edch){
- case DEL:
- j=scratch+i+o;
- while(*(j+1)!=0){
- *(j)=*(j+1);
- j++;
- }
- *(j)=*(j+1);
- break;
- case LEFTARROW:
- if(i>0)
- --i;
- else
- o=(o>0)?--o:0;
- break;
- case RIGHTARROW:
- if(*(scratch+i+o)==0)
- break;
- if ((i+o)==(edstrlen-1))
- break;
- if((i<(edlen-1))|| \
- ((i+o+1)==(edstrlen-1)))
- i++;
- else
- o++;
- break;
-
- case UPARROW:
- case DOWNARROW:
- if (arrowflag){
- breakflag=1;
- break;
- }
-
- default: continue;
- }
- break;
- case ENTER:
- breakflag=1;
- break;
- case BS:
- if(i==0) izeroflag=1;
- else izeroflag=0;
-
- if (izeroflag &&(o==0)) break ;
- if(izeroflag) o--;
- else i--;
- j=scratch+i+o;
- while(*(j+1)!=0){
- *(j)=*(j+1);
- j++;
- }
- *(j)=*(j+1);
- if(izeroflag) o++; /* put o back for looks */
- win_erase_region(win, \
- x, y, edlen,1);
- chattr(win,x,y, \
- edlen,1,WHITE,BLACK);
- break;
- default:
- if (isnprnt(edch)) break;
- if ((i+o)==(edstrlen-1)) break;
- *(scratch+i+o)=edch;
- if((i<(edlen-1))||((i+o+1)==(edstrlen-1)))
- i++;
- else
- o++;
- break;
- }
- if (breakflag) break;
- }
- new_cursor(BLANK_CURSE);
- strncpy(edstring, scratch, edstrlen);
- *(edstring+edstrlen-1)=0;
-
- return edch;
- }
-
- void controls_menu(void** listptr)
- /*
- ** puts up a select box.
- **
- **
- */
- {
- win_handle cm;
- int menhigh;
- int cmresp;
- int escflag=0;
-
- /* menu is sized according to whether or not tests were run.
- If they were, lower two choices are available */
-
- menhigh=(textreswin.made)? 12: 7;
- cm.made=0;
-
- mk_window(&cm, "Controls", 39, 2, 73, 2+menhigh, CYAN, WHITE,
- CYAN, BLUE, 1, 0);
-
- winprintstring(&cm, 1, 0, " Test Suite Configuration ...");
- winprintstring(&cm, 1, 2, " System Setup ...");
- winprintstring(&cm, 1, 4, " View/Choose Comparisons ...");
- winprintstring(&cm, 1, 6, " Review Results");
- winprintstring(&cm, 1, 8, " Save Results to File");
-
- cm.num_valid=(textreswin.made)? 5:3 ;
- cm.valid_lines=controls_valid_lines; /* predefined */
-
- winprintstring(&field,5,23,CMKEYLISTSTRING);
-
- /****** go into big loop ********/
- help_base=6;
- while(TRUE){
- display_help(&helptext, help_base);
- cmresp=get_resp_line(&cm, 0, 1, BLUE, WHITE, 0, 1);
- switch(cmresp){
- case -1: escflag=1;
- break;
- case 0:
- ts_config();
- winprintstring(&field,5,23,CMKEYLISTSTRING);
- break;
- case 1:
- sys_setup();
- machtodb((db_rec**)listptr,recs_in_db, \
- &machine_config);
- winprintstring(&field,5,23,CMKEYLISTSTRING);
- break;
- case 2:
- BLANKSCREEN;
- edit_data(listptr);
- UNBLANKSCREEN;
- break;
- case 3:
- BLANKSCREEN;
- reviewmode(listptr);
- UNBLANKSCREEN;
- break;
- case 4:
- winprintstring(&field,5,23,BLANKSTRING);
- dump_array(tres_ary, TEXTRESWIDE,ac_t_h, 0);
- winprintstring(&field,5,23,CMKEYLISTSTRING);
- break;
- }
- if(escflag) break;
- }
- kill_window(&cm);
-
- /* old help screen */
- display_help (&helptext, 0);
- help_base=0;
-
- return;
- }
-
- void ts_config(void)
- /*
- ** puts up a select box.
- **
- **
- */
- {
- win_handle tsc;
- int tscresp=-1;
- int def;
- int escflag=0;
- int choicetype=0;
- int tmpdef[14];
- int tempval;
- int i, boti, topi;
- char valstring[4] = {0, 0, 0, 0};
-
- for(i=0;i<14;i++)
- tmpdef[i]=tdef[i];
-
- tsc.made=0;
-
- mk_window(&tsc, "Test Settings", 38, 0, 78, 23, CYAN, WHITE,
- CYAN, BLUE, 1, 0);
-
- winprintstring(&tsc, 1, 0, " Sieve Duration (s.) .........");
- winprintstring(&tsc, 1, 1, " Sort Duration (s.) ..........");
- winprintstring(&tsc, 1, 2, " Integer Math Duration (s.) ..");
- winprintstring(&tsc, 1, 3, " String Move Duration (s.) ...");
-
- winprintstring(&tsc, 1, 5, " Fmath Duration (s.) .........");
- winprintstring(&tsc, 1, 6, " Fourier Duration (s.) .......");
-
- winprintstring(&tsc, 1, 8, " File I/O Duration (s.) ......");
- winprintstring(&tsc, 1, 9, " Logical Drive for File I/O ..");
- winprintstring(&tsc, 1, 10, " Run Low-Level Disk? .........");
- winprintstring(&tsc, 1, 11, " Test Hard Drive Unit ........");
-
- winprintstring(&tsc, 1, 13, " Text Duration (s./mode) .....");
- winprintstring(&tsc, 1, 14, " Graphics Duration (s./mode) .");
-
- winprintstring(&tsc, 1, 16, " Total Suite Repetitions .....");
-
- winprintstring(&tsc, 1, 18, " Save Changes");
- winprintstring(&tsc, 1, 19, " Store Configuration as Default");
- winprintstring(&tsc, 1, 20, " Restore Default Configuration");
-
- tsc.num_valid = tsuite_num_valid;
- tsc.valid_lines=tsuite_valid_lines; /* predefined */
-
- winprintstring(&field,5,23,TSCKEYLISTSTRING);
-
- help_base=11;
- def=0;
- boti=0;topi=13;
-
- /****** go into big, big loop ********/
- while(TRUE){
- for(i=boti;i<topi;i++){
- switch(i){
- case 7: *(valstring)=tmpdef[i]+'A'-1;
- *(valstring+1)=':';
- *(valstring+2)=0;
- break;
- case 8:
- *(valstring)=tmpdef[i]?'Y':'N';
- *(valstring+1)=0;
- break;
- case 9: if (tmpdef[i]<0){
- strcpy(valstring," - ");
- break;
- }
- itoa(tmpdef[i], valstring, 10);
- break;
-
- default: if (tmpdef[i]){
- itoa(tmpdef[i], \
- valstring, 10);
- }
- else
- strcpy(valstring,"Off");
- }
-
- win_erase_region(&tsc, 33, tsc.valid_lines[i], 3, 1);
- winprintstring(&tsc, 33, tsc.valid_lines[i], \
- valstring);
- chattr(&tsc, 33, tsc.valid_lines[i], 3, 1, \
- WHITE, BLACK);
- }
- if(def!=tscresp) display_help(&helptext, help_base+def);
- tscresp=get_resp_line(&tsc,def,1,BLUE,WHITE, \
- &choicetype,1);
- if(choicetype!=1){
- def=tscresp;
- if(def>12) continue;
- tempval=tmpdef[def];
- switch(choicetype){
- case LEFTARROW:
- tmpdef[def]--; break;
- case RIGHTARROW:
- tmpdef[def]++; break;
- case CTRLLA:
- tmpdef[def]-=50; break;
- case CTRLRA:
- if(!tmpdef[def]) tmpdef[def]=1;
- else tmpdef[def]+=50;
- break;
- default: break;
- }
- limcheck(tmpdef, 13);
- if (tempval!=tmpdef[def]) click();
- if (def==9){ /* special case */
- boti=8;topi=10;
- }
- else{
- boti=def;topi=def+1;
- }
- }
- else{
- switch(tscresp){
- case -1: escflag=1;
- break;
- case 13:
- for(i=0;i<14;i++)
- tdef[i]=tmpdef[i];
- def=0;
- boti=def;topi=def+1;
- break;
- case 14:
- for(i=0;i<14;i++)
- tdef[i]=tmpdef[i];
- dump_defs("bbdef.dat",tdef,14);
- def=0;
- boti=def;topi=def+1;
- break;
- case 15:
- read_defs("bbdef.dat",tdef,14);
- limcheck(tdef,13);
- for(i=0;i<14;i++)
- tmpdef[i]=tdef[i];
- boti=0;topi=13;
- def=0;
- break;
- default:
- def=tscresp;
- boti=def;topi=def+1;
- break;
- }
- if(escflag) {
- for(i=0;i<14;i++)
- if(tmpdef[i]!=tdef[i]) break;
- if (i==14) break;
- if(!alert_box( \
- "Save Changes?[y/n]", \
- YESNO, 0, 2)) break;
- for(i=0;i<14;i++)
- tdef[i]=tmpdef[i];
- break;
- }
- }
- }
- kill_window(&tsc);
-
- /* old help screen */
- display_help (&helptext, 6);
- help_base=6;
-
- return;
- }
-
- void sys_setup(void)
- /*
- ** puts up a select box for machine parameters
- **
- **
- */
- {
- win_handle sys;
- int sysresp=-1;
- int def;
- int escflag=0;
- int choicetype=0;
-
- struct mcfig tempmcfig;
- int tmpdef[14] ={60,60,60,60,60,60,60,3,1,0,60,60,1,1};
-
- int xoff, xlen;
- char *gtptr;
-
- int tempval;
- int sign;
- int snowchanged=0;
- int i, boti, topi;
- int posfpu[4]={0,87,287,387};
- char valstring[15];
- char tstring[5];
- char oldname[15];
-
- /* initialize */
- for(i=0;i<15;i++)
- valstring[i]=0;
- strcpy(tempmcfig.machine_name, machine_config.machine_name);
- strcpy(oldname, machine_config.machine_name);
- tempmcfig.graphics_type=machine_config.graphics_type;
- tempmcfig.proc_type=machine_config.proc_type;
- tempmcfig.fpu_type=machine_config.fpu_type;
- tempmcfig.MHz=machine_config.MHz;
- tempmcfig.num_hard=machine_config.num_hard;
- tempmcfig.dosnowplow=machine_config.dosnowplow;
- read_defs("bbdef.dat", tmpdef, 14);
- tmpdef[13]=tdef[13];
-
- sys.made=0;
-
- mk_window(&sys, "System Configuration", 38, 3, 78, 17, CYAN, WHITE,
- CYAN, BLUE, 1, 0);
-
- winprintstring(&sys, 1, 0, " Machine Name ..");
-
- winprintstring(&sys, 1, 2, " Processor ..............");
- winprintstring(&sys, 1, 3, " Math Coprocessor .......");
- winprintstring(&sys, 1, 4, " Video Type .............");
- winprintstring(&sys, 1, 5, " Number of Hard Drives ..");
-
- winprintstring(&sys, 1, 7, " Sound ..................");
- winprintstring(&sys, 1, 8, " CGA Snow Compensation ..");
-
- winprintstring(&sys, 1, 10, " Save Changes");
- winprintstring(&sys, 1, 11, " Auto Detect");
-
- sys.num_valid = sysset_num_valid;
- sys.valid_lines=sysset_valid_lines; /* predefined */
-
- winprintstring(&field,5,23,TSCKEYLISTSTRING);
-
- help_base=27;
- def=0;
- boti=0; topi=7;
-
-
- /****** go into big, big loop ********/
- while(TRUE){
- for(i=boti;i<topi;i++){
- switch(i){
- case 0: strcpy(valstring, \
- tempmcfig.machine_name);
- xoff=21; xlen=14;
- break;
- case 1:
- strcpy(valstring,"80");
- itoa(tempmcfig.proc_type,tstring, \
- 10);
- strcat(valstring,tstring);
- if (strlen(valstring)==4)
- *(valstring+3)='x';
- xoff=30; xlen=5;
- break;
- case 2:
- xoff=30; xlen=5;
- if(!tempmcfig.fpu_type){
- strcpy(valstring, "None");
- break;
- }
- strcpy(valstring,"80");
- itoa(tempmcfig.fpu_type, \
- tstring, 10);
- strcat(valstring,tstring); break;
- case 3:
- switch(tempmcfig.graphics_type){
- case MDA: gtptr="Mono"; break;
- case HERC:gtptr="HGC "; break;
- case EGAM:gtptr="EGA-M";break;
- case CGA:gtptr="CGA"; break;
- case EGAC:gtptr="EGA-C";break;
- case VGA:gtptr="VGA"; break;
- }
- strcpy(valstring, gtptr);
- xoff=30; xlen=5;
- break;
-
- case 4: itoa(tempmcfig.num_hard, \
- valstring, 10);
- xoff=30; xlen=5;
- break;
-
- case 5: if(tmpdef[13])
- strcpy(valstring, "On");
- else strcpy(valstring, "Off");
- xoff=30; xlen=5;
- break;
-
- case 6: if(tempmcfig.dosnowplow)
- strcpy(valstring, "On");
- else strcpy(valstring, "Off");
- xoff=30; xlen=5;
- break;
- }
-
- win_erase_region(&sys, xoff, sys.valid_lines[i], \
- xlen, 1);
- winprintstring(&sys, xoff, sys.valid_lines[i], \
- valstring);
- chattr(&sys, xoff, sys.valid_lines[i], xlen, 1, \
- WHITE, BLACK);
- }
- if(sysresp!=def) display_help(&helptext, help_base+def);
- sysresp=get_resp_line(&sys,def,1,BLUE,WHITE,&choicetype,1);
- if((choicetype==DEL)||(choicetype==CTRLD)|| \
- (choicetype==INS)||(choicetype==CTRLW)||(choicetype==CTRLS)){
- def=sysresp;
- boti=0; topi=0;
- continue;
- }
- if(sysresp==0){
- def=sysresp;
- if (choicetype==1)
- chattr(&sys, 1, 0, winstrlen(&sys, 1, 0), 1, \
- BLUE, WHITE); /* for consistency */
- edit_string(&sys,21,0,14, \
- tempmcfig.machine_name, 15, 1);
- boti=def;topi=def+1;
- continue;
- }
-
- if(choicetype!=1){
- def=sysresp;
- if(def>6) continue;
- sign=((choicetype==CTRLLA)||(choicetype==LEFTARROW))?
- -1 : +1;
- switch(def){
- case 1: tempval= \
- tempmcfig.proc_type+(100*sign);
- if((tempval<86) || (tempval>486))
- break;
- tempmcfig.proc_type=tempval;
- if (tmpdef[13]) click();
- break;
- case 2:
- for(i=0;i<4;i++)
- if(tempmcfig.fpu_type == \
- posfpu[i]) break;
- i+=sign;
- if ((i<0) || (i>3)) break;
- tempmcfig.fpu_type=posfpu[i];
- if (tmpdef[13]) click();
- break;
- case 3: tempval= \
- tempmcfig.graphics_type+sign;
- if((tempval<1) || (tempval>6))
- break;
- if(tempmcfig.graphics_type==CGA){
- tempmcfig.dosnowplow=0;
- snowchanged=1;
- }
- tempmcfig.graphics_type=tempval;
- if (tmpdef[13]) click();
- break;
- case 4: tempval= \
- tempmcfig.num_hard+sign;
- if((tempval<0) || (tempval>4))
- break;
- tempmcfig.num_hard=tempval;
- if (tmpdef[13]) click();
- break;
- case 5: tempval= \
- tmpdef[13]+sign;
- if((tempval<0) || (tempval>1))
- break;
- tmpdef[13]=tempval;
- if (tmpdef[13]) click();
- break;
- case 6:
- if(tempmcfig.graphics_type!=CGA)
- break;
- tempval= \
- tempmcfig.dosnowplow+sign;
- if((tempval<0) || (tempval>1))
- break;
- tempmcfig.dosnowplow=tempval;
- if (tmpdef[13]) click();
- break;
- }
- boti=def; topi=def+1;
- if (snowchanged) {topi=7; snowchanged=0;}
- }
- else{
- switch(sysresp){
- case -1: escflag=1;
- break;
- case 7:
- strcpy(machine_config.machine_name, \
- tempmcfig.machine_name);
- machine_config.graphics_type= \
- tempmcfig.graphics_type;
- machine_config.proc_type= \
- tempmcfig.proc_type;
- machine_config.fpu_type= \
- tempmcfig.fpu_type;
- machine_config.MHz= \
- tempmcfig.MHz;
- machine_config.num_hard= \
- tempmcfig.num_hard;
- machine_config.dosnowplow= \
- tempmcfig.dosnowplow;
- tdef[13]=tmpdef[13];
- dump_defs("bbdef.dat", tmpdef, 14);
- cgainit();
- def=0;
- topi=boti=0;
- break;
- case 8:
- machine_detect(&tempmcfig);
- tempmcfig.dosnowplow=0;
- topi=7; boti=0;
- def=0;
- break;
- default:
- topi=boti=0;
- def=sysresp;
- break;
- }
- }
- if(escflag){
- /* compare structures*/
- if(!strcmp(machine_config.machine_name, \
- tempmcfig.machine_name) &&
- machine_config.graphics_type== \
- tempmcfig.graphics_type &&
- machine_config.proc_type== \
- tempmcfig.proc_type &&
- machine_config.fpu_type== \
- tempmcfig.fpu_type &&
- machine_config.MHz== \
- tempmcfig.MHz &&
- machine_config.num_hard== \
- tempmcfig.num_hard &&
- machine_config.dosnowplow== \
- tempmcfig.dosnowplow &&
- tdef[13]==tmpdef[13]) break;
- if(!alert_box( \
- "Save Changes?[y/n]", \
- YESNO, 0, 2)) break;
- strcpy(machine_config.machine_name, \
- tempmcfig.machine_name);
- machine_config.graphics_type= \
- tempmcfig.graphics_type;
- machine_config.proc_type= \
- tempmcfig.proc_type;
- machine_config.fpu_type= \
- tempmcfig.fpu_type;
- machine_config.MHz= \
- tempmcfig.MHz;
- machine_config.num_hard= \
- tempmcfig.num_hard;
- machine_config.dosnowplow= \
- tempmcfig.dosnowplow;
- tdef[13]=tmpdef[13];
- dump_defs("bbdef.dat", tmpdef, 14);
- cgainit();
- break;
- }
- }
- /* fix graphs */
- if (strcmp(machine_config.machine_name,oldname))
- graphstale=staleflag=1;
- kill_window(&sys);
-
- /* old help screen */
- display_help (&helptext, 6);
- help_base=6;
-
- return;
- }
-
- int validpath(char * fname)
- /*
- ** determines if the fname string contitutes a valid path with
- ** (possibly valid) filename
- */
- {
- char *buffer;
- char *pathptr;
- int i;
- int retval;
-
- if (*(fname+1) == ':'){
- if((disk_check(toupper(*(fname))+1-'A', 0)) <= 0)
- return 0;
- }
-
- /* scan for last backslash */
- for(i=strlen(fname)-1; (*(fname+i)!='\\') && (i>0); i--);
-
- if (i==0) return 1; /* no path is good path */
-
-
- pathptr=(char*) malloc(i+2);
- strncpy(pathptr, fname, i);
- *(pathptr+i)=0;
- if (*(pathptr+(i-1)) ==':'){
- *(pathptr+i)='\\';
- *(pathptr+i+1)=0;
- }
- *(pathptr)=toupper(*(pathptr));
-
- /* save current path in buffer, in case the check works */
- buffer=(char *) malloc(68);
- buffer[0]=(get_default()+'A');
- strcpy(buffer+1, ":\\");
- getpath((int)(buffer[0]-'A'), buffer+3);
-
- retval = cdir(pathptr);
- cdir (buffer);
-
- free (buffer);
- free (pathptr);
-
- return retval;
- }
-
- int validfname(char * fname)
- /*
- ** finds the filename in a path string. returns 1 if filename valid, 0
- ** if not.
- **
- */
-
- {
- int i;
- int nameptr;
- int dotloc = -1;
-
- /* scan for last backslash */
- for(i=strlen(fname)-1; (*(fname+i)!='\\') && (i>0); i--);
-
- if((i==0) && (*(fname+1)==':')) nameptr=i=3;
- else nameptr= ++i;
-
- /* too long? */
- if((strlen(fname+nameptr)>12)||(strlen(fname+nameptr)<1))
- return 0;
-
- /* find invalid chars */
- for(;*(fname+i)!=0;i++){
- if( (*(fname+i)<=' ') ||
- (*(fname+i)=='"') ||
- ((*(fname+i)>='*')&&(*(fname+i)<=',')) ||
- (*(fname+i)=='/') ||
- ((*(fname+i)>=':')&&(*(fname+i)<='?')) ||
- ((*(fname+i)>='[')&&(*(fname+i)<=']')) ||
- (*(fname+i)=='|') ||
- (*(fname+i)>~~ 0x07e)
- ) return 0;
- }
-
- /* find the dot */
- for(;i>=nameptr;i--){
- if(*(fname+i)=='.'){
- if(dotloc<0) dotloc=i;
- else /* one dot to a filename */
- return 0;
- }
- }
-
- /* make sure dot is in the right place */
-
- if (dotloc>-1){
- if( ((dotloc-nameptr)>8) || (dotloc==nameptr) || \
- (strlen(fname+dotloc)>4) ) return 0;
- }
-
- return 1;
- }
-
- struct help_handle *make_helpspace(char *hfname, struct help_handle *hh)
- /*
- ** Given the proper filename, opens helpfile. Fills handle with
- ** chapter offsets. Returns pointer to help handle, or 0 on
- ** error.
- */
- {
- int hfh;
- unsigned int i, j;
- unsigned int crcount;
- char* bufptr;
- unsigned int numbytes;
- int num_ptrs;
-
- hh->filehandle = 0;
-
- hfh=open(hfname, O_BINARY|O_RDONLY);
- if(hfh==-1)
- return NULL;
-
- /* open a buffer */
- if ((bufptr=(char *)malloc(512))==NULL)
- return NULL;
-
- /* first offset is at 12; rest will be scanned */
- numbytes=(unsigned int) lseek(hfh, 12, 0);
- if(numbytes!=12){
- close(hfh);
- return NULL;/* not my file */
- }
- hh->chapter_offsets[0]=12;
-
- /* scan file for end of chapter markers (0x017) */
- /* count lines while we're at it */
- j=0;
- num_ptrs=1;
- crcount=0;
- while(num_ptrs<50){
- numbytes=read(hfh, bufptr, 512);
- if(numbytes<0){
- close(hfh);
- return NULL; /* read error */
- }
- for(i=0;i<numbytes;i++){
- if(*(bufptr+i)== CR){
- crcount++;
- continue;
- }
- if(*(bufptr+i)== 0x017){
- hh->chapter_offsets[num_ptrs] = (512*j)+i+13;
- num_ptrs++;
- act_h_h=(act_h_h>crcount)?act_h_h:crcount;
- crcount=0;
- }
- }
- if (numbytes<512) break; /* end of file */
- j++;
- }
-
- /* clear the rest of the array */
- for (i=num_ptrs;i<50;i++)
- hh->chapter_offsets[i] = 0;
-
- /* allocate enough memory for biggest section */
- if(((hh->arryptr)=(char*) malloc((act_h_h+1)*HWIDTH)) == NULL) {
- /* never too late to fail */
- close(hfh);
- return NULL;
- }
-
- hh->filehandle = hfh;
-
- return hh;
- }
-
- void kill_helpspace(struct help_handle *hh)
- /*
- ** cleans up after make_helpspace
- **
- */
- {
- if (hh->filehandle == 0) return;
-
- free(hh->arryptr);
- close(hh->filehandle);
-
- hh->filehandle=0;
- return;
- }
-
- int display_help (struct help_handle * hh, int index)
- /*
- ** displays a help screen in the help window.
- **
- */
- {
- char *bufptr;
- unsigned int i, crloc;
- int breakflag=0;
- int lincount=0;
- unsigned int linoff;
- unsigned int bytesread;
-
- if (hh->filehandle == 0){
- winprintstring(&help, 4, 7, NOHELPFILESTRING1);
- winprintstring(&help, 4, 8, NOHELPFILESTRING2);
- return 0;
- }
-
- /* make a line buffer */
- if((bufptr= (char*) malloc(HWIDTH+1)) == NULL)
- return 0; /* loser */
-
-
- /* find location in file */
- lseek( hh->filehandle, hh->chapter_offsets[index], 0);
-
- /* read-in loop */
-
- do{
- /* read in a line */
- bytesread=read(hh->filehandle, bufptr, HWIDTH);
-
- /* find first cr */
- for(i=0;i<bytesread;i++){
- if(*(bufptr+i)==CR){
- crloc=i;
- break;
- }
- }
- /* look for end of section mark */
- if (*(bufptr+(crloc+2)) == 0x017)
- breakflag=1;
-
- /* fix file pointer */
- lseek(hh->filehandle, \
- (signed)((crloc+2)-bytesread),1);
-
- linoff=lincount*HWIDTH;
-
- /* copy to real array */
- for(i=0;i<crloc;i++)
- *((hh->arryptr)+linoff+i)=*(bufptr+i);
- /* zero out rest of line */
- for(;i<HWIDTH;i++)
- *((hh->arryptr)+linoff+i)=0;
-
- lincount++;
-
- } while (!breakflag);
-
- act_h_h=lincount;
- free(bufptr);
-
- /* clean out help window, if neccesary */
- if(act_h_h<20)
- win_erase_region(&help, 0, 0, 30, 19);
-
- link_array(&help, hh->arryptr, HWIDTH, act_h_h, 0, 0);
-
- return 1;
-
- }
-
- int makeixgraphs(win_handle * winptr, void** lp, int which)
- /*
- ** Makes index graphs. Which means 286 (0) or 386 (1).
- */
- {
- char titlestring[34];
- int curroff, baseoff;
- int numgraphs;
- int i;
- int xs[4];
- int ys[4];
- int ws[4];
-
-
- if (which==1){
- strcpy(titlestring, "Performance Indexes / 386 Class");
- baseoff=offset_in_struc(db_rec, cpu386);
- }
- else{
- strcpy(titlestring, "Performance Indexes / AT Class");
- baseoff=offset_in_struc(db_rec, cpuat);
- }
-
- mk_window(winptr,titlestring, 0, 0, 82, 27, BLACK, WHITE,
- BLACK, WHITE, 0, 0);
-
- /* how many ? */
- curroff=lin_search_db(0, recs_in_db-1,lp, \
- offset_in_struc(db_rec,currflag), INTCODE, 1);
- numgraphs=0;
- for(i=0;i<(4*(sizeof(double)));i+=sizeof(double)){
- if(*((double*)((char*)(*(lp+curroff))+(baseoff+i)))!=0)
- numgraphs++;
- }
-
- /* determine positions and widths */
-
- switch (numgraphs){
- case 0: return 0;
- case 1: xs[0]=0; ys[0]=6; ws[0]=78;
- break;
- case 2: xs[0]=0; ys[0]=1; ws[0]=78;
- xs[1]=0; ys[1]=12; ws[1]=78;
- break;
- case 3: xs[0]=0; ys[0]=1; ws[0]=39;
- xs[1]=40; ys[1]=1; ws[1]=39;
- xs[2]=0; ys[2]=12; ws[2]=78;
- break;
- case 4: xs[0]=0; ys[0]=1; ws[0]=39;
- xs[1]=40; ys[1]=1; ws[1]=39;
- xs[2]=0; ys[2]=12; ws[2]=39;
- xs[3]=40; ys[3]=12; ws[3]=39;
- break;
- }
-
- /* guess and graph the screens */
- i=0;
- if(*((double*)((char*)(*(lp+curroff))+baseoff))!=0){
- curroff=graph("CPU Indexes",winptr, xs[i], ys[i], ws[i], lp,\
- baseoff, "Normalized Units");
- i++;
- }
- if(*((double*)((char*)(*(lp+curroff))+(baseoff+sizeof(double))))!=0){
- curroff=graph("FPU Indexes",winptr, xs[i], ys[i], ws[i], lp,\
- (baseoff+sizeof(double)), "Normalized Units");
- i++;
- }
- if(*((double*)((char*)(*(lp+curroff))+ \
- (baseoff+(2*sizeof(double)))))!=0){
- curroff=graph("Disk Indexes",winptr, xs[i], ys[i], ws[i], lp,\
- (baseoff+(2*sizeof(double))), \
- "Normalized Units");
- i++;
- }
- if(*((double*)((char*)(*(lp+curroff))+ \
- (baseoff+(3*sizeof(double)))))!=0){
- graph("Video Indexes",winptr, xs[i], ys[i], ws[i], lp,\
- (baseoff+(3*sizeof(double))), \
- "Normalized Units");
- i++;
- }
-
- return 1;
-
- }
-
- void edit_data(void** listptr)
- /*
- ** puts up a select box.
- **
- */
- {
- win_handle edat;
- win_handle keylist;
- win_handle sortwin;
- win_handle messwin;
- int edatresp;
- int choice;
- int def;
- int badnameflag;
- int eraser;
- int dontstop;
- int redispflag;
- int comps[2];
- int curroff, oldcurr;
- int lastchange=1;
- int datachanged=0;
- int soff;
- int sortcrit=0;
- int sr;
-
- int i;
- char tempstring[80];
-
- /* initialize */
- for (i=0;i<80;i++) tempstring[i]=0;
- keylist.made=edat.made=0;
- sortwin.num_valid=8;
- sortwin.valid_lines=sortwin_valid_lines;
-
- mk_window(&keylist, NULL, 0, 21, 79, 26, BLACK,CYAN,BLACK,CYAN, \
- 0,0);
-
- mk_window(&edat, "Comparison Machines", 0, 0, 79, 22, GREEN, WHITE,
- BLACK, GRAY, 1, 0);
-
- winprintstring(&keylist, 0, 0, " Esc - Previous Menu");
- winprintstring(&keylist, 26, 0, " Del - Delete Entry");
- winprintstring(&keylist, 46, 0, " Ins - Add Current to Defaults");
- winprintstring(&keylist, 0, 1, " ^W - Write as text file");
- winprintstring(&keylist, 26, 1, " ^S - Sort ...");
- winprintstring(&keylist, 46, 1, " Enter - Choose comparison (*)");
-
- winprintstring(&edat, 0, 0, DBTITLESTRING);
-
- /****** go into big loop ********/
- edat.valid_lines=edat_valid_lines;
- soff=offset_in_struc(db_rec,comp);
- def=0;
- redispflag=1;
- while(TRUE){
- if(redispflag){
-
- eraser= (recs_in_db==18) ? 18 : recs_in_db+1;
- win_erase_region(&edat, 0, 2, 77, eraser);
-
- sort_db(recs_in_db, listptr, \
- (offset_in_struc(db_rec,cpuat) \
- +sortcrit*sizeof(double)), \
- FLOATCODE);
- for(i=0;i<recs_in_db;i++){
- dbrec2string((db_rec *) *(listptr+i), \
- tempstring);
- winprintstring(&edat, 0, i+2, tempstring);
- }
- edat.num_valid=i;
-
- for(i=0;i<2;i++){
- comps[i]=lin_search_db(0,recs_in_db-1,listptr, soff, INTCODE, (i+1));
- if (comps[i]>=0)
- winputch(&edat,15, \
- edat.valid_lines[comps[i]],'*');
- }
-
- redispflag=0;
- }
-
- edatresp=get_resp_line(&edat, def, 0,CYAN, WHITE, &choice, 0);
- if((choice==1) && (edatresp==-1)){
- break;
- }
- switch(choice){
- case 1 : /* enter */
- def=edatresp;
- curroff=lin_search_db(0,recs_in_db-1,listptr, offset_in_struc(db_rec,currflag),INTCODE, 1);
- if(edatresp==curroff){
- alert_box( \
- "Can't select current machine",0,0,2);
- break;
- }
-
- datachanged=1;
- graphstale=1;
-
- comps[0]=lin_search_db(0,recs_in_db-1,listptr, soff, INTCODE, 1);
- comps[1]=lin_search_db(0,recs_in_db-1,listptr, soff, INTCODE, 2);
- /* turn off */
- if((edatresp==comps[0])||(edatresp==comps[1])){
- winputch(&edat,15, \
- edat.valid_lines[edatresp],' ');
- update_db(edatresp, listptr, soff, \
- INTCODE, (int) 0 );
- if((edatresp==comps[0]) \
- &&(comps[1]>(-1)))
- update_db(comps[1],listptr, \
- soff,INTCODE, (int) 1 );
- break;
- }
- /* turn off and turn on */
- if((comps[0]>(-1)) && (comps[1]>(-1))){
- lastchange=(lastchange)? 0 : 1;
- winputch(&edat,15, \
- edat.valid_lines[comps[lastchange]], \
- ' ');
- update_db(comps[lastchange], \
- listptr, soff, \
- INTCODE, (int) 0 );
- winputch(&edat,15, \
- edat.valid_lines[edatresp], \
- '*');
- update_db(edatresp,listptr, soff, \
- INTCODE, (lastchange+1) );
- break;
- }
- /* turn on */
- winputch(&edat,15,edat.valid_lines[edatresp], \
- '*');
- i=(comps[0]>-1)? 2: 1;
- update_db(edatresp,listptr, soff, \
- INTCODE, i );
- lastchange=(i-1);
- break;
- case DEL:
- curroff=lin_search_db(0, \
- recs_in_db-1,listptr, \
- offset_in_struc(db_rec,currflag), \
- INTCODE, 1);
- if(edatresp==curroff){
- alert_box( \
- "Can't delete current machine", \
- 0,0,2);
- def=edatresp;
- break;
- }
- if ((((db_rec*)(*(listptr+edatresp))) \
- ->basenum)>0){
- alert_box( \
- "Can't delete baseline", 0,0,2);
- def=edatresp;
- break;
- }
- if(!alert_box( \
- "Confirm: Delete Record?[y/n]", \
- YESNO, 0, 2)){
- def=edatresp;
- break;
- }
-
- graphstale=1;
-
- if \
- ((((db_rec*)(*(listptr+edatresp)))->comp)==1){
- comps[1]=lin_search_db(0, \
- recs_in_db-1,listptr, \
- soff, INTCODE, 2);
- if(comps[1]>(-1)){
- update_db(comps[1], \
- listptr, soff, \
- INTCODE, (int) 1 );
- }
- lastchange=0;
- }
- if \
- ((((db_rec*)(*(listptr+edatresp)))->comp)==2){
- lastchange=0;
- }
-
- free (*(listptr+edatresp));
- for(i=edatresp;i<recs_in_db-1;i++){
- *(listptr+i)=*(listptr+i+1);
- }
- *(listptr+i)=NULL;
- recs_in_db--;
- def=0;
- redispflag=1;
- datachanged=1;
- break;
- case INS:
- def=edatresp;
- if(recs_in_db==18){
- alert_box( \
- "No more room. Please delete an entry.", \
- 0,1, 3);
- break;
- }
- dontstop=1;
- do{
- badnameflag=0;
- for(i=0;i<recs_in_db;i++){
- if(!strcmp(machine_config.machine_name,
- (((db_rec*)(*(listptr+i)))->name))){
- if (!(((db_rec*) \
- (*(listptr+i)))->currflag)){
- badnameflag=1;
- break;
- }
- }
- }
- if(!strcmp(machine_config.machine_name, \
- NAMEDEF))
- badnameflag=1;
- if(badnameflag){
- dontstop=mod_default_box( \
- machine_config.machine_name, \
- 15, \
- "Name Conflicts. Please Rename:");
- }
- }while(badnameflag&&(dontstop));
- if(!dontstop) break;
-
- graphstale=1;
-
- def=0;
- redispflag=1;
- machtodb((db_rec**)listptr, recs_in_db, \
- &machine_config);
- recs_in_db=add_entry_db( 18, \
- recs_in_db,(db_rec**)listptr, machname);
- oldcurr=lin_search_db(0, \
- recs_in_db-1,listptr, \
- offset_in_struc(db_rec,name), \
- CHARPTRCODE, \
- (int) machine_config.machine_name);
- curroff=lin_search_db(0, \
- recs_in_db-1,listptr, \
- offset_in_struc(db_rec,currflag), \
- INTCODE, 1);
- dup_rec(listptr, curroff, oldcurr);
- /* duplication fixes */
- update_db(curroff,listptr, \
- offset_in_struc(db_rec, currflag) , \
- INTCODE, 1);
- update_db(curroff,listptr, \
- offset_in_struc(db_rec, name) , \
- CHARPTRCODE, (int) machname);
- strcpy(machine_config.machine_name, machname);
- sort_db(recs_in_db, listptr, \
- offset_in_struc(db_rec,currflag), \
- INTCODE);
- dump_db(recs_in_db-1, \
- ((db_rec**)listptr+1),"bbcomp.dat");
- def=0;
- redispflag=1;
- datachanged=1;
- break;
- case CTRLW:
- filedb((db_rec**)listptr);
- def=edatresp;
- break;
- case CTRLS:
- sortwin.made=0;
- mk_window(&sortwin, NULL, 59, 7, 73, \
- 19, CYAN, WHITE,CYAN, BLUE, 1, 0);
- winprintstring(&sortwin, 1, 0, "Sort On:");
- winprintstring(&sortwin, 3, 2, "CPU-AT");
- winprintstring(&sortwin, 3, 3, "FPU-AT");
- winprintstring(&sortwin, 3, 4, "Dsk-AT");
- winprintstring(&sortwin, 3, 5, "Vid-AT");
- winprintstring(&sortwin, 3, 6, "CPU-386");
- winprintstring(&sortwin, 3, 7, "FPU-386");
- winprintstring(&sortwin, 3, 8, "Dsk-386");
- winprintstring(&sortwin, 3, 9, "Vid-386");
- sr=get_resp_line(&sortwin, \
- 0, 3, BLUE, WHITE, 0, 0);
- sortcrit=(sr<0) ? sortcrit : sr;
- kill_window(&sortwin);
- def=0;
- redispflag=1;
- break;
- default:
- def=edatresp;
- break;
- }
- }
-
- if(datachanged){
- messwin.made=0;
- mk_window(&messwin,NULL,25,8,40,11,GREEN, \
- WHITE,GREEN,WHITE,1,0);
- winprintstring(&messwin, 3, 0, "Saving...");
- sort_db(recs_in_db, listptr, \
- offset_in_struc(db_rec,currflag),INTCODE);
- dump_db(recs_in_db-1, ((db_rec**)listptr+1),"bbcomp.dat");
- kill_window(&messwin);
- staleflag=1;
- }
-
- kill_window(&edat);
- kill_window(&keylist);
- return;
- }
-
- char* dbrec2string( db_rec* rptr, char * string)
- /*
- ** converts a database record to a string. Puts the results in string.
- */
- {
-
- if(!(rptr->cpuat||rptr->fpuat||rptr->diskat|| \
- rptr->videoat||rptr->cpu386||rptr->fpu386||rptr->disk386|| \
- rptr->video386)){
- sprintf(string, NODATASTRING, rptr->name);
- return string;
- }
-
- sprintf(string, \
- "%14s %6.2f %6.2f %6.2f %6.2f %7.2f %7.2f %7.2f %7.2f",\
- rptr->name, rptr->cpuat,rptr->fpuat,rptr->diskat, \
- rptr->videoat,rptr->cpu386,rptr->fpu386,rptr->disk386, \
- rptr->video386);
- return string;
- }
-
- void machtodb(db_rec ** listptr, char num_recs, struct mcfig * machdata)
- /*
- ** stuffs the current machine stuff into the current database entry.
- **
- */
- {
- int curroff;
-
- curroff=lin_search_db(0, num_recs-1,(void**) listptr, \
- offset_in_struc(db_rec,currflag), INTCODE, 1);
-
- (*(listptr+curroff))->proc=machdata->proc_type;
- (*(listptr+curroff))->mhz=machdata->MHz;
- strcpy(((*(listptr+curroff))->name),(machdata->machine_name));
-
- }
-
- int get_filename(int *fhptr, char * nameptr)
-
- {
-
- int yn;
-
- /* prompt for filename */
- while(TRUE){
- if(!(mod_default_box(nameptr, 80, "Name the file")))
- return 0;
- if (!validpath(nameptr)){
- alert_box("Path dosen't exist. Try Again.", 0,0,2);
- continue;
- }
- if (!validfname(nameptr)){
- alert_box("Bad filename. Try Again.", 0,0,2);
- continue;
- }
- break;
- }
-
- /*determine whether or not it exists*/
- if((*(fhptr)=open(nameptr, \
- O_WRONLY|O_BINARY|O_CREAT|O_EXCL,S_IWRITE))==-1){
- if(errno==EEXIST){
- yn=alert_box("Overwrite Existing File? [y,n]", \
- YESNO, 0,2);
- if(yn){
- if((*(fhptr)=open(nameptr, O_WRONLY| \
- O_BINARY|O_CREAT|O_TRUNC,S_IWRITE))==-1){
- alert_box("File Write Error",0,1,3);
- close(*(fhptr));
- return 0;
- }
- }
- else
- return 0;
- }
- else{
- alert_box("File Write Error", 0, 1,3);
- close(*(fhptr));
- return 0;
- }
- }
- return 1;
-
- }
-
-
- void filedb(db_rec ** listptr)
- /* dumps the db as a textfile */
- {
-
- int dbfh;
- int i;
- char tstring[80];
- char crlfbuf[2];
-
- crlfbuf[0]=CR;
- crlfbuf[1]=LF;
-
- if(!get_filename(&dbfh, dbtxname)) return;
-
- sprintf(tstring, DBTITLESTRING);
- strip0s(tstring, 80);
- if(write(dbfh, tstring, 77) < 77){
- close (dbfh);
- alert_box("File Write Error", 0, 1,3);
- return;
- }
- write(dbfh, crlfbuf, 2);
- write(dbfh, crlfbuf, 2);
-
- for(i=0;i<recs_in_db;i++){
- dbrec2string(*(listptr+i),tstring);
- if((*(listptr+i))->comp) tstring[15]='*';
- strip0s(tstring,80);
- if(write(dbfh, tstring, 77) < 77){
- close (dbfh);
- alert_box("File Write Error", 0, 1,3);
- return;
- }
- write(dbfh, crlfbuf, 2);
- }
- close(dbfh);
- return;
-
- }
-
- int batchgraph (void ** listptr, int which)
- /*
- ** This sets up all the graphs in a window, determined by which. This was
- ** set up so execute and reviewmode can both update graph windows.
- ** Returns current offset.
- */
- {
- int curval;
- int gx, gy, gw;
-
- if(which==1){
-
- graph("BYTE Sieve",&cpuwin, 0, 1, 39, listptr, \
- offset_in_struc(db_rec, sieveres), \
- "Iterations per second ");
- graph("BYTE Sort",&cpuwin, 40, 1, 39, listptr, \
- offset_in_struc(db_rec, sortres), \
- "Iterations per second ");
- graph("BYTE Int. Math",&cpuwin, 0, 12, 39, listptr, \
- offset_in_struc(db_rec, imathres), \
- "Iterations per second ");
- curval= \
- graph("BYTE Byte-wide move",&cpuwin, 40, 12, 39, listptr, \
- offset_in_struc(db_rec, movbres), \
- "Iterations per second ");
- }
-
-
- if(which==2){
- if(lastproc>286){
- gw=39; gx=40; gy=1;
- }
- else{
- gw=78; gx=0; gy=12;
- }
-
- graph("BYTE Word-Odd Move",&cpu2win, 0, 1, gw, listptr, \
- offset_in_struc(db_rec, movwores), \
- "Iterations per second ");
- graph("BYTE Word-Even Move",&cpu2win, gx, gy, gw, listptr, \
- offset_in_struc(db_rec, movweres), \
- "Iterations per second ");
-
- if(lastproc>286){
-
- graph("BYTE DWord-Odd Move",&cpu2win, 0, 12, 39, listptr, \
- offset_in_struc(db_rec, movdores), \
- "Iterations per second ");
- curval= \
- graph("BYTE DWord-Even Move",&cpu2win, 40, 12, 39, listptr, \
- offset_in_struc(db_rec, movderes), \
- "Iterations per second ");
- }
- }
-
- if(which==3){
- graph("BYTE Fmath",&fpuwin, 0, 1, 78, listptr, \
- offset_in_struc(db_rec, fourbangres), \
- "Iterations per second ");
- curval= \
- graph("BYTE Fourier",&fpuwin, 0, 12, 78, listptr, \
- offset_in_struc(db_rec, forres), \
- "Iterations per second ");
- }
-
- if(which==4){
- graph("BYTE File I/O Read",&diskwin, 0, 1, 39, listptr, \
- offset_in_struc(db_rec, fiorres), \
- "Kilobytes per second ");
- graph("BYTE File I/O Write",&diskwin, 40, 1, 39, listptr, \
- offset_in_struc(db_rec, fiowres), \
- "Kilobytes per second ");
- graph("BYTE Throughput",&diskwin, 0, 12, 39, listptr, \
- offset_in_struc(db_rec, tpres), \
- "Kilobytes per second ");
- curval= \
- graph("BYTE Seek Test",&diskwin, 40, 12, 39, listptr, \
- offset_in_struc(db_rec, seekres), \
- "Milliseconds ");
- }
-
- if(which==5){
- graph("BYTE Text Display",&vidwin, 0, 1, 39, listptr, \
- offset_in_struc(db_rec, txposres), \
- "Iterations per second ");
- graph("BYTE Text Scroll",&vidwin, 40, 1, 39, listptr, \
- offset_in_struc(db_rec, txscrollres), \
- "Iterations per second ");
- curval= \
- graph("BYTE Graphics",&vidwin, 0, 12, 78, listptr, \
- offset_in_struc(db_rec, graphres), \
- "Iterations per second ");
- }
-
- return curval;
-
- }
-
- int optparse(unsigned char * optarray, char* valarray, char **strargs,
- unsigned int numopt, int argc, char** argv)
- /*
- ** command line parser. optarray comes in filled with zeros; positions
- ** correspond to valid string pointers in vallarray.
- ** if strargs is null, no associated string. numop elements.
- ** On return, optarray has ones in positions that are set;
- ** strargs points to strings that are placed on command line ( filenames, for
- ** example).
- **
- ** options are always designated by '/'s or '-'s.
- **
- ** returns 1 on success, 0 on invalid option
- **
- */
-
- {
- char argstring[80];
- int arglen;
- int i, j;
- int lastslash;
-
- if(argc<2) return 1; /* nothing to do */
- strcpy(argstring, argv[1]);
- strcat(argstring, "\xff");
- for (i=2; i<argc; i++){
- strcat(argstring, argv[i]);
- strcat(argstring, "\xff");
- }
-
- arglen=strlen(argstring);
- argstring[arglen]=-1;
- arglen++;
- argstring[arglen]=-1;
- arglen++;
-
- if( (*(argstring) != '/')&&(*(argstring) != '-')) return 0;
- lastslash=1;
- for(i=1; i<arglen; i++){
- for (j=0;j<numopt;j++){
- if(valarray[j] == tolower(*(argstring+i))){
- optarray[j]++;
- if (strargs[j]!=NULL){
- if(*(argstring+i+1)==-1)
- i++;
- i+=ffcopy(strargs[j], argstring+i+1);
- }
- lastslash=0;
- break;
- }
- }
- if(j!=numopt) continue;
- if(*(argstring+i)== -1) continue;
- if(lastslash||((*(argstring+i)!='/') \
- &&(*(argstring+i)!='-')))
- return 0;
- lastslash=1;
- }
-
- return 1;
- }
-
- int ffcopy( char * dest, char * source)
- {
- int i;
- for (i=0;*(source+i)!=-1;i++)
- *(dest+i)=*(source+i);
- *(dest+i)=0;
- return i;
- }
-
- void switchlist(void)
-
- {
- printf("\n BBENCH -- BYTE DOS Benchmarks version 2.1\n");
- printf(" BYTE Magazine, Spring 1990\n\n");
-
- printf("Valid switches:\n");
- printf(" /n \"machine name\" -- Set default name for test machine\n");
- printf(" /r [resfile.nam] -- Generate results report\n");
- printf(" /c -- Run CPU tests immediately\n");
- printf(" /f -- Run FPU tests immediately\n");
- printf(" /d -- Run disk tests immediately\n");
- printf(" /v -- Run video tests immediately\n");
- printf(" /a -- Run all tests immediately (same as /cfdv)\n");
- printf(" /h -- Display this screen\n");
-
- }
-
- int delimres (void** lp)
- /*
- ** Creates delimited results file.
- ** zero on failure
- */
- {
- FILE *fh;
- int i;
- int co, i286off, i386off;
- char filname[13];
- char vendorname[80];
- char * productname;
-
- strncpy(filname, machname, 8);
- filname[8]=0;
- for(i=0; i<strlen(filname) ;i++){
- if( (*(filname+i)<=' ') ||
- (*(filname+i)=='\\') ||
- ((*(filname+i)>='*')&&(*(filname+i)<=',')) ||
- (*(filname+i)=='/') ||
- ((*(filname+i)>=':')&&(*(filname+i)<='?')) ||
- ((*(filname+i)>='[')&&(*(filname+i)<=']')) ||
- (*(filname+i)=='|') ||
- (*(filname+i)>~~ 0x07e)
- ) *(filname+i)='_';
- }
- strcat(filname, ".res");
-
- if((fh=(fopen(filname, "w")))==NULL) return 0;
-
- co=lin_search_db(0, recs_in_db-1, lp, \
- offset_in_struc(db_rec,currflag), INTCODE, 1);
-
- /* find 286 baseline */
- i286off=lin_search_db(0, recs_in_db-1, lp, \
- offset_in_struc(db_rec,basenum), INTCODE, 2);
-
- /* find 386 baseline */
- i386off=lin_search_db(0, recs_in_db-1, lp, \
- offset_in_struc(db_rec,basenum), INTCODE, 3);
-
- /* calculate indices */
- calc_indexes (lp, co, i286off, i386off);
-
- if(machine_config.proc_type>286)
- fprintf(fh, "%d,", 3);
- else
- fprintf(fh, "%d,", 2);
-
- /* seperate vendor from product */
- strcpy(vendorname,machname);
-
- for(i=0;i<strlen(vendorname);i++){
- if (*(vendorname+i)==' '){
- *(vendorname+i)=0;
- break;
- }
- }
-
- productname=vendorname+i+1;
-
- fprintf(fh, "\"%s\",", vendorname);
- fprintf(fh, "\"%s\",", productname);
- fprintf(fh, "%-6f,", vf(co, sieveres));
- fprintf(fh, "%-6f,", vf(co, sortres));
- fprintf(fh, "%-6f,", vf(co, imathres));
- fprintf(fh, "%-6f,", vf(co, movbres));
- fprintf(fh, "%-6f,", vf(co, movwores));
- fprintf(fh, "%-6f,", vf(co, movweres));
- fprintf(fh, "%-6f,", vf(co, movdores));
- fprintf(fh, "%-6f,", vf(co, movderes));
- fprintf(fh, "%-6f,", vf(co, fourbangres));
- fprintf(fh, "%-6f,", vf(co, forres));
- fprintf(fh, "%-6f,", vf(co, fiorres));
- fprintf(fh, "%-6f,", vf(co, fiowres));
- fprintf(fh, "%-6f,", vf(co, tpres));
- fprintf(fh, "%-6f,", vf(co, seekres));
- fprintf(fh, "%-6f,", vf(co, txposres));
- fprintf(fh, "%-6f,", vf(co, txscrollres));
- fprintf(fh, "%-6f,", vf(co, graphres));
- fprintf(fh, "%-6f,", vf(co, cpuat));
- fprintf(fh, "%-6f,", vf(co, fpuat));
- fprintf(fh, "%-6f,", vf(co, diskat));
- fprintf(fh, "%-6f,", vf(co, videoat));
- fprintf(fh, "%-6f,", vf(co, cpu386));
- fprintf(fh, "%-6f,", vf(co, fpu386));
- fprintf(fh, "%-6f,", vf(co, disk386));
- fprintf(fh, "%-6f", vf(co, video386));
-
- fclose(fh);
-
- return 1;
- }
-