Blob Blame History Raw
From 3b128ba59f6bfc943bfdc9a971daa00f612f1193 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt <ol.sc@web.de>
Date: Tue, 10 Sep 2019 09:49:06 +0200
Subject: [PATCH 037/170] Use MACHID to check for realtime clock.

There's no need to do guesswork to know if a realtime clock is present/active.
---
 doc/apple2.sgml         | 18 ++++++++----------
 doc/apple2enh.sgml      | 18 ++++++++----------
 libsrc/apple2/getres.s  |  8 ++++----
 libsrc/apple2/settime.s |  8 ++++----
 4 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/doc/apple2.sgml b/doc/apple2.sgml
index 648ee56d..91c02c7a 100644
--- a/doc/apple2.sgml
+++ b/doc/apple2.sgml
@@ -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
 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/
-then a realtime clock is supposed to be active and <tt/clock_settime()/ fails with
-<tt/ERANGE/. Otherwise <tt/clock_settime()/ sets the date - and completely ignores
-the time provided as parameter.
-
-<tt/clock_getres()/ too checks if the current time equals 0:00. If it does <bf/NOT/
-then a realtime clock is supposed to be active and <tt/clock_getres()/ returns a time
-resolution of one minute. Otherwise <tt/clock_getres()/ presumes that the only one
-who sets the RAM location is <tt/clock_settime()/ and therefore returns a time
-resolution of one day.
+So <tt/clock_settime()/ checks if a realtime clock is active. If it is then
+<tt/clock_settime()/ fails with <tt/ERANGE/. Otherwise <tt/clock_settime()/
+sets the date - and completely ignores the time provided as parameter.
+
+<tt/clock_getres()/ too checks if a realtime clock is active. If it is then
+<tt/clock_getres()/ returns a time resolution of one minute. Otherwise
+<tt/clock_getres()/ presumes that the only one who sets the RAM location is
+<tt/clock_settime()/ and therefore returns a time resolution of one day.
 
 
 
diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml
index d25aa7ef..fa70da4e 100644
--- a/doc/apple2enh.sgml
+++ b/doc/apple2enh.sgml
@@ -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
 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/
-then a realtime clock is supposed to be active and <tt/clock_settime()/ fails with
-<tt/ERANGE/. Otherwise <tt/clock_settime()/ sets the date - and completely ignores
-the time provided as parameter.
-
-<tt/clock_getres()/ too checks if the current time equals 0:00. If it does <bf/NOT/
-then a realtime clock is supposed to be active and <tt/clock_getres()/ returns a time
-resolution of one minute. Otherwise <tt/clock_getres()/ presumes that the only one
-who sets the RAM location is <tt/clock_settime()/ and therefore returns a time
-resolution of one day.
+So <tt/clock_settime()/ checks if a realtime clock is active. If it is then
+<tt/clock_settime()/ fails with <tt/ERANGE/. Otherwise <tt/clock_settime()/
+sets the date - and completely ignores the time provided as parameter.
+
+<tt/clock_getres()/ too checks if a realtime clock is active. If it is then
+<tt/clock_getres()/ returns a time resolution of one minute. Otherwise
+<tt/clock_getres()/ presumes that the only one who sets the RAM location is
+<tt/clock_settime()/ and therefore returns a time resolution of one day.
 
 
 
diff --git a/libsrc/apple2/getres.s b/libsrc/apple2/getres.s
index 6441671c..4364bc96 100644
--- a/libsrc/apple2/getres.s
+++ b/libsrc/apple2/getres.s
@@ -27,10 +27,10 @@ _clock_getres:
         ldx     #<day_res
         ldy     #>day_res
 
-        ; Check for existing minutes or hours
-        lda     TIMELO
-        ora     TIMELO+1
-        beq     :+
+        ; Check for realtme clock
+        lda     MACHID
+        lsr     a
+        bcc     :+
 
         ; Switch to minute resolution
         ldx     #<min_res
diff --git a/libsrc/apple2/settime.s b/libsrc/apple2/settime.s
index 07032fdd..f722f6f4 100644
--- a/libsrc/apple2/settime.s
+++ b/libsrc/apple2/settime.s
@@ -21,11 +21,11 @@ _clock_settime:
         ldy     __dos_type
         beq     enosys
 
-        ; Check for existing minutes or hours
+        ; Check for realtme clock
         tay                     ; Save A
-        lda     TIMELO
-        ora     TIMELO+1
-        bne     erange
+        lda     MACHID
+        lsr     a
+        bcs     erange
         tya                     ; Restore A
 
         ; Get tm
-- 
2.26.0