]> git.sur5r.net Git - cc65/commitdiff
Added a systime implementation by Stefan Haubenthal with a few changes. The
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 27 Jul 2009 18:44:37 +0000 (18:44 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 27 Jul 2009 18:44:37 +0000 (18:44 +0000)
routine reads the TOD clock of CIA1 on the C64 and C128. Since systime was a
dummy routine common for all CBMs before, this change adds an individual dummy
routine for all other CBM systems. CBM510/610 do also have a TOD clock, so a
similar function as in the C64 could be used ...

git-svn-id: svn://svn.cc65.org/cc65/trunk@3974 b7a2c559-68d2-44c3-8de9-860c34a00d81

16 files changed:
libsrc/c128/Makefile
libsrc/c128/c128.inc
libsrc/c128/systime.s [new file with mode: 0644]
libsrc/c16/Makefile
libsrc/c16/systime.s [new file with mode: 0644]
libsrc/c64/Makefile
libsrc/c64/c64.inc
libsrc/c64/systime.s [new file with mode: 0644]
libsrc/cbm/Makefile
libsrc/cbm/systime.s [deleted file]
libsrc/cbm510/Makefile
libsrc/cbm510/systime.s [new file with mode: 0644]
libsrc/cbm610/Makefile
libsrc/cbm610/systime.s [new file with mode: 0644]
libsrc/plus4/Makefile
libsrc/plus4/systime.s [new file with mode: 0644]

index 87df0f76e03d3e075a27f664e117b0dbd6fe4197..95b739ecd84c9bbf2a4a1168b50c5d62229c78a4 100644 (file)
@@ -63,6 +63,7 @@ OBJS =        _scrsize.o              \
         randomize.o            \
         revers.o               \
        slow.o                  \
+        systime.o               \
         sysuname.o              \
        tgi_mode_table.o        \
        toggle_videomode.o
index 65d269868f08918e329f9affc46abf2e4a198145..ffe531b49507f8262d3ea72eea5d87b44c46456d 100644 (file)
@@ -171,6 +171,10 @@ CIA1_PRA           := $DC00
 CIA1_PRB               := $DC01
 CIA1_DDRA              := $DC02
 CIA1_DDRB              := $DC03
+CIA1_TOD10      := $DC08
+CIA1_TODSEC     := $DC09
+CIA1_TODMIN     := $DC0A
+CIA1_TODHR      := $DC0B
 CIA1_ICR               := $DC0D
 CIA1_CRA               := $DC0E
 CIA1_CRB               := $DC0F
@@ -180,6 +184,10 @@ CIA2_PRA           := $DD00
 CIA2_PRB               := $DD01
 CIA2_DDRA              := $DD02
 CIA2_DDRB              := $DD03
+CIA2_TOD10      := $DD08
+CIA2_TODSEC     := $DD09
+CIA2_TODMIN     := $DD0A
+CIA2_TODHR      := $DD0B
 CIA2_ICR               := $DD0D
 CIA2_CRA               := $DD0E
 CIA2_CRB               := $DD0F
diff --git a/libsrc/c128/systime.s b/libsrc/c128/systime.s
new file mode 100644 (file)
index 0000000..eb19509
--- /dev/null
@@ -0,0 +1,64 @@
+;
+; Stefan Haubenthal, 27.7.2009
+;
+; time_t _systime (void);
+; /* Similar to time(), but:
+;  *   - Is not ISO C
+;  *   - Does not take the additional pointer
+;  *   - Does not set errno when returning -1
+;  */
+;
+
+        .include        "time.inc"
+        .include        "c128.inc"
+
+       .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
+       sed
+       clc
+       adc     #$12
+       cld
+AM:    jsr     BCD2dec
+       sta     TM + tm::tm_hour
+       lda     CIA1_TODMIN
+       jsr     BCD2dec
+       sta     TM + tm::tm_min
+       lda     CIA1_TODSEC
+       jsr     BCD2dec
+       sta     TM + tm::tm_sec
+       lda     CIA1_TOD10              ; Dummy read to unfreeze
+       lda     #<TM
+       ldx     #>TM
+       jmp     _mktime
+
+; dec = (((BCD>>4)*10) + (BCD&0xf))
+BCD2dec:tax
+       and     #%00001111
+       sta     tmp1
+       txa
+        and     #%11110000      ; *16
+        lsr                     ; *8
+        sta     tmp2
+        lsr
+        lsr                     ; *2
+        adc     tmp2            ; = *10
+        adc     tmp1
+        rts
+
+.endproc
+
+.bss
+
+TM:    .tag    tm
index a9bffbbf747d8eaef52186ae0aef71c5d1e46a85..f8f4bf017ff777c7eb70d253225cde11b968d078 100644 (file)
@@ -57,6 +57,7 @@ OBJS =        _scrsize.o      \
         mainargs.o      \
         randomize.o     \
         revers.o        \
+        systime.o       \
         sysuname.o
 
 #--------------------------------------------------------------------------
diff --git a/libsrc/c16/systime.s b/libsrc/c16/systime.s
new file mode 100644 (file)
index 0000000..1d039e8
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; Ullrich von Bassewitz, 12.11.2002
+;
+; time_t _systime (void);
+; /* Similar to time(), but:
+;  *   - Is not ISO C
+;  *   - Does not take the additional pointer
+;  *   - Does not set errno when returning -1
+;  */
+;
+
+       .export         __systime
+
+        .importzp       sreg
+
+.code
+
+.proc   __systime
+
+        lda     #$FF
+        tax
+        sta     sreg
+        sta     sreg+1
+        rts                     ; Return -1
+
+.endproc
+
+
index 90b5c3ebb60433eecc8a730e5ff441d862abea12..7da97138414ed66687e361845149e42af8e2df5c 100644 (file)
@@ -62,6 +62,7 @@ OBJS =        _scrsize.o              \
         mcbdefault.o            \
         randomize.o             \
         revers.o                \
+        systime.o               \
         sysuname.o              \
         tgi_mode_table.o
 
index 2e56beed7e6e757e6a19359c5e94c93b2dff885f..715e11d816f0948cc172941bce75b6438afa74c9 100644 (file)
@@ -164,6 +164,10 @@ CIA1_PRA           := $DC00
 CIA1_PRB               := $DC01
 CIA1_DDRA              := $DC02
 CIA1_DDRB              := $DC03
+CIA1_TOD10      := $DC08
+CIA1_TODSEC     := $DC09
+CIA1_TODMIN     := $DC0A
+CIA1_TODHR      := $DC0B
 CIA1_ICR               := $DC0D
 CIA1_CRA               := $DC0E
 CIA1_CRB               := $DC0F
@@ -173,6 +177,10 @@ CIA2_PRA           := $DD00
 CIA2_PRB               := $DD01
 CIA2_DDRA              := $DD02
 CIA2_DDRB              := $DD03
+CIA2_TOD10      := $DD08
+CIA2_TODSEC     := $DD09
+CIA2_TODMIN     := $DD0A
+CIA2_TODHR      := $DD0B
 CIA2_ICR               := $DD0D
 CIA2_CRA               := $DD0E
 CIA2_CRB               := $DD0F
diff --git a/libsrc/c64/systime.s b/libsrc/c64/systime.s
new file mode 100644 (file)
index 0000000..6654e85
--- /dev/null
@@ -0,0 +1,64 @@
+;
+; Stefan Haubenthal, 27.7.2009
+;
+; time_t _systime (void);
+; /* Similar to time(), but:
+;  *   - Is not ISO C
+;  *   - Does not take the additional pointer
+;  *   - Does not set errno when returning -1
+;  */
+;
+
+        .include        "time.inc"
+        .include        "c64.inc"
+
+       .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
+       sed
+       clc
+       adc     #$12
+       cld
+AM:    jsr     BCD2dec
+       sta     TM + tm::tm_hour
+       lda     CIA1_TODMIN
+       jsr     BCD2dec
+       sta     TM + tm::tm_min
+       lda     CIA1_TODSEC
+       jsr     BCD2dec
+       sta     TM + tm::tm_sec
+       lda     CIA1_TOD10              ; Dummy read to unfreeze
+       lda     #<TM
+       ldx     #>TM
+       jmp     _mktime
+
+; dec = (((BCD>>4)*10) + (BCD&0xf))
+BCD2dec:tax
+       and     #%00001111
+       sta     tmp1
+       txa
+        and     #%11110000      ; *16
+        lsr                     ; *8
+        sta     tmp2
+        lsr
+        lsr                     ; *2
+        adc     tmp2            ; = *10
+        adc     tmp1
+        rts
+
+.endproc
+
+.bss
+
+TM:    .tag    tm
index daf86d6d749caa16241140f6475dce63b930a2cf..4fd88a2a9ee5ebc4ac4756570f0a8703a042e8fb 100644 (file)
@@ -79,7 +79,6 @@ S_OBJS =      c_acptr.o       \
                 scratch.o       \
                 sysremove.o     \
                 sysrename.o     \
-                systime.o       \
                wherex.o        \
                 wherey.o        \
                 write.o
diff --git a/libsrc/cbm/systime.s b/libsrc/cbm/systime.s
deleted file mode 100644 (file)
index 1d039e8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-;
-; Ullrich von Bassewitz, 12.11.2002
-;
-; time_t _systime (void);
-; /* Similar to time(), but:
-;  *   - Is not ISO C
-;  *   - Does not take the additional pointer
-;  *   - Does not set errno when returning -1
-;  */
-;
-
-       .export         __systime
-
-        .importzp       sreg
-
-.code
-
-.proc   __systime
-
-        lda     #$FF
-        tax
-        sta     sreg
-        sta     sreg+1
-        rts                     ; Return -1
-
-.endproc
-
-
index cd25dbc75aa8b65cd4fd1c3dce553f01a3a3404b..2d1f36c066579e7788a2167307c5a951cfcac12f 100644 (file)
@@ -72,6 +72,7 @@ OBJS =        _scrsize.o      \
        pokesys.o       \
         randomize.o     \
        revers.o        \
+        systime.o       \
         sysuname.o      \
        tgi_mode_table.o
 
diff --git a/libsrc/cbm510/systime.s b/libsrc/cbm510/systime.s
new file mode 100644 (file)
index 0000000..1d039e8
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; Ullrich von Bassewitz, 12.11.2002
+;
+; time_t _systime (void);
+; /* Similar to time(), but:
+;  *   - Is not ISO C
+;  *   - Does not take the additional pointer
+;  *   - Does not set errno when returning -1
+;  */
+;
+
+       .export         __systime
+
+        .importzp       sreg
+
+.code
+
+.proc   __systime
+
+        lda     #$FF
+        tax
+        sta     sreg
+        sta     sreg+1
+        rts                     ; Return -1
+
+.endproc
+
+
index 5783504744a9cd58bf42fea0dc4037921ba8dc34..22f516c62a21cd8c3125b5a947d95da22f8d3887 100644 (file)
@@ -65,6 +65,7 @@ OBJS =        _scrsize.o      \
        pokesys.o       \
         randomize.o     \
        revers.o        \
+        systime.o       \
         sysuname.o
 
 #--------------------------------------------------------------------------
diff --git a/libsrc/cbm610/systime.s b/libsrc/cbm610/systime.s
new file mode 100644 (file)
index 0000000..1d039e8
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; Ullrich von Bassewitz, 12.11.2002
+;
+; time_t _systime (void);
+; /* Similar to time(), but:
+;  *   - Is not ISO C
+;  *   - Does not take the additional pointer
+;  *   - Does not set errno when returning -1
+;  */
+;
+
+       .export         __systime
+
+        .importzp       sreg
+
+.code
+
+.proc   __systime
+
+        lda     #$FF
+        tax
+        sta     sreg
+        sta     sreg+1
+        rts                     ; Return -1
+
+.endproc
+
+
index 00a63c4d032a33c475e9485f1a9bb05474ce5116..e2bedca37f292f0447a95268d01a27b8c00c841f 100644 (file)
@@ -78,6 +78,7 @@ OBJS =        _scrsize.o      \
         mainargs.o      \
         randomize.o     \
         revers.o        \
+        systime.o       \
         sysuname.o      \
        tgi_mode_table.o
 
diff --git a/libsrc/plus4/systime.s b/libsrc/plus4/systime.s
new file mode 100644 (file)
index 0000000..1d039e8
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; Ullrich von Bassewitz, 12.11.2002
+;
+; time_t _systime (void);
+; /* Similar to time(), but:
+;  *   - Is not ISO C
+;  *   - Does not take the additional pointer
+;  *   - Does not set errno when returning -1
+;  */
+;
+
+       .export         __systime
+
+        .importzp       sreg
+
+.code
+
+.proc   __systime
+
+        lda     #$FF
+        tax
+        sta     sreg
+        sta     sreg+1
+        rts                     ; Return -1
+
+.endproc
+
+