-
Notifications
You must be signed in to change notification settings - Fork 1
/
chip-ssi263.a
2905 lines (2254 loc) · 54.8 KB
/
chip-ssi263.a
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;license:MIT
;(c) 2021-2024 by Tom Charlesworth
;
; SSI263 related
;
;------------------------------------------------------------------------------
DetectSSI263
; Pre: zpTmp1 = 6522 bitmap in b1:0
; Post:
; SSI263 is only on MB-C & Phasor, both of which have 2x 6522's
; - Speech using 6522 PCR w/o IRQ (based on Willy Byte's SSI263 detection code)
lda #SSI_A_BASE
sta SSI263BaseL
lda MBBaseH
sta SSI263BaseH
lda #SY6522_B_BASE
sta MBBaseL
lda #1
sta zpTmp2 ; mask
lda zpTmp1
and #HAS_6522B ; SSI263A is connected to 2nd 6522
beq @nextSSI263
@loop lda #IER_CLR|IxR_SSI263
ldy #SY6522_IER
sta (MBBase),y ; disable CA1(Speech) IRQ
dey ; Y=IFR
sta (MBBase),y ; clear CA1(Speech) IRQ flag
jsr KickSSI263
lda #$FF
jsr WAIT ; delay for 0x28882 (166018) cycles / ~163ms
ldy #SY6522_IFR
lda #IxR_SSI263 ; check CA1(Speech) IRQ
and (MBBase),y
beq @nextSSI263
sta (MBBase),y ; clear CA1(Speech) IRQ
jsr DisableSSI263
lda zpTmp2
ora hasSSI263
sta hasSSI263
@nextSSI263
lda MBBaseL
beq +
lda #SSI_B_BASE
sta SSI263BaseL
lda #SY6522_A_BASE
sta MBBaseL
asl zpTmp2 ; mask<<1
lda zpTmp1
and #HAS_6522A ; SSI263B is connected to 1st 6522
bne @loop
+ rts
;------------------------------------------------------------------------------
DisableSSI263
; NB. Called from userland & ISR
lda #CONTROL_H
ldy #SSI_CTTRAMP
sta (SSI263Base),y
lda #MODE_IRQ_DISABLED+$00 ; DR1:DR0=0, P5:P0=$00
ldy #SSI_DURPHON
sta (SSI263Base),y
lda #CONTROL_L ; H->L sets SSI263 operation mode = DR1:DR0, ie. IRQ inactive
ldy #SSI_CTTRAMP
sta (SSI263Base),y
rts
;------------------------------------------------------------------------------
KickSSI263_no_PCR
lda #$00 ; NB. No different to setting to 0x0C
beq +
KickSSI263
lda #$0C ; Peripheral for PA port Control: CA2 = low output (Not connected to SSI263)
; CA1 = negative active edge (input) (SSI263 Pin4: A/!R)
; NB. Can use a value of 0x00 and it still works (tested on real MB & Phasor)
+ ldy #SY6522_PCR
sta (MBBase),y
lda #IxR_SSI263
ldy #SY6522_IFR
sta (MBBase),y ; Clear CA1(Speech) IRQ after setting PCR
lda #CONTROL_H
ldy #SSI_CTTRAMP
sta (SSI263Base),y
lda #MODE_PHONEME_TRANSITIONED_INFLECTION+$00 ; DR1:DR0=3 , P5:P0=$00
ldy #SSI_DURPHON
sta (SSI263Base),y
lda #CONTROL_L ; H->L sets SSI263 operation mode = DR1:DR0, ie. IRQ active
ldy #SSI_CTTRAMP
sta (SSI263Base),y
rts
;------------------------------------------------------------------------------
PlaySSI263_no_PCR
ldy #1
bne +
PlaySSI263
; Pre: X:A = phoneme data
; MB mode : MBBaseL = SY6522_A_BASE / SY6522_B_BASE
; Phasor mode: MBBaseL = SY6522_A_PH_BASE / SY6522_B_BASE
ldy #0
+ sty zpTmp2
sta SpeechDataL
stx SpeechDataH
sei
inc doingSpeech
lda #0
sta irqT1IntCount
lda zpTmp2
bne @noPCR1
jsr KickSSI263
jmp +
@noPCR1 jsr KickSSI263_no_PCR
+
lda #$ff ; T1C = T1L = $FFFF
ldy #SY6522_TIMER1L_COUNTER
sta (MBTimer),y
iny ; SY6522_TIMER1H_COUNTER
sta (MBTimer),y ; (and clears IFR.b6)
lda #ACR_FREERUNNING
ldy #SY6522_ACR
sta (MBTimer),y ; Free-running timer
lda #IER_SET|IxR_TIMER1
ldy #SY6522_IER
sta (MBTimer),y ; Enable Timer1 IRQ
lda zpTmp2
bne @noPCR2
lda #IER_SET|IxR_SSI263
;ldy #SY6522_IER
sta (MBBase),y ; Enable CA1(Speech) IRQ
@noPCR2
cli
rts
;------------------------------------------------------------------------------
; SSI263-A SSI263-B
; SSI263Base $Cs40 $Cs20
; MBBase $Cs80 $Cs10 input for CA1 (SSI263 interrupt) to this 6522's IFR
; MBTimer $Cs80 $Cs80 same for both SSI263s
; hasSSI263 .b0 .b1
;
TestSSI263
; Pre: has6522, hasSSI263
; Post: C=0(OK), C=1(NG)
; Uses: zpTmp1 (so don't use in sub-funcs)
lda has6522
and #HAS_6522A
beq +
lda #IER_CLR|IxR_TIMER1|IxR_TIMER2|IxR_SSI263
ldy #SY6522_A_BASE+SY6522_IER ; disable IRQ
sta (MBBase),y
ldy #SY6522_A_BASE+SY6522_IFR ; clear IRQ flag
sta (MBBase),y
+ lda has6522
and #HAS_6522B
beq +
lda #IER_CLR|IxR_TIMER1|IxR_TIMER2|IxR_SSI263
ldy #SY6522_B_BASE+SY6522_IER ; disable IRQ
sta (MBBase),y
ldy #SY6522_B_BASE+SY6522_IFR ; clear IRQ flag
sta (MBBase),y
+
lda #<TestSSI263ISR
ldx #>TestSSI263ISR
jsr SetIrqVector ; Since we have an SSI263, then MB card won't generate NMI
lda #COMPONENT_SSI263+1 ; test component $41
sta testComponentNum
lda #$ff
sta testNum ; test #00
lda #SSI_A_BASE
sta SSI263BaseL
lda MBBaseH
sta MBTimerH
sta SSI263BaseH
lda #SY6522_B_BASE
sta MBBaseL
sta MBTimerL ; NB. MBTimer is used for TIMER1, and so doesn't change for SSI263A/SSI263B
lda hasSSI263
lsr
sta zpTmp1
bcc @nextSSI263
@loop inc testNum ; test #00, $80
jsr T263_0
bcs @error
inc testNum ; test #01, $81
jsr T263_1
bcs @error
inc testNum ; test #02, $82
jsr T263_2
bcs @error
inc testNum ; test #03, $83
jsr T263_3
bcs @error
inc testNum ; test #04, $84
jsr T263_4
bcs @error
inc testNum ; test #05, $85
jsr T263_5
bcs @error
inc testNum ; test #06, $86
jsr T263_6
bcs @error
inc testNum ; test #07, $87
jsr T263_7
bcs @error
inc testNum ; test #08, $88
jsr T263_8
bcs @error
inc testNum ; test #09, $89
jsr T263_9
bcs @error
inc testNum ; test #0A, $8A
jsr T263_A
bcs @error
@nextSSI263
lda #$7f
sta testNum
lda #SSI_B_BASE
sta SSI263BaseL
lda #SY6522_A_PH_BASE
sta MBBaseL
lsr zpTmp1
bcs @loop
lda #SY6522_A_BASE
sta MBBaseL
clc
bcc @done
@error
; Pre: zpTmp2 = expected value
; A = actual value
; Post: C=1(NG)
ldx zpTmp2
jsr SetError
sec
@done
php
lda MBTimerL ; =SY6522_B_BASE
sta MBBaseL
jsr WaitT1OneShotUnderflow ; Pre: MBBaseH/L (restore to one-shot mode)
lda #SY6522_A_BASE
sta MBBaseL
plp
rts
;------------------------------------------------------------------------------
CalcPhraseDuration
lda irqT1IntCount
sta phraseDuration+0 ;# T1 ints
lda irqT1H
cmp irqT1H2
beq +
; T1 underflow between T1H & T1H2, so use: T1=T1H|00
; and irqT1IntCount will account for the underflow
lda #0
sta irqT1L
; NB. normally for multi-byte subtraction you'd start with T1L, but since there's no borrow ($FFFF-HHLL) it's OK this way!
; (do it this way so that the order is: phraseDuration-H,M,L)
+ sec ; $FFFF - T1H|T1L
lda #$ff
sbc irqT1H
sta phraseDuration+1 ;T1H
lda #$ff
sbc irqT1L
sta phraseDuration+2 ;T1L
rts
;------------------------------------------------------------------------------
T263_0
; Pre: MBBase, SSI263Base
; Post: C=0(OK), C=1(NG)
;
; Test#0
; . Play phrase "CLASSIC ADVENTURE" and check total duration is within tolerance
jsr resetSubTest ; subTest #0
jsr incTotalTests
lda #<ClassicAdv
ldx #>ClassicAdv
jsr PlaySSI263
ldy #10 ; delay of 0x19555F cycles = 1,660,255 = ~1.623s
- lda #$ff
jsr WAIT
lda doingSpeech ; done? (or user hit ESC to skip)
beq @ok
dey
bne -
beq @error
@ok clc ; C=0(OK)
bcc @done
@error
; Error: phrase not complete
lda #0
sta zpTmp2 ; expected
sec ; C=1(NG)
@done
sei
php
ldy #SY6522_IER
lda #IER_CLR|IxR_SSI263
sta (MBBase),y ; Disable CA1(Speech) IRQ
lda #IER_CLR|IxR_TIMER1
sta (MBTimer),y ; Disable Timer1 IRQ
lda MBBaseL
pha
lda MBTimerL
sta MBBaseL
jsr WaitT1OneShotUnderflow ; Disable the free-running time on MBTimer/$Cs80
pla
sta MBBaseL
jsr CalcPhraseDuration ; Real MB: 0x132BDD,0x132E59,0x133073 (AppleWin: 0x18D3D8,0x192332/running; ~0x14EFFF,0x14F247/stepping)
lda #1 ; actual
plp
rts
;------------------------------------------------------------------------------
T263_1
; Pre:
; Post: C=0(OK), C=1(NG)
;
; Test#1 (AppleWin-GH#52: the infamous Willy Byte bug!)
; . With a pending T1 IRQ, writing to SSI_FILFREQ clears the T1 IRQ
; . With a pending T2 IRQ, writing to reg8 clears the T2 IRQ
; . test the 3 addr modes: sta addr16,x; sta addr16,y; sta (zp),y
sei
; Ensure we are using the 6522 at $Cn00 regardless of the SSI263 we are testing
lda MBBaseL
pha
lda #SY6522_A_BASE
sta MBBaseL
; SMC to set correct addr
lda SSI263BaseL
sta @smc16x+1
sta @smc16y+1
lda SSI263BaseH
sta @smc16x+2
sta @smc16y+2
lda #IER_SET|IxR_TIMER1|IxR_TIMER2
ldy #SY6522_IER
sta (MBBase),y ; Enable Timer1/Timer2 IRQ
ldy #SY6522_IFR
sta (MBBase),y ; Clear any Timer1/Timer2 IRQ
lda #ACR_ONESHOT
ldy #SY6522_ACR
sta (MBBase),y ; T1 one-shot mode
jsr resetSubTest
dec subTestNum
jsr incTotalTests
lda #2
sta zpTmp2 ; addr mode to test
@loop
; Timer1 IRQ
jsr incSubTestNum ; subTest #0, 4, 8
lda #0 ; Set T1C=T1L=$0000
ldy #SY6522_TIMER1L_COUNTER
sta (MBBase),y
ldy #SY6522_TIMER1H_COUNTER
sta (MBBase),y
ldy #SY6522_IFR
lda (MBBase),y
ldx #IxR_TIMER1
and #IxR_TIMER1
beq @error
jsr incSubTestNum ; subTest #1, 5, 9
ldy #SSI_FILFREQ ; reg4
jsr @FalseRead ; write to 6522.T1C_l & the write does a false read from 6522.T1C_l to clear the IRQ!
lda zpTmp2
bne +
lda is65C02 ; NB. 65816 behaves like 6502 for sta (zp),y
beq +
; sta (zp),y && 65C02
ldy #SY6522_IFR
lda (MBBase),y
ldx #IxR_TIMER1
and #IxR_TIMER1
beq @error
bne ++
+ ldy #SY6522_IFR
lda (MBBase),y
ldx #0
and #IxR_TIMER1
bne @error
++ ; Timer2 IRQ
jsr incSubTestNum ; subTest #2, 6, A
lda #0 ; Set T2C=$0000
ldy #SY6522_TIMER2L_COUNTER
sta (MBBase),y
ldy #SY6522_TIMER2H_COUNTER
sta (MBBase),y
ldy #SY6522_IFR
lda (MBBase),y
ldx #IxR_TIMER2
and #IxR_TIMER2
beq @error
jsr incSubTestNum ; subTest #3, 7, B
ldy #8 ; reg8 (only 3 addr bits for SSI263, so wraps to SSI_DURPHON)
jsr @FalseRead ; write to 6522.T2C_l & the write does a false read from 6522.T2C_l to clear the IRQ!
lda zpTmp2
bne +
lda is65C02 ; NB. 65816 behaves like 6502 for sta (zp),y
beq +
; sta (zp),y && 65C02
ldy #SY6522_IFR
lda (MBBase),y
ldx #IxR_TIMER2
and #IxR_TIMER2
beq @error
bne ++
+ ldy #SY6522_IFR
lda (MBBase),y
ldx #0
and #IxR_TIMER2
bne @error
++ dec zpTmp2
bpl @loop
jsr WaitT1OneShotUnderflow
jsr WaitT2OneShotUnderflow
pla
sta MBBaseL
clc
rts ; C=0(OK)
@error ; pre: A=actual, X=expected
stx zpTmp2 ; expected
tax
pla
sta MBBaseL
txa
sec
rts ; C=1(NG)
;
@FalseRead
; Pre: zpTmp2=addr mode to test
; Y=SSI reg#
lda #0
ldx zpTmp2
beq @addr8y
dex
beq @addr16y
@addr16x
tya
tax
lda #0
@smc16x
sta $C440,x ; (smc)
rts
@addr16y
@smc16y
sta $C440,y ; (smc)
rts
@addr8y
sta (SSI263Base),y ; false-read only for 6502/65816 (not 65C02)
rts
;------------------------------------------------------------------------------
T263_2
; Pre:
; Post: C=0(OK), C=1(NG)
;
; Test#2 - Phasor only
; . phoneme request using SSI263.D7 w/o IRQ (mode=MODE_PHONEME_TRANSITIONED_INFLECTION) & check IRQ
; . phoneme request using SSI263.D7 w/o IRQ (mode=MODE_IRQ_DISABLED) & check *no* IRQ
; . phoneme request using SSI263.D7 w/o IRQ (mode=MODE_PHONEME_IMMEDIATE_INFLECTION) & check IRQ
; . phoneme request using SSI263.D7 w/o IRQ (mode=MODE_IRQ_DISABLED) & check *no* IRQ
; . phoneme request using SSI263.D7 w/o IRQ (mode=MODE_FRAME_IMMEDIATE_INFLECTION) & check IRQ
; . phoneme request using SSI263.D7 w/o IRQ (mode=MODE_IRQ_DISABLED) & check *no* IRQ
sei
lda isPhasorCard
bne +
clc
rts
+
jsr resetSubTestMinus1 ; subTest #-1
jsr incTotalTests
lda #PH_PHASOR
jsr SetPhasorMode
lda #<NullPhrase
ldx #>NullPhrase
sta SpeechDataL
stx SpeechDataH
lda #$F0 ; RATE[7:4]=$F (quickest), INF[3:0]=$0
ldy #SSI_RATEINF
sta (SSI263Base),y
lda #MODE_PHONEME_TRANSITIONED_INFLECTION
sta @deviceMode
lda #0
sta @disableIntsFlag
@loop ; Kick with phoneme $00 && device mode && ena/dis ints
; . R = RATE = $F (set above)
; loop# - Device Mode:
; 0 - $C0: 4ms: FD = 4ms * (16-R) = 4ms; PD = FD * (4-D) = 4ms (where D = %11 = 3) [Phoneme timing mode]
; 1 - $00: 16ms (use previous device mode, but D=0, so PD = FD * 4 = 16ms)
; 2 - $80: 8ms: FD = 4ms * (16-R) = 4ms; PD = FD * (4-D) = 8ms (where D = %10 = 2) [Phoneme timing mode]
; 3 - $00: 16ms (use previous device mode, but D=0, so PD = FD * 4 = 16ms)
; 4 - $40: 4ms: FD = 4ms * (16-R) = 4ms [Frame timing mode]
; 5 - $00: 4ms (use previous device mode)
lda #CONTROL_H
ldy #SSI_CTTRAMP
sta (SSI263Base),y
lda @disableIntsFlag
bne @disInts1
lda @deviceMode
bne + ; (bra)
@disInts1 lda #MODE_IRQ_DISABLED
+ ldy #SSI_DURPHON
sta (SSI263Base),y
lda #CONTROL_L
ldy #SSI_CTTRAMP
sta (SSI263Base),y
jsr incSubTestNum ; subTest #0,3,6,9,C,F
lda (SSI263Base),y ; Y=$3 (can be $0-$F)
and #REQ_NEW_DATA
bne @errorNot00 ; Check D7==0
lda #$E0 ; NB. pick a big enough delay for AppleWin emulator!
jsr WAIT ; WAIT($E0) = delay for 0x1F5DD (128,477) cycles / ~128ms
jsr incSubTestNum ; subTest #1,4,7,A,D,10
ldy #SSI_DURPHON
lda (SSI263Base),y
and #REQ_NEW_DATA
beq @errorNot80 ; Check D7==1
jsr incSubTestNum ; subTest #2,5,8,B,E,11
lda #0
sta isrFlag
cli
sei
lda @disableIntsFlag
bne @disInts2
lda isrFlag
beq @errorNot01 ; Check that MODE_PHONEME|FRAME_XXX allows IRQ to occur
bne + ; (bra)
@disInts2 lda isrFlag
bne @errorNot00 ; Check that MODE_IRQ_DISABLED prevents IRQ from occurring
+
lda @disableIntsFlag
eor #1
sta @disableIntsFlag
bne @loop
lda @deviceMode
sec
sbc #$40
beq @done
sta @deviceMode
jmp @loop
@done
clc ; C=0(OK)
bcc @exit
;
@errorNot00 ; pre: A=actual; post X=0
ldx #$00
beq + ; (bra)
@errorNot01 ; pre: A=actual; post X=0
ldx #$01
bne + ; (bra)
@errorNot80 ; pre: A=actual; post X=0
ldx #$80
+ ; pre: A=actual, X=expected
stx zpTmp2 ; expected
sec ; C=1(NG)
@exit
php
pha
lda #PH_MOCKINGBOARD
jsr SetPhasorMode
pla
plp
rts
@deviceMode !byte 0
@disableIntsFlag !byte 0
;------------------------------------------------------------------------------
T263_3
; Pre:
; Post: C=0(OK), C=1(NG)
;
; Test#3
; . Test phoneme playback using 6522 PCR IRQ (MB & Phasor)
sei
;
; First test Mockingboard (or Phasor in Mockingboard mode)
;
jsr resetSubTest ; subTest #0
jsr incTotalTests
lda #<NullPhrase
ldx #>NullPhrase
jsr PlaySSI263
- lda doingSpeech
beq +
lda irqT1IntCount
cmp #4 ; timeout = ~256ms
bcc - ; loop if < 4
bcs @error
+
sei
lda isPhasorCard
beq @done
jsr incSubTestNum ; subTest #1
;
; Now test Phasor in native Phasor mode
; NB. Phasor uses direct IRQ (which still works even if PCR is setup)
;
lda #PH_PHASOR
jsr SetPhasorMode
lda #<NullPhrase
ldx #>NullPhrase
jsr PlaySSI263
- lda doingSpeech
beq +
lda irqT1IntCount
cmp #4 ; timeout = ~256ms
bcc - ; loop if < 4
bcs @error
+
@done
clc ; C=0(OK)
bcc @exit
;
@error ; pre: A=actual
ldx #0 ; X=expected
stx zpTmp2 ; expected
sec ; C=1(NG)
@exit
sei
php
pha
lda #PH_MOCKINGBOARD
jsr SetPhasorMode
lda #IER_CLR|IxR_TIMER1
ldy #SY6522_IER
sta (MBTimer),y ; Disable Timer1 IRQ
pla
plp
rts
;------------------------------------------------------------------------------
T263_4
; Pre:
; Post: C=0(OK), C=1(NG)
;
; Test#4
; . Test phoneme playback using direct IRQ (MB & Phasor)
; NB. Mockingboard must fail, as SSI263 IRQ isn't directly connected
sei
lda #IER_CLR|IxR_SSI263
ldy #SY6522_IER
sta (MBBase),y ; Disable CA1(Speech) IRQ
ldy #SY6522_IFR
sta (MBBase),y ; Clear any CA1(Speech) IRQ
;
; First test Mockingboard (or Phasor in Mockingboard mode)
; . Show that SSI263 IRQ isn't directly connected
;
jsr resetSubTest ; subTest #0
jsr incTotalTests
lda #<NullPhrase
ldx #>NullPhrase
jsr PlaySSI263_no_PCR
ldx #1
- lda doingSpeech
beq @error ; speech phrase complete... an error, as expect it to timeout for MB
lda irqT1IntCount
cmp #4 ; timeout = ~256ms (expected for Mockingboard)
bcc - ; loop if < 4
+
sei
jsr incSubTestNum ; subTest #1
; IFR=IxR_SSI263 during the timeout (as CA1=input)
ldy #SY6522_IFR
lda #IxR_SSI263
tax ; expected
and (MBBase),y ; Check CA1(Speech) IRQ
beq @error
sta (MBBase),y ; Clear the CA1(Speech) IRQ
; SSI263 is still asserting A/!R interrupt: switching to Phasor mode will cause a 6502 IRQ! (On CLI opcode)
; ...because SSI263 only de-asserts A/!R by writing to regs 0,1 or 2 (or set reg3.CTL=1)
jsr KickSSI263
lda #$FF
jsr WAIT ; delay for 0x28882 (166018) cycles / ~163ms
jsr incSubTestNum ; subTest #2
ldy #SY6522_IFR
lda #IxR_SSI263
tax ; expected
and (MBBase),y ; Check CA1(Speech) IRQ
beq @error
sta (MBBase),y ; Clear the CA1(Speech) IRQ
jsr DisableSSI263
;
lda isPhasorCard
beq @done
jsr incSubTestNum ; subTest #3
;
; Now test Phasor in native Phasor mode
;
lda #PH_PHASOR
jsr SetPhasorMode
lda #<NullPhrase
ldx #>NullPhrase
jsr PlaySSI263_no_PCR
- lda doingSpeech
beq +
lda irqT1IntCount
cmp #4 ; timeout = ~256ms
bcc - ; loop if < 4
bcs @error0
+
@done
clc ; C=0(OK)
bcc @exit
;
@error0 ; pre: A=actual
ldx #0
@error ; pre: A=actual, X=expected
stx zpTmp2 ; expected
sec ; C=1(NG)
@exit
sei
php
pha
lda #PH_MOCKINGBOARD
jsr SetPhasorMode
lda #IER_CLR|IxR_TIMER1
ldy #SY6522_IER
sta (MBTimer),y ; Disable Timer1 IRQ
pla
plp
rts
;------------------------------------------------------------------------------
T263_5
; Pre:
; Post: C=0(OK), C=1(NG)
;
; Test#5 - Phasor only
; . Part-1: Test clearing IRQ using writes to all 16 register locations (polling, ints disabled)
; . Part-2: Test clearing IRQ using writes to all 16 register locations (using ISR, ints enabled)
lda isPhasorCard
bne +
clc
rts
+
jsr resetSubTestMinus1 ; subTest #-1
jsr incTotalTests
sei
lda #<@T263_5_ISR
ldx #>@T263_5_ISR
jsr SetIrqVector
lda #PH_PHASOR
jsr SetPhasorMode
;
;-------------- Part-1:
;
; Kick with phoneme $00 && MODE_PHONEME_TRANSITIONED_INFLECTION
jsr KickSSI263_no_PCR
lda #0 ; Countup from $0 to $F
sta @regNum
- jsr incSubTestNum ; subTest# = regNum * 2
jsr @waitPhonemeDone
beq +
jmp @error
+
jsr incSubTestNum ; subTest# = regNum * 2 + 1
lda @regNum
and #7
tay ; y=0..7
lda @regs,y
ldy @regNum ; y=0..F
sta (SSI263Base),y ; Try to clear IRQ by writing to an SSI263 reg
lda (SSI263Base),y
and #REQ_NEW_DATA ; D7
cpy #3 ; (reg3 = SSI_CTTRAMP)
bcc @irqClear ; 0 <= y < 3 ?
cpy #8
bcc @irqSet ; 3 <= y < 8 ?
cpy #3+8 ; (reg3 = SSI_CTTRAMP)
bcc @irqClear ; 8 <= y < (3+8) ?
@irqSet ldx #REQ_NEW_DATA
cmp #REQ_NEW_DATA
beq +
jmp @error
@irqClear
ldx #0
cmp #0
bne @error
+
;
iny
sty @regNum
cpy #$10