]> git.sur5r.net Git - cc65/blob - libsrc/atari/clock.s
lseek: Implement additional feedback from PR #723.
[cc65] / libsrc / atari / clock.s
1 ;
2 ; Piotr Fusik, 04.11.2001
3 ; originally by Ullrich von Bassewitz and Sidney Cadot
4 ;
5 ; clock_t clock (void);
6 ; unsigned _clocks_per_sec (void);
7 ;
8
9         .export         _clock, __clocks_per_sec
10         .importzp       sreg
11
12         .include        "atari.inc"
13
14
15 .proc   _clock
16
17         ldx     #5              ; Synchronize with Antic, so the interrupt won't change RTCLOK
18         stx     WSYNC           ; while we're reading it. The synchronization is done same as
19 @L1:    dex                     ; in SETVBLV function in Atari OS.
20         bne     @L1
21         stx     sreg+1          ; Byte 3 is always zero
22         lda     RTCLOK+2
23         ldx     RTCLOK+1
24         ldy     RTCLOK
25         sty     sreg
26         rts
27
28 .endproc
29
30
31 .proc   __clocks_per_sec
32
33         ldx     #$00            ; Clear high byte of return value
34         lda     PAL             ; use hw register, PALNTS is only supported on XL/XE ROM
35         and     #$0e
36         bne     @NTSC
37         lda     #50
38         rts
39 @NTSC:  lda     #60
40         rts
41
42 .endproc