|
|
1.1 root 1: /*
2: * Copyright (c) 1985 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)terminal.c 5.2 (Berkeley) 6/27/88";
20: #endif /* not lint */
21:
22: /*
23: * Hunt
24: * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
25: * San Francisco, California
26: */
27:
28: # include "hunt.h"
29: # define TERM_WIDTH 80 /* Assume terminals are 80-char wide */
30:
31: /*
32: * cgoto:
33: * Move the cursor to the given position on the given player's
34: * terminal.
35: */
36: cgoto(pp, y, x)
37: register PLAYER *pp;
38: register int y, x;
39: {
40: if (x == pp->p_curx && y == pp->p_cury)
41: return;
42: sendcom(pp, MOVE, y, x);
43: pp->p_cury = y;
44: pp->p_curx = x;
45: }
46:
47: /*
48: * outch:
49: * Put out a single character.
50: */
51: outch(pp, ch)
52: register PLAYER *pp;
53: char ch;
54: {
55: if (++pp->p_curx >= TERM_WIDTH) {
56: pp->p_curx = 0;
57: pp->p_cury++;
58: }
59: (void) putc(ch, pp->p_output);
60: }
61:
62: /*
63: * outstr:
64: * Put out a string of the given length.
65: */
66: outstr(pp, str, len)
67: register PLAYER *pp;
68: register char *str;
69: register int len;
70: {
71: pp->p_curx += len;
72: pp->p_cury += (pp->p_curx / TERM_WIDTH);
73: pp->p_curx %= TERM_WIDTH;
74: while (len--)
75: (void) putc(*str++, pp->p_output);
76: }
77:
78: /*
79: * clrscr:
80: * Clear the screen, and reset the current position on the screen.
81: */
82: clrscr(pp)
83: register PLAYER *pp;
84: {
85: sendcom(pp, CLEAR);
86: pp->p_cury = 0;
87: pp->p_curx = 0;
88: }
89:
90: /*
91: * ce:
92: * Clear to the end of the line
93: */
94: ce(pp)
95: PLAYER *pp;
96: {
97: sendcom(pp, CLRTOEOL);
98: }
99:
100: /*
101: * ref;
102: * Refresh the screen
103: */
104: ref(pp)
105: register PLAYER *pp;
106: {
107: sendcom(pp, REFRESH);
108: }
109:
110: /*
111: * sendcom:
112: * Send a command to the given user
113: */
114: /* VARARGS2 */
115: sendcom(pp, command, arg1, arg2)
116: register PLAYER *pp;
117: register int command;
118: int arg1, arg2;
119: {
120: (void) putc(command, pp->p_output);
121: switch (command & 0377) {
122: case MOVE:
123: (void) putc(arg1, pp->p_output);
124: (void) putc(arg2, pp->p_output);
125: break;
126: case ADDCH:
127: case READY:
128: (void) putc(arg1, pp->p_output);
129: break;
130: }
131: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.