]> git.sur5r.net Git - cc65/blob - libsrc/vic20/get_tv.s
13c5c428ab68b96683840b189d0a1271c6c89a46
[cc65] / libsrc / vic20 / get_tv.s
1 ;
2 ; Stefan Haubenthal, 2004-10-07
3 ; Based on code from Pu-239
4 ;
5 ; unsigned char __fastcall__ get_tv (void);
6 ; /* Return the video mode the machine is using */
7 ;
8
9         .export         _get_tv
10
11         .include        "vic20.inc"
12
13
14 ;--------------------------------------------------------------------------
15 ; _get_tv
16
17 .proc   _get_tv
18
19 NTSC_LINES = 261
20         ; detect the system
21         lda     #0
22         tax
23 @L0:    ldy     VIC_HLINE
24         cpy     #1
25         bne     @L0             ; wait for line 1
26 @L1:    ldy     VIC_HLINE
27         beq     @L2             ; line 0 reached -> NTSC
28         cpy     #NTSC_LINES/2+2
29         bne     @L1
30         lda     #1
31 @L2:    rts                     ; system detected: 0 for NTSC, 1 for PAL
32
33 .endproc