Advertisement
Zeda

sin88 (eZ80 optimized)

Jul 28th, 2018
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cos88:
  2.     ld de,40h
  3.     add hl,de
  4. sin88:
  5. ;This computes sin(2pi*x/256), where
  6. ;x=H.L is an 8.8 fixed point number
  7. ;Output is H.L
  8. ;when l>=128, just negate the output.
  9.     ld a,l
  10.     add a,a
  11.     push af
  12.     jp p,$+5
  13.     neg
  14.     cp 124
  15.     ld hl,256
  16.     jr nc,+_
  17.     rrca
  18.     sbc hl,hl
  19.     ld l,a
  20.     ex de,hl
  21.     ld hl,sinLUT
  22.     add hl,de
  23.     ld e,(hl)
  24.     ex de,hl
  25. _:
  26.     pop af
  27.     ret nc
  28.     ex de,hl
  29.     or a
  30.     sbc hl,hl
  31.     sbc hl,de
  32.     ret
  33. sinLUT:
  34. .db 0,6,13,19,25,31,38,44,50,56,62,68,74,80,86,92
  35. .db 98,104,109,115,121,126,132,137,142,147,152,157,162,167,172,177
  36. .db 181,185,190,194,198,202,206,209,213,216,220,223,226,229,231,234
  37. .db 237,239,241,243,245,247,248,250,251,252,253,254,255,255
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement