Skip to content

Commit f6a2117

Browse files
committed
avoid snes driver stepping on atarivox
1 parent f721dde commit f6a2117

1 file changed

Lines changed: 53 additions & 10 deletions

File tree

includes/std_routines.asm

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,13 @@ skipvoxprocessing
646646
rts
647647

648648
processavoxvoice
649+
ifconst HSSUPPORT
650+
; ** we skip speech if hi-score is on and no vox was detected
651+
; ** this is to avoid later collision with snes pads.
652+
lda hsdevice
653+
and #2
654+
beq processavoxvoicereturn
655+
endif ; HSSUPPORT
649656
lda avoxenable
650657
bne avoxfixport
651658
SPKOUT tempavox
@@ -656,6 +663,7 @@ avoxfixport
656663
rts
657664
silenceavoxvoice
658665
SPEAK avoxsilentdata
666+
processavoxvoicereturn
659667
rts
660668
avoxsilentdata
661669
.byte 31,255
@@ -709,7 +717,18 @@ SWCHA_INVDIRMASK
709717

710718
; Probe each port for SNES, and see if autodetection succeeds anywhere.
711719
SNES_AUTODETECT
720+
ifconst HSSUPPORT
721+
; ** an atarivox might be plugged in, so we skip scanning the second
722+
; ** port for a snes if vox was detected...
723+
lda hsdevice ; b1 high means atarivox/savekey was detected
724+
lsr
725+
and #1
726+
eor #1
727+
tax
728+
else
712729
ldx #1
730+
endif ; HSSUPPORT
731+
713732
SNES_AUTODETECT_LOOP
714733
lda #1 ; proline
715734
sta port0control,x
@@ -749,7 +768,9 @@ SNES_READ
749768
lda SWCHA
750769
ora SWCHA_INVDIRMASK,x
751770
eor SWCHA_DIRMASK,x
752-
beq SNES_ABORT
771+
bne SNES_READ_cont1
772+
jmp SNES_ABORT
773+
SNES_READ_cont1
753774

754775
lda port0control,x
755776
cmp #11 ; snes
@@ -760,8 +781,17 @@ snes2atari_signal_go
760781
jsr SNES2ATARI_SIGNAL
761782
snes2atari_signal_skip
762783

763-
lda SNES_CTLSWA_MASK,x
784+
;lda SNES_CTLSWA_MASK,x
785+
786+
lda CTLSWA
787+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
788+
ora SNES_CTLSWA_MASK,x
764789
sta CTLSWA ; enable pins UP/DOWN to work as outputs
790+
791+
lda SWCHA
792+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
793+
ora SNES_CTLSWA_MASK,x
794+
765795
sta SWCHA ; latch+clock high
766796
nop
767797
nop
@@ -770,17 +800,21 @@ snes2atari_signal_skip
770800
nop
771801
nop
772802
nop
773-
lda #$0
803+
lda SWCHA
804+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
774805
sta SWCHA ; latch and clock low
775806
ldy #16 ; 16 bits
776807
SNES2ATARILOOP
777808
rol INPT4,x ; sample data into carry
778-
lda SNES_CLOCK_PORT_BIT,x
809+
lda SWCHA
810+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
811+
ora SNES_CLOCK_PORT_BIT,x
779812
sta SWCHA ; clock low
780813
rol snes2atari0lo,x
781814
rol snes2atari0hi,x
782-
lda #0
783-
sta SWCHA ; clock high
815+
lda SWCHA
816+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
817+
sta SWCHA ; latch and clock low
784818
dey ; next bit
785819
bne SNES2ATARILOOP
786820
rol INPT4,x ; 17th bit should be lo if controller is there.
@@ -790,25 +824,34 @@ SNES2ATARILOOP
790824
sta snesdetected0,x
791825
beq SNES_STOP_CLOCK ; if snes isn't detected, leave port in default state
792826
stx snesport ; snesport keeps the index of the latest autodetected controller
793-
lda SNES_CLOCK_PORT_BIT,x
827+
lda SWCHA
828+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
829+
ora SNES_CLOCK_PORT_BIT,x
794830
SNES_STOP_CLOCK
795831
sta SWCHA ; clock low
832+
lda CTLSWA
833+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
834+
ora SNES_CLOCK_PORT_BIT,x
796835
sta CTLSWA ; set port bits to input avoid conflict with other drivers
797836
rts
798837
SNES_ABORT
799838
sta snesdetected0,x
800839
rts
801840
SNES2ATARI_SIGNAL
802841
; signal to SNES2ATARI++ that we want SNES mode...
803-
lda SNES_CTLSWA_SIGNAL,x
842+
lda CTLSWA
843+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
844+
ora SNES_CTLSWA_SIGNAL,x
804845
sta CTLSWA
805-
lda #0
846+
lda CTLSWA
847+
and SWCHA_INVDIRMASK,x ; preserve othr nibble
806848
sta SWCHA
807849
ldy #0
808850
SNES_SIGNAL_LOOP
809851
dey
810852
bne SNES_SIGNAL_LOOP
811-
lda #$FF
853+
lda SWCHA
854+
ora SWCHA_DIRMASK,x
812855
sta SWCHA
813856
rts
814857
endif

0 commit comments

Comments
 (0)