Re: [AD] Allegro 4.2 todos

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


>> Can we have such a macro as a public one inside Allegro then? It'd be
>> useful to the other programs/examples too...
> 
> Yes, I guess we can do that and document the macro at the end of the
> "Differences between platforms" section.
> 
> Add it to include/allegro/internal/alconfig.h alongside the other macros,
> guarded by an #ifdef/#endif so that each port can override it. And document
> it in the aforementioned section, making it clear that it applies only a
> simple transformation to the libc's rand() to improve (perceived)
> randomness; in particular it still works with srand().
> 
> And post the patch to the list first, so that we can discuss it before it
> gets commited :-)

Done, see attached patch.
I'd have posted the patch here anyway before commiting it this time :P

The current formula is:

((rand() >> 8) + (rand() & 0xff00))

As previously suggested on this list. I've found the following formula works
better under OSX though:

((rand() >> 16) + rand())

I've tested other shift values between 8 and 16, but the best remains 16. So
I wonder: is this due to the machine endianess or just OSX rand()
implementation? I think the latter, but could someone test the thing under
another big endian machine and report the results?
If it's endianess-dependent, it'd be better to declare it accordingly in
alconfig.h...

-- 
Angelo Mottola
a.mottola@xxxxxxxxxx

Attachment: rand.diff.gz
Description: Binary data



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/