]> git.sur5r.net Git - cc65/blob - libsrc/c64/acc_detect_c65.s
remove TABs
[cc65] / libsrc / c64 / acc_detect_c65.s
1 ;
2 ; Marco van den Heuvel, 2018-04-27
3 ;
4
5 ; unsigned char detect_c65 (void);
6 ;
7 ;/* Check for the presence of a C65/C64DX in C64 mode.
8 ; *
9 ; * Possible return values:
10 ; * 0x00  : C65/C64DX in C64 mode not present
11 ; * 0x01  : C65/C64DX in C64 mode present
12 ; */
13
14         .export         _detect_c65
15
16         .include        "accelerator.inc"
17
18 _detect_c65:
19         ldy     $D000
20
21 ; Make sure the CPU is not a 65816
22         clc
23         .byte   $E2,$01                ; NOP #$01 on 6510 and 65(S)C02, LDA $(01,S),Y on 65CE02 and 4510, SEP #$01 on 65816
24         lda     #$00
25         tax
26         bcs     not_found              ; carry will be set on 65816
27
28 ; Make sure the CPU is not a 6510
29         .byte   $1A                    ; NOP on 6510, INA on 65(S)C(E)02
30         beq     not_found
31         txa
32
33 ; Make sure the CPU is a 65CE02/4510
34         .byte   $A3,$A3                ; NOP NOP on 65(S)C02, LDZ #$A3 on 65CE02 and 4510
35         .byte   $6B                    ; NOP on 65(S)C02, TZA on 65CE02 and 4510
36         cmp     #$A3
37         bne     not_found
38
39 ; Switch to VICIII mode and check if $D040 is a mirror of $D000
40         ldy     #C65_VICIII_UNLOCK_1
41         sty     C65_VICIII_KEY
42         ldy     #C65_VICIII_UNLOCK_2
43         sty     C65_VICIII_KEY
44         cpy     $D040
45         bne     found
46         inc     $D000
47         cpy     $D040
48         bne     not_found
49
50 found:
51         lda     #$01
52 not_found:
53         sty     $D000
54         sta     C65_VICIII_KEY
55         rts