.proc DetectPokey ; Reset/initialise POKEY. lda #0 sta gamePokeyDetected sta PAUDCTL sta PSKCTL ; Short delay before RANDOM is valid. nop nop nop ; Read the RANDOM register (should return 0xFF when POKEY is in reset) lda PRANDOM cmp #$FF bne @NoPokeyDetected ; Take POKEY out of reset. lda #3 sta PSKCTL ; Short delay before RANDOM is valid. nop nop nop ; Read RANDOM 4 times and junk the first read. lda PRANDOM ; Should yield 0x00 - Junked. lda PRANDOM ; Should yield 0x80 ldx PRANDOM ; Should yield 0xF8 ldy PRANDOM ; Should yield 0x0F ; See if POKEY is there. cmp #$80 ; Expected value? bne @NoPokeyDetected ; No... POKEY *NOT* detected. cpx #$F8 ; Expected value? bne @NoPokeyDetected ; No... POKEY *NOT* detected. cpy #$0F ; Expected value? bne @NoPokeyDetected ; No... POKEY *NOT* detected. rts ; POKEY not detected. @NoPokeyDetected: dec gamePokeyDetected ; Switch off POKEY sound rts .endprocIts in CC65 assembler format and is easily converted to DASM etc. The variable gamePokeyDetected is 0xFF if POKEY isn't detected or 0x00 if it is. The basic theory of operation is that it relies on reading POKEY's RANDOM register several times to get known values after the 17 bit polynomial counter is reset to all 1's. Hopefully this will avoid false positives caused by bus float problems.
I've tested it on my CC2 with:-
7800_32K - POKEY not detected (as expected).
78POKEY - POKEY detected (as expected).
It doesn't detect POKEY in the ProSystem emulator because the RANDOM register is not emulated














