home *** CD-ROM | disk | FTP | other *** search
-
- * Maxon C++ Library:
- * Modul "random"
- * Jens Gelhar 24.09.91, 15.04.94
-
- xdef _srand,srand__Ui
- xdef _rand,rand_
- xdef Random_,Random__Ui
-
- xref uintdiv
-
- _srand:
- srand__Ui:
- move.l 4(a7),LastRand
- rts
-
- _rand:
- rand_: move.l LastRand(pc),d0
- mulu #26731,d0
- add.l #47110815,d0
- move.l d0,LastRand
- and.l #$7FFF,d0
- rts
-
- Random__Ui: ; Stackparameter: int
- move.l d1,-(a7)
- bsr.b SpecialRand
- move.l 8(a7),d1
- jsr uintdiv
- move.l d1,d0
- move.l (a7)+,d1
- rts
-
- Random_:
- ; Double zurückgeben:
- move.l d2,-(a7)
- bsr.b SpecialRand
- move.l d0,d1
- bsr.b SpecialRand
- and.l #$000FFFFF,d0
- move.l #$3FF,d2
- .loop btst #20,d0
- bne.b .end
- subq.w #1,d2
- rol.l #1,d1
- roxl.l #1,d0
- bra.b .loop
- .end bclr #20,d0
- swap d2
- asl.l #4,d2
- or.l d2,d0
- move.l (a7)+,d2
- rts
-
- SpecialRand:
- move.l LastRand(pc),d0
- mulu #26731,d0
- add.l #47110815,d0
- add.l $DFF004,d0
- move.l d0,LastRand
- rts
-
- LastRand: blk.l 1
-
- end
-