Drennthew

Oracle RNG algorithm

May 23rd, 2014
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. ; Note: b, c, h, and l are all 8-bit values which can be combined into 16-bit values.
  2.  
  3. ; RNGlo is address 0xFF94; RNGhi is address 0xFF95.
  4.  
  5. ; On hard reset, RNGlo is set to 0x37. RNGhi is set to 0x0d.
  6.  
  7. ; Load hl and bc with current RNG values
  8. ld a,(RNGlo)
  9. ld l,a
  10. ld c,a
  11. ld a,(RNGhi)
  12. ld h,a
  13. ld b,a
  14.  
  15. ; multiply RNG by 3
  16. add hl,hl
  17. add hl,bc
  18.  
  19. ; Store the new value into RNGhi.
  20. ld a,h
  21. ld (RNGhi),a
  22.  
  23. ; Add the new hi and lo bytes together, and store it in RNGlo.
  24. add a,c
  25. ld (RNGlo),a
  26.  
  27. ; Return the new value of RNGlo in register A.
  28. ret
Advertisement
Add Comment
Please, Sign In to add comment