-
Notifications
You must be signed in to change notification settings - Fork 82
/
filter.src
84 lines (71 loc) · 1.77 KB
/
filter.src
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
.page
.subttl FILTER Command
;******************************************************************
;
; filter freq, lp, bp, hp, res
; -- set values for filter
; freq = filter frequency (0-1023)
; lp = low pass filter on (1) or off (0)
; bp = band pass filter on (1) or off (0)
; hp = high pass filter on (1) or off (0)
; res = resonance (0-15)
;
;******************************************************************
filter pha
ldy #3
10$ lda filters,y ;save filter values
sta fltsav,y
dey
bpl 10$
pla ;check first character of arg
cmp #','
beq 20$ ;skip if no value given
jsr getwrd ;get filter frequency
cmp #8 ;test m.s. byte
bcs 90$ ;error if > 2047
sty fltsav ;save lower byte
; idea: shift lower 3 bits of upper byte into lower byte, forming bits 10-3
sty fltsav+1
lsr a
ror fltsav+1
lsr a
ror fltsav+1 ;save upper 7 bits (10-3)
lsr a
ror fltsav+1
20$ lda #$10
sta fltflg
30$ jsr optbyt ;get filter value
bcc 50$ ;skip if no value input
cpx #1
bcc 35$ ;..0 is ok,
beq 35$ ;..and so is 1,
jmp fcerr ;..but >1 isn't!
35$ lda fltsav+3 ;get filter flags byte
ora fltflg ;set filter on
bcs 40$ ;skip if should be on
eor fltflg ;turn filter off
40$ sta fltsav+3 ;save value
50$ asl fltflg ;shift for next filter
bpl 30$ ;loop 3 times
jsr optbyt ;get resonance value
bcc 70$ ;skip if no value given
cpx #16
bcs 90$ ;error if >15
txa
asl a
asl a ;shift to upper nibble
asl a
asl a
sta nibble
lda fltsav+2 ;get current value
and #$0f ;mask it out
ora nibble ;add new value
sta fltsav+2 ;save it
70$ ldy #3
80$ lda fltsav,y ;resave values
sta filters,y
dey
bpl 80$
rts
90$ jmp fcerr ;illegal quantity error
;end