Re: Sv: Sv: Sv: A83: Random values


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

Re: Sv: Sv: Sv: A83: Random values




ok, writeback isn't hard.
make a label at the end of your program, like this:

lastRandom:

and allocate it 1 byte like this:

lastRandom: .db $00

now we have where we place the random number.  We do it like so...

;code getting random number into 'e'
ld hl,lastRandom     ;get ready to copy the random number
ex a,e               ;exchange 'a' and 'e', putting the random number                      
;from 'e' into 'a', while not destroying 'a'
ld (hl),a            ;(hl) is the memory location, lastRandom, and we
                     ;just put the random number into there
ex a,e               ;restore the registors 'a' and 'e' by putting                      
;back the origional values

hope this helps, any questions just ask.

-Phelan 'Amen' Wolf


>From owner-assembly-83-outgoing@towerguard.unix.edu.sollentuna.se Fri 
Sep 11 11:48:46 1998
>Delivered-To: assembly-83-outgoing@towerguard.unix.edu.sollentuna.se
>Received: by towerguard.unix.edu.sollentuna.se (VMailer, from userid 
507)
>	id 44099C60AF; Fri, 11 Sep 1998 20:48:31 +0200 (CEST)
>Message-ID: <000701bdddb4$f98a8ae0$bcc752c3@turn>
>From: "Thomas Turn Jensen" <Mukke@get2net.dk>
>To: <assembly-83@lists.ticalc.org>
>Subject: Sv: Sv: Sv: A83: Random values
>Date: Fri, 11 Sep 1998 20:49:55 +0200
>MIME-Version: 1.0
>Content-Type: text/plain;
>	charset="iso-8859-1"
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Mailer: Microsoft Outlook Express 4.72.3110.5
>X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
>Content-Transfer-Encoding: 8bit
>X-MIME-Autoconverted: from quoted-printable to 8bit by 
towerguard.unix.edu.sollentuna.se id UAA20933
>Sender: owner-assembly-83@lists.ticalc.org
>Precedence: list
>Reply-To: assembly-83@lists.ticalc.org
>Errors-To: assembly-83-errors@lists.ticalc.org
>
>
>Ah.... That last thing sounds interesting...
>the writing back thing is kinda tricky.. Wouldn't know how to do that 
yet - and any explanation ppl could get me would still be too technical 
I'm afraid... but just wait.. maybe next week I'll ask....
>
>Thanks again for the great delay measuring trick.
>
>-----Oprindelig meddelelse-----
>Fra: Linus Akesson <lairfight@softhome.net>
>Til: Thomas Turn Jensen <assembly-83@lists.ticalc.org>
>Dato: 11. september 1998 20:45
>Emne: Re: Sv: Sv: A83: Random values
>
>
>>
>>Yupp. So you can do a writeback to the program, saving the last random 
number
>>and reading it back as the first random number when the program is run 
again.
>>Another widely used method is to check how long time the user waits 
before
>>pressing a key. This would involve using your own key loop, instead of
>>_getkey:ing.
>>
>>Linus
>>
>>On 11-Sep-98, Thomas Turn Jensen wrote:
>>
>>>But if I start with a constant - wouldn't my program just come up 
with the
>>>same random numbers everytime it is run?
>>
>>>This may be a stupid question, but I simply doesn't follow you.. Care 
to
>>>explain more (plz :-)?
>>
>>>-----Oprindelig meddelelse-----
>>>Fra: Linus Akesson <lairfight@softhome.net>
>>>Til: Thomas Turn Jensen <assembly-83@lists.ticalc.org>
>>>Dato: 11. september 1998 18:30
>>>Emne: Re: Sv: A83: Random values
>>
>>
>>>>
>>>>You don't. Use a constant, or the contents of some register at 
program start
>>>>or whatever. The random routines in the os always start with the 
same
>>number,
>>>>I think it is 0.94 or something the first time you use math->rand 
with new
>>>>batteries.
>>>>
>>>>Linus
>>>>
>>>>On 10-Sep-98, Thomas Turn Jensen wrote:
>>>>
>>>>>Great!....
>>>>>..ehm.. How do I get that Starting random # ?
>>>>
>>>>>-----Oprindelig meddelelse-----
>>>>>Fra: Linus Akesson <lairfight@softhome.net>
>>>>>Til: Thomas Turn Jensen <assembly-83@lists.ticalc.org>
>>>>>Dato: 10. september 1998 21:02
>>>>>Emne: Re: A83: Random values
>>>>
>>>>
>>>>>>
>>>>>>Random algorithms are quite numerous out there... one idea is to 
take the
>>>>>>previous random number you got, rotate it some, add some, eor 
some, then
>>>try
>>>>>>the program and see if there's a visible pattern. If there is, 
change some
>>>>of
>>>>>>the constants and try again...
>>>>>>
>>>>>>Linus
>>>>>>
>>>>>>On 10-Sep-98, Thomas Turn Jensen wrote:
>>>>>>>I need to get two random values...
>>>>>>>one in the range [0..94] and the other in [1..64] (yes you guesed 
it -
>>>it's
>>>>>>>for the graph-screen)
>>>>>>
>>>>>>>I've found a function called "_Random" but have no idea what 
parameters
>>it
>>>>>>>takes where - nor what/where the output is...
>>>>>>
>>>>>>>Could someone either explain to me how it works or tell me how to 
write
>>>>>>>something which results in the above mentined numbers. (If i get 
a
>>>function
>>>>>>>that results in a random byte thats ok - where I need it, speed 
isn't
>>>>>>>essential so I can just check it and if not good generate another 
random
>>>>>>>number)
>>>>>>>In case someone gives me some code, _plz_ explain what it does as 
I'm
>>more
>>>>>>>interesting in learning how to make it rather than always use 
other
>>>peoples
>>>>>>>code.
>>>>>>
>>>>>>>Thank you.
>>>>>>
>>>>>>>***
>>>>>>>Thomas Turn Jensen
>>>>>>>Icq uin => 8128636
>>>>>>>IRC, Undernet => Mukke
>>>>>>>***
>>>>>>>If your computer gives you trouble
>>>>>>>Call for Mukke on the double
>>>>>>>***
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>>
>
>


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Follow-Ups: