From: uz Date: Thu, 24 Sep 2009 20:12:40 +0000 (+0000) Subject: Systime implementation for the CBM610, derived from the C64. X-Git-Tag: V2.13.0rc1~31 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=753bbab40d4a3be1697764d0bbe8aab6bcc7dd16;p=cc65 Systime implementation for the CBM610, derived from the C64. git-svn-id: svn://svn.cc65.org/cc65/trunk@4225 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/cbm610/systime.s b/libsrc/cbm610/systime.s index 1d039e80e..7d44a38f4 100644 --- a/libsrc/cbm610/systime.s +++ b/libsrc/cbm610/systime.s @@ -1,5 +1,6 @@ ; -; Ullrich von Bassewitz, 12.11.2002 +; Stefan Haubenthal, 2009-07-27 +; Ullrich von Bassewitz, 2009-09-24 ; ; time_t _systime (void); ; /* Similar to time(), but: @@ -9,20 +10,89 @@ ; */ ; - .export __systime + .include "time.inc" + .include "cbm610.inc" + .include "extzp.inc" - .importzp sreg + .import sys_bank, restore_bank + .importzp tmp1, tmp2 + +;---------------------------------------------------------------------------- .code -.proc __systime +.proc __systime + +; Switch to the system bank + + jsr sys_bank + +; Read the clock + + ldy #CIA::TODHR + lda (cia),y + bpl AM + and #%01111111 + sed + clc + adc #$12 + cld +AM: jsr BCD2dec + sta TM + tm::tm_hour + ldy #CIA::TODMIN + lda (cia),y + jsr BCD2dec + sta TM + tm::tm_min + ldy #CIA::TODSEC + lda (cia),y + jsr BCD2dec + sta TM + tm::tm_sec + ldy #CIA::TOD10 + lda (cia),y ; Dummy read to unfreeze + +; Restore the bank + + jsr restore_bank - lda #$FF - tax - sta sreg - sta sreg+1 - rts ; Return -1 +; Convert to a time + + lda #TM + jmp _mktime .endproc +;---------------------------------------------------------------------------- +; dec = (((BCD>>4)*10) + (BCD&0xf)) + +.proc BCD2dec + + tax + and #%00001111 + sta tmp1 + txa + and #%11110000 ; *16 + lsr ; *8 + sta tmp2 + lsr + lsr ; *2 + adc tmp2 ; = *10 + adc tmp1 + 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