]> git.sur5r.net Git - cc65/blob - libsrc/c64/acc_detect_c64dtv.s
Merge pull request #628 from ops/VIAFIX_PET
[cc65] / libsrc / c64 / acc_detect_c64dtv.s
1 ;
2 ; Marco van den Heuvel, 2018-04-14
3 ;
4
5 ; unsigned char detect_c64dtv (void);
6 ;
7 ;/* Check for the presence of the C64DTV.
8 ; *
9 ; * Possible return values:
10 ; * 0x00  : C64DTV not present
11 ; * 0x01  : C64DTV present
12 ; */
13
14         .export         _detect_c64dtv
15
16         .include        "accelerator.inc"
17
18 _detect_c64dtv:
19         ldy     C64DTV_Extended_Regs
20         lda     #$00
21         ldx     $D000
22
23 ; Make sure the CPU is a 6510
24         .byte   $1A                   ; NOP on 8502, INA on 65(S)C(E)02, 4510 and 65816
25         bne     not_found
26         lda     #$01
27         sta     C64DTV_Extended_Regs
28
29 ; Check if $D000 is mirrored at $D040
30         cpx     $D040
31         bne     found
32         inc     $D000
33         cpx     $D040
34         bne     not_found
35 found:
36         lda     #$01
37         .byte   $2C
38 not_found:
39         lda     #$00
40         stx     $D000
41         ldx     #$00
42         sty     C64DTV_Extended_Regs
43         rts
44