Skip to content

Commit

Permalink
Use fixed-point DIV function for a generalized sine_wave table macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Feb 3, 2018
1 parent d11cac9 commit b0d84c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions macros/code.asm
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ maskbits: MACRO
; example usage in rejection sampling:
; .loop
; call Random
; maskbits 30
; cp 30
; maskbits 26
; cp 26
; jr nc, .loop
x = 1
rept 8
Expand Down
5 changes: 3 additions & 2 deletions macros/data.asm
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ ENDM


sine_wave: MACRO
x = 0.0
; \1 samples of sin(x) from x=0 to x<32768 (pi radians)
x = 0
rept \1
dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up
x = x + 1024.0 ; a circle has 65536.0 "degrees"
x = x + DIV(32768, \1) ; a circle has 65536 "degrees"
endr
ENDM

Expand Down

0 comments on commit b0d84c6

Please sign in to comment.