-;
+;
; Randum number generator
;
; Written and donated by Sidney Cadot - sidney@ch.twi.tudelft.nl
.export _rand, _srand
-.bss
+.data
-rand: .res 4 ; Seed
+; The seed. When srand() is not called, the C standard says that that rand()
+; should behave as if srand() was called with an argument of 1 before.
+rand: .dword 1
.code
lda rand+3
adc #$31
sta rand+3
- pla ; return bit 8-22 in (X,A)
+ pla ; return bit 8-22 in (X,A)
rts
_srand: sta rand+0 ; Store the seed
sta rand+3
rts
+