-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsine.dasm
85 lines (74 loc) · 1.36 KB
/
sine.dasm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
sine_7bits equ $0480
sine_6bits equ $0500
sine_5bits equ $0580
sine_4bits equ $0600
sine_3bits equ $0680
sine_2bits equ $0700
sine_1bits equ $0780
; 40 bytes
sine_init: subroutine
ldx #$00
ldy #$00
.loop
lda sine_table,y
lsr
sta sine_7bits,x
lsr
sta sine_6bits,x
lsr
sta sine_5bits,x
lsr
sta sine_4bits,x
lsr
sta sine_3bits,x
lsr
sta sine_2bits,x
lsr
sta sine_1bits,x
inx
iny
iny
bne .loop
rts
; 61 bytes
sine_of_scale: subroutine
; returns scaled value of sine table
; a = sine max
; x = sine pos
eor #$ff
sta temp00
; half x for lookup table
txa
lsr
tax
lda #$00
lsr temp00
lsr temp00
bcs .not_1bits
adc sine_1bits,x
.not_1bits
lsr temp00
bcs .not_2bits
adc sine_2bits,x
.not_2bits
lsr temp00
bcs .not_3bits
adc sine_3bits,x
.not_3bits
lsr temp00
bcs .not_4bits
adc sine_4bits,x
.not_4bits
lsr temp00
bcs .not_5bits
adc sine_5bits,x
.not_5bits
lsr temp00
bcs .not_6bits
adc sine_6bits,x
.not_6bits
lsr temp00
bcs .not_7bits
adc sine_7bits,x
.not_7bits
rts