[comp.sys.amiga.tech] Lattice BLink problem

mapjilg@gdr.bath.ac.uk (J I L Gold) (11/22/90)

In one of the modules in the game I'm writing, I'm needing to get
a random number. So, I #include <math.h> and use the function
drand48() to give a double in [0,1). In my BLink LIB section,
I've tried lcffp.lib and lcmieee.lib (or whatever they were),
and both times the linker chokes up something like _CX405 un-
defined (default _stub). So what library do I use to link 
the module properly?
-- 
#  J.Gold                            |    mapjilg@uk.ac.bath.gdr               #
#  University of Bath , UK           |    jilg@uk.ac.bath.maths                #
#  The more improbable an event is, the more likely it is to happen :-)        #

csg019@cck.cov.ac.uk (Z*A*P*H*O*D) (11/27/90)

In article <1990Nov22.133240.12613@gdr.bath.ac.uk> mapjilg@gdr.bath.ac.uk (J I L Gold) writes:
>In one of the modules in the game I'm writing, I'm needing to get
>a random number. So, I #include <math.h> and use the function
>drand48() to give a double in [0,1). In my BLink LIB section,
>I've tried lcffp.lib and lcmieee.lib (or whatever they were),
>and both times the linker chokes up something like _CX405 un-
>defined (default _stub). So what library do I use to link 
>the module properly?

I don't realy know much about C but you could link a module with the following
assembly language program, this will return a psedo random number (it is in
fact the current raster beam Y-position...
you could use it if you are realy desperate...

start
	move.b $dff006,random
	rts

Massive eh? 



-- 
*********///  O O **A member of S.H.I.T. (Super High Intelegence Team)**///***
*       ///    u    Fight, defeat and kill organized laming.           ///   *
*  \\\ ///    ---  Zaphod of Intuition  csg019@uk.ac.cov.cck ok?  \\\ ///    *
****\\X//**********************************************************\\X//******

forgeas@swinjm.UUCP (Jean-Michel Forgeas) (12/12/90)

In article <1990Nov22.133240.12613@gdr.bath.ac.uk>, J I L Gold writes:

> In one of the modules in the game I'm writing, I'm needing to get
> a random number. So, I #include <math.h> and use the function
> drand48() to give a double in [0,1). [...]

Don't know if you really want a double, but if not you'll find all you
need into amiga.lib (1.2, 1.3, 2.0x):

extern ULONG RangeSeed;             /* declared in amiga.lib */
    ...
    RangeSeed = your_seed_value;
    ...
    your_random_number = RangeRand( maximum );
    ...
--
                                     \___/
Jean-Michel Forgeas                   \-/
cbmvax!cbmehq!cbmfra!swinjm!forgeas    |    The Software Winery
                                      -^-
                           And, where is the universe ?

jesup@cbmvax.commodore.com (Randell Jesup) (12/13/90)

In article <1990Nov26.181340.17891@cck.cov.ac.uk> csg019@cck.cov.ac.uk (Z*A*P*H*O*D) writes:
>I don't realy know much about C but you could link a module with the following
>assembly language program, this will return a psedo random number (it is in
>fact the current raster beam Y-position...
>you could use it if you are realy desperate...
>
>start
>	move.b $dff006,random
>	rts

	Unfortunately, that produces an extremely poor random number.  First,
it's limited to 0-255, secondly certain values will never show up (due to 
vblank interrupts, TOF stuff, etc eating all the cpu for those lines), 
thirdly, the distribution of the numbers remaining will be uneven due to
PAL machines having more than 256 lines, and NTSC having less.

	Just Say No.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com  BIX: rjesup  
Thus spake the Master Ninjei: "If your application does not run correctly,
do not blame the operating system."  (From "The Zen of Programming")  ;-)

csg019@cck.cov.ac.uk (-~=Zaphod=~-) (01/04/91)

In article <16490@cbmvax.commodore.com> jesup@cbmvax.commodore.com (Randell Jesup) writes:
>In article <1990Nov26.181340.17891@cck.cov.ac.uk> csg019@cck.cov.ac.uk (Z*A*P*H*O*D) writes:
>>I don't realy know much about C but you could link a module with the following
>>assembly language program, this will return a psedo random number (it is in
>>fact the current raster beam Y-position...
>>you could use it if you are realy desperate...
>>
>>start
>>	move.b $dff006,random
>>	rts
>
>	Unfortunately, that produces an extremely poor random number.  First,
>it's limited to 0-255, secondly certain values will never show up (due to 
>vblank interrupts, TOF stuff, etc eating all the cpu for those lines), 
>thirdly, the distribution of the numbers remaining will be uneven due to
>PAL machines having more than 256 lines, and NTSC having less.
>
>	Just Say No.

I know its a lame way thats why i said only use if if you were desperate :)

I  think you'll  probably have to look  it up in a maths book, there is a way
of getting a pseudo random number by using LOG's and other mathmatical stuff,
but i'm not  so hot on that side of things.....


I suppose you could mesure how long it takes AmigaDOS to  corrupt a disk, 
thats VERY random number.


-- 
*********///  O O **A member of S.H.I.T. (Super High Intelegence Team)**///***
*       ///    u    Fight, defeat and kill organized laming.           ///   *
*  \\\ ///    ---      Zaphod (TCC)  csg019@uk.ac.cov.cck ok?     \\\ ///    *
****\\X//**********************************************************\\X//******