diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-11-28 19:01:50 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-11-28 19:01:50 +0000 |
commit | c7ecef45f9da8d0878b07ad3f6a78653767db4f0 (patch) | |
tree | 806bbe1c42e8da99ea6e0cec3729eaada999ae2f /sys/ddb | |
parent | 1f147e6ea07ae37a64709a94b8cb857f795fdf0a (diff) |
Actually draw the hanging. Remove some statics. Fix a bug in
case handling. Still less than 1 K! Most stuff from Andreas Gunnarsson,
<zzlevo@dd.chalmers.se>
Diffstat (limited to 'sys/ddb')
-rw-r--r-- | sys/ddb/db_hangman.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/sys/ddb/db_hangman.c b/sys/ddb/db_hangman.c index bb0cb153849..d715a424c5c 100644 --- a/sys/ddb/db_hangman.c +++ b/sys/ddb/db_hangman.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_hangman.c,v 1.8 1996/10/21 05:11:47 deraadt Exp $ */ +/* $OpenBSD: db_hangman.c,v 1.9 1996/11/28 19:01:49 niklas Exp $ */ /* * Copyright (c) 1996 Theo de Raadt, Michael Shalayeff @@ -18,8 +18,8 @@ * 4. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -39,13 +39,15 @@ #include <dev/cons.h> #include <dev/rndvar.h> -#define TOLOWER(c) (('A'<=(c)&&(c)<='Z')?(c)-'a'+'A':(c)) +#define TOLOWER(c) (('A'<=(c)&&(c)<='Z')?(c)-'A'+'a':(c)) #define ISALPHA(c) (('a'<=(c)&&(c)<='z')||('A'<=(c)&&(c)<='Z')) -static __inline size_t db_random __P((size_t)); -static __inline char *db_randomsym __P((size_t *)); -static void db_hang __P((int, char *, char *)); -static int db_hangon __P((void)); +static __inline size_t db_random __P((size_t)); +static __inline char *db_randomsym __P((size_t *)); +void db_hang __P((int, char *, char *)); +int db_hangon __P((void)); + +static int skill; static __inline size_t db_random( mod ) @@ -56,8 +58,6 @@ db_random( mod ) return ret % mod; } -static int skill; - static __inline char * db_randomsym(lenp) size_t *lenp; @@ -81,8 +81,18 @@ db_randomsym(lenp) return q; } +static char hangpic[]= + "\n88888 \r\n" + "9 7 6 \r\n" + "97 5 \r\n" + "9 423\r\n" + "9 2 \r\n" + "9 1 0\r\n" + "9\r\n" + "9 "; +static char substchar[]="\\/|\\/O|/-|"; -static void +void db_hang(tries, word, abc) int tries; register char *word; @@ -90,7 +100,17 @@ db_hang(tries, word, abc) { register char *p; - cnputc(' '); + for(p=hangpic; *p; p++) { + if(*p>='0' && *p<='9') + { + if(tries<=(*p)-'0') + cnputc(substchar[(*p)-'0']); + else + cnputc(' '); + } else + cnputc(*p); + } + for (p = word; *p; p++) if (ISALPHA(*p)) cnputc(abc[TOLOWER(*p) - 'a']); @@ -99,8 +119,6 @@ db_hang(tries, word, abc) cnputc(' '); cnputc('('); - cnputc('0' + tries); - cnputc(' '); for (p = abc; *p; p++) if (*p == '_') @@ -111,7 +129,7 @@ db_hang(tries, word, abc) } -static int +int db_hangon(void) { static size_t len; @@ -157,7 +175,7 @@ db_hangon(void) } if (tries && len) - return db_hangon(); + return 1; if (!tries && skill > 2) { |