[Prev][Next][Index][Thread]
Re: A85: Random Numbers
>Whenever I try to randomize it by doing "and 3" it still only puts in the
>random numbers 1 or 3. Is this possibly due to a repeative motion that
>effects what the memory refresh outputs? This was the same reason that
>I gave up on my version of an old game called Tapper. Could someone
>please show me where there is a simple, but good random number generator
>(if there is such a thing).
> Thanks,
> Mike
>
by popular demand, here is jimmy mardell's random routine, used in
ZTetris and borrowed for Solytare: inputs and outputs are the a
register.
;Randomization routine by Jimmy Mardell (used in ZTetris v3.0)
PRandom: ; Creates a pseudorandom number 0 <= x < A
ld b,a
ld a,r
add a,a
ld hl,0
ld d,0
ld e,a
RMul:
add hl,de
djnz RMul
ld a,h
ret
-mike
mgp4007@omega.uta.edu
References: