[comp.sys.atari.8bit] Turbo Basic and Time

hans@umd5 (Hans Breitenlohner) (01/16/87)

The Turbo Basic interpreter which was posted recently assumes 50Hz vertical
scan rate for its timing functions, and therefore gives erroneous results.
(On machines using 60Hz, of course).
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.

hans@umd5 (Hans Breitenlohner) (01/16/87)

Upon staring at the code some more, I have changed my guess
about the TIME command.  My best guess at this point is that it
looks something like

          TIME "HHMMSS"

and not what I stated before.  Sorry about the confusion.