Annotation of 43BSD/games/hunt/terminal.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *  Hunt
                      3:  *  Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
                      4:  *  San Francisco, California
                      5:  *
                      6:  *  Copyright (c) 1985 Regents of the University of California.
                      7:  *  All rights reserved.  The Berkeley software License Agreement
                      8:  *  specifies the terms and conditions for redistribution.
                      9:  */
                     10: 
                     11: # include      "hunt.h"
                     12: # define       TERM_WIDTH      80      /* Assume terminals are 80-char wide */
                     13: 
                     14: /*
                     15:  * cgoto:
                     16:  *     Move the cursor to the given position on the given player's
                     17:  *     terminal.
                     18:  */
                     19: cgoto(pp, y, x)
                     20: register PLAYER        *pp;
                     21: register int   y, x;
                     22: {
                     23:        if (x == pp->p_curx && y == pp->p_cury)
                     24:                return;
                     25:        sendcom(pp, MOVE, y, x);
                     26:        pp->p_cury = y;
                     27:        pp->p_curx = x;
                     28: }
                     29: 
                     30: /*
                     31:  * outch:
                     32:  *     Put out a single character.
                     33:  */
                     34: outch(pp, ch)
                     35: register PLAYER        *pp;
                     36: char           ch;
                     37: {
                     38:        if (++pp->p_curx >= TERM_WIDTH) {
                     39:                pp->p_curx = 0;
                     40:                pp->p_cury++;
                     41:        }
                     42:        (void) putc(ch, pp->p_output);
                     43: }
                     44: 
                     45: /*
                     46:  * outstr:
                     47:  *     Put out a string of the given length.
                     48:  */
                     49: outstr(pp, str, len)
                     50: register PLAYER        *pp;
                     51: register char  *str;
                     52: register int   len;
                     53: {
                     54:        pp->p_curx += len;
                     55:        pp->p_cury += (pp->p_curx / TERM_WIDTH);
                     56:        pp->p_curx %= TERM_WIDTH;
                     57:        while (len--)
                     58:                (void) putc(*str++, pp->p_output);
                     59: }
                     60: 
                     61: /*
                     62:  * clrscr:
                     63:  *     Clear the screen, and reset the current position on the screen.
                     64:  */
                     65: clrscr(pp)
                     66: register PLAYER        *pp;
                     67: {
                     68:        sendcom(pp, CLEAR);
                     69:        pp->p_cury = 0;
                     70:        pp->p_curx = 0;
                     71: }
                     72: 
                     73: /*
                     74:  * ce:
                     75:  *     Clear to the end of the line
                     76:  */
                     77: ce(pp)
                     78: PLAYER *pp;
                     79: {
                     80:        sendcom(pp, CLRTOEOL);
                     81: }
                     82: 
                     83: /*
                     84:  * ref;
                     85:  *     Refresh the screen
                     86:  */
                     87: ref(pp)
                     88: register PLAYER        *pp;
                     89: {
                     90:        sendcom(pp, REFRESH);
                     91: }
                     92: 
                     93: /*
                     94:  * sendcom:
                     95:  *     Send a command to the given user
                     96:  */
                     97: /* VARARGS2 */
                     98: sendcom(pp, command, arg1, arg2)
                     99: register PLAYER                *pp;
                    100: register int   command;
                    101: int                    arg1, arg2;
                    102: {
                    103:        (void) putc(command, pp->p_output);
                    104:        switch (command & 0377) {
                    105:          case MOVE:
                    106:                (void) putc(arg1, pp->p_output);
                    107:                (void) putc(arg2, pp->p_output);
                    108:                break;
                    109:          case ADDCH:
                    110:          case READY:
                    111:                (void) putc(arg1, pp->p_output);
                    112:                break;
                    113:        }
                    114: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.