2002-11-12 22:49:38 +00:00
|
|
|
;
|
2007-01-05 16:16:34 +00:00
|
|
|
; Oliver Schmidt, 22.08.2006
|
2002-11-12 22:49:38 +00:00
|
|
|
;
|
|
|
|
; 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
|
|
|
|
; */
|
|
|
|
;
|
|
|
|
|
2009-07-27 17:59:27 +00:00
|
|
|
.include "time.inc"
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "zeropage.inc"
|
|
|
|
.include "mli.inc"
|
2007-01-05 16:16:34 +00:00
|
|
|
|
2005-01-06 12:26:47 +00:00
|
|
|
__systime:
|
2013-05-09 11:56:54 +00:00
|
|
|
; Update time
|
|
|
|
lda #GET_TIME_CALL
|
|
|
|
ldx #GET_TIME_COUNT
|
|
|
|
jsr callmli
|
|
|
|
bcs err
|
|
|
|
|
|
|
|
lda DATELO+1
|
|
|
|
lsr
|
|
|
|
php ; Save month msb
|
|
|
|
cmp #70 ; Year < 70?
|
|
|
|
bcs :+ ; No, leave alone
|
|
|
|
adc #100 ; Move 19xx to 20xx
|
|
|
|
: sta TM + tm::tm_year
|
|
|
|
lda DATELO
|
|
|
|
tax ; Save day
|
|
|
|
plp ; Restore month msb
|
|
|
|
ror
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
beq err ; [1..12] allows for validity check
|
|
|
|
tay
|
|
|
|
dey ; Move [1..12] to [0..11]
|
|
|
|
sty TM + tm::tm_mon
|
|
|
|
txa ; Restore day
|
|
|
|
and #%00011111
|
|
|
|
sta TM + tm::tm_mday
|
|
|
|
|
|
|
|
lda TIMELO+1
|
|
|
|
sta TM + tm::tm_hour
|
|
|
|
lda TIMELO
|
|
|
|
sta TM + tm::tm_min
|
|
|
|
|
|
|
|
lda #<TM
|
|
|
|
ldx #>TM
|
|
|
|
jmp _mktime
|
|
|
|
|
|
|
|
err: lda #$FF
|
|
|
|
tax
|
|
|
|
sta sreg
|
|
|
|
sta sreg+1
|
|
|
|
rts ; Return -1
|
|
|
|
|
|
|
|
.bss
|
|
|
|
|
|
|
|
TM: .tag tm
|