There seems to be two ways to do integers on the C64 (and yes I know floats are
fastest), I was wondering about these two methods of generating a random
positive number between 1 and 64 inclusive:
10 X=INT(64*RND(0)+1)
or
10 X%=64*RND(0)+1
The latter saves two whole bytes, but is it faster to convert to integer
directly with the INT keyword, or is the implicit declaration below faster?
Second question, let's say you want to generate a random number in multiple
places, you could use the above several times in a listing, but one could also
define a function as I understand it, like:
0 DEF FN A(X)=X*RND(0)
So each time in your listing, you will have,
10 X%=FN A(39): Y%=FN A(24)
...
100 S%=FN A(10)+1: D%=FN A(10)+1
etc...
Other than less typing throughout the program (where you might have lots of
repeated random number generation in this example), are there any benefits to
using CBM functions? Does it save bytes overall would be perhaps one that I
could think of.
Many thanks,
Shaun.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|