I've recently jumped into the world of NES development, and since I know a little C I decided to start with it. So far it's gone great and I'm about 99% done with my first project with it, but I'm having a little trouble getting my random numbers to be very random. I know getting anything close to true random numbers (or PRNG even) out of an NES is not really feasible, but I'm confused by the behavior I'm seeing. I've looked at the source of Zooming Secretary and a couple other homebrews and I see they have an otherwise-unused rand16() in the title screen loop, and in various other places, to burn through random numbers and start the game with (hopefully) different numbers. However, doing that, I only seem to get maybe 6 or 8 different playfield arrangements no matter how long I wait at the title screen. My code that bit is pretty simple:
In addition, using set_rand function just seems to screw the whole thing up and I end up with my randomly-positioned spites all lined up on the left.
I'm still a noob when it comes to NES internals, so apologies if this is addressed somewhere that I've missed. It's tricky to search for "C"!
Code:
while(1)
{
ppu_wait_frame();
rand16();
if(pad_trigger(0)&PAD_START) break;
}
{
ppu_wait_frame();
rand16();
if(pad_trigger(0)&PAD_START) break;
}
In addition, using set_rand function just seems to screw the whole thing up and I end up with my randomly-positioned spites all lined up on the left.
I'm still a noob when it comes to NES internals, so apologies if this is addressed somewhere that I've missed. It's tricky to search for "C"!