From 83be732983e9714821bf975e289b84f84d49db6c Mon Sep 17 00:00:00 2001 From: uz Date: Thu, 24 Sep 2009 19:40:36 +0000 Subject: [PATCH] The CIA TOD needs a write to the 1/10 sec register to start. Shortened the code by using initialized data. git-svn-id: svn://svn.cc65.org/cc65/trunk@4224 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/c128/systime.s | 39 +++++++++++++++++++++++++++++++-------- libsrc/c64/systime.s | 39 +++++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/libsrc/c128/systime.s b/libsrc/c128/systime.s index eb1950906..dced83c06 100644 --- a/libsrc/c128/systime.s +++ b/libsrc/c128/systime.s @@ -12,17 +12,15 @@ .include "time.inc" .include "c128.inc" - .importzp tmp1, tmp2 + .constructor initsystime + .importzp tmp1, tmp2 + +;---------------------------------------------------------------------------- .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 +57,31 @@ 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 + 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 diff --git a/libsrc/c64/systime.s b/libsrc/c64/systime.s index 6654e8508..c0b4238bc 100644 --- a/libsrc/c64/systime.s +++ b/libsrc/c64/systime.s @@ -12,17 +12,15 @@ .include "time.inc" .include "c64.inc" - .importzp tmp1, tmp2 + .constructor initsystime + .importzp tmp1, tmp2 + +;---------------------------------------------------------------------------- .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 +57,31 @@ 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 + 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 -- 2.39.5