1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-27 15:29:46 +00:00

Use MACHID to check for realtime clock.

There's no need to do guesswork to know if a realtime clock is present/active.
This commit is contained in:
Oliver Schmidt 2019-09-10 09:49:06 +02:00
parent c53b167307
commit 3b128ba59f
4 changed files with 22 additions and 26 deletions

View File

@ -500,16 +500,14 @@ From that perspective it makes most sense to not set both the date and the time
rather only set the date and have the time just stay zero. Then files show up in a rather only set the date and have the time just stay zero. Then files show up in a
directory as <tt/DD-MON-YY 0:00/. directory as <tt/DD-MON-YY 0:00/.
So <tt/clock_settime()/ checks if the current time equals 0:00. If it does <bf/NOT/ So <tt/clock_settime()/ checks if a realtime clock is active. If it is then
then a realtime clock is supposed to be active and <tt/clock_settime()/ fails with <tt/clock_settime()/ fails with <tt/ERANGE/. Otherwise <tt/clock_settime()/
<tt/ERANGE/. Otherwise <tt/clock_settime()/ sets the date - and completely ignores sets the date - and completely ignores the time provided as parameter.
the time provided as parameter.
<tt/clock_getres()/ too checks if the current time equals 0:00. If it does <bf/NOT/ <tt/clock_getres()/ too checks if a realtime clock is active. If it is then
then a realtime clock is supposed to be active and <tt/clock_getres()/ returns a time <tt/clock_getres()/ returns a time resolution of one minute. Otherwise
resolution of one minute. Otherwise <tt/clock_getres()/ presumes that the only one <tt/clock_getres()/ presumes that the only one who sets the RAM location is
who sets the RAM location is <tt/clock_settime()/ and therefore returns a time <tt/clock_settime()/ and therefore returns a time resolution of one day.
resolution of one day.

View File

@ -501,16 +501,14 @@ From that perspective it makes most sense to not set both the date and the time
rather only set the date and have the time just stay zero. Then files show up in a rather only set the date and have the time just stay zero. Then files show up in a
directory as <tt/DD-MON-YY 0:00/. directory as <tt/DD-MON-YY 0:00/.
So <tt/clock_settime()/ checks if the current time equals 0:00. If it does <bf/NOT/ So <tt/clock_settime()/ checks if a realtime clock is active. If it is then
then a realtime clock is supposed to be active and <tt/clock_settime()/ fails with <tt/clock_settime()/ fails with <tt/ERANGE/. Otherwise <tt/clock_settime()/
<tt/ERANGE/. Otherwise <tt/clock_settime()/ sets the date - and completely ignores sets the date - and completely ignores the time provided as parameter.
the time provided as parameter.
<tt/clock_getres()/ too checks if the current time equals 0:00. If it does <bf/NOT/ <tt/clock_getres()/ too checks if a realtime clock is active. If it is then
then a realtime clock is supposed to be active and <tt/clock_getres()/ returns a time <tt/clock_getres()/ returns a time resolution of one minute. Otherwise
resolution of one minute. Otherwise <tt/clock_getres()/ presumes that the only one <tt/clock_getres()/ presumes that the only one who sets the RAM location is
who sets the RAM location is <tt/clock_settime()/ and therefore returns a time <tt/clock_settime()/ and therefore returns a time resolution of one day.
resolution of one day.

View File

@ -27,10 +27,10 @@ _clock_getres:
ldx #<day_res ldx #<day_res
ldy #>day_res ldy #>day_res
; Check for existing minutes or hours ; Check for realtme clock
lda TIMELO lda MACHID
ora TIMELO+1 lsr a
beq :+ bcc :+
; Switch to minute resolution ; Switch to minute resolution
ldx #<min_res ldx #<min_res

View File

@ -21,11 +21,11 @@ _clock_settime:
ldy __dos_type ldy __dos_type
beq enosys beq enosys
; Check for existing minutes or hours ; Check for realtme clock
tay ; Save A tay ; Save A
lda TIMELO lda MACHID
ora TIMELO+1 lsr a
bne erange bcs erange
tya ; Restore A tya ; Restore A
; Get tm ; Get tm