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