A2osX/SYS/KERNEL.S.TIME.txt
2016-08-31 17:38:48 +02:00

277 lines
5.3 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* https://www.cise.ufl.edu/~cop4600/cgi-bin/lxr/http/source.cgi/lib/ansi/gmtime.c
*--------------------------------------
SECSDAY .EQ 86400 60*60*24
CENTURY0 .EQ 19
YEAR0 .EQ 70
DAY0 .EQ 4 day 0 was a thursday
*--------------------------------------
* S.CTime2Time
* In :
* PULLW = Src CTIME DWORD
* PULLW = Dst PTR To S.TIME
*--------------------------------------
S.CTime2Time >PULLW ZPQuickPtr1
>PULLW ZPQuickPtr2
ldy #3
.1 lda (ZPQuickPtr1),y
sta S.CTime.DWORD,y
dey
bpl .1
stz S.CTime.DivDay
stz S.CTime.DivDay+1
.2 lda S.CTime.DWORD
sta S.CTime.ModDay
sec
sbc #SECSDAY
pha
lda S.CTime.DWORD+1
sta S.CTime.ModDay+1
sbc /SECSDAY
pha
lda S.CTime.DWORD+2
sta S.CTime.ModDay+2
sbc #0
pha
lda S.CTime.DWORD+3
sbc #0
bcc .3 end of DIV/MOD ?
sta S.CTime.DWORD+3
pla
sta S.CTime.DWORD+2
pla
sta S.CTime.DWORD+1
pla
sta S.CTime.DWORD
inc S.CTime.DivDay
bne .2
inc S.CTime.DivDay+1
bne .2
.3 pla
pla
pla
stz S.CTime.Div60
stz S.CTime.Div60+1
.4 lda S.CTime.ModDay
sta S.CTime.Mod
sec
sbc #60
pha
lda S.CTime.ModDay+1
sbc #0
pha
lda S.CTime.ModDay+2
sbc #0
bcc .5
sta S.CTime.ModDay+2
pla
sta S.CTime.ModDay+1
pla
sta S.CTime.ModDay
inc S.CTime.Div60
bne .4
inc S.CTime.Div60+1
bne .4
.5 pla
pla
lda S.CTime.Mod
ldy #S.TIME.SECOND
sta (ZPQuickPtr2),y
stz S.CTime.Div3600
.6 lda S.CTime.Div60
sta S.CTime.Mod
sec
sbc #60
pha
lda S.CTime.Div60+1
sbc #0
pha
bcc .7
sta S.CTime.Div60+1
pla
sta S.CTime.Div60
inc S.CTime.Div3600
bne .6
.7 pla
lda S.CTime.Mod
dey ldy #S.TIME.MINUTE
sta (ZPQuickPtr2),y
lda S.CTime.Div3600
dey ldy #S.TIME.HOUR
sta (ZPQuickPtr2),y
lda S.CTime.DivDay WDAY computation : (DivDay + DAY0) mod 7
clc
adc #DAY0
pha
lda S.CTime.DivDay+1
adc /DAY0
eor #$ff
tax
pla
.8 sta S.CTime.Mod
sec
sbc #7
bcs .8
inx
bne .8
lda S.CTime.Mod
ldy #S.TIME.WDAY
sta (ZPQuickPtr2),y
lda #CENTURY0
sta S.CTime.Century
lda #YEAR0
sta S.CTime.Year
* si l'année est divisible par 4 et non divisible par 100, ou
* si l'année est divisible par 400.
S.CTime.DWORD .BS 4
S.CTime.DivDay .BS 2
S.CTime.ModDay .BS 3
S.CTime.Div60 .BS 2
S.CTime.Div3600 .BS 1
S.CTime.Mod .BS 1
S.CTime.Century .BS 1
S.CTime.Year .BS 1
*--------------------------------------
* S.TimeYA get System Time
* In :
* Y,A = PTR to S.TIME
* Out :
* S.TIME filled with ProDOS MLI date/time
*--------------------------------------
S.TimeYA >STYA ZPQuickPtr2
>MLICALL MLIGETTIME
>LDYAI DATELO
>STYA ZPQuickPtr1
bra S.PTime2Time.1
*--------------------------------------
* In :
* PULLW = Src PDATE/TIME (DWORD)
* PULLW = Dst PTR To S.TIME
*--------------------------------------
S.PTime2Time >PULLW ZPQuickPtr1
>PULLW ZPQuickPtr2
S.PTime2Time.1 lda (ZPQuickPtr1) Get Year
lsr C is high bit of month
ldy #S.TIME.YEAR
sta (ZPQuickPtr2),y set year
pla save it for century adjust
ldy #1
lda (ZPQuickPtr1),y Get Month/day
pha save Day
ror
lsr
lsr
lsr
lsr
ldy #S.TIME.MONTH
sta (ZPQuickPtr2),y set month
pla get back day
and #$1F
iny
sta (ZPQuickPtr2),y set day
pla get back year
cmp #70 if before 70's CC
lda #19
adc #0 set date before 1970 -> 20xx
sta (ZPQuickPtr2) set Century
ldy #3
lda (ZPQuickPtr1),y Get Min
tax
dey
lda (ZPQuickPtr1),y Get Hour
ldy #S.TIME.HOUR
sta (ZPQuickPtr2),y set hour
iny
txa
sta (ZPQuickPtr2),y set min
iny
lda #0
sta (ZPQuickPtr2),y set seconds (ProDOS does not provide it)
S.ComputeWDAY
clc
rts
*--------------------------------------
* S.StrFTime
* In :
* PULLW = Src PTR To S.TIME
* PULLW = Src PTR To Format String
* %a Abbreviated weekday name : Thu
* %A Full weekday name : Thursday
* %b Abbreviated month name : Aug
* %B Full month name : August
* %d Day of the month, zero-padded (01-31)
* %H Hour in 24h format (00-23) 14
* %I Hour in 12h format (01-12) 02
* %m Month as a decimal number (01-12) 08
* %M Minute (00-59) 55
* %p AM or PM designation PM
* %S Second (00-61) 02
* %w Weekday as a decimal number with Sunday as 0 (0-6)
* %y Year, last two digits (00-99)
* %Y Year four digits 2001
* PULLW = Dst PSTR Buffer
*--------------------------------------
S.StrFTime
clc
rts
*--------------------------------------
*--------------------------------------
S.IsLeapYearYA
clc
rts
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.TIME
LOAD SYS/KERNEL.S
ASM