| www.retrosoftware.co.uk http://www.retrosoftware.co.uk/forum/ |
|
| RND Clarification? http://www.retrosoftware.co.uk/forum/viewtopic.php?f=17&t=645 |
Page 1 of 1 |
| Author: | mga1103 [ Wed Jul 06, 2011 2:20 am ] |
| Post subject: | RND Clarification? |
Rich, I notice your use of the RND function in the demo (nice demo, BTW!), is confined to usage within the EQUB directive, thus making it somewhat static (i.e. generates a random number at assembly, but thereafter, remains fixed). Is there a way to use this function mid-code to facilitate dynamic random number generation? (Also, did I read in another thread somewhere that you're working on making usage of such functions non-case sensitive, or am I going through another senior moment? Would appreciate any clarification...TIA! |
|
| Author: | RichTW [ Wed Jul 06, 2011 7:09 am ] |
| Post subject: | Re: RND Clarification? |
Hi! No you can't use RND mid-code because it's not a 6502 subroutine, it's just a function which (like RND in BASIC) just returns a random number when called at assemble-time. So the random number tables will be statically baked into the executable, and contain the same values each time it's run, but different tables would be generated each time it's assembled, if that makes sense. If you wanted it to be truly dynamic, you'd have to write a 6502 random number subroutine (e.g. the one that tricky posted the other day), and fill out the table at runtime - and even then, you'd have to use some kind of seed based on the current time, otherwise chances are it'd generate the same values each time it was run. Regarding case-sensitivity in function keywords, I ruled this out and made them upper-case only, because of things like the variable 'hitcount' being interpreted as HI(tcount). On reflection, I could make the brackets part of the keyword, but this'd mean I'd have to rewrite my expression parser, and I didn't really fancy this. Also, BBC BASIC doesn't require brackets around function parameters, and I wanted to keep this compatible. |
|
| Author: | mga1103 [ Wed Jul 06, 2011 7:55 am ] |
| Post subject: | Re: RND Clarification? |
Just as I figured! Thanks for the clarification |
|
| Page 1 of 1 | All times are UTC [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|