Re: [cc65] two little bugs

From: Greg King <greg.king41verizon.net>
Date: 2009-08-24 18:00:13
From: "Ullrich von Bassewitz"; on Friday, Aug. 21, 2009; at 07:14 AM -0400
>
> Here is a short test-snippet.  It reads the time from the TOD clock
> directly, and via time().  With the write to tod_10 disabled, the clock
> does not run.  It looks like someone/something has stopped the clock
> by writing to tod_hour before, because the program works OK
> when the write is enabled.
> -------------------------------------------------------------------------
> #include <stdio.h>
> #include <time.h>
> #include <cbm.h>
>
> static unsigned char bcdtoa (unsigned char x)
> {
>     return (x & 0x0F) + (x >> 4) * 10;
> }
>
> int main(void)
> {
>     time_t T;
>     unsigned char hour, min, sec, sec10;
>
>     /* CIA1.tod_10 = 0; */
>     while (1) {
>         hour = CIA1.tod_hour;
>         min  = CIA1.tod_min;
>         sec  = CIA1.tod_sec;
>         sec10 = CIA1.tod_10;
>         printf ("%02d:%02d:%02d\n",
>                   bcdtoa (hour), bcdtoa (min), bcdtoa (sec));
>
>         T = time (0);
>         printf ("%s\n", asctime (localtime (&T)));
>     }
> }

(As Spiro hinted ...)
A hardware-reset stops all of the timers in the CIA chip.  After that, the
Time-Of-Day clock will not run until you have written a time into it.  The
firmware does not write into those registers.  [Even though BASIC's rnd(0)
reads some of  those registers in CIA1 -- see the entry for location 57495
in the "MAPPING THE Commodore 64" book.]

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Aug 24 19:13:25 2009

This archive was generated by hypermail 2.1.8 : 2009-08-24 19:13:27 CEST