#include "4107.h" /* * Convert xy pair to terminal encoded syntax. */ encode_xy(x,y) register long x,y; { static lasthix = 0xfff, lasthiy = 0xfff, lastloy = 0xfff, lastext = 0xfff; int hix, lox, hiy, loy, ext; if (x < 0) x = 0; else if (x >= 4096) x = 4096 - 1; if (y < 0) y = 0; else if (y >= 3133) y = 3133 - 1; hix = x & 0xf80; lox = x & 0x07c; hiy = y & 0xf80; loy = y & 0x07c; ext = ((y & 0x03) << 2) | (x & 0x03); putchar( (hiy >> 7) | 0x20 ); putchar( ext | 0x60 ); putchar( (loy >> 2) | 0x60 ); putchar( (hix >> 7) | 0x20 ); putchar( (lox >> 2) | 0x40 ); } /* * Convert integer parameter to terminal syntax. */ encode(i) register long i; { char buffer[50]; register char *bp = &buffer[49]; *bp-- = '\0'; if (i < 0) { i = -i; *bp-- = (i & 0xf) | 0x20; } else { *bp-- = (i & 0xf) | 0x30; } i >>= 4; while (i > 0) { *bp-- = (i & 0x3f) | 0x40; i >>= 6; } while (*++bp) putchar(*bp); } /* * Encode a string into an integer array */ encode_str(str) /* requires a variable length string terminated with \0 */ /* encode(-135, "l") */ char str[1]; { register i; encode(strlen(str)); for (i=0 ; i