]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hunt/huntd/terminal.c
a54d61b194bdfd98eb10e75b4d83d6ecfda63ff3
1 /* $NetBSD: terminal.c,v 1.5 2008/01/28 03:23:29 dholland Exp $ */
3 * Copyright (c) 1983-2003, Regents of the University of California.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * + Neither the name of the University of California, San Francisco nor
16 * the names of its contributors may be used to endorse or promote
17 * products derived from this software without specific prior written
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
35 __RCSID("$NetBSD: terminal.c,v 1.5 2008/01/28 03:23:29 dholland Exp $");
40 #define TERM_WIDTH 80 /* Assume terminals are 80-char wide */
44 * Move the cursor to the given position on the given player's
52 if (x
== pp
->p_curx
&& y
== pp
->p_cury
)
54 sendcom(pp
, MOVE
, y
, x
);
61 * Put out a single character.
68 if (++pp
->p_curx
>= TERM_WIDTH
) {
72 (void) putc(ch
, pp
->p_output
);
77 * Put out a string of the given length.
86 pp
->p_cury
+= (pp
->p_curx
/ TERM_WIDTH
);
87 pp
->p_curx
%= TERM_WIDTH
;
89 (void) putc(*str
++, pp
->p_output
);
94 * Clear the screen, and reset the current position on the screen.
107 * Clear to the end of the line
113 sendcom(pp
, CLRTOEOL
);
125 sendcom(pp
, REFRESH
);
131 * Send a command to the given user
134 sendcom(PLAYER
*pp
, int command
, ...)
139 va_start(ap
, command
);
140 (void) putc(command
, pp
->p_output
);
141 switch (command
& 0377) {
143 arg1
= va_arg(ap
, int);
144 arg2
= va_arg(ap
, int);
145 (void) putc(arg1
, pp
->p_output
);
146 (void) putc(arg2
, pp
->p_output
);
150 arg1
= va_arg(ap
, int);
151 (void) putc(arg1
, pp
->p_output
);
155 va_end(ap
); /* No return needed for void functions. */