annotate lib/alib/rnd.a @ 2474:7d70b7e1cb21

Moved net and alib files into here
author boisy
date Tue, 30 Mar 2010 02:44:42 +0000
parents
children aaba193af04f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2474
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
1 ***************************************
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
3 * Subroutine to calc. a random number
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
4 * Based on routine by L.A. Middaugh
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
5 * The Rainbow Jan/85 p. 277
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
6
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
7 * Value truncated so that it is =>0 and <=passed value in D.
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
8
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
9 * OTHER MODULES NEEDED: none
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
10
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
11 * ENTRY: D=max value of number to be returned
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
12 * EXIT: D = value
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
13
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
14
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
15 nam Rnd
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
16 ttl Assembler Library Module
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
17
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
18
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
19 psect Rnd,0,0,0,0,0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
20
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
21 vsect dp
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
22
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
23 SEED rmb 4
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
24
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
25 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
26
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
27 RND:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
28 pshs d,x,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
29
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
30 rnd0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
31 ldx #SEED point to seed
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
32 ldb #8 number of shifts
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
33 loop
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
34 lda 3,x exclusive or bit 28 with 31
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
35 rora
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
36 rora
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
37 rora
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
38 eora 3,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
39 rora result in carry
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
40 rora
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
41 ror 0,x rotate carry into bit0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
42 ror 1,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
43 ror 2,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
44 ror 3,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
45 decb do 8 times
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
46 bne loop
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
47 ldd 1,x get rnd value
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
48 bne trunc ensure we never return a 0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
49 inc 1,x fudge it so we get a non-zero
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
50 inc 3,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
51 bra rnd0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
52
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
53 trunc
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
54 cmpd ,s in range specified?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
55 bls exit yes
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
56 subd ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
57 bra trunc
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
58
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
59 exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
60 leas 2,s forget original D
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
61 puls x,u,pc
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
62
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
63
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
64 **********************************************
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
65 *
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
66 * Subroutine to seed the random number buffer
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
67 * with the current system date
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
68
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
69 * ENTRY: none
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
70 * EXIT: none
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
71
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
72 SEEDRND:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
73 pshs d,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
74 leas -6,s make room for date
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
75 tfr s,x point X to buffer
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
76 os9 F$Time
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
77 addd 4,x add min/secs to value in D
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
78 addd <SEED add to orig value
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
79 std <SEED set msb of seed
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
80 addd <SEED+2 add lsb of seed to new msb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
81 std <SEED+2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
82 leas 6,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
83 puls d,x,pc
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
84
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
85 endsect