[comp.sys.atari.8bit] Turbo-Basic clock fixes

hans@umd5.umd.edu (Hans Breitenlohner) (08/08/89)

I was on vacation when the recent discussion about that topic took place,
so please forgive the delayed response.

Following is a copy of an article which I posted a long time ago, when
Turbo Basic first came out.

Two notes:  My explanation of time setting is incorrect, the correct way is
   TIME$="hhmmss", as was previously discussed here.
   The changes are given in hex, for those of you who have the appropriate
   tools, and also based on the binhex file which was used for the original
   distribution.  If someone would like to use this, but doesn't have the
   appropriate tools, let me know, and we'll see what we can work out.
----------

To: comp.sys.atari.8bit
From: hans
Date: Thu, 15 Jan 87 16:11:00 EST
Subject: 60 Hz mods for Turbo Basic

The Turbo Basic interpreter which was posted recently assumes 50Hz vertical
scan rate for its timing functions, and therefore gives erroneous results.
Following are changes which should rectify that situation.
Warning:  I have arrived at these by looking at disassembled code, and have
not had a chance to test them.

Apparently there is a statement of the form
          TIME HOURS,MINUTES,SECONDS
to set the time.  It multiplies seconds by 50 to get the jiffy count.  It is
simple to change that to a multiply by 60.  To do the exact conversion would
require somewhat more work, and I am not able to do that at this point.

            Address   old   new
             FBA6     F2    16
             FBA7     FB    FC  . change JSR $FBF2 to JSR $FC16

If you want to change the BINHEX file, change line 946 (counting .start. as
line 1) from
          FC20C4FBC93CB01C20DEFB20F2FB20ECFBA5
                                  ____
to
          FC20C4FBC93CB01C20DEFB2016FC20ECFBA5
Of course the checksum will be incorrect after you do this.

The TIME function returns the current jiffy count.
The TIME$ function has a constant of jiffies per day built in, at address
FB6E to FB73.  The built in value is $430432000000, or 4320000
(which is 50*60*60*24).  This could be changed to one of the following:
  a.  $430518400000  for a scan rate of 60 Hz.
  b.  $430517882052  for a scan rate of 59.94005233 Hz.
  c.  $430517737658  for a scan rate of 59.92334 Hz.
The first case has the advantage of being compatible with the TIME command
above, but it will make the clock loose about 86 seconds per day.
The second case uses the standard scan rate (see recent rec.video and
comp.graphics posting).
The third value is taken from "Mapping The Atari", Revised edition, page 182.
I do not know what its justification is.  The difference between b and c
should be about 24 seconds per day, the difference between a and c about
110 seconds per day.

To make the change in the BINHEX file, change line 943
from
          05E6F2604102560000004304320000002000
                              ------------
and fill in your favorite value.

I have no idea how accurate the crystals in Ataris are.  And then there is
the problem of loosing scan counts when VBIs are disabled ...

Again:  I hope this is useful, but I have NOT had an opportunity
to test it.

----------