gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Not clearing memory at start up

#8170 - Lupin - Thu Jul 03, 2003 6:34 pm

I'm using Jeff Frohweins crt0.s file, but I want to disable the memory clearing, but I don't know where I could disable it :(

I also need to know an address of the GBA where most likely every rom will store some code, because I want to use the non-cleared memory for creating random numbers.

#8171 - niltsair - Thu Jul 03, 2003 6:50 pm

Will the memory content really be different after a powerup?

If not, there's been talk about generating random numbers, one technique was to use a start screen, and you seed one from the amount of time it took the user to press start. Another one would be to sample time elapsed after certain events in-game, and save it to SRam (Gamepak save), you then use this value upon startup to seed your randoms numbers.

#8197 - Quirky - Fri Jul 04, 2003 7:36 am

Do a search for the text "Clear Internal WRAM" to find where it clears IWRAM. You can just to comment out the 4 lines underneath this so the memory clear is not performed. EWRAM only appears to be cleared if you have __MultiBootInclude defined. Comment out that line and it won't clear ewram either (I think - that might be useful for pogoshell plugins at least).

Not sure if it'd be any use for random numbers though, I have a sneaking suspicion that the memory might be all 0s anyway.

#8200 - sgeos - Fri Jul 04, 2003 8:59 am

Lupin wrote:
because I want to use the non-cleared memory for creating random numbers.


As far as I know, this is not a reliable way of creating random numbers. Even if the initial values in ram are not predictable, I'm not conviced that they are especially random either.

-Brendan