Jump to content

Luck manipulation (Generation I): Difference between revisions

m
Incredible! No need to shorten this if it's well-organized, which it is. Just adding a category to it.
>Bbbbbbbbba
(Added hard-reset manipulations. I guess this article is getting too long for first time readers... Cleanup is welcome.)
>Sherkel
m (Incredible! No need to shorten this if it's well-organized, which it is. Just adding a category to it.)
Line 24:
At the very beginning of the game's startup process (before the copyright screen), hRandomAdd ($FFD3) and hRandomSub ($FFD4) are zeroed with the entire HRAM; apart from that, Random_ is the only place in the code that directly changes them. If the exact timings and circumstances (actually only the carry flag matters) of those calls can be predicted (e.g. in a TAS or shortly after a hard reset), then the results can be predicted too. That's the principle behind luck manipulation.
 
==Advancement of the RNG==
 
Usually, the RNG is advanced (i.e. Random_ is called) whenever a random number is needed. In addition, it is also advanced once per frame during the V-Blank interrupt. Since the game doesn't need random numbers very often, the majority of RNG advancements come from the V-Blank.
Line 34:
 
==DSum manipulation==
The "DSum manipulation" is considered one of the easier RNG manipulation techniques because it doesn't require frame-level precision. The '''DSum''' is just the sum of hRandomAdd and hRandomSub (mod 256). Since during any RNG advancement, the main part of their change is rDIV being added to the former and subtracted from the latter, the DSum remains nearly constant after a single RNG advancement.
 
Two factors cause the DSum to change:
Line 45:
* A change of rDIV between the two reads is comparatively rare, and doesn't affect the DSum much. <!-- TODO: Estimation of frequency? -->
 
In summary, '''the DSum decreases in the overworld, and increases during a battle, by about 0.5 everyper frame on average'''.
 
===Application===
Line 135:
#[http://wiki.pokemonspeedruns.com/index.php/Pok%C3%A9mon_Red/Blue/Yellow_DSum_Manipulation DSum manipulation FAQ on Pokémon Speedruns wiki]
#[https://github.com/pret/pokered/blob/6ba3765c5932996f5da6417ae703794ff10bb1cb/engine/random.asm random.asm]
 
[[Category:Non-glitch exploits]]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.