0
|
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 *
|
|
23 * Ed. Comments Who YY/MM/DD
|
|
24 * ------------------------------------------------------------------
|
|
25 * 1 Created BRI 87/05/03
|
|
26
|
|
27 nam SSPak
|
|
28 ttl Speech-Sound Pak Text-To-Speech Driver
|
|
29
|
|
30 ifp1
|
|
31 use defsfile
|
|
32 use scfdefs
|
|
33 endc
|
|
34
|
|
35 BuffCnt equ 200 character count before flushing buffer (0-255)
|
|
36 BusyBit equ %10000000 SSPak busy status bit (active low)
|
|
37 CharMask equ %01111111 printable ASCII character mask
|
|
38 CRA equ $01 PIA CRA offset
|
|
39 CRB equ $03 PIA CRB offset
|
|
40 MUXBit equ %00001000 COCO sound MUX control/select bit position
|
|
41 SpeakBit equ %01000000 SSPak speech status bit (active low)
|
|
42 SSPData equ $01 SSPak data register offset
|
|
43 SSPReset equ $00 SSPak reset register offset
|
|
44 SSPStat equ $01 SSPak status register offset
|
|
45
|
|
46 rev equ $01
|
|
47 edition set 1
|
|
48
|
|
49 mod SEnd,SNam,Drivr+Objct,ReEnt+rev,SEntry,SMem
|
|
50
|
|
51 org V.SCF SCF manager data area
|
|
52 Count rmb 1 character counter
|
|
53 SMem equ .
|
|
54
|
|
55 fcb SHARE.+PWRIT.+WRITE. device capabilities
|
|
56
|
|
57 SNam fcs "SSPak"
|
|
58 fcb edition
|
|
59
|
|
60 SEntry lbra SInit
|
|
61 lbra SRead
|
|
62 lbra SWrite
|
|
63 lbra SGetStat
|
|
64 lbra SSetStat
|
|
65 lbra STerm
|
|
66
|
|
67 SInit equ *
|
|
68 STerm equ *
|
|
69 ldx V.PORT,u
|
|
70 ldb #$01
|
|
71 stb SSPReset,x reset SSPak
|
|
72 clrb
|
|
73 stb SSPReset,x end SSPak reset
|
|
74 rts
|
|
75
|
|
76 SRead comb
|
|
77 ldb #E$BMode
|
|
78 rts
|
|
79
|
|
80 SWrite anda #CharMask strip MSBit of character
|
|
81 cmpa #C$CR carriage return?
|
|
82 beq SpkOut yes, go enable SSPak speech output
|
|
83 inc Count,u increment character counter
|
|
84 cmpa #C$SPAC higher than space?
|
|
85 bhi WritChar yes, go write character to SSPak
|
|
86 lda #C$SPAC only space allowed through here
|
|
87 ldb Count,u get current character count
|
|
88 cmpb #BuffCnt time to flush buffer?
|
|
89 blo WritChar no, go write space to SSPak
|
|
90 SpkOut clr Count,u reset character count
|
|
91 ldy #PIA0Base
|
|
92 lda CRA,y get PIA0 CRA
|
|
93 ldb CRB,y get PIA0 CRB
|
|
94 pshs d save them
|
|
95 anda #^MUXBit clear PIA0 CA2 control LSBit
|
|
96 orb #MUXBit set PIA0 CB2 control LSBit
|
|
97 sta CRA,y * set COCO sound MUX to cartridge input
|
|
98 stb CRB,y *
|
|
99 ldy #PIA1Base
|
|
100 ldb CRB,y get PIA1 CRB
|
|
101 pshs b save it
|
|
102 orb #MUXBit set PIA1 CB2 control LSBit
|
|
103 stb CRB,y enable COCO sound MUX
|
|
104 lda #C$CR load execute speech character
|
|
105 bsr WritChar go write command character to SSPak
|
|
106 bsr SSWait go wait until SSPak has finished
|
|
107 puls b recover original PIA1 CRB
|
|
108 stb CRB,y disable COCO sound MUX
|
|
109 puls d recover original PIA0 CRA & CRB
|
|
110 ldy #PIA0Base
|
|
111 sta CRA,y *restore COCO sound MUX to previous setting
|
|
112 stb CRB,y *
|
|
113 clrb
|
|
114 rts
|
|
115 WritChar bsr BusyWait go check if SSPak is busy
|
|
116 sta SSPData,x write character to SSPak
|
|
117 clrb
|
|
118 rts
|
|
119
|
|
120 SGetStat equ *
|
|
121 SSetStat equ *
|
|
122 comb
|
|
123 ldb #E$UnkSvc
|
|
124 rts
|
|
125
|
|
126 BusyWait ldx V.PORT,u
|
|
127 ldb SSPStat,x get SSPak status
|
|
128 andb #BusyBit SSPak busy?
|
|
129 beq BusyWait yes, go check again
|
|
130 ldb SSPStat,x *allow for slow busy bit
|
|
131 andb #BusyBit *
|
|
132 beq BusyWait *
|
|
133 ldb SSPStat,x *allow for very slow busy bit
|
|
134 andb #BusyBit *
|
|
135 beq BusyWait *
|
|
136 rts
|
|
137
|
|
138 SSWait ldx V.PORT,u
|
|
139 ldb SSPStat,x get SSPak status
|
|
140 andb #SpeakBit SSPak speech active yet?
|
|
141 bne SSWait no, go check again
|
|
142 SSWait0 ldx #$0001 sleep remainder of tick
|
|
143 os9 F$Sleep
|
|
144 ldx V.PORT,u
|
|
145 ldb SSPStat,x get SSPak status
|
|
146 andb #SpeakBit SSPak speech still active?
|
|
147 beq SSWait0 yes, go sleep some more
|
|
148 rts
|
|
149
|
|
150 emod
|
|
151 SEnd equ *
|
|
152 end
|
|
153
|