• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • 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

  • 4
    Posts
    2
    Years
    • Seen Sep 30, 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:
    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