-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSWSTST.MAC
379 lines (375 loc) · 9 KB
/
SWSTST.MAC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
;TITLE SWSTST.MAC
;
;STAR WARS SOUND BOARD SPEECH TEST PROGRAM
;
;PROGRAMMER: JED MARGOLIN
;DATE: 2/4/83, 4/5/83
;
;
;MEMORY MAP FOR STAR WARS SOUND BOARD
;A15 IS A DON'T CARE, SO ALL ADDRESSES ARE DOUBLE MAPPED
;
;SOUT W 0000 WRITE SOUND DATA LATCH TO BE READ BY MAIN
; PROCESSOR (SETS SOUND FLAG)
;SIN R 0800 READ MAIN DATA LATCH, WRITTEN BY MAIN PROCESSOR
; (RESETS MAIN FLAG)
;PRAM R/W 1000-107F 6532 RAM, 128 BYTES
;PAD R/W 1080 6532, PORT A, DATA
; PA0 OUT WS-NOT, SPEECH SYNTHESIZER WRITE STROBE
; PA1 OUT RS-NOT, SPEECH SYNTHESIZER READ STROBE
; PA2 IN RDY-NOT,SPEECH SYNTHESIZER READY FLAG
; PA3 OUT FM-NOT, FM CONTROL FOR SHIFT REGISTER CLOCK
; PA4 IN SOUND BOARD DIAGNOSTIC SWITCH, 1=OFF
; PA5 OUT POWER CONTROL FOR 5220, 1=OFF
; PA6 IN SOUNDFLAG, A 1 MEANS THE MAIN PROCESSOR HAS
; NOT READ THE DATA LATCH WRITTEN INTO BY THE
; SOUND PROCESSOR
; PA7 IN MAINFLAG, A 1 MEANS THE MAIN PROCESSOR HAS
; WRITTEN INTO ITS DATA LATCH WHICH IS NOW
; READY TO BE READ BY THE SOUND PROCESSOR
;PADD R/W 1081 6532, PORT A, DIRECTION
;PBD R/W 1082 6532, PORT B, DATA (SPEECH DATA)
;PBDD R/W 1083 6532, PORT B, DIRECTION
;DINED W 1084 6532, DISABLE PA7 INTERRUPTS, NEGATIVE EDGE DETECT
;DIPED W 1085 6532, DISABLE PA7 INTERRUPTS, POSITIVE EDGE DETECTS
;EINED W 1086 6532, ENABLE PA7 INTERRUPTS, NEGATIVE EDGE DETECTS
;EIPED W 1087 6532, ENABLE PA7 INTERRUPTS, POSITIVE EDGE DETECTS
;RTDI R 1084 6532, READ TIMER, DISABLE TIMER INTERRUPT
;RTEI R 108C 6532, READ TIMER, ENABLE TIMER INTERRUPT
;RIF R 1085 6532, READ INTERRUPT FLAG, D7=TIMER FLAG, D6=PA7 FLAG
; , RESETS PA7 FLAG
;D1T W 1094 6532, WRITE TO TIMER 1T, DISABLE TIMER INTERRUPT
;D8T W 1095 6532, WRITE TO TIMER 8T, DISABLE TIMER INTERRUPT
;D64T W 1096 6532, WRITE TO TIMER 64T, DISABLE TIMER INTERRUPT
;D1024T W 1097 6532, WRITE TO TIMER 1024T, DISABLE TIMER INTERRUPT
;E1T W 109C 6532, WRITE TO TIMER 1T, ENABLE TIMER INTERRUPT
;E8T W 109D 6532, WRITE TO TIMER 8T, ENABLE TIMER INTERRUPT
;E64T W 109E 6532, WRITE TO TIMER 64T, ENABLE TIMER INTERRUPT
;E1024T W 109F 6532, WRITE TO TIMER 1024T, ENABLE TIMER INTERRUPT
;
;1800-1807 R/W POKEY0 0-7
;1808-180F R/W POKEY1 0-7
;1810-1817 R/W POKEY2 0-7
;1818-181F R/W POKEY3 0-7
;
;1820-1827 R/W POKEY0 8-F
;1828-182F R/W POKEY1 8-F
;1830-1837 R/W POKEY2 8-F
;1838-183F R/W POKEY3 8-F
;
;
;2000-27FF R/W RAM (2K)
;
;
;4000-7FFF W ROM (16K)
;
; METHOD FOR USING TMS-5220 SPEECH SYNTHESIZER WITH EXTERNAL
; PARALLEL DATA WITH 2 MS INTERRUPTS
;
; MAC69
;
; -------------SPEECH ALGORITHM-----------------------------------
; PA5 controls the supply voltage to the 5220, enabling the programmer to
; turn off power to the device when it gets lost beyond all hope.
;
; PA5 = 1 = 5220 power off.
;
; The 5220's Power-up Clear sequence is supposed to take 15 ms.
;
;
; If Reset-Count is non-zero:
; Make Write Strobe False
; Write FF to Speech Data Latch
; Make Write Strobe True
; Decrement Reset-Count
; Return
;
; If Reset-Count is zero and Ready is False:
; Return
;
; If Reset-Count is zero and Ready is True:
; Make Write Strobe False
;
;
; If Reset-Count is zero and Ready is True and Talk-Status is
;
; 0: If SBCNT .EQ. 0, There is nothing to be said
; Return
; If SBCNT .NE. 0
; Use SBOUT to get next speech word index
; Use Word as index to get start and end addresses of speech data
; Write Speak External Command (60) to Speech Data Latch
; Begin Write Strobe
; Increment Talk-Status
; Return
;
; 1: Get next Speech byte and write to Speech Data Latch
; Begin Write Strobe
; Increment Data Pointer
; If end of word: Increment Talk-Status
; Inter = 80 (Interword Delay)
; Return
;
; 2: Decrement Inter
; If Inter = 0, set Talk-Status = 0
;
;
;
; Power-On Initialization:
; Reset-Count = 0A
; Talk-Status = 00
;
;
; ------------------------------------------------------------
.ASECT
.RADIX 16
.ENABL AMA
.GLOBL SWI3, SWI2, FIRQ, IRQ, SWI, NMI, RES
;
;
SOUT =0000
SIN =0800
;
DIRECT=1000
;DIRECT PAGE
SBIN =00 ;CIRCULAR BUFFER INPUT POINTER FOR SPEECH
SBOUT =01 ;CIRCULAR BUFFER OUTPUT POINTER FOR SPEECH
SBCNT =02 ;BYTE COUNTER FOR SPEECH BUFFER
TSTAT =03 ;TALK-STATUS
TRCNT =04 ;RESET-COUNT
INTER =05 ;INTERWORD DELAY
WADR =06 ;WORD ADDRESS (2 BYTES)
EWADR =08 ;END WORD ADDRESS (2 BYTES)
FRAME =0A ;IRQ FRAME FLAG, 1=NEW FRAME (SET BY IRQ TIMER)
SPBUFF =DIRECT+10 ;START OF CIRCULAR BUFFER FOR SPEECH
;
;6532 ADDRESSES
PAD =1080
PADD =1081
PBD =1082
PBDD =1083
DINED =1084
DIPED =1085
EINED =1086
EIPED =1087
RTDI =1084
RTEI =108C
RIF =1085
;
D1T =1094
D8T =1095
D64T =1096
D1024T =1097
;
E1T =109C
E8T =109D
E64T =109E
E1024T =109F
;
VOCAB =6000 ;VOCABULARY ADDRESS BASE
.=4000
RES: JMP INIT
IRQ: JMP RIRQ
FIRQ: JMP INIT
NMI: JMP INIT
SWI: JMP INIT
SWI2: JMP INIT
SWI3: JMP INIT
;
;
INIT: ;INITIALISE
;
LDS #107F ;STACK WILL BE IN 6532 RAM
LDA #10
TFR A,DPR ;DIRECT PAGE WILL ALSO BE IN 6532 RAM
LDA RIF ;MAKE SURE PA7 FLAG IS RESET
LDA #0FF ;SET UP PBD AS OUTPUTS
STA PBDD
STA PBD ;ALL ONES IS THE SAFEST
STA PAD ;MAKE SURE CONTROL STROBES ARE HIGH
LDB #2B ;SET UP PAD
STB PADD
LDA #00 ;INITIALISE CIRCULAR BUFFER
STA SBIN
STA SBOUT
STA SBCNT
STA TSTAT ;TALKSTATUS=0
STA FRAME ;IRQ FRAME
;
;FROM RESET, THE 5220 COMES UP POWERED OFF. WAIT 30 MS
LDX #18FF
10$: LEAX -1(X)
BNE 10$
;TURN ON 5220
LDA PAD
ANDA #0DF
STA PAD
;WAIT 30 MS
LDX #18FF
20$: LEAX -1(X)
BNE 20$
;READY FOR ACTION
LDA #0A ;RESET COMMANDS
STA TRCNT
LDA PAD ;TURN FM ON
ANDA #0F7
STA PAD
ANDA #10 ;CHECK FOR TEST SWITCH
BNE 30$
CLR SPBUFF ;SAY WORD 0
INC SBIN
INC SBCNT
30$: LDA #03 ;SET UP 2 MS IRQ TIMER
STA E1024T
STA EIPED ;ENABLE PA7 INTERRUPTS WITH POSITIVE EDGE DETECTS
ANDCC #0EF
;
;
MAIN:
LDA FRAME
BEQ MAIN
;THIS IS PROBABLY WHERE POKEY SOUNDS WOULD GO
JSR SPEAK
CLR FRAME
BRA MAIN
;
;
;
;------------------------------------------------------------------------------
;IF INTERRUPT IS FROM THE TIMER, SET THE FRAME FLAG.
;IF INTERRUPT IS FROM THE PARALLEL INTERFACE, ADD SIN TO THE SPEECH BUFFER.
RIRQ:
;
LDA RIF ;READ INPUT FLAGS (RESETS PA7 FLAG)
ANDA #40 ;D6 IS PA7 FLAG (1=SIN DATA READY)
BEQ 20$
;ADD INPUT TO CIRCULAR SPEECH BUFFER
LDB SBIN
LDX #SPBUFF
ABX
LDA SIN
CMPA #20 ;0-1F IS RESERVED FOR SPEECH
BHS 15$ ;20 OR GREATER, JUST ECHO INTO SOUT
STA (X)
INC SBCNT
LDB SBIN
INCB
CMPB #20
BNE 10$
CLRB
10$: STB SBIN
15$: STA E,0000 ;SOUT (ECHO INPUT FOR NOW)
20$: LDA RIF
;
BPL 30$ ;TEST FOR TIMER INTERRUPT
LDA #01 ;TIMER FLAG SET
STA FRAME
LDA #03 ;RESTART IRQ TIMER
STA E1024T
30$:
RTI
;
;
;
;------------------------------------------------------------------------------
;SPEECH SUBROUTINE - USES ACCA, ACCB, X
;
SPEAK:
;
;CHECK RESET-COUNT
LDA TRCNT
BEQ 10$ ;CONTINUE IF NOT IN RESET MODE
LDA PAD ;WRITE STROBE HIGH
ORA #01
STA PAD
LDA #0FF ;SEND A RESET
STA PBD
LDA PAD ;WRITE STROBE LOW
ANDA #0FE
STA PAD
DEC TRCNT
LBRA 100$
;
;CHECK FOR SYNTHESIZER READY
10$: LDA PAD
ANDA #04
LBNE 100$ ;BRANCH OUT IF NOT READY
;MAKE WRITE STROBE HIGH (WILL EITHER BE ALREADY HIGH OR BE COMPLETION OF WRITE)
LDA PAD
ORA #01
STA PAD
;
;CHECK TALKSTATUS
LDA TSTAT
BNE 30$
;
;TSTAT=0, READY FOR NEXT WORD
LDB SBCNT ;IS THE SPEECH BUFFER EMPTY?
LBEQ 100$ ;IF YES, DON'T DO ANYTHING, TSTAT WILL REMAIN AT 0
LDB SBOUT ;GET NEXT BYTE FROM BUFFER
LDX #SPBUFF
ABX
LDB (X) ;ACCB CONTAINS NEXT SPEECH WORD INDEX
CLRA ;FORM INDEX FOR ADDRESS TABLE
ASLB ;TIMES FOUR
ROLA
ASLB
ROLA
ADDD #VOCAB ;ADD VOCABULARY BASE ADDRESS
TFR D,X
LDD (X)++ ;GET STARTING AND ENDING ADDRESSES
STD WADR
LDD (X)++
STD EWADR
LDA #60 ;GENERATE SPEAK EXTERNAL COMMAND
STA PBD
LDA PAD ;WRITE STROBE LOW
ANDA #0FE
STA PAD
INC TSTAT ;NEXT TSTAT IS 1
LDA SBOUT ;ADVANCE CIRCULAR BUFFER
INCA
CMPA #20 ;BUFFER IS 20 LONG
BNE 20$
CLRA
20$: STA SBOUT ;SBOUT WILL WRAP AROUND AT LENGTH OF 20
DEC SBCNT
BRA 100$
;
30$: CMPA #01
BNE 40$
;
;TSTAT=1, SEND NEXT SPEECH BYTE
LDX WADR
LDA (X)+
STA PBD
LDA PAD ;WRITE STROBE LOW
ANDA #0FE
STA PAD
STX WADR
CMPX EWADR
BNE 100$
INC TSTAT ;END OF WORD, NEXT TSTAT IS 2
LDA #80
STA INTER
BRA 100$
;
40$: CMPA #02
BEQ 50$
SWI ;SHOULD NEVER GET HERE
;
;TSTAT=2, INTERWORD DELAY
50$: DEC INTER ;INTERWORD DELAY
BNE 100$
CLR TSTAT ;INTERWORD DELAY IS OVER, NEXT TSTAT IS 0
;
100$: RTS
;
;
;------------------------------------------------------------------------------
;
;
.END
;
;