kernel - support dummy reallocblks in devfs
[dragonfly.git] / games / larn / header.h
blob5516aa1761203b6e1f0fc7f29983cc7e9c1af392
1 /* header.h Larn is copyrighted 1986 by Noah Morgan. */
2 /* $DragonFly: src/games/larn/header.h,v 1.5 2006/08/26 17:05:05 pavalos Exp $ */
4 #include <fcntl.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <termcap.h>
9 #include <time.h>
10 #include <unistd.h>
12 #define MAXLEVEL 11
13 /* max # levels in the dungeon */
14 #define MAXVLEVEL 3
15 /* max # of levels in the temple of the luran */
16 #define MAXX 67
17 #define MAXY 17
19 #define SCORESIZE 10
20 /* this is the number of people on a scoreboard max */
21 #define MAXPLEVEL 100
22 /* maximum player level allowed */
23 #define MAXMONST 56
24 /* maximum # monsters in the dungeon */
25 #define SPNUM 38
26 /* maximum number of spells in existence */
27 #define MAXSCROLL 28
28 /* maximum number of scrolls that are possible */
29 #define MAXPOTION 35
30 /* maximum number of potions that are possible */
31 #define TIMELIMIT 30000
32 /* the maximum number of moves before the game is called */
33 #define TAXRATE 1/20
34 /* the tax rate for the LRS */
35 #define MAXOBJ 93
36 /* the maximum number of objects n < MAXOBJ */
38 /* this is the structure definition of the monster data */
39 struct monst {
40 const char *name;
41 char level;
42 short armorclass;
43 char damage;
44 char attack;
45 char defense;
46 char genocided;
47 char intelligence; /* monsters intelligence -- used to choose movement */
48 short gold;
49 short hitpoints;
50 unsigned long experience;
53 /* this is the structure definition for the items in the dnd store */
54 struct _itm {
55 short price;
56 short obj;
57 short arg;
58 short qty;
61 /* this is the structure that holds the entire dungeon specifications */
62 struct cel {
63 short hitp; /* monster's hit points */
64 char mitem; /* the monster ID */
65 char item; /* the object's ID */
66 short iarg; /* the object's argument */
67 char know; /* have we been here before */
70 /* this is the structure for maintaining & moving the spheres of annihilation */
71 struct sphere {
72 struct sphere *p; /* pointer to next structure */
73 char x,y,lev; /* location of the sphere */
74 char dir; /* direction sphere is going in */
75 char lifetime; /* duration of the sphere */
78 /* defines for the character attribute array c[] */
79 #define STRENGTH 0 /* characters physical strength not due to objects */
80 #define INTELLIGENCE 1
81 #define WISDOM 2
82 #define CONSTITUTION 3
83 #define DEXTERITY 4
84 #define CHARISMA 5
85 #define HPMAX 6
86 #define HP 7
87 #define GOLD 8
88 #define EXPERIENCE 9
89 #define LEVEL 10
90 #define REGEN 11
91 #define WCLASS 12
92 #define AC 13
93 #define BANKACCOUNT 14
94 #define SPELLMAX 15
95 #define SPELLS 16
96 #define ENERGY 17
97 #define ECOUNTER 18
98 #define MOREDEFENSES 19
99 #define WEAR 20
100 #define PROTECTIONTIME 21
101 #define WIELD 22
102 #define AMULET 23
103 #define REGENCOUNTER 24
104 #define MOREDAM 25
105 #define DEXCOUNT 26
106 #define STRCOUNT 27
107 #define BLINDCOUNT 28
108 #define CAVELEVEL 29
109 #define CONFUSE 30
110 #define ALTPRO 31
111 #define HERO 32
112 #define CHARMCOUNT 33
113 #define INVISIBILITY 34
114 #define CANCELLATION 35
115 #define HASTESELF 36
116 #define EYEOFLARN 37
117 #define AGGRAVATE 38
118 #define GLOBE 39
119 #define TELEFLAG 40
120 #define SLAYING 41
121 #define NEGATESPIRIT 42
122 #define SCAREMONST 43
123 #define AWARENESS 44
124 #define HOLDMONST 45
125 #define TIMESTOP 46
126 #define HASTEMONST 47
127 #define CUBEofUNDEAD 48
128 #define GIANTSTR 49
129 #define FIRERESISTANCE 50
130 #define BESSMANN 51
131 #define NOTHEFT 52
132 #define HARDGAME 53
133 #define CPUTIME 54
134 #define BYTESIN 55
135 #define BYTESOUT 56
136 #define MOVESMADE 57
137 #define MONSTKILLED 58
138 #define SPELLSCAST 59
139 #define LANCEDEATH 60
140 #define SPIRITPRO 61
141 #define UNDEADPRO 62
142 #define SHIELD 63
143 #define STEALTH 64
144 #define ITCHING 65
145 #define LAUGHING 66
146 #define DRAINSTRENGTH 67
147 #define CLUMSINESS 68
148 #define INFEEBLEMENT 69
149 #define HALFDAM 70
150 #define SEEINVISIBLE 71
151 #define FILLROOM 72
152 #define RANDOMWALK 73
153 #define SPHCAST 74 /* nz if an active sphere of annihilation */
154 #define WTW 75 /* walk through walls */
155 #define STREXTRA 76 /* character strength due to objects or enchantments */
156 #define TMP 77 /* misc scratch space */
157 #define LIFEPROT 78 /* life protection counter */
159 /* defines for the objects in the game */
161 #define OALTAR 1
162 #define OTHRONE 2
163 #define OORB 3
164 #define OPIT 4
165 #define OSTAIRSUP 5
166 #define OELEVATORUP 6
167 #define OFOUNTAIN 7
168 #define OSTATUE 8
169 #define OTELEPORTER 9
170 #define OSCHOOL 10
171 #define OMIRROR 11
172 #define ODNDSTORE 12
173 #define OSTAIRSDOWN 13
174 #define OELEVATORDOWN 14
175 #define OBANK2 15
176 #define OBANK 16
177 #define ODEADFOUNTAIN 17
178 #define OMAXGOLD 70
179 #define OGOLDPILE 18
180 #define OOPENDOOR 19
181 #define OCLOSEDDOOR 20
182 #define OWALL 21
183 #define OTRAPARROW 66
184 #define OTRAPARROWIV 67
186 #define OLARNEYE 22
188 #define OPLATE 23
189 #define OCHAIN 24
190 #define OLEATHER 25
191 #define ORING 60
192 #define OSTUDLEATHER 61
193 #define OSPLINT 62
194 #define OPLATEARMOR 63
195 #define OSSPLATE 64
196 #define OSHIELD 68
197 #define OELVENCHAIN 92
199 #define OSWORDofSLASHING 26
200 #define OHAMMER 27
201 #define OSWORD 28
202 #define O2SWORD 29
203 #define OSPEAR 30
204 #define ODAGGER 31
205 #define OBATTLEAXE 57
206 #define OLONGSWORD 58
207 #define OFLAIL 59
208 #define OLANCE 65
209 #define OVORPAL 90
210 #define OSLAYER 91
212 #define ORINGOFEXTRA 32
213 #define OREGENRING 33
214 #define OPROTRING 34
215 #define OENERGYRING 35
216 #define ODEXRING 36
217 #define OSTRRING 37
218 #define OCLEVERRING 38
219 #define ODAMRING 39
221 #define OBELT 40
223 #define OSCROLL 41
224 #define OPOTION 42
225 #define OBOOK 43
226 #define OCHEST 44
227 #define OAMULET 45
229 #define OORBOFDRAGON 46
230 #define OSPIRITSCARAB 47
231 #define OCUBEofUNDEAD 48
232 #define ONOTHEFT 49
234 #define ODIAMOND 50
235 #define ORUBY 51
236 #define OEMERALD 52
237 #define OSAPPHIRE 53
239 #define OENTRANCE 54
240 #define OVOLDOWN 55
241 #define OVOLUP 56
242 #define OHOME 69
244 #define OKGOLD 71
245 #define ODGOLD 72
246 #define OIVDARTRAP 73
247 #define ODARTRAP 74
248 #define OTRAPDOOR 75
249 #define OIVTRAPDOOR 76
250 #define OTRADEPOST 77
251 #define OIVTELETRAP 78
252 #define ODEADTHRONE 79
253 #define OANNIHILATION 80 /* sphere of annihilation */
254 #define OTHRONE2 81
255 #define OLRS 82 /* Larn Revenue Service */
256 #define OCOOKIE 83
257 #define OURN 84
258 #define OBRASSLAMP 85
259 #define OHANDofFEAR 86 /* hand of fear */
260 #define OSPHTAILSMAN 87 /* tailsman of the sphere */
261 #define OWWAND 88 /* wand of wonder */
262 #define OPSTAFF 89 /* staff of power */
263 /* used up to 92 */
265 /* defines for the monsters as objects */
267 #define BAT 1
268 #define GNOME 2
269 #define HOBGOBLIN 3
270 #define JACKAL 4
271 #define KOBOLD 5
272 #define ORC 6
273 #define SNAKE 7
274 #define CENTIPEDE 8
275 #define JACULI 9
276 #define TROGLODYTE 10
277 #define ANT 11
278 #define EYE 12
279 #define LEPRECHAUN 13
280 #define NYMPH 14
281 #define QUASIT 15
282 #define RUSTMONSTER 16
283 #define ZOMBIE 17
284 #define ASSASSINBUG 18
285 #define BUGBEAR 19
286 #define HELLHOUND 20
287 #define ICELIZARD 21
288 #define CENTAUR 22
289 #define TROLL 23
290 #define YETI 24
291 #define WHITEDRAGON 25
292 #define ELF 26
293 #define CUBE 27
294 #define METAMORPH 28
295 #define VORTEX 29
296 #define ZILLER 30
297 #define VIOLETFUNGI 31
298 #define WRAITH 32
299 #define FORVALAKA 33
300 #define LAMANOBE 34
301 #define OSEQUIP 35
302 #define ROTHE 36
303 #define XORN 37
304 #define VAMPIRE 38
305 #define INVISIBLESTALKER 39
306 #define POLTERGEIST 40
307 #define DISENCHANTRESS 41
308 #define SHAMBLINGMOUND 42
309 #define YELLOWMOLD 43
310 #define UMBERHULK 44
311 #define GNOMEKING 45
312 #define MIMIC 46
313 #define WATERLORD 47
314 #define BRONZEDRAGON 48
315 #define GREENDRAGON 49
316 #define PURPLEWORM 50
317 #define XVART 51
318 #define SPIRITNAGA 52
319 #define SILVERDRAGON 53
320 #define PLATINUMDRAGON 54
321 #define GREENURCHIN 55
322 #define REDDRAGON 56
323 #define DEMONLORD 57
324 #define DEMONPRINCE 64
326 #define BUFBIG 4096 /* size of the output buffer */
327 #define MAXIBUF 4096 /* size of the input buffer */
328 #define LOGNAMESIZE 40 /* max size of the players name */
329 #define PSNAMESIZE 40 /* max size of the process name */
331 #ifndef NODEFS
332 extern char VERSION, SUBVERSION;
333 extern char aborted[], alpha[], beenhere[], boldon, cheat, ckpfile[], ckpflag;
334 extern char *class[], course[], diagfile[], fortfile[], helpfile[];
335 extern char *inbuffer, is_alpha[], is_digit[];
336 extern char item[MAXX][MAXY], iven[], know[MAXX][MAXY], larnlevels[], lastmonst[];
337 extern char level, *levelname[], logfile[], loginname[], logname[], *lpbuf, *lpend;
338 extern char *lpnt, moved[MAXX][MAXY], mitem[MAXX][MAXY], monstlevel[];
339 extern char monstnamelist[], nch[], ndgg[], nlpts[], nomove, nosignal, nowelcome;
340 extern char nplt[], nsw[], *objectname[];
341 extern char objnamelist[], optsfile[], playerids[], potprob[];
342 extern char predostuff, psname[], restorflag, savefilename[], scorefile[], scprob[];
343 extern char screen[MAXX][MAXY], sex, *spelcode[], *speldescript[];
344 extern char spelknow[], *spelname[], *spelmes[], spelweird[MAXMONST + 8][SPNUM];
345 extern char splev[], stealth[MAXX][MAXY], to_lower[], to_upper[], wizard;
346 extern short diroffx[], diroffy[], hitflag, hit2flag, hit3flag, hitp[MAXX][MAXY];
347 extern short iarg[MAXX][MAXY], ivenarg[], lasthx, lasthy, lastnum, lastpx, lastpy;
348 extern short nobeep, oldx, oldy, playerx, playery;
349 extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid,
350 io_outfd, io_infd;
351 extern time_t initialtime;
352 extern long outstanding_taxes, skill[], gtime, c[], cbak[];
353 extern struct cel *cell;
354 extern struct monst monster[];
355 extern struct sphere *spheres;
356 extern struct _itm itm_[];
357 extern const char *potionhide[], *potionname[], *scrollhide[], *scrollname[];
359 /* bill.c */
360 void mailbill(void);
362 /* create.c */
363 void makeplayer(void);
364 void newcavelevel(int);
365 void eat(int, int);
366 int fillmonst(char);
368 /* diag.c */
369 #ifdef EXTRA
370 int diag(void);
371 #endif
372 int savegame(char *);
373 void restoregame(char *);
375 /* display.c */
376 void bottomline(void);
377 void bottomhp(void);
378 void bottomspell(void);
379 void bottomdo(void);
380 void bot_linex(void);
381 void bottomgold(void);
382 void draws(int, int, int, int);
383 void drawscreen(void);
384 void showcell(int, int);
385 void show1cell(int, int);
386 void showplayer(void);
387 int moveplayer(int);
388 void seemagic(int);
390 /* fortune.c */
391 const char *fortune(void);
393 /* global.c */
394 void raiselevel(void);
395 void loselevel(void);
396 void raiseexperience(long);
397 void loseexperience(long);
398 void losehp(int);
399 void losemhp(int);
400 void raisehp(int);
401 void raisemhp(int);
402 void raisemspells(int);
403 void losemspells(int);
404 int makemonst(int);
405 void positionplayer(void);
406 void recalc(void);
407 void quit(void);
408 void more(void);
409 int take(int, int);
410 int drop_object(int);
411 void enchantarmor(void);
412 void enchweapon(void);
413 int pocketfull(void);
414 int nearbymonst(void);
415 int stealsomething(void);
416 int emptyhanded(void);
417 void creategem(void);
418 void adjustcvalues(int, int);
419 int getpassword(void);
420 int getyn(void);
421 int packweight(void);
422 #ifndef MACRORND
423 int rnd(int);
424 int rund(int);
425 #endif
427 /* help.c */
428 void help(void);
429 void welcome(void);
431 /* io.c */
432 void setupvt100(void);
433 void clearvt100(void);
434 char getchr(void);
435 void scbr(void);
436 void sncbr(void);
437 void newgame(void);
438 void lprintf(const char *, ...);
439 void lprint(long);
440 void lwrite(char *, int);
441 long lgetc(void);
442 long lrint_x(void);
443 void lrfill(char *, int);
444 char *lgetw(void);
445 char *lgetl(void);
446 int lcreat(char *);
447 int lopen(char *);
448 int lappend(char *);
449 void lrclose(void);
450 void lwclose(void);
451 void lprcat(const char *);
452 void cursor(int, int);
453 void cursors(void);
454 #ifndef VT100
455 void init_term(void);
456 #endif
457 void cl_line(int, int);
458 void cl_up(int, int);
459 void cl_dn(int, int);
460 void standout(const char *);
461 void set_score_output(void);
462 void lflush(void);
463 #ifndef VT100
464 char *tmcapcnv(char *, char *);
465 #endif
466 void beep(void);
468 /* main.c */
469 void qshowstr(void);
470 void show3(int);
471 void parse2(void);
472 unsigned long readnum(long);
474 /* monster.c */
475 void createmonster(int);
476 void createitem(int, int);
477 void cast(void);
478 void godirect(int, int, const char *, int, char);
479 int vxy(int *, int *);
480 void hitmonster(int, int);
481 int hitm(int, int, int);
482 void hitplayer(int, int);
483 void dropgold(int);
484 void something(int);
485 int newobject(int, int *);
486 void checkloss(int);
487 long annihilate(void);
488 long newsphere(int, int, int, int);
489 long rmsphere(int, int);
491 /* moreobj.c */
492 void oaltar(void);
493 void othrone(int);
494 void odeadthrone(void);
495 void ochest(void);
496 void ofountain(void);
498 /* movem.c */
499 void movemonst(void);
501 /* nap.c */
502 void nap(int);
504 /* object.c */
505 void lookforobject(void);
506 void oteleport(int);
507 void quaffpotion(int);
508 void larn_adjtime(long);
509 void read_scroll(int);
510 void readbook(int);
511 void iopts(void);
512 void ignore(void);
514 /* regen.c */
515 void regen(void);
517 /* savelev.c */
518 void savelevel(void);
519 void getlevel(void);
521 /* scores.c */
522 int makeboard(void);
523 int hashewon(void);
524 long paytaxes(long);
525 void showscores(void);
526 void showallscores(void);
527 void died(int);
528 void diedlog(void);
529 #ifndef UIDSCORE
530 int getplid(char *);
531 #endif
533 /* signal.c */
534 void sigsetup(void);
536 /* store.c */
537 void dndstore(void);
538 void oschool(void);
539 void obank(void);
540 void obank2(void);
541 void ointerest(void);
542 void otradepost(void);
543 void olrs(void);
545 /* tok.c */
546 int yylex(void);
547 void flushall(void);
548 void sethard(int);
549 void readopts(void);
551 /* macro to create scroll #'s with probability of occurrence */
552 #define newscroll() (scprob[rund(81)])
553 /* macro to return a potion # created with probability of occurrence */
554 #define newpotion() (potprob[rund(41)])
555 /* macro to return the + points on created leather armor */
556 #define newleather() (nlpts[rund(c[HARDGAME]?13:15)])
557 /* macro to return the + points on chain armor */
558 #define newchain() (nch[rund(10)])
559 /* macro to return + points on plate armor */
560 #define newplate() (nplt[rund(c[HARDGAME]?4:12)])
561 /* macro to return + points on new daggers */
562 #define newdagger() (ndgg[rund(13)])
563 /* macro to return + points on new swords */
564 #define newsword() (nsw[rund(c[HARDGAME]?6:13)])
565 /* macro to destroy object at present location */
566 #define forget() (item[playerx][playery]=know[playerx][playery]=0)
567 /* macro to wipe out a monster at a location */
568 #define disappear(x,y) (mitem[x][y]=know[x][y]=0)
570 #ifdef VT100
571 /* macro to turn on bold display for the terminal */
572 #define setbold() (lprcat(boldon?"\33[1m":"\33[7m"))
573 /* macro to turn off bold display for the terminal */
574 #define resetbold() (lprcat("\33[m"))
575 /* macro to setup the scrolling region for the terminal */
576 #define setscroll() (lprcat("\33[20;24r"))
577 /* macro to clear the scrolling region for the terminal */
578 #define resetscroll() (lprcat("\33[;24r"))
579 /* macro to clear the screen and home the cursor */
580 #define clear() (lprcat("\33[2J\33[f"), cbak[SPELLS]= -50)
581 #define cltoeoln() lprcat("\33[K")
582 #else /* VT100 */
583 /* defines below are for use in the termcap mode only */
584 #define ST_START 1
585 #define ST_END 2
586 #define BOLD 3
587 #define END_BOLD 4
588 #define CLEAR 5
589 #define CL_LINE 6
590 #define CL_DOWN 14
591 #define CURSOR 15
592 /* macro to turn on bold display for the terminal */
593 #define setbold() (*lpnt++ = ST_START)
594 /* macro to turn off bold display for the terminal */
595 #define resetbold() (*lpnt++ = ST_END)
596 /* macro to setup the scrolling region for the terminal */
597 #define setscroll() enable_scroll=1
598 /* macro to clear the scrolling region for the terminal */
599 #define resetscroll() enable_scroll=0
600 /* macro to clear the screen and home the cursor */
601 #define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50)
602 /* macro to clear to end of line */
603 #define cltoeoln() (*lpnt++ = CL_LINE)
604 #endif /* VT100 */
606 /* macro to output one byte to the output buffer */
607 #define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ = (ch)))
609 #ifdef MACRORND
610 extern unsigned long randx;
611 /* macro to seed the random number generator */
612 #define srand(x) (randx=x)
613 /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
614 #define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1)
615 #define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)) )
616 #endif /* MACRORND */
617 /* macros for miscellaneous data conversion */
618 #define min(x,y) (((x)>(y))?(y):(x))
619 #define max(x,y) (((x)>(y))?(x):(y))
620 #define isalpha(x) (is_alpha[x])
621 #define isdigit(x) (is_digit[x])
622 #define tolower(x) (to_lower[x])
623 #define toupper(x) (to_upper[x])
624 #define lcc(x) (to_lower[x])
625 #define ucc(x) (to_upper[x])
626 #endif /* NODEFS */