• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[pokefirered] Better RNG

3
Posts
1
Years
    • Seen Jan 16, 2024
    This replaces the base RNG (e. g. the Random() function) in pokefirered with a better one (i.e. the numbers it produces are closer to totally random). It also adds new RNG functions and macros for getting numbers in a range that are higher quality (and usually faster) than what the original game used. It works fine with either agbcc or modern gcc, but modern gcc is recommended as it appears to be better at microoptimizing.

    There's two versions of the tree available:
    sfc-vanilla, which doesn't change the original game code except where changes were necessary for the game to continue to work, for better compatibility with other patches.
    sfc, which modifies the original game code to use the new RNG functions and macros, and probably won't be compatible with other patches without some work.

    Important note
    Do not call Random() from interrupt callbacks to advance the RNG state. The original VBlank callbacks have been edited to use the new BurnRandomNumber() function, which returns nothing, in both branches, but you will need to modify any callbacks you have created to use that function to prevent RNG corruption. If you need to get a random number in an interrupt callback, let me know and I can try to help you figure something out.

    How to use
    • git remote add tertu-m
    • git pull tertu-m (sfc-vanilla or sfc)
    In either case, there should be no additional work required to use the game, unless the merge fails.

    I recommend that you read the README.md file for the appropriate branch for documentation, discussion of the changes, and suggestions. Both branches have removed and changed some functions (e. g. SeedRng() is gone), so if you use those you will need to change your code.

    Feel free to contact me with any questions or post them here.

    EDIT: On December 31, 2022, I fixed a major bug. DO NOT use code from before that point.
     
    Last edited:
    3
    Posts
    1
    Years
    • Seen Jan 16, 2024
    Glad you think it's useful!

    I found another bug: I accidentally set the wrong bit in TM2CNT_H, so the counters didn't behave how I wanted them to behave for seeding purposes. That said, it's way less critical than the last one. It has been fixed.
     
    Back
    Top