Jump to content

Luck manipulation (Generation I): Difference between revisions

Explained the deviation of V-Blank timings to my best understanding.
>Bbbbbbbbba
(→‎Application: Welp, I make a mistake again. Stepping in the grass actually doesn't advance the RNG at all.)
>Bbbbbbbbba
(Explained the deviation of V-Blank timings to my best understanding.)
Line 28:
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.
 
Since the timing of the V-Blank interrupt itself is almost fixed (with one source of deviation mentioned below), the timing of those framely RNG advancements only depend on the few lines of code between the start of the VBlank function and the Random_ call. As a result, the processor time taken by many things that happen during the main loop doesn't actually change the timing of framely RNG advancements. This fact makes luck manipulation much simpler.
<!-- TODO: Which things do matter? -->
 
There is one complication to the timing of the V-Blank interrupt. Usually, the game executes a "halt" instruction each frame after the necessary processing, to put the console in "sleep mode", and wait until an interrupt (usually V-Blank) wakes it up. However, when there is too much processing to do, or when the game is busy-waiting for user input, the V-Blank interrupt may happen before the "halt" instruction. In this case, the game can save a few cycles waking up, but do need to wait for the current instruction to finish before executing the V-Blank routine. This results in a deviation of up to 20 cycles for the timing of the V-Blank interrupt, which may be enough to affect the RNG. Everything that happens during the previous frame may affect this deviation, but thankfully the odds that it actually changes the RNG is low, because the value of rDIV is only increased every 256 cycles.
 
==DSum manipulation==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.