ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/devcomm.c
(Generate patch)

Comparing ray/src/rt/devcomm.c (file contents):
Revision 1.7 by greg, Wed Nov 1 17:33:03 1989 UTC vs.
Revision 1.12 by greg, Thu Feb 22 11:46:13 1990 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *      10/5/88
11   */
12  
13 < #include <stdio.h>
13 > #include "standard.h"
14  
15   #include <signal.h>
16  
# Line 26 | Line 26 | static char SCCSid[] = "$SunId$ LBL";
26   #define vfork           fork
27   #endif
28  
29 #ifndef WFLUSH
30 #define WFLUSH          30              /* flush after this many rays */
31 #endif
32
29   extern char     *getpath(), *getenv();
30  
31   int     onsigio();
32  
33   int     comm_close(), comm_clear(), comm_paintr(), comm_errout(),
34 <                comm_getcur(), comm_comout(), comm_comin();
34 >                comm_getcur(), comm_comout(), comm_comin(), comm_flush();
35  
36 < struct driver   comm_driver, comm_default = {
36 > struct driver   comm_driver = {
37          comm_close, comm_clear, comm_paintr, comm_getcur,
38 <        comm_comout, comm_comin,
43 <        MAXRES, MAXRES, 0
38 >        comm_comout, comm_comin, comm_flush
39   };
40  
41   FILE    *devin, *devout;
# Line 81 | Line 76 | char   *dname, *id;
76                  goto syserr;
77          if ((devin = fdopen(p2[0], "r")) == NULL)
78                  goto syserr;
84        bcopy(&comm_default, &comm_driver, sizeof(comm_driver));
79                                                  /* verify & get resolution */
80          putw(COM_SENDM, devout);
81          fflush(devout);
82          if (getw(devin) != COM_RECVM)
83                  return(NULL);
84 +        fread((char *)&comm_driver.pixaspect,
85 +                        sizeof(comm_driver.pixaspect), 1, devin);
86          comm_driver.xsiz = getw(devin);
87          comm_driver.ysiz = getw(devin);
88                                                  /* input handling */
# Line 123 | Line 119 | comm_clear(xres, yres)                         /* clear screen */
119   int     xres, yres;
120   {
121          putc(COM_CLEAR, devout);
122 <        fwrite(&xres, sizeof(xres), 1, devout);
123 <        fwrite(&yres, sizeof(yres), 1, devout);
122 >        putw(xres, devout);
123 >        putw(yres, devout);
124          fflush(devout);
125   }
126  
# Line 134 | Line 130 | comm_paintr(col, xmin, ymin, xmax, ymax)       /* paint a re
130   COLOR   col;
131   int     xmin, ymin, xmax, ymax;
132   {
137        extern long     nrays;          /* number of rays traced */
138        static long     lastflush = 0;  /* ray count at last flush */
139
133          putc(COM_PAINTR, devout);
134 <        fwrite(col, sizeof(COLOR), 1, devout);
135 <        fwrite(&xmin, sizeof(xmin), 1, devout);
136 <        fwrite(&ymin, sizeof(ymin), 1, devout);
137 <        fwrite(&xmax, sizeof(xmax), 1, devout);
138 <        fwrite(&ymax, sizeof(ymax), 1, devout);
146 <        if (nrays - lastflush >= WFLUSH) {
147 <                fflush(devout);
148 <                lastflush = nrays;
149 <        }
134 >        fwrite((char *)col, sizeof(COLOR), 1, devout);
135 >        putw(xmin, devout);
136 >        putw(ymin, devout);
137 >        putw(xmax, devout);
138 >        putw(ymax, devout);
139   }
140  
141  
142 + static
143 + comm_flush()                            /* flush output to driver */
144 + {
145 +        putc(COM_FLUSH, devout);
146 +        fflush(devout);
147 + }
148 +
149 +
150   static int
151   comm_getcur(xp, yp)                     /* get and return cursor position */
152   int     *xp, *yp;
# Line 161 | Line 158 | int    *xp, *yp;
158          if (getc(devin) != COM_GETCUR)
159                  reply_error("getcur");
160          c = getc(devin);
161 <        fread(xp, sizeof(*xp), 1, devin);
162 <        fread(yp, sizeof(*yp), 1, devin);
161 >        *xp = getw(devin);
162 >        *yp = getw(devin);
163          return(c);
164   }
165  
# Line 178 | Line 175 | char   *str;
175  
176  
177   static
178 < comm_comin(buf)                         /* read string from command line */
178 > comm_comin(buf, prompt)                 /* read string from command line */
179   char    *buf;
180 + char    *prompt;
181   {
182          putc(COM_COMIN, devout);
183 +        if (prompt == NULL)
184 +                putc(0, devout);
185 +        else {
186 +                putc(1, devout);
187 +                myputs(prompt, devout);
188 +        }
189          fflush(devout);
190          if (getc(devin) != COM_COMIN)
191                  reply_error("comin");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines