Login
Back to forumSee the full topicGo to last reply

Posted By

siz
on 2016-05-18
04:26:53
 Re: How to detect SID card?

My solution (yeah, a bit overcomplicated but detects NST SID card and 6581/8580 too):

; Output:
; io_soundtype:
; bit 7: 1: NAE (NST Audio Extension - BSz SID Card), 0: legacy SID Card
; bit 6-0: 0: TED only, 1: 6581 2: 8580
; io_sidbase: SID address
;================================================
sidptr = 2

lda #0
sta io_soundtype

ldx #<$fd40
ldy #>$fd40
jsr io_detsidaddr
cmp #$ff
beq hassid
ldx #<$fe80
ldy #>$fe80
jsr io_detsidaddr
cmp #$ff
bne nosid
hassid
inc io_soundtype
jsr detsidtp
jsr detnae
; Do whatever you need with SID
rts
nosid
; Do whatever you need without SID
rts

;=======================================
; In: XR: SID address low
; YR: SID address high
; Out: AC: 0: not found $ff: found
;=======================================

io_detsidaddr
lda #0
sta io_sidbase
sta io_sidbase+1

stx sidptr
sty sidptr+1

ldy #24
- sta (sidptr),y
dey
bpl -

ldy #25
lda (sidptr),y
iny
and (sidptr),y
rts

; Detect SID chip type
; original version from Reflex Math demo
;=======================================

detsidtp
lda #1
sta io_soundtype

;Set a low frequency for Oscillator
; (Voice 3) #$0200 which is somewhere
; between B-0 and C-1, according to demo

ldy #15
lda #$02
sta (sidptr),y

;Set Sawtooth and Triangle waveforms for
;voice 3 and start release of ADSR

ldy #18
lda #%00110000
sta (sidptr),y

;Check if output of voice 3 ever goes
;higher than $80. It's only possible on
;new SID chip (8580) and never on the
;old one (6581)

ldy #0
ldx #0
sty ystore
loop2 ldy #27
lda (sidptr),y
bmi newsid
dex
bne loop2
ldy ystore
dey
sty ystore
bne loop2
beq oldsid
newsid
inc io_soundtype
oldsid
rts

;=======================================
; Detect NST SIDCard
;=======================================

detnae
lda #%11100000
sta nae_control+13
ldx #0
- lda nae_control+15
cmp nae_control+15
bne +
dex
bne -
and #%11100000
cmp #%11100000
beq + ; Legacy SID-Card
lda nae_control+15
beq + ; VICE happy
lda io_soundtype
ora #%10000000
- sta io_soundtype
+ rts

io_soundtype .byte 0
io_sidbase .word 0




Back to top


Copyright © Plus/4 World Team, 2001-2024