comparison level1/modules/sspak.asm @ 1321:acc63d0452bd

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