well, I searched the archives carefully and didn't find RNG code like
this :-|
do you have a note of the eor-constant for 32bit (any other too)
pretty please....
cheers,
col.
>
> static int _rndseed = 1;
>
> int rand(void) {
>
> if(_rndseed&1) {
> _rndseed>>=1;
> _rndseed^=0xb400;
> }else{
> _rndseed>>=1;
> }
>
> return(_rndseed);
>
> }
>
> void srand(int r) {
> _rndseed=r;
> }
>
> what about this? works fine for me :o) (thats for 16bit numbers
> obviously) ... actually, this one has been taken from a discussion
> that came up HERE loooooooooooooong ago :o) search the archives,
there
> are the other eor-constants for various bitlenghts aswell :=)
... No, but if you are simply looking to steer bullets, you can just normalize the deltas. dx = pEnemy->x - pPlayer->x; dy = pEnemy->y - pPlayer->y; dx =...
... been ... yeah, this would work ok and was my first thought as well, but there are 2 divides which aint so cool for gba :( At a guess I could probably get a...
Hello colinraybrown, ... You can try to convert this to one divide and two multiplications (calculte reciprocal). This was faster on old PCs and I guess this ...
... Why would you ignore the lsb bits? The msb bits overflow into the lsb bits each iteration. There's nothing "less random" about the msb bits. As for the...
... First off no, the msb bits do not flow into the lsb bits. In fact a bit at position I will not affect a bit at position I-1. Multiplications modulo 2^k...
... well, i just tried it out and without >>16 the results aren't random whatsoever :) and to increase randomness you can call it once every time the player ...
Hello Markus, ... MG> well, i just tried it out and without >>16 the results aren't random MG> whatsoever :) MG> and to increase randomness you can call it...
... Umm? No? This is known as a Linear Feedback Shift Register or LFSR and the normal course of operation is to take the LSB [or MSB depending on how you...
Hello tom, Tuesday, April 30, 2002, 4:43:46 PM, you wrote: tsd> Don't get me wrong guys, alot of your suggestions will work such as the tsd> LCG or this LFSR....
... Er. They can? That seems kind of ghetto. Is there a reasonable way to implement a class for PRNGs that can intercept bad initialization sequences and...
or you can read state of player button in rand function xoring or something like in your seed value, this work for me. Keywiz [cropped by mod]...
Pablo Testa
pablo_testa@...
Apr 30, 2002 3:27 pm
... He wasn't saying that it was an LSB. He was just saying that it was good enough for him. ... I'm tempted to go into a crypto newsgroup and start telling...
... well, I searched the archives carefully and didn't find RNG code like this :-| do you have a note of the eor-constant for 32bit (any other too) pretty...
Hello colinraybrown, Wednesday, May 01, 2002, 3:54:40 AM, you wrote: c> --- In gbadev@y..., groepaz <groepaz@g...> wrote: c> well, I searched the archives...
... Or just use a decent PRNG. I mean if you are going to use a LCG then at least use one with a C constant... e.g. of the form rnd = rnd * B + C Personally...
... ?isn't there still a divide in that atan2 function? ... gives a little variation in bullet speed - very nice. (another "now why didn't I think of that?"...
... c> ?isn't there still a divide in that atan2 function? Yes, there is one. But its the fastest method to calculate (accurate) unit vector I know. ... c> :)...
... Thanks might try this, but for just aiming bullets the cheap and dirty one is great. ... as long as the compiler uses an asr (arithmetic shift right), is ...
... The old cliche "horses for courses" comes to mind. Not to disparage your crypto background but, realistically, we're talking about a games console here -...
... I can imagine quite a few other uses for the GBA. For example, a portable packet radio terminal :-) ... Yeah, I have to agree here. Going over board is...
... There's a typo which Tom pointed out - the correct expression is: gSeed = (16807*gSeed)%0x7fffffff Which unfortunately isn't fast at all on a GBA. ...