0
|
1 ********************************************************************
|
|
2 * SndDrv - Sound Driver for CoCo 3
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Should be fully compatible with old SS.Tone.
|
|
7 * (needs cleaning up for space)
|
|
8 *
|
|
9 * Ed. Comments Who YY/MM/DD
|
|
10 * ------------------------------------------------------------------
|
|
11 * First working version KKD 88/08/24
|
|
12 * Bell version for critics <grin> KKD 88/11/14
|
|
13 * 6 Upgrade to edition 3 from Monk-o-Ware BGP 98/09/26
|
|
14
|
|
15 nam SndDrv
|
|
16 ttl Sound Driver for CoCo 3
|
|
17
|
|
18 ifp1
|
|
19 use defsfile
|
|
20 endc
|
|
21
|
|
22 * SYSTEM MAP GLOBALS:
|
|
23
|
|
24 rev set 1
|
|
25 edition set 3
|
|
26
|
|
27 mod sndlen,sndnam,systm+objct,reent+rev,entry,0
|
|
28
|
|
29 sndnam fcs "SndDrv"
|
|
30 fcb edition
|
|
31
|
|
32 *******************************************************
|
|
33 entry lbra init init codriver
|
|
34 lbra getstt
|
|
35 lbra setstt ss.tone
|
|
36 lbra term terminate
|
|
37
|
|
38 *******************************************************
|
|
39 * INIT: set bell vector for F$Alarm
|
|
40
|
|
41 init leax Bell,pcr
|
|
42 stx >WGlobal+G.BelVec save bell vector
|
|
43 getstt
|
|
44 term
|
|
45 okend clrb
|
|
46 rts
|
|
47
|
|
48 *******************************************************
|
|
49 * SETSTT: do SS.Tone ($98) calls
|
|
50 * SS.Tone 98
|
|
51 * regs: X=vol,duration, Y=tone
|
|
52 * Y=path desc
|
|
53
|
|
54 setstt ldx PD.RGS,y get user regs
|
|
55 ldd #$1000 check for 1-4095 range
|
|
56 subd R$Y,x on passed Y
|
|
57 lble BadArgs ..okay if less
|
|
58 cmpd #$1000 ..else err on $1000
|
|
59 lbge BadArgs ..
|
|
60 tfr d,y set tone to D
|
|
61
|
|
62 ldd R$X,x get vol, duration
|
|
63 stb >WGlobal+G.TnCnt save duration
|
|
64 ldb #1 fake cycles
|
|
65 anda #$3F make volume ok
|
|
66 bra BellTone ..do it
|
|
67
|
|
68 BadArgs comb
|
|
69 ldb #E$IllArg
|
|
70 rts
|
|
71
|
|
72 *******************************************************
|
|
73 * Bell ($07):
|
|
74 * can destroy D,Y
|
|
75
|
|
76 Bell inc >WGlobal+G.BelTnF set bell flag
|
|
77 * lda #230/4 start value
|
|
78 * ldb #230/2-18 cycle repeats
|
|
79 * ldd #60*256+96
|
|
80 ldd #$3E60
|
|
81 ldy #$0060 bell freq
|
|
82
|
|
83 * COMMON SS.TONE and BELL ROUTINE:
|
|
84 * A=volume byte (0-63)
|
|
85 * B=cycle repeats (1 means use G.TnCnt as countdown)
|
|
86 * Y=freq
|
|
87
|
|
88 BellTone lsla set A for PIA D/A bits
|
|
89 lsla
|
|
90 lbeq okend okay end if just setting it
|
|
91 ora #2 add printer port bit
|
|
92 pshs a,b,x
|
|
93 ldx #PIA0Base save current PIA setting
|
|
94 lda 1,x
|
|
95 ldb 3,x
|
|
96 pshs a,b
|
|
97
|
|
98 anda #$F7 set for sound
|
|
99 andb #$F7
|
|
100 sta 1,x
|
|
101 stb 3,x
|
|
102 leax $20,x save PIA2 setting
|
|
103 lda 3,x
|
|
104 pshs A
|
|
105 ora #8 and set it too
|
|
106 sta 3,x
|
|
107 bra ToneLoop ..enter main play loop
|
|
108
|
|
109 BellLoop lda 3,s only bell does this countdown
|
|
110 deca
|
|
111 deca
|
|
112 sta 3,s
|
|
113 anda #$F7
|
|
114 ora #$02
|
|
115 bra Loop2
|
|
116 ToneLoop ldd 3,s get D/A byte, repeat cnt
|
|
117 Loop2 bsr SendByte send it (Y=tone delay)
|
|
118 lda #2 go back to zero
|
|
119 bsr SendByte send it
|
|
120 decb count-1 (SS.Tone always=0!)
|
|
121 bne BellLoop ..loop if bell cycles only <<
|
|
122
|
|
123 ldb >WGlobal+G.BelTnF is it bell?
|
|
124 bne ToneExit ..yes, end
|
|
125 ldb >WGlobal+G.TnCnt else get ticks left
|
|
126 bne ToneLoop and do again if any, else...
|
|
127
|
|
128 * Note: G.TnCnt is counted down by cc3io at 60hz.
|
|
129
|
|
130 ToneExit clr >WGlobal+G.BelTnF clear bell flag
|
|
131 puls A reset PIA's as before:
|
|
132 sta 3,x
|
|
133 leax -$20,x
|
|
134 puls a,b
|
|
135 sta 1,x
|
|
136 stb 3,x
|
|
137 clrb okay
|
|
138 puls a,b,x,pc end tone/bell.
|
|
139
|
|
140 SendByte pshs y save delay
|
|
141 sta ,x store D/A byte
|
|
142 SendDely leay -1,y delay
|
|
143 bne SendDely for tone
|
|
144 puls y,pc retn.
|
|
145
|
|
146 emod
|
|
147 sndlen equ *
|
|
148 end
|