]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/global.c
Since our gcc doesn't warn about NULL format strings anymore, we can
[bsdgames-darwin.git] / larn / global.c
1 /* $NetBSD: global.c,v 1.6 1997/10/18 20:03:20 christos Exp $ */
2
3 /*
4 * global.c Larn is copyrighted 1986 by Noah Morgan.
5 *
6 * raiselevel() subroutine to raise the player one level
7 * loselevel() subroutine to lower the player by one level
8 * raiseexperience(x) subroutine to increase experience points
9 * loseexperience(x) subroutine to lose experience points
10 * losehp(x) subroutine to remove hit points from the player
11 * losemhp(x) subroutine to remove max # hit points from the player
12 * raisehp(x) subroutine to gain hit points
13 * raisemhp(x) subroutine to gain maximum hit points
14 * losespells(x) subroutine to lose spells
15 * losemspells(x) subroutine to lose maximum spells
16 * raisespells(x) subroutine to gain spells
17 * raisemspells(x) subroutine to gain maximum spells
18 * recalc() function to recalculate the armor class of the player
19 * makemonst(lev) function to return monster number for a randomly
20 * selected monster
21 * positionplayer() function to be sure player is not in a wall
22 * quit() subroutine to ask if the player really wants to quit
23 */
24 #include <sys/cdefs.h>
25 #ifndef lint
26 __RCSID("$NetBSD: global.c,v 1.6 1997/10/18 20:03:20 christos Exp $");
27 #endif /* not lint */
28
29 #include <string.h>
30 #include <unistd.h>
31 #include "header.h"
32 #include "extern.h"
33 extern int score[], srcount, dropflag;
34 extern int random; /* the random number seed */
35 extern short playerx, playery, lastnum, level;
36 extern u_char cheat;
37 extern char monstnamelist[], logname[];
38 extern char lastmonst[], *what[], *who[];
39 extern char winner[];
40 extern u_char monstlevel[];
41 extern char sciv[SCORESIZE + 1][26][2], *potionname[], *scrollname[];
42 /*
43 ***********
44 RAISE LEVEL
45 ***********
46 raiselevel()
47
48 subroutine to raise the player one level
49 uses the skill[] array to find level boundarys
50 uses c[EXPERIENCE] c[LEVEL]
51 */
52 void
53 raiselevel()
54 {
55 if (c[LEVEL] < MAXPLEVEL)
56 raiseexperience((long) (skill[c[LEVEL]] - c[EXPERIENCE]));
57 }
58
59 /*
60 ***********
61 LOOSE LEVEL
62 ***********
63 loselevel()
64
65 subroutine to lower the players character level by one
66 */
67 void
68 loselevel()
69 {
70 if (c[LEVEL] > 1)
71 loseexperience((long) (c[EXPERIENCE] - skill[c[LEVEL] - 1] + 1));
72 }
73
74 /*
75 ****************
76 RAISE EXPERIENCE
77 ****************
78 raiseexperience(x)
79
80 subroutine to increase experience points
81 */
82 void
83 raiseexperience(x)
84 long x;
85 {
86 int i, tmp;
87 i = c[LEVEL];
88 c[EXPERIENCE] += x;
89 while (c[EXPERIENCE] >= skill[c[LEVEL]] && (c[LEVEL] < MAXPLEVEL)) {
90 tmp = (c[CONSTITUTION] - c[HARDGAME]) >> 1;
91 c[LEVEL]++;
92 raisemhp((int) (rnd(3) + rnd((tmp > 0) ? tmp : 1)));
93 raisemspells((int) rund(3));
94 if (c[LEVEL] < 7 - c[HARDGAME])
95 raisemhp((int) (c[CONSTITUTION] >> 2));
96 }
97 if (c[LEVEL] != i) {
98 cursors();
99 beep();
100 lprintf("\nWelcome to level %d", (long) c[LEVEL]); /* if we changed levels */
101 }
102 bottomline();
103 }
104
105 /*
106 ****************
107 LOOSE EXPERIENCE
108 ****************
109 loseexperience(x)
110
111 subroutine to lose experience points
112 */
113 void
114 loseexperience(x)
115 long x;
116 {
117 int i, tmp;
118 i = c[LEVEL];
119 c[EXPERIENCE] -= x;
120 if (c[EXPERIENCE] < 0)
121 c[EXPERIENCE] = 0;
122 while (c[EXPERIENCE] < skill[c[LEVEL] - 1]) {
123 if (--c[LEVEL] <= 1)
124 c[LEVEL] = 1; /* down one level */
125 tmp = (c[CONSTITUTION] - c[HARDGAME]) >> 1; /* lose hpoints */
126 losemhp((int) rnd((tmp > 0) ? tmp : 1)); /* lose hpoints */
127 if (c[LEVEL] < 7 - c[HARDGAME])
128 losemhp((int) (c[CONSTITUTION] >> 2));
129 losemspells((int) rund(3)); /* lose spells */
130 }
131 if (i != c[LEVEL]) {
132 cursors();
133 beep();
134 lprintf("\nYou went down to level %d!", (long) c[LEVEL]);
135 }
136 bottomline();
137 }
138
139 /*
140 ********
141 LOOSE HP
142 ********
143 losehp(x)
144 losemhp(x)
145
146 subroutine to remove hit points from the player
147 warning -- will kill player if hp goes to zero
148 */
149 void
150 losehp(x)
151 int x;
152 {
153 if ((c[HP] -= x) <= 0) {
154 beep();
155 lprcat("\n");
156 nap(3000);
157 died(lastnum);
158 }
159 }
160
161 void
162 losemhp(x)
163 int x;
164 {
165 c[HP] -= x;
166 if (c[HP] < 1)
167 c[HP] = 1;
168 c[HPMAX] -= x;
169 if (c[HPMAX] < 1)
170 c[HPMAX] = 1;
171 }
172
173 /*
174 ********
175 RAISE HP
176 ********
177 raisehp(x)
178 raisemhp(x)
179
180 subroutine to gain maximum hit points
181 */
182 void
183 raisehp(x)
184 int x;
185 {
186 if ((c[HP] += x) > c[HPMAX])
187 c[HP] = c[HPMAX];
188 }
189
190 void
191 raisemhp(x)
192 int x;
193 {
194 c[HPMAX] += x;
195 c[HP] += x;
196 }
197
198 /*
199 ************
200 RAISE SPELLS
201 ************
202 raisespells(x)
203 raisemspells(x)
204
205 subroutine to gain maximum spells
206 */
207 void
208 raisespells(x)
209 int x;
210 {
211 if ((c[SPELLS] += x) > c[SPELLMAX])
212 c[SPELLS] = c[SPELLMAX];
213 }
214
215 void
216 raisemspells(x)
217 int x;
218 {
219 c[SPELLMAX] += x;
220 c[SPELLS] += x;
221 }
222
223 /*
224 ************
225 LOOSE SPELLS
226 ************
227 losespells(x)
228 losemspells(x)
229
230 subroutine to lose maximum spells
231 */
232 void
233 losespells(x)
234 int x;
235 {
236 if ((c[SPELLS] -= x) < 0)
237 c[SPELLS] = 0;
238 }
239
240 void
241 losemspells(x)
242 int x;
243 {
244 if ((c[SPELLMAX] -= x) < 0)
245 c[SPELLMAX] = 0;
246 if ((c[SPELLS] -= x) < 0)
247 c[SPELLS] = 0;
248 }
249
250 /*
251 makemonst(lev)
252 int lev;
253
254 function to return monster number for a randomly selected monster
255 for the given cave level
256 */
257 int
258 makemonst(lev)
259 int lev;
260 {
261 int tmp, x;
262 if (lev < 1)
263 lev = 1;
264 if (lev > 12)
265 lev = 12;
266 tmp = WATERLORD;
267 if (lev < 5)
268 while (tmp == WATERLORD)
269 tmp = rnd((x = monstlevel[lev - 1]) ? x : 1);
270 else
271 while (tmp == WATERLORD)
272 tmp = rnd((x = monstlevel[lev - 1] - monstlevel[lev - 4]) ? x : 1) + monstlevel[lev - 4];
273
274 while (monster[tmp].genocided && tmp < MAXMONST)
275 tmp++; /* genocided? */
276 return (tmp);
277 }
278
279 /*
280 positionplayer()
281
282 function to be sure player is not in a wall
283 */
284 void
285 positionplayer()
286 {
287 int try;
288 try = 2;
289 while ((item[playerx][playery] || mitem[playerx][playery]) && (try))
290 if (++playerx >= MAXX - 1) {
291 playerx = 1;
292 if (++playery >= MAXY - 1) {
293 playery = 1;
294 --try;
295 }
296 }
297 if (try == 0)
298 lprcat("Failure in positionplayer\n");
299 }
300
301 /*
302 recalc() function to recalculate the armor class of the player
303 */
304 void
305 recalc()
306 {
307 int i, j, k;
308 c[AC] = c[MOREDEFENSES];
309 if (c[WEAR] >= 0)
310 switch (iven[c[WEAR]]) {
311 case OSHIELD:
312 c[AC] += 2 + ivenarg[c[WEAR]];
313 break;
314 case OLEATHER:
315 c[AC] += 2 + ivenarg[c[WEAR]];
316 break;
317 case OSTUDLEATHER:
318 c[AC] += 3 + ivenarg[c[WEAR]];
319 break;
320 case ORING:
321 c[AC] += 5 + ivenarg[c[WEAR]];
322 break;
323 case OCHAIN:
324 c[AC] += 6 + ivenarg[c[WEAR]];
325 break;
326 case OSPLINT:
327 c[AC] += 7 + ivenarg[c[WEAR]];
328 break;
329 case OPLATE:
330 c[AC] += 9 + ivenarg[c[WEAR]];
331 break;
332 case OPLATEARMOR:
333 c[AC] += 10 + ivenarg[c[WEAR]];
334 break;
335 case OSSPLATE:
336 c[AC] += 12 + ivenarg[c[WEAR]];
337 break;
338 }
339
340 if (c[SHIELD] >= 0)
341 if (iven[c[SHIELD]] == OSHIELD)
342 c[AC] += 2 + ivenarg[c[SHIELD]];
343 if (c[WIELD] < 0)
344 c[WCLASS] = 0;
345 else {
346 i = ivenarg[c[WIELD]];
347 switch (iven[c[WIELD]]) {
348 case ODAGGER:
349 c[WCLASS] = 3 + i;
350 break;
351 case OBELT:
352 c[WCLASS] = 7 + i;
353 break;
354 case OSHIELD:
355 c[WCLASS] = 8 + i;
356 break;
357 case OSPEAR:
358 c[WCLASS] = 10 + i;
359 break;
360 case OFLAIL:
361 c[WCLASS] = 14 + i;
362 break;
363 case OBATTLEAXE:
364 c[WCLASS] = 17 + i;
365 break;
366 case OLANCE:
367 c[WCLASS] = 19 + i;
368 break;
369 case OLONGSWORD:
370 c[WCLASS] = 22 + i;
371 break;
372 case O2SWORD:
373 c[WCLASS] = 26 + i;
374 break;
375 case OSWORD:
376 c[WCLASS] = 32 + i;
377 break;
378 case OSWORDofSLASHING:
379 c[WCLASS] = 30 + i;
380 break;
381 case OHAMMER:
382 c[WCLASS] = 35 + i;
383 break;
384 default:
385 c[WCLASS] = 0;
386 }
387 }
388 c[WCLASS] += c[MOREDAM];
389
390 /* now for regeneration abilities based on rings */
391 c[REGEN] = 1;
392 c[ENERGY] = 0;
393 j = 0;
394 for (k = 25; k > 0; k--)
395 if (iven[k]) {
396 j = k;
397 k = 0;
398 }
399 for (i = 0; i <= j; i++) {
400 switch (iven[i]) {
401 case OPROTRING:
402 c[AC] += ivenarg[i] + 1;
403 break;
404 case ODAMRING:
405 c[WCLASS] += ivenarg[i] + 1;
406 break;
407 case OBELT:
408 c[WCLASS] += ((ivenarg[i] << 1)) + 2;
409 break;
410
411 case OREGENRING:
412 c[REGEN] += ivenarg[i] + 1;
413 break;
414 case ORINGOFEXTRA:
415 c[REGEN] += 5 * (ivenarg[i] + 1);
416 break;
417 case OENERGYRING:
418 c[ENERGY] += ivenarg[i] + 1;
419 break;
420 }
421 }
422 }
423
424
425 /*
426 quit()
427
428 subroutine to ask if the player really wants to quit
429 */
430 void
431 quit()
432 {
433 int i;
434 cursors();
435 strcpy(lastmonst, "");
436 lprcat("\n\nDo you really want to quit?");
437 while (1) {
438 i = getchar();
439 if (i == 'y') {
440 died(300);
441 return;
442 }
443 if ((i == 'n') || (i == '\33')) {
444 lprcat(" no");
445 lflush();
446 return;
447 }
448 lprcat("\n");
449 setbold();
450 lprcat("Yes");
451 resetbold();
452 lprcat(" or ");
453 setbold();
454 lprcat("No");
455 resetbold();
456 lprcat(" please? Do you want to quit? ");
457 }
458 }
459
460 /*
461 function to ask --more-- then the user must enter a space
462 */
463 void
464 more()
465 {
466 lprcat("\n --- press ");
467 standout("space");
468 lprcat(" to continue --- ");
469 while (getchar() != ' ');
470 }
471
472 /*
473 function to put something in the players inventory
474 returns 0 if success, 1 if a failure
475 */
476 int
477 take(itm, arg)
478 int itm, arg;
479 {
480 int i, limit;
481 /* cursors(); */
482 if ((limit = 15 + (c[LEVEL] >> 1)) > 26)
483 limit = 26;
484 for (i = 0; i < limit; i++)
485 if (iven[i] == 0) {
486 iven[i] = itm;
487 ivenarg[i] = arg;
488 limit = 0;
489 switch (itm) {
490 case OPROTRING:
491 case ODAMRING:
492 case OBELT:
493 limit = 1;
494 break;
495 case ODEXRING:
496 c[DEXTERITY] += ivenarg[i] + 1;
497 limit = 1;
498 break;
499 case OSTRRING:
500 c[STREXTRA] += ivenarg[i] + 1;
501 limit = 1;
502 break;
503 case OCLEVERRING:
504 c[INTELLIGENCE] += ivenarg[i] + 1;
505 limit = 1;
506 break;
507 case OHAMMER:
508 c[DEXTERITY] += 10;
509 c[STREXTRA] += 10;
510 c[INTELLIGENCE] -= 10;
511 limit = 1;
512 break;
513
514 case OORBOFDRAGON:
515 c[SLAYING]++;
516 break;
517 case OSPIRITSCARAB:
518 c[NEGATESPIRIT]++;
519 break;
520 case OCUBEofUNDEAD:
521 c[CUBEofUNDEAD]++;
522 break;
523 case ONOTHEFT:
524 c[NOTHEFT]++;
525 break;
526 case OSWORDofSLASHING:
527 c[DEXTERITY] += 5;
528 limit = 1;
529 break;
530 };
531 lprcat("\nYou pick up:");
532 srcount = 0;
533 show3(i);
534 if (limit)
535 bottomline();
536 return (0);
537 }
538 lprcat("\nYou can't carry anything else");
539 return (1);
540 }
541
542 /*
543 subroutine to drop an object
544 returns 1 if something there already else 0
545 */
546 int
547 drop_object(k)
548 int k;
549 {
550 int itm;
551 if ((k < 0) || (k > 25))
552 return (0);
553 itm = iven[k];
554 cursors();
555 if (itm == 0) {
556 lprintf("\nYou don't have item %c! ", k + 'a');
557 return (1);
558 }
559 if (item[playerx][playery]) {
560 beep();
561 lprcat("\nThere's something here already");
562 return (1);
563 }
564 if (playery == MAXY - 1 && playerx == 33)
565 return (1); /* not in entrance */
566 item[playerx][playery] = itm;
567 iarg[playerx][playery] = ivenarg[k];
568 srcount = 0;
569 lprcat("\n You drop:");
570 show3(k); /* show what item you dropped */
571 know[playerx][playery] = 0;
572 iven[k] = 0;
573 if (c[WIELD] == k)
574 c[WIELD] = -1;
575 if (c[WEAR] == k)
576 c[WEAR] = -1;
577 if (c[SHIELD] == k)
578 c[SHIELD] = -1;
579 adjustcvalues(itm, ivenarg[k]);
580 dropflag = 1; /* say dropped an item so wont ask to pick it
581 * up right away */
582 return (0);
583 }
584
585 /*
586 function to enchant armor player is currently wearing
587 */
588 void
589 enchantarmor()
590 {
591 int tmp;
592 if (c[WEAR] < 0) {
593 if (c[SHIELD] < 0) {
594 cursors();
595 beep();
596 lprcat("\nYou feel a sense of loss");
597 return;
598 } else {
599 tmp = iven[c[SHIELD]];
600 if (tmp != OSCROLL)
601 if (tmp != OPOTION) {
602 ivenarg[c[SHIELD]]++;
603 bottomline();
604 }
605 }
606 }
607 tmp = iven[c[WEAR]];
608 if (tmp != OSCROLL)
609 if (tmp != OPOTION) {
610 ivenarg[c[WEAR]]++;
611 bottomline();
612 }
613 }
614
615 /*
616 function to enchant a weapon presently being wielded
617 */
618 void
619 enchweapon()
620 {
621 int tmp;
622 if (c[WIELD] < 0) {
623 cursors();
624 beep();
625 lprcat("\nYou feel a sense of loss");
626 return;
627 }
628 tmp = iven[c[WIELD]];
629 if (tmp != OSCROLL)
630 if (tmp != OPOTION) {
631 ivenarg[c[WIELD]]++;
632 if (tmp == OCLEVERRING)
633 c[INTELLIGENCE]++;
634 else if (tmp == OSTRRING)
635 c[STREXTRA]++;
636 else if (tmp == ODEXRING)
637 c[DEXTERITY]++;
638 bottomline();
639 }
640 }
641
642 /*
643 routine to tell if player can carry one more thing
644 returns 1 if pockets are full, else 0
645 */
646 int
647 pocketfull()
648 {
649 int i, limit;
650 if ((limit = 15 + (c[LEVEL] >> 1)) > 26)
651 limit = 26;
652 for (i = 0; i < limit; i++)
653 if (iven[i] == 0)
654 return (0);
655 return (1);
656 }
657
658 /*
659 function to return 1 if a monster is next to the player else returns 0
660 */
661 int
662 nearbymonst()
663 {
664 int tmp, tmp2;
665 for (tmp = playerx - 1; tmp < playerx + 2; tmp++)
666 for (tmp2 = playery - 1; tmp2 < playery + 2; tmp2++)
667 if (mitem[tmp][tmp2])
668 return (1); /* if monster nearby */
669 return (0);
670 }
671
672 /*
673 function to steal an item from the players pockets
674 returns 1 if steals something else returns 0
675 */
676 int
677 stealsomething()
678 {
679 int i, j;
680 j = 100;
681 while (1) {
682 i = rund(26);
683 if (iven[i])
684 if (c[WEAR] != i)
685 if (c[WIELD] != i)
686 if (c[SHIELD] != i) {
687 srcount = 0;
688 show3(i);
689 adjustcvalues(iven[i], ivenarg[i]);
690 iven[i] = 0;
691 return (1);
692 }
693 if (--j <= 0)
694 return (0);
695 }
696 }
697
698 /*
699 function to return 1 is player carrys nothing else return 0
700 */
701 int
702 emptyhanded()
703 {
704 int i;
705 for (i = 0; i < 26; i++)
706 if (iven[i])
707 if (i != c[WIELD])
708 if (i != c[WEAR])
709 if (i != c[SHIELD])
710 return (0);
711 return (1);
712 }
713
714 /*
715 function to create a gem on a square near the player
716 */
717 void
718 creategem()
719 {
720 int i, j;
721 switch (rnd(4)) {
722 case 1:
723 i = ODIAMOND;
724 j = 50;
725 break;
726 case 2:
727 i = ORUBY;
728 j = 40;
729 break;
730 case 3:
731 i = OEMERALD;
732 j = 30;
733 break;
734 default:
735 i = OSAPPHIRE;
736 j = 20;
737 break;
738 };
739 createitem(i, rnd(j) + j / 10);
740 }
741
742 /*
743 function to change character levels as needed when dropping an object
744 that affects these characteristics
745 */
746 void
747 adjustcvalues(itm, arg)
748 int itm, arg;
749 {
750 int flag;
751 flag = 0;
752 switch (itm) {
753 case ODEXRING:
754 c[DEXTERITY] -= arg + 1;
755 flag = 1;
756 break;
757 case OSTRRING:
758 c[STREXTRA] -= arg + 1;
759 flag = 1;
760 break;
761 case OCLEVERRING:
762 c[INTELLIGENCE] -= arg + 1;
763 flag = 1;
764 break;
765 case OHAMMER:
766 c[DEXTERITY] -= 10;
767 c[STREXTRA] -= 10;
768 c[INTELLIGENCE] += 10;
769 flag = 1;
770 break;
771 case OSWORDofSLASHING:
772 c[DEXTERITY] -= 5;
773 flag = 1;
774 break;
775 case OORBOFDRAGON:
776 --c[SLAYING];
777 return;
778 case OSPIRITSCARAB:
779 --c[NEGATESPIRIT];
780 return;
781 case OCUBEofUNDEAD:
782 --c[CUBEofUNDEAD];
783 return;
784 case ONOTHEFT:
785 --c[NOTHEFT];
786 return;
787 case OLANCE:
788 c[LANCEDEATH] = 0;
789 return;
790 case OPOTION:
791 case OSCROLL:
792 return;
793
794 default:
795 flag = 1;
796 };
797 if (flag)
798 bottomline();
799 }
800
801 /*
802 function to read a string from token input "string"
803 returns a pointer to the string
804 */
805 void
806 gettokstr(str)
807 char *str;
808 {
809 int i, j;
810 i = 50;
811 while ((getchar() != '"') && (--i > 0));
812 i = 36;
813 while (--i > 0) {
814 if ((j = getchar()) != '"')
815 *str++ = j;
816 else
817 i = 0;
818 }
819 *str = 0;
820 i = 50;
821 if (j != '"')
822 /* if end due to too long, then find closing quote */
823 while ((getchar() != '"') && (--i > 0));
824 }
825
826 /*
827 function to ask user for a password (no echo)
828 returns 1 if entered correctly, 0 if not
829 */
830 static char gpwbuf[33];
831 int
832 getpassword()
833 {
834 int i, j;
835 char *gpwp;
836 extern char *password;
837 scbr(); /* system("stty -echo cbreak"); */
838 gpwp = gpwbuf;
839 lprcat("\nEnter Password: ");
840 lflush();
841 i = strlen(password);
842 for (j = 0; j < i; j++)
843 read(0, gpwp++, 1);
844 gpwbuf[i] = 0;
845 sncbr(); /* system("stty echo -cbreak"); */
846 if (strcmp(gpwbuf, password) != 0) {
847 lprcat("\nSorry\n");
848 lflush();
849 return (0);
850 } else
851 return (1);
852 }
853
854 /*
855 subroutine to get a yes or no response from the user
856 returns y or n
857 */
858 int
859 getyn()
860 {
861 int i;
862 i = 0;
863 while (i != 'y' && i != 'n' && i != '\33')
864 i = getchar();
865 return (i);
866 }
867
868 /*
869 function to calculate the pack weight of the player
870 returns the number of pounds the player is carrying
871 */
872 int
873 packweight()
874 {
875 int i, j, k;
876 k = c[GOLD] / 1000;
877 j = 25;
878 while ((iven[j] == 0) && (j > 0))
879 --j;
880 for (i = 0; i <= j; i++)
881 switch (iven[i]) {
882 case 0:
883 break;
884 case OSSPLATE:
885 case OPLATEARMOR:
886 k += 40;
887 break;
888 case OPLATE:
889 k += 35;
890 break;
891 case OHAMMER:
892 k += 30;
893 break;
894 case OSPLINT:
895 k += 26;
896 break;
897 case OSWORDofSLASHING:
898 case OCHAIN:
899 case OBATTLEAXE:
900 case O2SWORD:
901 k += 23;
902 break;
903 case OLONGSWORD:
904 case OSWORD:
905 case ORING:
906 case OFLAIL:
907 k += 20;
908 break;
909 case OLANCE:
910 case OSTUDLEATHER:
911 k += 15;
912 break;
913 case OLEATHER:
914 case OSPEAR:
915 k += 8;
916 break;
917 case OORBOFDRAGON:
918 case OBELT:
919 k += 4;
920 break;
921 case OSHIELD:
922 k += 7;
923 break;
924 case OCHEST:
925 k += 30 + ivenarg[i];
926 break;
927 default:
928 k++;
929 };
930 return (k);
931 }
932
933 #ifndef MACRORND
934 /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
935 int
936 rnd(x)
937 int x;
938 {
939 return ((((randx = randx * 1103515245 + 12345) >> 7) % (x)) + 1);
940 }
941
942 int
943 rund(x)
944 int x;
945 {
946 return ((((randx = randx * 1103515245 + 12345) >> 7) % (x)));
947 }
948 #endif /* MACRORND */