--- ray/src/hd/rhdisp2.c 1999/03/04 10:29:22 3.32 +++ ray/src/hd/rhdisp2.c 2004/01/01 11:21:55 3.37 @@ -1,9 +1,6 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rhdisp2.c,v 3.37 2004/01/01 11:21:55 schorsch Exp $"; #endif - /* * Holodeck beam tracking for display process */ @@ -25,9 +22,16 @@ static int maxcbeam = 0; /* size of cbeam array */ VIEWPOINT cureye; /* current eye position */ +static int newcbeam(void); +static int cbeamcmp(const void *cb1, const void *cb2); +static int cbeamcmp2(const void *cb1, const void *cb2); +static int findcbeam(int hd, int bi); +static int getcbeam(int hd, int bi); +static void cbeamsort(int adopt); -int -newcbeam() /* allocate new entry at end of cbeam array */ + +static int +newcbeam(void) /* allocate new entry at end of cbeam array */ { int i; @@ -37,7 +41,7 @@ newcbeam() /* allocate new entry at end of cbeam arra cbeam = (PACKHEAD *)malloc( maxcbeam*sizeof(PACKHEAD) ); else - cbeam = (PACKHEAD *)realloc( (char *)cbeam, + cbeam = (PACKHEAD *)realloc((void *)cbeam, maxcbeam*sizeof(PACKHEAD) ); if (cbeam == NULL) error(SYSTEM, "out of memory in newcbeam"); @@ -46,37 +50,43 @@ newcbeam() /* allocate new entry at end of cbeam arra } -int -cbeamcmp(cb1, cb2) /* compare two cbeam entries for sort: keep orphans */ -register PACKHEAD *cb1, *cb2; +static int +cbeamcmp( /* compare two cbeam entries for sort: keep orphans */ + const void *cb1, + const void *cb2 +) { register int c; - if ((c = cb1->bi - cb2->bi)) /* sort on beam index first */ + if ((c = ((PACKHEAD*)cb1)->bi - ((PACKHEAD*)cb2)->bi)) /* sort on beam index first */ return(c); - return(cb1->hd - cb2->hd); /* use hd to resolve matches */ + return(((PACKHEAD*)cb1)->hd - ((PACKHEAD*)cb2)->hd); /* use hd to resolve matches */ } -int -cbeamcmp2(cb1, cb2) /* compare two cbeam entries for sort: no orphans */ -register PACKHEAD *cb1, *cb2; +static int +cbeamcmp2( /* compare two cbeam entries for sort: no orphans */ + const void *cb1, + const void *cb2 +) { register int c; - if (!cb1->nr) /* put orphans at the end, unsorted */ - return(cb2->nr); - if (!cb2->nr) + if (!((PACKHEAD*)cb1)->nr) /* put orphans at the end, unsorted */ + return(((PACKHEAD*)cb2)->nr); + if (!((PACKHEAD*)cb2)->nr) return(-1); - if ((c = cb1->bi - cb2->bi)) /* sort on beam index first */ + if ((c = ((PACKHEAD*)cb1)->bi - ((PACKHEAD*)cb2)->bi)) /* sort on beam index first */ return(c); - return(cb1->hd - cb2->hd); /* use hd to resolve matches */ + return(((PACKHEAD*)cb1)->hd - ((PACKHEAD*)cb2)->hd); /* use hd to resolve matches */ } -int -findcbeam(hd, bi) /* find the specified beam in our sorted list */ -int hd, bi; +static int +findcbeam( /* find the specified beam in our sorted list */ + int hd, + int bi +) { PACKHEAD cb; register PACKHEAD *p; @@ -92,10 +102,11 @@ int hd, bi; } -int -getcbeam(hd, bi) /* get the specified beam, allocating as necessary */ -register int hd; -int bi; +static int +getcbeam( /* get the specified beam, allocating as necessary */ + register int hd, + int bi +) { register int n; /* first, look in sorted list */ @@ -106,9 +117,9 @@ int bi; if (cbeam[n].bi == bi && cbeam[n].hd == hd) return(n); /* check legality */ - if (hd < 0 | hd >= HDMAX || hdlist[hd] == NULL) + if ((hd < 0) | (hd >= HDMAX) || hdlist[hd] == NULL) error(INTERNAL, "illegal holodeck number in getcbeam"); - if (bi < 1 | bi > nbeams(hdlist[hd])) + if ((bi < 1) | (bi > nbeams(hdlist[hd]))) error(INTERNAL, "illegal beam index in getcbeam"); n = newcbeam(); /* allocate and assign */ cbeam[n].hd = hd; cbeam[n].bi = bi; cbeam[n].nr = cbeam[n].nc = 0; @@ -116,8 +127,10 @@ int bi; } -cbeamsort(adopt) /* sort our beam list, possibly turning out orphans */ -int adopt; +static void +cbeamsort( /* sort our beam list, possibly turning out orphans */ + int adopt +) { register int i; @@ -136,8 +149,10 @@ int adopt; } -beam_init(fresh) /* clear beam list for new view(s) */ -int fresh; +extern void +beam_init( /* clear beam list for new view(s) */ + int fresh +) { register int i; @@ -150,12 +165,14 @@ int fresh; } -int2 * -beam_view(vn, hr, vr) /* add beam view (if advisable) */ -VIEW *vn; -int hr, vr; +extern int16 * +beam_view( /* add beam view (if advisable) */ + VIEW *vn, + int hr, + int vr +) { - int2 *slist; + int16 *slist; BEAMLIST blist; double eravg, d; register HOLO *hp; @@ -174,7 +191,7 @@ int hr, vr; if (blist.bl[i].nr > cbeam[n].nr) cbeam[n].nr = blist.bl[i].nr; } - free((char *)blist.bl); /* free list */ + free((void *)blist.bl); /* free list */ if (MEYERNG <= FTINY) return(slist); /* compute average eye range */ @@ -199,9 +216,10 @@ int hr, vr; } -int -beam_sync(all) /* update beam list on server */ -int all; +extern int +beam_sync( /* update beam list on server */ + int all +) { /* set new eye position */ serv_request(DR_VIEWPOINT, sizeof(VIEWPOINT), (char *)&cureye); @@ -211,19 +229,21 @@ int all; if (all) { if (ncbeams > 0) serv_request(DR_NEWSET, - ncbeams*sizeof(PACKHEAD), cbeam); + ncbeams*sizeof(PACKHEAD), (char *)cbeam); } else { if (ncbeams+xcbeams > 0) serv_request(DR_ADJSET, - (ncbeams+xcbeams)*sizeof(PACKHEAD), cbeam); + (ncbeams+xcbeams)*sizeof(PACKHEAD), (char *)cbeam); } xcbeams = 0; /* truncate our list */ return(ncbeams); } -gridlines(f) /* run through holodeck section grid lines */ -int (*f)(); +extern void +gridlines( /* run through holodeck section grid lines */ + void (*f)(FVECT wp[2]) +) { register int hd, w, i; int g0, g1;