Geekboy

Untitled

Oct 25th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TestEnemyScriptA:
  2.  .call(LFSR)
  3.  .shoot(r0)
  4.  .pause
  5.  .jump(TestEnemyScriptA)
  6.  
  7. LFSR: ; outputs random value in a
  8. ;Input:  HL = ptr to seed
  9. ;Output: A = Random 8bit Number
  10. ;Destroys AF , HL (HL remains as the pointer)
  11. ;Has a period of 255
  12. ;Each number will only show up once
  13. ;39/57 cycles
  14. .runasm(LFSR_)
  15.     ld  hl,lfsrseed
  16.     ld  a,(hl)
  17.     rrca
  18.     ld  (hl),a
  19.     jp  nc,r.runasm.ret
  20.     xor %00111000
  21.     ld  (hl),a
  22.     ld (ix+r0),a
  23.  jp r.runasm.ret
  24. LFSR_:
  25.  .return
Advertisement
Add Comment
Please, Sign In to add comment