[comp.sys.amiga.tech] Idea

SLMYQ@USU.BITNET (04/23/88)

This most likely wouldn't work, but here goes...

The T.O.D. (Time Of Day) clocks in the 8520s on the Amiga aren't used, right?
Would it be possible to hook up a battery and a little switching circuitry to
one of the 8520s and use it's TOD clock as a battery backed clock?  Or would
a RESET signal clear it?  Would it be at all practical?

                                Bryan Ford (SLMYQ@USU.BITNET)

grr@cbmvax.UUCP (George Robbins) (04/24/88)

In article <8804231647.AA09390@jade.berkeley.edu> SLMYQ@USU.BITNET writes:
> This most likely wouldn't work, but here goes...
> 
> The T.O.D. (Time Of Day) clocks in the 8520s on the Amiga aren't used, right?
> Would it be possible to hook up a battery and a little switching circuitry to
> one of the 8520s and use it's TOD clock as a battery backed clock?  Or would
> a RESET signal clear it?  Would it be at all practical?

Uh...no....

The TOD clocks *are* used, although they are used more a binary interval
counters than TOD clocks.  The 8520's are NMOS, not low-power CMOS, so
ignoreing other issues, it wouldn't be all that easy to provide battery
back up.

-- 
George Robbins - now working for,	uucp: {uunet|ihnp4|rutgers}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@uunet.uu.net
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)

avery@puff.cs.wisc.edu (Aaron Avery) (04/25/88)

In article <3687@cbmvax.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>The TOD clocks *are* used, although they are used more a binary interval
>counters than TOD clocks.  The 8520's are NMOS, not low-power CMOS, so

I thought that one of the TOD clocks was hooked up to the 50 or 60Hz line
frequency and was used as the system clock, and that the other one was set
up to be used for the MICROHZ timer. I'm pretty sure I'm right about the
system clock, since it runs just fine if interrupts are disabled. If I'm 
wrong, where is the system clock handled?

-- 
Aaron Avery (avery@puff.cs.wisc.edu)
	    ({seismo,caip,allegra,harvard,rutgers,ihnp4}!uwvax!puff!avery)

ewhac@well.UUCP (Leo L. Schwab) (04/26/88)

In article <8804231647.AA09390@jade.berkeley.edu> SLMYQ@USU.BITNET writes:
>The T.O.D. (Time Of Day) clocks in the 8520s on the Amiga aren't used, right?
>Would it be possible to hook up a battery and a little switching circuitry to
>one of the 8520s and use it's TOD clock as a battery backed clock?  Or would
>a RESET signal clear it?  Would it be at all practical?
>
	It'd be practical and wonderful, but it won't work.

	I had this same idea about a year ago, and wrote a quickie program to
discover if it would work.   As it turns out, hitting Ctrl-A-A asserts
RESET, and RESET resets the 8520's Time-Of-Day clock.  Personally, I think
it was a mistake on the part of the designer to have done that.

	Sigh....

P.S:	This was how I found out that there's no CloseResource() call in the
system.  So what am I supposed to do with something that I've
OpenResource()d?
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape  ihnp4!pacbell -\
 \_ -_		Recumbent Bikes:	      dual ---> !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

avery@puff.cs.wisc.edu (Aaron Avery) (04/27/88)

In article <5809@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
>	I had this same idea about a year ago, and wrote a quickie program to
>discover if it would work.   As it turns out, hitting Ctrl-A-A asserts
>RESET, and RESET resets the 8520's Time-Of-Day clock.  Personally, I think
>it was a mistake on the part of the designer to have done that.
Me, too.

>P.S:	This was how I found out that there's no CloseResource() call in the
>system.  So what am I supposed to do with something that I've
>OpenResource()d?

This has been gone over before. Apparently, all that happens when you call
OpenResource() is that you get back a pointer useful for allocating those
resources. A big difference between a Resource and a Library is that the
Resources don't keep an OpenCount. Because of this, it doesn't care when you're
not using it any more, so you just de-allocate all associated resources, don't
call any CloseResource(), since it doesn't care, and ignore the pointer you got
from OpenResource()!

-- 
Aaron Avery (avery@puff.cs.wisc.edu)
	    ({seismo,caip,allegra,harvard,rutgers,ihnp4}!uwvax!puff!avery)

doug@eris (Doug Merritt) (04/27/88)

>In article <8804231647.AA09390@jade.berkeley.edu> SLMYQ@USU.BITNET writes:
>>The T.O.D. (Time Of Day) clocks in the 8520s on the Amiga aren't used, right?

In article <5809@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
>	I had this same idea about a year ago, and wrote a quickie program to
>discover if it would work.   As it turns out, hitting Ctrl-A-A asserts
>RESET, and RESET resets the 8520's Time-Of-Day clock.  Personally, I think

How about if you add a keyboard reset handler that grabs the TOD and
saves it somewhere...say in an unused part of the boot block (forget it!)
or touches a df0: file (better) or a vd0: file (better yet)?

'Course, it makes the 8520 part of the idea useless, but I've been
meaning to mention for a long time now that I wrote a sort of cron
job that updates a vd0: file with the current time every thirty seconds,
and my startup-sequence sets the time/date from that. Makes a very,
very nice substitute for a true clock...the time is always *approximately*
correct, whereas it's *always* wrong otherwise. Sure helps with 'make'!

