Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sine:
- ;Inputs:
- ; A is a signed 8-bit value
- ;Output:
- ; BC is the result (B is either FF or 00)
- ;Notes: I use this in Grammer, so certain things are here to work with Grammer and no other reason.
- ; To compute cosine, just add 40h to the input.
- ld d,a
- bit 6,a
- jr z,$+5
- cpl
- xor 80h
- and 63
- ld c,a
- ld hl,sinTable
- ld b,0
- add hl,bc
- ld c,(hl)
- rlc d
- ret nc ;123
- xor a
- sub c
- ld c,a
- sbc a,a
- sub b
- ld b,a
- ret
- sinTable:
- .db 0,3,6,9,13,16,19,22,25,28,31,34,37,40,43,46
- .db 49,52,55,58,60,63,66,68,71,74,76,79,81,84,86,88
- .db 91,93,95,97,99,101,103,105,106,108,110,111,113,114,116,117
- .db 118,119,121,122,122,123,124,125,126,126,127,127,127,128,128,128
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement