Re: A86: random numbers


[Prev][Next][Index][Thread]

Re: A86: random numbers




i am having a slight problem.  in this game i am making, i have the
following routine using your random number thing:

PlaceMoney:
 ld a,(my)                     ;    |
 ld d,a                          ;    |
 ld a,(mx)                     ;    |->erase current money sprite
 ld e,a                           ;   |
 ld hl,sprite_0              ;    |
 call GridPutSprite      ;   |
 ld a,13
 ld b,3
 call Random
 ld (mx),a
 ld a,5
 ld b,3
 call Random
 ld (my),a
 ld a,(mx)
 ld e,a
 ld a,(my)
 ld d,a
 ld hl,money
 call GridPutSprite
PMEND:
 ret

i know that i have the lower and upper bounds reversed, but even if they are
not reversed, it only works for a couple of times.  i mean that it will
place a money thing once, twice or three times randomly, but other times, it
places it outside the bounds or not at all.  does anyone know why this
doesn't work?

akshay
http://akdjr.freeservers.com
----- Original Message -----
From: <ComAsYuAre@aol.com>
To: <assembly-86@lists.ticalc.org>
Sent: Wednesday, May 05, 1999 5:15 PM
Subject: Re: A86: random numbers


>
> In a message dated 5/5/99 8:05:52 PM Eastern Daylight Time,
> akdjr@SoftHome.net writes:
>
> > hi
> >  sorry to bother everyone with random numbers again, its just that i
> recently
> > lost all of my email (plus 40 or so other programs because of
> Half-life....)
> > including the ones on random numbers.
> >  i was looking for a routine that could generate a random (or
pseudorandom)
> > number that would generate a number between a lower bound and an upper
> bound.
> >  for example- if 1 is in a and 14 is in b, then the routine should
generate
> a
> > number between 1 and 14 inclusive.  does anyone know of such a routine?
or
> > does someone know how i could make one? (i would need help step by step
> > though.....).  also if it involves ops, then i would need help on those
as
> > well.
> >  thanks a million
>
>
> well, if you don't want to use the r register (which doesn't give very
random
> stuff), then the ops are a good way of doing it.
>
> this is a routine which returns in a a random number between a and b.  it
> uses the system call _randint which returns in OP1 a random integer
between
> OP1 and OP2.
>
> _randint equ $5544
>
> Rand:
> call _SetXXOP1 ;OP1=a (lower bound)
> ld a,b
> call _SetXXOP2 ;OP2=a (upper bound)
> call _randint ;get random number between OP1 and OP2
> jp _convOP1 ;put random number in a and return
>
>



References: