1321
|
1 ********************************************************************
|
|
2 * SSPak - Speech-Sound Pak Text-To-Speech Driver
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * by Bruce Isted (CIS 76625,2273)
|
|
7 * released to the Public Domain 87/05/03
|
|
8 *
|
|
9 * This driver supports only the Speech-Sound Pak's text-to-speech mode.
|
|
10 * Bit 7 is cleared and control codes are filtered to ensure that only carriage
|
|
11 * returns and characters in the range of $20-$7F (inclusive) are passed. A
|
|
12 * character count and automatic buffer flush is used, which should prevent
|
|
13 * buffer overflow in the Speech-Sound Pak.
|
|
14 *
|
|
15 * Due to way the COCO's sound select circuitry is tied in with other sound
|
|
16 * sources and the joysticks, only one will function at a time. This means
|
|
17 * that while the Speech-Sound Pak is active other sound sources and/or the
|
|
18 * joysticks cannot be used. Speech output is enabled only when a carriage
|
|
19 * return is received, or when the buffer is flushed. Speech output is
|
|
20 * disabled as soon as the Speech-Sound Pak is finished speaking the string
|
|
21 * received before the carriage return or buffer flush.
|
|
22 *
|
1499
|
23 * Edt/Rev YYYY/MM/DD Modified by
|
|
24 * Comment
|
1321
|
25 * ------------------------------------------------------------------
|
1499
|
26 * 1 1987/05/03 Bruce Isted
|
|
27 * Created.
|
1321
|
28
|
|
29 nam SSPak
|
|
30 ttl Speech-Sound Pak Text-To-Speech Driver
|
|
31
|
|
32 ifp1
|
|
33 use defsfile
|
|
34 endc
|
|
35
|
|
36 BuffCnt equ 200 character count before flushing buffer (0-255)
|
|
37 BusyBit equ %10000000 SSPak busy status bit (active low)
|
|
38 CharMask equ %01111111 printable ASCII character mask
|
|
39 CRA equ $01 PIA CRA offset
|
|
40 CRB equ $03 PIA CRB offset
|
|
41 MUXBit equ %00001000 COCO sound MUX control/select bit position
|
|
42 SpeakBit equ %01000000 SSPak speech status bit (active low)
|
|
43 SSPData equ $01 SSPak data register offset
|
|
44 SSPReset equ $00 SSPak reset register offset
|
|
45 SSPStat equ $01 SSPak status register offset
|
|
46
|
|
47 rev equ $00
|
|
48 edition set 1
|
|
49
|
|
50 mod SEnd,SNam,Drivr+Objct,ReEnt+rev,SEntry,SMem
|
|
51
|
|
52 org V.SCF SCF manager data area
|
|
53 Count rmb 1 character counter
|
|
54 SMem equ .
|
|
55
|
|
56 fcb SHARE.+PWRIT.+WRITE. device capabilities
|
|
57
|
|
58 SNam fcs "SSPak"
|
|
59 fcb edition
|
|
60
|
|
61 SEntry lbra SInit
|
|
62 lbra SRead
|
|
63 lbra SWrite
|
|
64 lbra SGetStat
|
|
65 lbra SSetStat
|
|
66 lbra STerm
|
|
67
|
|
68 SInit equ *
|
|
69 STerm equ *
|
|
70 ldx V.PORT,u
|
|
71 ldb #$01
|
|
72 stb SSPReset,x reset SSPak
|
|
73 clrb
|
|
74 stb SSPReset,x end SSPak reset
|
|
75 rts
|
|
76
|
|
77 SRead comb
|
|
78 ldb #E$BMode
|
|
79 rts
|
|
80
|
|
81 SWrite anda #CharMask strip MSBit of character
|
|
82 cmpa #C$CR carriage return?
|
|
83 beq SpkOut yes, go enable SSPak speech output
|
|
84 inc Count,u increment character counter
|
|
85 cmpa #C$SPAC higher than space?
|
|
86 bhi WritChar yes, go write character to SSPak
|
|
87 lda #C$SPAC only space allowed through here
|
|
88 ldb Count,u get current character count
|
|
89 cmpb #BuffCnt time to flush buffer?
|
|
90 blo WritChar no, go write space to SSPak
|
|
91 SpkOut clr Count,u reset character count
|
|
92 ldy #PIA0Base
|
|
93 lda CRA,y get PIA0 CRA
|
|
94 ldb CRB,y get PIA0 CRB
|
|
95 pshs d save them
|
|
96 anda #^MUXBit clear PIA0 CA2 control LSBit
|
|
97 orb #MUXBit set PIA0 CB2 control LSBit
|
|
98 sta CRA,y * set COCO sound MUX to cartridge input
|
|
99 stb CRB,y *
|
|
100 ldy #PIA1Base
|
|
101 ldb CRB,y get PIA1 CRB
|
|
102 pshs b save it
|
|
103 orb #MUXBit set PIA1 CB2 control LSBit
|
|
104 stb CRB,y enable COCO sound MUX
|
|
105 lda #C$CR load execute speech character
|
|
106 bsr WritChar go write command character to SSPak
|
|
107 bsr SSWait go wait until SSPak has finished
|
|
108 puls b recover original PIA1 CRB
|
|
109 stb CRB,y disable COCO sound MUX
|
|
110 puls d recover original PIA0 CRA & CRB
|
|
111 ldy #PIA0Base
|
|
112 sta CRA,y *restore COCO sound MUX to previous setting
|
|
113 stb CRB,y *
|
|
114 clrb
|
|
115 rts
|
|
116 WritChar bsr BusyWait go check if SSPak is busy
|
|
117 sta SSPData,x write character to SSPak
|
|
118 clrb
|
|
119 rts
|
|
120
|
|
121 SGetStat equ *
|
|
122 SSetStat equ *
|
|
123 comb
|
|
124 ldb #E$UnkSvc
|
|
125 rts
|
|
126
|
|
127 BusyWait ldx V.PORT,u
|
|
128 ldb SSPStat,x get SSPak status
|
|
129 andb #BusyBit SSPak busy?
|
|
130 beq BusyWait yes, go check again
|
|
131 ldb SSPStat,x *allow for slow busy bit
|
|
132 andb #BusyBit *
|
|
133 beq BusyWait *
|
|
134 ldb SSPStat,x *allow for very slow busy bit
|
|
135 andb #BusyBit *
|
|
136 beq BusyWait *
|
|
137 rts
|
|
138
|
|
139 SSWait ldx V.PORT,u
|
|
140 ldb SSPStat,x get SSPak status
|
|
141 andb #SpeakBit SSPak speech active yet?
|
|
142 bne SSWait no, go check again
|
|
143 SSWait0 ldx #$0001 sleep remainder of tick
|
|
144 os9 F$Sleep
|
|
145 ldx V.PORT,u
|
|
146 ldb SSPStat,x get SSPak status
|
|
147 andb #SpeakBit SSPak speech still active?
|
|
148 beq SSWait0 yes, go sleep some more
|
|
149 rts
|
|
150
|
|
151 emod
|
|
152 SEnd equ *
|
|
153 end
|
|
154
|