| 8 |
|
#include <string.h> |
| 9 |
|
#include <ctype.h> |
| 10 |
|
|
| 11 |
+ |
#include "rterror.h" |
| 12 |
|
#include "rholo.h" |
| 13 |
|
#include "rhdisp.h" |
| 14 |
|
#include "rhdriver.h" |
| 58 |
|
#define RDY_DEV 02 |
| 59 |
|
#define RDY_SIN 04 |
| 60 |
|
|
| 61 |
+ |
static int disp_wait(void); |
| 62 |
+ |
static void add_holo(HDGRID *hdg, char *gfn, char *pfn); |
| 63 |
+ |
static void disp_bundle(PACKHEAD *p); |
| 64 |
+ |
static void new_view(VIEW *v); |
| 65 |
+ |
static void set_focus(char *args); |
| 66 |
+ |
static int usr_input(void); |
| 67 |
+ |
static void printview(void); |
| 68 |
|
|
| 69 |
< |
main(argc, argv) |
| 70 |
< |
int argc; |
| 71 |
< |
char *argv[]; |
| 69 |
> |
|
| 70 |
> |
int |
| 71 |
> |
main( |
| 72 |
> |
int argc, |
| 73 |
> |
char *argv[] |
| 74 |
> |
) |
| 75 |
|
{ |
| 76 |
|
int rdy, inp, res = 0, pause = 0; |
| 77 |
|
|
| 160 |
|
#endif |
| 161 |
|
/* all done */ |
| 162 |
|
quit(0); |
| 163 |
+ |
return 0; /* pro forma return */ |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
|
| 167 |
< |
int |
| 168 |
< |
disp_wait() /* wait for more input */ |
| 167 |
> |
static int |
| 168 |
> |
disp_wait(void) /* wait for more input */ |
| 169 |
|
{ |
| 170 |
|
fd_set readset, errset; |
| 171 |
|
int flgs; |
| 172 |
|
int n; |
| 161 |
– |
register int i; |
| 173 |
|
/* see if we can avoid select call */ |
| 174 |
|
if (hdlist[0] == NULL) |
| 175 |
|
return(RDY_SRV); /* initialize first */ |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
|
| 217 |
< |
add_holo(hdg, gfn, pfn) /* register a new holodeck section */ |
| 218 |
< |
HDGRID *hdg; |
| 219 |
< |
char *gfn, *pfn; |
| 217 |
> |
static void |
| 218 |
> |
add_holo( /* a new holodeck section */ |
| 219 |
> |
HDGRID *hdg, |
| 220 |
> |
char *gfn, |
| 221 |
> |
char *pfn |
| 222 |
> |
) |
| 223 |
|
{ |
| 224 |
|
VIEW nv; |
| 225 |
|
double d; |
| 226 |
< |
register int hd; |
| 226 |
> |
int hd; |
| 227 |
|
|
| 228 |
|
for (hd = 0; hd < HDMAX && hdlist[hd] != NULL; hd++) |
| 229 |
|
; |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
|
| 258 |
< |
disp_bundle(p) /* display a ray bundle */ |
| 259 |
< |
register PACKHEAD *p; |
| 258 |
> |
static void |
| 259 |
> |
disp_bundle( /* display a ray bundle */ |
| 260 |
> |
PACKHEAD *p |
| 261 |
> |
) |
| 262 |
|
{ |
| 263 |
|
GCOORD gc[2]; |
| 264 |
|
FVECT ro, rd, wp; |
| 265 |
|
double d; |
| 266 |
< |
register int i; |
| 266 |
> |
int i; |
| 267 |
|
/* get beam coordinates */ |
| 268 |
< |
if (p->hd < 0 | p->hd >= HDMAX || hdlist[p->hd] == NULL) |
| 268 |
> |
if ((p->hd < 0) | (p->hd >= HDMAX) || hdlist[p->hd] == NULL) |
| 269 |
|
error(INTERNAL, "bad holodeck number in disp_bundle"); |
| 270 |
|
if (!hdbcoord(gc, hdlist[p->hd], p->bi)) |
| 271 |
|
error(INTERNAL, "bad beam index in disp_bundle"); |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
|
| 289 |
< |
new_view(v) /* change view parameters */ |
| 290 |
< |
register VIEW *v; |
| 289 |
> |
static void |
| 290 |
> |
new_view( /* change view parameters */ |
| 291 |
> |
VIEW *v |
| 292 |
> |
) |
| 293 |
|
{ |
| 294 |
|
static VIEW viewhist[VIEWHISTLEN]; |
| 295 |
|
static unsigned nhist; |
| 325 |
|
return; |
| 326 |
|
} |
| 327 |
|
*v = *(viewhist + ((nhist-1)%VIEWHISTLEN)); |
| 328 |
< |
goto again; /* poss. overloading dev_section()? */ |
| 328 |
> |
goto again; /* XXX overloading dev_section()? */ |
| 329 |
|
} |
| 330 |
|
DCHECK(*slist < 0, WARNING, "no visible sections in new_view"); |
| 331 |
|
for ( ; *slist >= 0; slist++) |
| 343 |
|
} |
| 344 |
|
|
| 345 |
|
|
| 346 |
< |
set_focus(args) /* set focus frame */ |
| 347 |
< |
char *args; |
| 346 |
> |
static void |
| 347 |
> |
set_focus( /* set focus frame */ |
| 348 |
> |
char *args |
| 349 |
> |
) |
| 350 |
|
{ |
| 351 |
|
double hcent, vcent, hsiz, vsiz; |
| 352 |
|
VIEW *dv, vwfocus; |
| 382 |
|
vwfocus.horiz = hsiz * odev.v.horiz; |
| 383 |
|
vwfocus.vert = vsiz * odev.v.vert; |
| 384 |
|
break; |
| 385 |
+ |
case VT_PLS: |
| 386 |
+ |
vwfocus.horiz = hsiz * sin((PI/180./2.)*odev.v.horiz) / |
| 387 |
+ |
(1.0 + cos((PI/180./2.)*odev.v.horiz)); |
| 388 |
+ |
vwfocus.horiz *= vwfocus.horiz; |
| 389 |
+ |
vwfocus.horiz = (2.*180./PI)*acos((1. - vwfocus.horiz) / |
| 390 |
+ |
(1. + vwfocus.horiz)); |
| 391 |
+ |
vwfocus.vert = vsiz * sin((PI/180./2.)*odev.v.vert) / |
| 392 |
+ |
(1.0 + cos((PI/180./2.)*odev.v.vert)); |
| 393 |
+ |
vwfocus.vert *= vwfocus.vert; |
| 394 |
+ |
vwfocus.vert = (2.*180./PI)*acos((1. - vwfocus.vert) / |
| 395 |
+ |
(1. + vwfocus.vert)); |
| 396 |
+ |
break; |
| 397 |
|
case VT_HEM: |
| 398 |
|
vwfocus.horiz = 2.*180./PI*asin( |
| 399 |
|
hsiz * sin(PI/180./2.*odev.v.horiz) ); |
| 417 |
|
} |
| 418 |
|
|
| 419 |
|
|
| 420 |
< |
int |
| 421 |
< |
usr_input() /* get user input and process it */ |
| 420 |
> |
static int |
| 421 |
> |
usr_input(void) /* get user input and process it */ |
| 422 |
|
{ |
| 423 |
|
VIEW vparams; |
| 424 |
|
char cmd[256]; |
| 425 |
< |
register char *args; |
| 426 |
< |
register int i; |
| 425 |
> |
char *args; |
| 426 |
> |
int i; |
| 427 |
|
|
| 428 |
|
if (fgets(cmd, sizeof(cmd), sstdin) == NULL) { |
| 429 |
|
fclose(sstdin); |
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
|
| 492 |
< |
printview() /* print our current view to server stdout */ |
| 492 |
> |
static void |
| 493 |
> |
printview(void) /* print our current view to server stdout */ |
| 494 |
|
{ |
| 495 |
|
fputs(VIEWSTR, sstdout); |
| 496 |
|
fprintview(&odev.v, sstdout); |
| 500 |
|
|
| 501 |
|
|
| 502 |
|
int |
| 503 |
< |
serv_result() /* get next server result and process it */ |
| 503 |
> |
serv_result(void) /* get next server result and process it */ |
| 504 |
|
{ |
| 505 |
|
static char *buf = NULL; |
| 506 |
|
static int bufsiz = 0; |
| 507 |
|
MSGHEAD msg; |
| 475 |
– |
int n; |
| 508 |
|
/* read message header */ |
| 509 |
< |
if (fread((char *)&msg, sizeof(MSGHEAD), 1, stdin) != 1) |
| 509 |
> |
if (getbinary(&msg, sizeof(MSGHEAD), 1, stdin) != 1) |
| 510 |
|
goto readerr; |
| 511 |
|
if (msg.nbytes > 0) { /* get the message body */ |
| 512 |
|
if (msg.nbytes > bufsiz) { |
| 518 |
|
if (buf == NULL) |
| 519 |
|
error(SYSTEM, "out of memory in serv_result"); |
| 520 |
|
} |
| 521 |
< |
if (fread(buf, 1, msg.nbytes, stdin) != msg.nbytes) |
| 521 |
> |
if (getbinary(buf, 1, msg.nbytes, stdin) != msg.nbytes) |
| 522 |
|
goto readerr; |
| 523 |
|
} |
| 524 |
|
switch (msg.type) { /* process results */ |
| 543 |
|
break; |
| 544 |
|
case DS_STARTIMM: |
| 545 |
|
case DS_ENDIMM: |
| 546 |
< |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
| 546 |
> |
if (!(imm_mode = (msg.type==DS_STARTIMM))) |
| 547 |
|
dev_flush(); |
| 548 |
|
#ifdef DEBUG |
| 549 |
|
{ |
| 572 |
|
if (feof(stdin)) |
| 573 |
|
error(SYSTEM, "server process died"); |
| 574 |
|
error(SYSTEM, "error reading from server process"); |
| 575 |
+ |
return -1; |
| 576 |
|
} |
| 577 |
|
|
| 578 |
|
|
| 579 |
< |
serv_request(type, nbytes, p) /* send a request to the server process */ |
| 580 |
< |
int type, nbytes; |
| 581 |
< |
char *p; |
| 579 |
> |
void |
| 580 |
> |
serv_request( /* send a request to the server process */ |
| 581 |
> |
int type, |
| 582 |
> |
int nbytes, |
| 583 |
> |
char *p |
| 584 |
> |
) |
| 585 |
|
{ |
| 586 |
|
MSGHEAD msg; |
| 587 |
|
int m; |
| 597 |
|
} |
| 598 |
|
msg.type = type; /* write and flush the message */ |
| 599 |
|
msg.nbytes = nbytes; |
| 600 |
< |
fwrite((char *)&msg, sizeof(MSGHEAD), 1, stdout); |
| 600 |
> |
putbinary(&msg, sizeof(MSGHEAD), 1, stdout); |
| 601 |
|
if (nbytes > 0) |
| 602 |
< |
fwrite(p, 1, nbytes, stdout); |
| 602 |
> |
putbinary(p, 1, nbytes, stdout); |
| 603 |
|
if (fflush(stdout) < 0) |
| 604 |
|
error(SYSTEM, "write error in serv_request"); |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
|
| 608 |
|
void |
| 609 |
< |
eputs(s) /* put error message to stderr */ |
| 610 |
< |
register char *s; |
| 609 |
> |
eputs( /* put error message to stderr */ |
| 610 |
> |
const char *s |
| 611 |
> |
) |
| 612 |
|
{ |
| 613 |
|
static int midline = 0; |
| 614 |
|
|
| 627 |
|
|
| 628 |
|
|
| 629 |
|
void |
| 630 |
< |
quit(code) /* clean up and exit */ |
| 631 |
< |
int code; |
| 630 |
> |
quit( /* clean up and exit */ |
| 631 |
> |
int code |
| 632 |
> |
) |
| 633 |
|
{ |
| 634 |
|
if (code) |
| 635 |
|
exit(code); |