annotate level2/modules/snddrv.asm @ 473:091a1e4ae051

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