]> git.sur5r.net Git - cc65/blob - libsrc/c128/tmcommon.s
Changed most "backticks" (grave accents) into apostrophes.
[cc65] / libsrc / c128 / tmcommon.s
1 ;
2 ; Oliver Schmidt, 16.8.2018
3 ;
4 ; Common stuff for the clock routines
5 ;
6
7         .include        "c128.inc"
8         .include        "get_tv.inc"
9
10         .export         TM, load_tenth
11
12         .constructor    inittime
13         .importzp       sreg
14         .import         _get_tv
15
16
17 ;----------------------------------------------------------------------------
18 .code
19
20 .proc   load_tenth
21
22         lda     #<(100 * 1000 * 1000 / $10000)
23         ldx     #>(100 * 1000 * 1000 / $10000)
24         sta     sreg
25         stx     sreg+1
26         lda     #<(100 * 1000 * 1000)
27         ldx     #>(100 * 1000 * 1000)
28         rts
29
30 .endproc
31
32 ;----------------------------------------------------------------------------
33 ; Constructor that writes to the 1/10 sec register of the TOD to kick it
34 ; into action. If this is not done, the clock hangs. We will read the register
35 ; and write it again, ignoring a possible change in between.
36 .segment "ONCE"
37
38 .proc   inittime
39
40         lda     CIA1_TOD10
41         sta     CIA1_TOD10
42         jsr     _get_tv
43         cmp     #TV::PAL
44         bne     @60Hz
45         lda     CIA1_CRA
46         ora     #$80
47         sta     CIA1_CRA
48 @60Hz:  rts
49
50 .endproc
51
52 ;----------------------------------------------------------------------------
53 ; TM struct with date set to 1970-01-01
54 .data
55
56 TM:     .word           0       ; tm_sec
57         .word           0       ; tm_min
58         .word           0       ; tm_hour
59         .word           1       ; tm_mday
60         .word           0       ; tm_mon
61         .word           70      ; tm_year
62         .word           0       ; tm_wday
63         .word           0       ; tm_yday
64         .word           0       ; tm_isdst