Path: utzoo!attcan!uunet!aplcen!samsung!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!DOCKMASTER.NCSC.MIL!McAllister From: McAllister@DOCKMASTER.NCSC.MIL Newsgroups: comp.sys.apple Subject: softclocks Message-ID: <891118183816.615157@DOCKMASTER.ARPA> Date: 18 Nov 89 18:38:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 88 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 #