User Tools

Site Tools


No renderer 'pdf' found for mode 'pdf'
base:detecting_6526_vs_6526a_cia_chips

This is an old revision of the document!


Detecting 6526 vs 6526A CIA Chips

by White Flame

This sets off a single-shot NMI to interrupt immediately before an INC statement. The older 6526 triggers one cycle later, so it will run the INC while the newer one won't.

Make sure the screen & sprites are off first.

oldCia should be in zeropage, and will have a 0 or 1 after this routine.

testCIAVersion:
 ; Set NMI vector
 lda #<continue
 sta $fffa
 lda #>continue
 sta $fffb

 lda #$81  ;also don't forget to set mask. Setting $01 to an appropriate value will also help :-) (Bitbreaker/Oxyron)
 sta $dd0d

 ; Set timer to 5 cycles
 lda #4
 sta $dd04
 lda #0
 sta $dd05

 ; Clear the detection flag
 sta oldCIA

 ; Fire a 1-shot timer
 lda #%10011001
 sta $dd0e

 ; This should be interrupted before the INC
 ; only if it's a newer chip.
 lda $dd0d
 lda $dd0d
 inc oldCIA
 jmp * ; just in case

continue:
 lda $dd0d
 pla
 pla
 pla

Note by Karoshier: I had problems making this work once adapted to use CIA1 instead of CIA2, as the interrupt wouldn't fire at all and the CPU remained locked in the JMP *. The cause of this was the two consecutive LDA $DC0D before the INC oldCIA instruction. It happened by chance that one of them had been cycle-exact synchronized with the CIA and cleared the interrupt flag in the very same cycle as the one in which the interrupt was asserted. The interrupt pulse didn't last enough and the CPU didn't see it (tried on both VICE 2.4 and on the real hardware). I have solved the problem by replacing those LDA $DC0D with NOPs and readjusting the number of clock cycles the timer A is set to timeout at.

base/detecting_6526_vs_6526a_cia_chips.1508995125.txt.gz · Last modified: 2017-10-26 07:18 by white_flame