1*48502Sbostic /*- 2*48502Sbostic * Copyright (c) 1983 The Regents of the University of California. 3*48502Sbostic * All rights reserved. 4*48502Sbostic * 5*48502Sbostic * %sccs.include.proprietary.c% 6*48502Sbostic */ 7*48502Sbostic 815526Sralph #ifndef lint 9*48502Sbostic static char sccsid[] = "@(#)subr.c 5.2 (Berkeley) 04/22/91"; 10*48502Sbostic #endif /* not lint */ 1115526Sralph 1215526Sralph #include "aed.h" 1315526Sralph 1415526Sralph /* 1515526Sralph * The following table is used to convert numbers to hex. We cannot use 1615526Sralph * standard C library conversion because it generates lower case letters 1715526Sralph * which are bad news to the AED512. 1815526Sralph */ 1915526Sralph 2015526Sralph static char hex[] = "0123456789ABCDEF"; 2115526Sralph 2215526Sralph /*--------------------------------------------------------- 2315526Sralph * This is a local routine that converts an integer to a string 2415526Sralph * of hexadecimal characters. 2515526Sralph * 2615526Sralph * Results: None. 2715526Sralph * 2815526Sralph * Side Effects: 2915526Sralph * The string contains the value of the low-order nchars 4-bit chunks 3015526Sralph * of val, as represented in hexadecimal. String is zero-filled. 3115526Sralph *--------------------------------------------------------- 3215526Sralph */ 3315526Sralph chex(val, string, nchars) 3415526Sralph int val; /* Integer value to be converted. */ 3515526Sralph char *string; /* Pointer to area for converted result. */ 3615526Sralph int nchars; /* Number of characters to be converted. */ 3715526Sralph { 3815526Sralph string = &(string[nchars]); 3915526Sralph *string = '\0'; 4015526Sralph for (; nchars>0 ; nchars--) 4115526Sralph { 4215526Sralph *(--string) = hex[val & 017]; 4315526Sralph val >>= 4; 4415526Sralph } 4515526Sralph } 4615526Sralph 4715526Sralph /*--------------------------------------------------------- 4815526Sralph * This local routine outputs an x-y coordinate pair in the standard 4915526Sralph * format required by the AED display. 5015526Sralph * 5115526Sralph * Results: None. 5215526Sralph * 5315526Sralph * Side Effects: 5415526Sralph * Characters are output to the AED512 in the standard way required 5515526Sralph * for values indicated by "xy20" in the user manual. 5615526Sralph * 5715526Sralph * Errors: None. 5815526Sralph *--------------------------------------------------------- 5915526Sralph */ 6015526Sralph outxy20(x, y) 6115526Sralph int x, y; /* The coordinates to be output. Note: 6215526Sralph * these are world coordinates, not screen 6315526Sralph * ones. We scale in this routine. 6415526Sralph */ 6515526Sralph { 6615526Sralph char s1[4], s2[4], s3[4]; 6715526Sralph x = ((x - xbot) * scale)>>12; 6815526Sralph y = ((y - ybot) * scale)>>12; 6915526Sralph chex(((y>>8)&03) | ((x>>6)&014), s1, 1); 7015526Sralph chex(x&0377, s2, 2); 7115526Sralph chex(y&0377, s3, 2); 7215526Sralph fprintf(stdout, "%s%s%s", s1, s2, s3); 7315526Sralph } 7415526Sralph 7515526Sralph /*--------------------------------------------------------- 7615526Sralph * This routine sets the display's current color. 7715526Sralph * 7815526Sralph * Results: None. 7915526Sralph * 8015526Sralph * Side Effects: 8115526Sralph * The current color in the display is set to pcolor, if it 8215526Sralph * isn't that already. 8315526Sralph *--------------------------------------------------------- 8415526Sralph */ 8515526Sralph setcolor(pcolor) 8615526Sralph char *pcolor; /* Pointer to a string giving the desired 8715526Sralph * color in hexadecimal. 8815526Sralph */ 8915526Sralph { 9015526Sralph static char curcolor[] = "xx"; 9115526Sralph if ((pcolor[0] != curcolor[0]) || (pcolor[1] != curcolor[1])) 9215526Sralph { 9315526Sralph curcolor[0] = pcolor[0]; 9415526Sralph curcolor[1] = pcolor[1]; 9515526Sralph putc('L', stdout); 9615526Sralph fputs(curcolor, stdout); 9715526Sralph } 9815526Sralph } 99