base:detecting_6526_vs_6526a_cia_chips
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
base:detecting_6526_vs_6526a_cia_chips [2015-04-17 04:31] – external edit 127.0.0.1 | base:detecting_6526_vs_6526a_cia_chips [2018-02-24 10:33] (current) – tww_ctr | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Detecting 6526 vs 6526A CIA Chips ====== | ====== Detecting 6526 vs 6526A CIA Chips ====== | ||
+ | |||
+ | by White Flame | ||
This sets off a single-shot NMI to interrupt immediately before an INC statement. | This sets off a single-shot NMI to interrupt immediately before an INC statement. | ||
Line 43: | Line 45: | ||
pla | pla | ||
| | ||
- | White Flame (aka David Holz)\\ | + | |
- | http:// | + | |
Note by Karoshier: I had problems making this work once adapted to use CIA1 instead of CIA2, as the interrupt wouldn' | Note by Karoshier: I had problems making this work once adapted to use CIA1 instead of CIA2, as the interrupt wouldn' | ||
+ | |||
+ | Modified to the following to allow detection of both CIAs and should account for the comment above from Bitbreaker & Karoshier. Note that the routine can be slimmed down considerably if you run this in a interrupt controlled environment: | ||
+ | |||
+ | < | ||
+ | |||
+ | // Detects both CIAs and returns to BASIC after being run | ||
+ | // Based on White Flame' | ||
+ | // By TWW/ | ||
+ | |||
+ | : | ||
+ | | ||
+ | start: | ||
+ | |||
+ | sei | ||
+ | lda #$35 | ||
+ | sta $01 // Disable IRQs and bank out BASIC and KERNAL | ||
+ | |||
+ | lda #< | ||
+ | sta $fffe | ||
+ | lda #> | ||
+ | sta $ffff | ||
+ | lda #< | ||
+ | sta $fffa | ||
+ | lda #> | ||
+ | sta $fffb // Set IRQ/NMI vectors | ||
+ | |||
+ | lda #$7f | ||
+ | sta $dc0d | ||
+ | sta $dd0d // Mask out all IRQ/NMI sources | ||
+ | |||
+ | lda #$82 | ||
+ | sta $dc0d | ||
+ | lda #$81 | ||
+ | sta $dd0d // Mask in Interrupt Sources from CIA #1 Timer B and CIA #2 Timer A | ||
+ | |||
+ | lda $dc0d | ||
+ | lda $dd0d // Ack any pending interrupts | ||
+ | | ||
+ | tsx // Preserve STACK Pointer | ||
+ | |||
+ | lda #0 | ||
+ | sta $dc06 | ||
+ | sta $dc07 | ||
+ | sta $dd04 | ||
+ | sta $dd05 // Set timers to 1 cycle | ||
+ | |||
+ | cli // Allow IRQs to trigger | ||
+ | lda #%00011001 | ||
+ | sta $dc0f // Fire a 1-shot timer | ||
+ | bit $00 | ||
+ | // IRQ happens here if it's the new CIA type | ||
+ | inc oldCIA1 | ||
+ | // IRQ happens here if it's the old CIA type | ||
+ | |||
+ | continue1: | ||
+ | sei | ||
+ | lda #%10011001 | ||
+ | sta $dd0e // Fire a 1-shot timer | ||
+ | bit $00 | ||
+ | // NMI happens here if it's the new CIA type | ||
+ | inc oldCIA2 | ||
+ | // NMI happens here if it's the old CIA type | ||
+ | |||
+ | continue2: | ||
+ | txs // Restore STACK Pointer | ||
+ | lda #$7f | ||
+ | sta $dc0d | ||
+ | sta $dd0d | ||
+ | lda #$81 | ||
+ | sta $dc0d // Mask out IRQs and re-enable CIA #1 Timer A to allow BASIC to run. | ||
+ | |||
+ | lda $dc0d // ack the IRQ | ||
+ | lda $dd0d // ack the NMI | ||
+ | |||
+ | lda #$37 | ||
+ | sta $01 | ||
+ | cli // enable IRQs and Bank back BASIC and KERNAL | ||
+ | |||
+ | lda oldCIA1 | ||
+ | sta $0400 | ||
+ | lda oldCIA2 | ||
+ | sta $0402 // Show result | ||
+ | rts | ||
+ | |||
+ | oldCIA1: | ||
+ | oldCIA2: | ||
+ | </ |
base/detecting_6526_vs_6526a_cia_chips.txt · Last modified: 2018-02-24 10:33 by tww_ctr