Anyone interested? I never posted it because I felt like it was
sort of kludgy (both the concept, and also that I'm not sure if it
works correctly if you reboot right around midnight on Dec 31, but
didn't care enough to check...It works, I'm busy). But upon consideration,
anyone without a real time clock should use *something* like this. Better
than nothing!

Perhaps better yet would be to use the "cron" that's been floating around;
haven't tried it yet myself.

			*	*	*

>P.S:	This was how I found out that there's no CloseResource() call in the
>system.  So what am I supposed to do with something that I've OpenResource()d?

Hmmm...Wasn't this part of the (ancient) general discussion about "How come
there's a call for OpenXXXXX() but no CloseXXXXX() ???" Answer being, no
need, other than esthetics. CATS will probably answer this momentarily anyway.

			*	*	*

Speaking of kludges regarding the date, sorry for the miniflame, but:
both Peck (the book's author) and Rokicki (who wrote this particular piece
of code) should be *ashamed* to have released a piece of code like
ShowDate() on page 42 of the Programmer's Guide to the Amiga. I thought
it was a publisher's misprint at first, it was so full of magic meaningless
constants.

The algorithm is *totally* opaque, despite the fact that I understand
the USUAL approaches to date algorithms, including the the one for
calculating the day of the week that any day in history falls on, in your
head. So I tried to prove it didn't work. Well, I was wrong, it does work
(as far as I could tell). I even started to get an idea of why before I
gave it up as a waste of time.

Considering the usual fine quality of work I've seen both of them do,
this kind of dreck (in a "How To" book at that!) is both surprising
and disappointing. Some #defines and some comments, at *minimum*,
are mandatory for something as obscure as this. See, for instance,
The Elements of Programming Style (Kernighan & Plauger).  I hope it'll
be fixed (or at least deleted) in the second edition.

If it's too much trouble to hack something minor like that, I'd be happy
to donate code to a perfectly clear (although possibly less efficient, as
if that matters) version of ShowDate(). I wrote it for my cron-date
program, since I didn't trust the one in the book. (Hence my flame;
it says a lot if it's more reliable to cook something up from scratch than
to copy a few lines from a book.)

BTW I loved the rest of the book, and I very much appreciate all of
the work that both Tom and Bob have done for the Amiga world. (Don't
want you thinking I'm ungrateful!)

	Doug Merritt		doug@mica.berkeley.edu (ucbvax!mica!doug)
			or	ucbvax!unisoft!certes!doug
			or	sun.com!cup.portal.com!doug-merritt

rokicki@polya.STANFORD.EDU (Tomas G. Rokicki) (04/28/88)

> Speaking of kludges regarding the date, sorry for the miniflame, but:
> both Peck (the book's author) and Rokicki (who wrote this particular piece
> of code) should be *ashamed* to have released a piece of code like
> ShowDate() on page 42 of the Programmer's Guide to the Amiga. I thought
> it was a publisher's misprint at first, it was so full of magic meaningless
> constants.

Naw, ShowDate() is actually pretty neat!  (Of course, I wrote it.)
It was *intended* (by me at least) to be a magic piece of code;
the puzzle was to figure out how it worked.  Ditto with my blitter
LIFE.  Anyone could and can write the straight-forward approach; I
wanted an approach which would use the mininum number of bytes and
execute in the quickest time.  Not for any real purpose (except to
save a couple of bytes) but simply as a puzzle.

> The algorithm is *totally* opaque, despite the fact that I understand
> the USUAL approaches to date algorithms, including the the one for
> calculating the day of the week that any day in history falls on, in your
> head. So I tried to prove it didn't work. Well, I was wrong, it does work
> (as far as I could tell). I even started to get an idea of why before I
> gave it up as a waste of time.

The algorithm in ShowDate() is very close to the one for calculating the
day of the week that any day in history falls on.  I'm sorry you had
such difficulties figuring it out; maybe I'll explain it to you at
DevCon.

Programming wouldn't be half as fun if I couldn't come up with gems like
that.

doug@eris (Doug Merritt) (04/28/88)

I wrote:
>> Speaking of kludges regarding the date, sorry for the miniflame, [ ...]
>> should be *ashamed* to have released a piece of code like ShowDate()

In article <2699@polya.STANFORD.EDU> rokicki@polya.UUCP (Tomas G. Rokicki) writes:
>It was *intended* (by me at least) to be a magic piece of code;
>the puzzle was to figure out how it worked.  Ditto with my blitter LIFE.

Hmmm. Well, at the very least the next edition of the book should have
a little note saying that it's a puzzle.

But I guess that *does* shed some light on why it was so opaque. Since
it was intended to be, congratulations! Good job! :-)

>Programming wouldn't be half as fun if I couldn't come up with gems like
>that.

Yep. Might want to attach ":-)" to code like that, though!

	Doug Merritt		doug@mica.berkeley.edu (ucbvax!mica!doug)
			or	ucbvax!unisoft!certes!doug
			or	sun.com!cup.portal.com!doug-merritt

cjp@antique.UUCP (Charles Poirier) (04/28/88)

In article <2699@polya.STANFORD.EDU> rokicki@polya.UUCP (Tomas G. Rokicki) writes:

>Programming wouldn't be half as fun if I couldn't come up with gems like that.

But, "gems" should be transparent.  Opaque diamonds are just abrasive.  :-), :-)

-- 
	Charles Poirier   (decvax,ihnp4,attmail)!vax135!cjp

   "Docking complete...       Docking complete...       Docking complete..."