[comp.sys.apple] softclocks

ericmcg@pro-generic.cts.com (Eric Mcgillicuddy) (11/12/89)

Does anyone know of a software clock for all Apple //'s? I think the VBL
interupt can be used, but I have little experience with this kind of thing. 
Are there any PD routines available?

McAllister@DOCKMASTER.NCSC.MIL (11/19/89)

someone wrote to info-apple:

>Does anyone know of a software clock for all Apple //'s? I think the VBL
>interupt can be used, but I have little experience with this kind of thing.
>Are there any PD routines available?

    Here is a softclock routine that I wrote for my Apple IIc.  It uses the
vertical blanking interrupt (approx 60 per sec) to update the hours, minutes,
and seconds as you can see in the 65C02 assembly listing.  I was discouraged
from exploring any general use of this method of implementing a software clock
after observing that it ran about 3-4 seconds slow per hour, and the processing
of interrupts 60 times per second was otherwise too much overhead.  What
follows is a BASIC program which views the clock, and a fairly standard machine
language routine for setting up and using interrupts through the use of the
existing firmware, including the mouse.  Be careful to repair the interrupt
structure after leaving this routine.

------------------------------------------------------------------------------
100 HOME:D$=CHR$(4)
110 PRINT D$;"BLOAD INTST"
120 GOSUB 300:CALL 768
130 POKE 1403,0:VTAB1
140:HH=PEEK(787):MM=PEEK(788):SS=PEEK(789)
150:HH$=STR$(HH):IF HH<10 THEN HH$="0"+HH$
160:MM$=STR$(MM):IF MM<10 THEN MM$="0"+MM$
170:SS$=STR$(SS):IF SS<10 THEN SS$="0"+SS$
200 PRINT HH$":";MM$":";SS$;
210 GOTO 130
300 PRINT "Set Clock":INPUT "   Hour: ";HH$
310 INPUT "Minutes: ";MM$:HOME
320:HH=VAL(HH$):POKE 787,HH
330:MM=VAL(MM$):POKE 788,MM
340 POKE 789,0
350 RETURN

------------------------------------------------------------------------------
INTST

0300:        0300    1           ORG   $0300
0300:        0300    2           X6502
0300:        03FE    3 VECTL     EQU   $03FE
0300:        03FF    4 VECTH     EQU   $03FF
0300:        0008    5 VBLMOD    EQU   $08
0300:        C43D    6 SETMOU    EQU   $C43D
0300:                7 *
0300:A9 17           8 STINT     LDA   #>INT
0302:8D FE 03        9           STA   VECTL
0305:A9 03          10           LDA   #<INT
0307:8D FF 03       11           STA   VECTH
030A:A9 08          12           LDA   #VBLMOD
030C:20 3D C4       13           JSR   SETMOU
030F:B0 01   0312   14           BCS   ERROR
0311:60             15           RTS
0312:00             16 ERROR     BRK
0313:               17 *
0313:0C             18 HOUR      DFB   12
0314:00             19 MINS      DFB   00
0315:00             20 SECS      DFB   00
0316:00             21 COUNT     DFB   00
0317:               22 *
0317:78             23 INT       SEI
0318:EE 16 03       24           INC   COUNT
031B:AD 16 03       25           LDA   COUNT
031E:C9 3C          26           CMP   #60
0320:D0 2A   034C   27           BNE   XINT
0322:9C 16 03       28           STZ   COUNT
0325:EE 15 03       29           INC   SECS
0328:AD 15 03       30           LDA   SECS
032B:C9 3C          31           CMP   #60
032D:D0 1D   034C   32           BNE   XINT
032F:9C 15 03       33           STZ   SECS
0332:EE 14 03       34           INC   MINS
0335:AD 14 03       35           LDA   MINS
0338:C9 3C          36           CMP   #60
033A:D0 10   034C   37           BNE   XINT
033C:9C 14 03       38           STZ   MINS
033F:EE 13 03       39           INC   HOUR
0342:AD 13 03       40           LDA   HOUR
0345:C9 18          41           CMP   #24
0347:D0 03   034C   42           BNE   XINT
0349:9C 13 03       43           STZ   HOUR
034C:58             44 XINT      CLI
034D:40             45           RTI

-------------------------------------------------------------------------------
McAllister@dockmaster.ncsc.mil

P.S. Thanks for keeping INFO-APPLE alive for us.

saa33413@uxa.cso.uiuc.edu (11/20/89)

Note that the program just given only works on a IIc, though.  A while back,
Nibble published a program called "SoftClock."  It adds a timestamp to ProDOS
files in any computer that has no clock.  It doesn't keep real time (it only
adds a minute or two to the time every time you save something), but you can
use it to keep track of what file was saved before another, etc.  I don't know
offhand what issue this program was in, but I'll come back later and give you
the issue.  You can either get a copy of the issue from them or you can buy
the program on disk.  BTW, IMHO, Nibble is a magazine no one reading comp.sys.
apple should be without.

-------------------------------------------------------------------------------
! Scott Alfter        !   Go   ! McCoy:  ...they don't exactly like you.      !
! alftersoft@uiuc.edu ! Illini ! Kirk:  I know, Bones.  The feeling's mutual. !
-------------------------------------------------------------------------------

greyelf@wpi.wpi.edu (Michael J Pender) (11/29/89)

In article <187.infoapple.net@pro-generic> ericmcg@pro-generic.cts.com (Eric Mcgillicuddy) writes:
>Does anyone know of a software clock for all Apple //'s? I think the VBL
>interupt can be used, but I have little experience with this kind of thing. 
>Are there any PD routines available?

I wrote one a while back that works with Daemon, check apple2-l,
they should have it, and others.
---
Michael J Pender Jr  Box 1942 c/o W.P.I.        ... (Mankind) has already 
greyelf@wpi.bitnet   100 Institute Rd.          used its last chance.
greyelf@wpi.wpi.edu  Worcester, Ma 01609               - Gen. MacArthur