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