Advertisement
kd2bwzgen

SMW RNG

Apr 4th, 2018
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Original 6502 code:
  2. -------------------
  3. GetRand:
  4. PHY
  5. LDY #$01
  6. JSR TickRandom
  7. DEY
  8. JSR TickRandom
  9. PLY
  10. RTL
  11.  
  12. TickRandom:
  13. LDA $148B
  14. ASL
  15. ASL
  16. SEC
  17. ADC $148B
  18. STA $148B
  19. ASL $148C
  20. LDA #$20
  21. BIT $148C
  22. BCC Label1
  23. BEQ Label3
  24. BNE Label2
  25. Label1: BNE Label3
  26. Label2: INC $148C
  27. Label3: LDA $148C
  28. EOR $148B
  29. STA $148D,Y
  30. RTL
  31.  
  32. Converted GBz80 code: (with help of GBDev Discord)
  33. --------------------------------------------------
  34. Random_:
  35. ld bc,wRandomState+3
  36. call TickRandom
  37. dec bc
  38. jp TickRandom
  39.  
  40. TickRandom:
  41. ld hl,wRandomState
  42. ld a,(hl)
  43. add a,a
  44. add a,a
  45. scf
  46. adc a,(hl)
  47. ld (hli),a
  48. sla (hl)
  49. bit 5,(hl)
  50. jr nc,.one
  51. jr z,.three
  52. jr nz,.two
  53. .one jr nz,.three
  54. .two inc (hl)
  55. .three ld a,(hld)
  56. xor (hl)
  57. ld h,b ; ld16 hl,bc
  58. ld l,c
  59. ld (hl),a
  60. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement