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