mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-05-28 15:41:29 +00:00
Switch time "factor" code over to 0-based month indexing.
This matches both struct tm and ReadTimeHex, so it avoids needing to increment the values. Also, simplify the time() code a little bit.
This commit is contained in:
parent
17faeda1de
commit
b302a85fd6
33
time.asm
33
time.asm
|
@ -33,7 +33,7 @@ TimeCommon privdata
|
||||||
; For conversion to/from seconds since 13 Nov 1969
|
; For conversion to/from seconds since 13 Nov 1969
|
||||||
;
|
;
|
||||||
year ds 4 year 0..99
|
year ds 4 year 0..99
|
||||||
month ds 4 month 1..12
|
month ds 4 month 0..11
|
||||||
day ds 4 day 1..31
|
day ds 4 day 1..31
|
||||||
hour ds 4 hour 0..23
|
hour ds 4 hour 0..23
|
||||||
minute ds 4 minute 0..59
|
minute ds 4 minute 0..59
|
||||||
|
@ -269,19 +269,18 @@ lb0d stz second+2
|
||||||
;
|
;
|
||||||
; compute the # of days since 13 Nov 1969
|
; compute the # of days since 13 Nov 1969
|
||||||
;
|
;
|
||||||
lb0e mul4 year,#365,count count := 365*year + day + 31*(month-1)
|
lb0e mul4 year,#365,count count := 365*year + day + 31*month
|
||||||
add4 count,day
|
add4 count,day
|
||||||
mul4 month,#31,t1
|
mul4 month,#31,t1
|
||||||
add4 count,t1
|
add4 count,t1
|
||||||
sub4 count,#31
|
|
||||||
add4 year,#32800,t2 t2 := year + 32800 (so it is positive)
|
add4 year,#32800,t2 t2 := year + 32800 (so it is positive)
|
||||||
lda month if January or February then
|
lda month if January or February then
|
||||||
cmp #3
|
cmp #2
|
||||||
bge lb1
|
bge lb1
|
||||||
dec4 t2 year := year-1
|
dec4 t2 year := year-1
|
||||||
bra lb2 else
|
bra lb2 else
|
||||||
lb1 mul4 month,#4,t1 count := count - (month*4+23) div 10
|
lb1 mul4 month,#4,t1 count := count - (month*4+27) div 10
|
||||||
add4 t1,#23
|
add4 t1,#27
|
||||||
div4 t1,#10
|
div4 t1,#10
|
||||||
sub4 count,t1
|
sub4 count,t1
|
||||||
lb2 div4 t2,#4,t1 count := count + (year+32800) div 4
|
lb2 div4 t2,#4,t1 count := count + (year+32800) div 4
|
||||||
|
@ -504,8 +503,8 @@ lb1 plb
|
||||||
lda #69 find the year
|
lda #69 find the year
|
||||||
sta year
|
sta year
|
||||||
lda #1
|
lda #1
|
||||||
sta month
|
|
||||||
sta day
|
sta day
|
||||||
|
stz month
|
||||||
stz hour
|
stz hour
|
||||||
stz minute
|
stz minute
|
||||||
stz second
|
stz second
|
||||||
|
@ -531,7 +530,6 @@ lb2a ble lb2
|
||||||
lda year set the year
|
lda year set the year
|
||||||
sta tm_year
|
sta tm_year
|
||||||
lda month set the month
|
lda month set the month
|
||||||
dec A
|
|
||||||
sta tm_mon
|
sta tm_mon
|
||||||
sub4 t,count find the number of seconds
|
sub4 t,count find the number of seconds
|
||||||
move4 t,t1
|
move4 t,t1
|
||||||
|
@ -605,7 +603,6 @@ temp2 equ 5 temp variable
|
||||||
dey
|
dey
|
||||||
dey
|
dey
|
||||||
lda [tmptr],Y
|
lda [tmptr],Y
|
||||||
inc A
|
|
||||||
sta month
|
sta month
|
||||||
dey
|
dey
|
||||||
dey
|
dey
|
||||||
|
@ -631,8 +628,8 @@ temp2 equ 5 temp variable
|
||||||
brl lb1
|
brl lb1
|
||||||
lb0 move4 count,temp save the value for later return
|
lb0 move4 count,temp save the value for later return
|
||||||
lda #1 compute the days since the start of the
|
lda #1 compute the days since the start of the
|
||||||
sta month year
|
sta day year
|
||||||
sta day
|
stz month
|
||||||
jsr factor
|
jsr factor
|
||||||
sub4 temp,count,count
|
sub4 temp,count,count
|
||||||
div4 count,#60*60*24
|
div4 count,#60*60*24
|
||||||
|
@ -681,20 +678,16 @@ time start
|
||||||
and #$00FF
|
and #$00FF
|
||||||
inc A
|
inc A
|
||||||
sta day
|
sta day
|
||||||
lda 5,S set the month
|
lda 6,S set the month
|
||||||
and #$FF00
|
and #$00FF
|
||||||
xba
|
|
||||||
inc A
|
|
||||||
sta month
|
sta month
|
||||||
lda 3,S set the year
|
lda 4,S set the year
|
||||||
and #$FF00
|
and #$00FF
|
||||||
xba
|
|
||||||
sta year
|
sta year
|
||||||
lda 3,S set the hour
|
lda 3,S set the hour
|
||||||
and #$00FF
|
and #$00FF
|
||||||
sta hour
|
sta hour
|
||||||
lda 1,S set the minute
|
lda 2,S set the minute
|
||||||
xba
|
|
||||||
and #$00FF
|
and #$00FF
|
||||||
sta minute
|
sta minute
|
||||||
pla set the second
|
pla set the second
|
||||||
|
|
Loading…
Reference in New Issue
Block a user