X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=libsrc%2Fc128%2Fsystime.s;h=468d7da19100530c1dbcbc1aa931d75c72dfc5c9;hb=bf59515a9e248675c07d5edf623856a15d808901;hp=eb19509061654d22a3bab2e67645cdb1046474f8;hpb=931add050ea929e67a45242fbff758464e8ef3c7;p=cc65 diff --git a/libsrc/c128/systime.s b/libsrc/c128/systime.s index eb1950906..468d7da19 100644 --- a/libsrc/c128/systime.s +++ b/libsrc/c128/systime.s @@ -11,18 +11,18 @@ .include "time.inc" .include "c128.inc" + .include "get_tv.inc" - .importzp tmp1, tmp2 + .constructor initsystime + .importzp tmp1, tmp2 + .import _get_tv + +;---------------------------------------------------------------------------- .code -; Jan 1st 1970, CIA #1 TOD .proc __systime - lda #70 - sta TM + tm::tm_year - lda #1 - sta TM + tm::tm_mday lda CIA1_TODHR bpl AM and #%01111111 @@ -59,6 +59,37 @@ BCD2dec:tax .endproc -.bss +;---------------------------------------------------------------------------- +; Constructor that writes to the 1/10 sec register of the TOD to kick it +; into action. If this is not done, the clock hangs. We will read the register +; and write it again, ignoring a possible change in between. + +.proc initsystime + + lda CIA1_TOD10 + sta CIA1_TOD10 + jsr _get_tv + cmp #TV::PAL + bne @60Hz + lda CIA1_CRA + ora #$80 + sta CIA1_CRA +@60Hz: rts + +.endproc + + +;---------------------------------------------------------------------------- +; TM struct with date set to 1970-01-01 +.data + +TM: .word 0 ; tm_sec + .word 0 ; tm_min + .word 0 ; tm_hour + .word 1 ; tm_mday + .word 0 ; tm_mon + .word 70 ; tm_year + .word 0 ; tm_wday + .word 0 ; tm_yday + .word 0 ; tm_isdst -TM: .tag tm