aboutsummaryrefslogtreecommitdiff
path: root/rand.s
blob: 1fa7d8d38dfb4531b76060364f5785636c111ee3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

 .export _randi, _randl
 .importzp sreg

RANDOM = 53770 ; POKEY LFSR read address, defined in the Atari OS

; void __fastcall__ randi(void);
; NB cc65's rand() returns a positive signed int, meaning
; 0 to 0x7fff.
_randi:
 lda RANDOM
 and #$7f
 tax
 lda RANDOM
 rts

; void __fastcall__ randl(void);
_randl:
 lda RANDOM
 sta sreg
 lda RANDOM
 sta sreg+1
 lda RANDOM
 ldx RANDOM
 rts