Re: A86: Random
[Prev][Next][Index][Thread]
Re: A86: Random
Wow, that looks almost exactly like the routine that I used in my last game
:)
> r is only a sort of random... It gets incremented after every
> instruction and never goes over 127. Another decent way of getting
> random numbers is to load data directly out of the rom; I did this in
> FD2:
>
> push hl
> ld a,r ;a=random-ish number <128
> srl a ;a<64
> ld h,a ;use that as the upper byte of an address
> lrand:
> ld l,0 ;use some value as the lower byte...
> add a,(hl) ;get a number from there
> ld (lrand+1),a ;and use that as the next lower byte
> pop hl
> ret
>
> ...which is a lot faster than using rom calls, but not really as
> effective.
>
> Andrew T wrote:
> >
> > Ok im looking for a random function. Now I think that register r is a
> > random number or no? Also I was looking at something that used the call
> > _setxxop2 I included every file that i have and i still could not get it
to
> > work does anyone know whats going on here?
> >
> > Andrew
>
> --
> Aaron Curtis <acurti1@umbc.edu>
> http://www.gl.umbc.edu/~acurti1
>
>
References: