- 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
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.
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)
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.
https://github.com/tertu-m/pokefirered/blob/sfc-vanilla/README.md- https://github.com/tertu-m/pokefirered/blob/sfc/README.md
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: