home *** CD-ROM | disk | FTP | other *** search
- /* displayd - display the special demo file demo.mp2.
-
- Copyright 1986 John B. Allison */
-
- displayd(){
-
- #define READMODE 0x8000 /* open a file in read mode */
-
- int fp, n;
- float x, y;
-
- struct { /* input record structure */
- int type;
- float xvalue,
- yvalue;
- } record;
-
-
-
- /* Open the binary .mp2 file for read. */
-
- if((fp=open("demo.mp2", READMODE)) == -1){
- closegraphics();
- printf("Error opening demo.mp2\n");
- exit();
- }
-
- /* Read file until EOF */
-
- while((n=read(fp, &record, sizeof(record))) != 0){
-
- if(n == -1){ /* read error */
- closegraphics();
- printf("Error reading demo.mp2\n");
- exit();
- }
-
- x = record.xvalue; /* successful read */
- y = record.yvalue;
-
- if(record.type == 0){ /* start a new string */
- movabs(&x, &y);
- } else { /* draw line segment */
- lnabs(&x, &y);
- }
- }
-
- close(fp);
- }