annotate level2/modules/sspak.asm @ 977:dd89c62ea2ca

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