![]() |
Routines |
| Prev: 53488 | Up: Map | Next: 53695 |
|
Used by the routines at Generate_Random_Byte, Process_Tracked_Enemy_Entity and Spawn_Tracked_Enemy_Entities.
Advances the linear congruential generator one step. The seed at RNG_Seed is updated using the recurrence seed = seed × 33 + 41 (multiply by 33, add 41), producing the next pseudo-random value. Called by Generate_Random_Byte to generate each random byte during enemy spawning.
|
||||
| Advance_RNG_Seed | 53672 | LD HL,(50396) | Load the current RNG seed from RNG_Seed. | |
| 53675 | PUSH BC | Stash BC on the stack. | ||
| 53676 | ADD HL,HL | Multiply the seed by 32 by shifting left five times. | ||
| 53677 | ADD HL,HL | |||
| 53678 | ADD HL,HL | |||
| 53679 | ADD HL,HL | |||
| 53680 | ADD HL,HL | |||
| 53681 | LD BC,(50396) | Reload the original seed into BC and add it (total factor: 33). | ||
| 53685 | ADD HL,BC | |||
| 53686 | LD BC,41 | Add 0041 and store the new seed back to RNG_Seed. | ||
| 53689 | ADD HL,BC | |||
| 53690 | LD (50396),HL | |||
| 53693 | POP BC | Restore BC and return. | ||
| 53694 | RET | |||
| Prev: 53488 | Up: Map | Next: 53695 |