]> git.sur5r.net Git - cc65/blob - libsrc/pce/clock.s
Fixed _textcolor definition.
[cc65] / libsrc / pce / clock.s
1 ;
2 ; clock_t clock (void);
3 ;
4
5         .constructor    initclock
6         .export         _clock
7
8         .forceimport    ticktock        ; make sure that tickcount changes
9         .importzp       tickcount, sreg
10
11
12 ; Make the process clock start at zero.
13
14         .segment        "ONCE"
15 initclock:
16         ldx     #4 - 1
17 @lp:    stz     tickcount,x
18         dex
19         bpl     @lp
20         rts
21
22 ; ------------------------------------------------------------------------
23 .code
24
25 ; This function might be interrupted while it is reading the several bytes of
26 ; the clock.  They are read again if that happens.  (We do not want to stop
27 ; interrupts because that might cause glitches in interrupt-driven graphics
28 ; and sound.)
29
30 .proc   _clock
31         lda     tickcount
32         ldy     tickcount+3
33         sty     sreg+1
34         ldy     tickcount+2
35         sty     sreg
36         ldx     tickcount+1
37         cmp     tickcount
38         bne     _clock                  ; clock changed; reread it
39         rts
40 .endproc