1*15526Sralph #ifndef lint 2*15526Sralph static char sccsid[] = "@(#)subr.c 4.1 (Berkeley) 11/11/83"; 3*15526Sralph #endif 4*15526Sralph 5*15526Sralph #include "aed.h" 6*15526Sralph 7*15526Sralph /* 8*15526Sralph * The following table is used to convert numbers to hex. We cannot use 9*15526Sralph * standard C library conversion because it generates lower case letters 10*15526Sralph * which are bad news to the AED512. 11*15526Sralph */ 12*15526Sralph 13*15526Sralph static char hex[] = "0123456789ABCDEF"; 14*15526Sralph 15*15526Sralph /*--------------------------------------------------------- 16*15526Sralph * This is a local routine that converts an integer to a string 17*15526Sralph * of hexadecimal characters. 18*15526Sralph * 19*15526Sralph * Results: None. 20*15526Sralph * 21*15526Sralph * Side Effects: 22*15526Sralph * The string contains the value of the low-order nchars 4-bit chunks 23*15526Sralph * of val, as represented in hexadecimal. String is zero-filled. 24*15526Sralph *--------------------------------------------------------- 25*15526Sralph */ 26*15526Sralph chex(val, string, nchars) 27*15526Sralph int val; /* Integer value to be converted. */ 28*15526Sralph char *string; /* Pointer to area for converted result. */ 29*15526Sralph int nchars; /* Number of characters to be converted. */ 30*15526Sralph { 31*15526Sralph string = &(string[nchars]); 32*15526Sralph *string = '\0'; 33*15526Sralph for (; nchars>0 ; nchars--) 34*15526Sralph { 35*15526Sralph *(--string) = hex[val & 017]; 36*15526Sralph val >>= 4; 37*15526Sralph } 38*15526Sralph } 39*15526Sralph 40*15526Sralph /*--------------------------------------------------------- 41*15526Sralph * This local routine outputs an x-y coordinate pair in the standard 42*15526Sralph * format required by the AED display. 43*15526Sralph * 44*15526Sralph * Results: None. 45*15526Sralph * 46*15526Sralph * Side Effects: 47*15526Sralph * Characters are output to the AED512 in the standard way required 48*15526Sralph * for values indicated by "xy20" in the user manual. 49*15526Sralph * 50*15526Sralph * Errors: None. 51*15526Sralph *--------------------------------------------------------- 52*15526Sralph */ 53*15526Sralph outxy20(x, y) 54*15526Sralph int x, y; /* The coordinates to be output. Note: 55*15526Sralph * these are world coordinates, not screen 56*15526Sralph * ones. We scale in this routine. 57*15526Sralph */ 58*15526Sralph { 59*15526Sralph char s1[4], s2[4], s3[4]; 60*15526Sralph x = ((x - xbot) * scale)>>12; 61*15526Sralph y = ((y - ybot) * scale)>>12; 62*15526Sralph chex(((y>>8)&03) | ((x>>6)&014), s1, 1); 63*15526Sralph chex(x&0377, s2, 2); 64*15526Sralph chex(y&0377, s3, 2); 65*15526Sralph fprintf(stdout, "%s%s%s", s1, s2, s3); 66*15526Sralph } 67*15526Sralph 68*15526Sralph /*--------------------------------------------------------- 69*15526Sralph * This routine sets the display's current color. 70*15526Sralph * 71*15526Sralph * Results: None. 72*15526Sralph * 73*15526Sralph * Side Effects: 74*15526Sralph * The current color in the display is set to pcolor, if it 75*15526Sralph * isn't that already. 76*15526Sralph *--------------------------------------------------------- 77*15526Sralph */ 78*15526Sralph setcolor(pcolor) 79*15526Sralph char *pcolor; /* Pointer to a string giving the desired 80*15526Sralph * color in hexadecimal. 81*15526Sralph */ 82*15526Sralph { 83*15526Sralph static char curcolor[] = "xx"; 84*15526Sralph if ((pcolor[0] != curcolor[0]) || (pcolor[1] != curcolor[1])) 85*15526Sralph { 86*15526Sralph curcolor[0] = pcolor[0]; 87*15526Sralph curcolor[1] = pcolor[1]; 88*15526Sralph putc('L', stdout); 89*15526Sralph fputs(curcolor, stdout); 90*15526Sralph } 91*15526Sralph } 92