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