summaryrefslogtreecommitdiffstats
path: root/monop/roll.c
diff options
context:
space:
mode:
authormycroft <mycroft@NetBSD.org>1993-08-07 08:27:53 +0000
committermycroft <mycroft@NetBSD.org>1993-08-07 08:27:53 +0000
commit2cf6c0757b6b0b6a5d897b1f4d34417a919a2e5d (patch)
tree1a2cb27e0c7cff39de1cd3007e6cea4b97782935 /monop/roll.c
parentfff970121118fba4dda5b1df821221703499ca49 (diff)
downloadbsdgames-darwin-2cf6c0757b6b0b6a5d897b1f4d34417a919a2e5d.tar.gz
bsdgames-darwin-2cf6c0757b6b0b6a5d897b1f4d34417a919a2e5d.tar.zst
bsdgames-darwin-2cf6c0757b6b0b6a5d897b1f4d34417a919a2e5d.zip
New version from uunet.
Diffstat (limited to 'monop/roll.c')
-rw-r--r--monop/roll.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/monop/roll.c b/monop/roll.c
index f0d24281..5d01fe9c 100644
--- a/monop/roll.c
+++ b/monop/roll.c
@@ -32,17 +32,35 @@
*/
#ifndef lint
-/*static char sccsid[] = "from: @(#)roll.c 5.5 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: roll.c,v 1.3 1993/08/01 18:53:31 mycroft Exp $";
+/*static char sccsid[] = "from: @(#)roll.c 5.6 (Berkeley) 9/29/92";*/
+static char rcsid[] = "$Id: roll.c,v 1.4 1993/08/07 08:28:06 mycroft Exp $";
#endif /* not lint */
+#include <stdlib.h>
+
/*
* This routine rolls ndie nside-sided dice.
*/
-#include <stdlib.h>
+# define reg register
+
+# if defined(pdp11)
+# define MAXRAND 32767L
+
+roll(ndie, nsides)
+int ndie, nsides; {
+
+ reg long tot;
+ reg unsigned n, r;
+
+ tot = 0;
+ n = ndie;
+ while (n--)
+ tot += rand();
+ return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
+}
-#define reg register
+# else
roll(ndie, nsides)
reg int ndie, nsides; {
@@ -56,3 +74,4 @@ reg int ndie, nsides; {
tot += (r = rand()) * (num_sides / RAND_MAX) + 1;
return tot;
}
+# endif