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