Bob’s Notebook: Digital Clock for the TS 2068

Authors

Publication

Pub Details

Date

Pages

See all articles from Sinc-Link v9 n5

This bit of code will provide a digital 24-hour clock which can be used in various applications. It uses the Z80’s Interrupt Mode 2 to allow the clock to appear, via multitasking, while another program is operating.

The clock will show hours, minutes and seconds in the upper right corner of the screen. An experienced machine code programmer can alter the screen location, if this is desirable.

To start the clock GO TO 3000, which POKEs the time value entered into the code and then does a RANDOMIZE USR 65020 to activate the IM2 routine and divert the interrupts. GO TO 4000 to stop the clock which does a RANDOMIZE USR 65077 which triggers and IM1 routine to make the interrupts normal again. To restart the clock, GO TO 3030.

Memory used is from 64256 to 65291, part of which is taken up with a 257 byte table of 251s necessary to make the IM2 routine work with the TS2068. See the column Sep-Oct 85 for a more detailed explanation of how this interrupt mode 2 function.

I used Carol Brooksbank’s timer routine in ZX Computing Oct/Nov 85 as my source, converting it from Spectrum to TS2068 use, mainly to include the IM2 modifications; and changing the display to a 24-hour clock, which involved adding a little extra code. Machine code buffs can find added information in that article. The clock will not keep time accurately to the second, if left running for very long. The only adjustment provided is a coarse one at address 65097. It is originally set at 60 and can be change to a higher value to slow the clock or a lower one to speed it up. I found it best to leave the value 60 as is; other values only made it less accurate.

Using disk SAVE and LAD commands while the clock is running will cause the clock to stop running briefly and then resume. Using the NME button will cause a crash so it is better to turn the clock off when about to do this.

Enter the listing into the TS2068 and GO TO 9000 to save it to disk. When the program is first loaded, it will POKE the code into upper memory at 65020.

Products

 

Image Gallery

Source Code

    1 REM Bob Mitchell
    2 REM Sinc-Link v9 n5
    3 REM https://archive.org/details/SincLink/Sinc-Link%20Vol%2009%20No%205/page/27/mode/1up
    5 CLEAR 65019
  100 REM Clock
  105 REM GO TO LINE 3000 to start clock.  Enter time in 24-hour format (eg 7:39pm is 192800)
  110 REM GO TO LINE 4000 to stop clock
  115 REM value in 65097 can be changes to alter clock speed. 60 is normal; higher value slows clock
  120 REM turn clock off before using NMI button
 1000 DATA 33,0,252,1,251,0,113,35,16,252,113,62,195,50,251,251
 1001 DATA 33,60,254,34,252,251,62,252,237,71,237,94,253,54,2,0
 1002 DATA 24,11,22,0,24,48,48,58,48,48,58,48,48,33,30,254
 1003 DATA 6,11,126,215,35,5,32,250,201,237,86,62,63,237,71,201
 1004 DATA 245,229,197,213,175,58,1,255,60,50,1,255,254,60,218,74
 1005 DATA 0,175,50,1,255,58,9,255,60,50,9,255,254,10,56,104
 1006 DATA 175,50,9,255,58,8,255,60,50,8,255,254,6,56,89,175
 1007 DATA 50,8,255,58,6,255,60,50,6,255,254,10,56,74,175,50
 1008 DATA 6,255,58,5,255,60,50,5,255,254,6,56,59,175,50,5
 1009 DATA 255,58,3,255,60,50,3,255,254,4,40,2,32,21,58,2
 1010 DATA 255,254,2,32,14,58,3,255,175,50,3,255,58,2,255,175
 1011 DATA 50,2,255,58,3,255,50,3,255,254,10,56,11,175,50,3
 1012 DATA 255,58,2,255,60,50,2,255,62,24,50,10,255,62,2,50
 1013 DATA 11,255,79,6,255,10,135,135,135,79,6,0,33,128,61,9
 1014 DATA 58,10,255,95,62,64,87,6,8,126,18,35,20,5,32,249
 1015 DATA 58,10,255,60,50,10,255,58,11,255,60,254,10,40,2,24
 1016 DATA 206,195,74,0,0,0,0,0,10,0,0,10,0,0,0,0
 3000 RESTORE 1000: FOR i=1 to 272: READ a: POKE 65019+i,a: NEXT i
 3005 INPUT "time? hhmmss "; LINE t$: POKE 65281,0: POKE 65282,VAL t$(1): POKE 65283, VAL t$(2)
 3010 POKE 65285,VAL t$(3): POKE 65286, VAL t$(4)
 3020 POKE 65288,VAL t$(5):POKE 65289,VAL t$(6)
 3030 RANDOMIZE USR 65020: STOP: REM start clock
 4000 RANDOMIZE USR 65077: STOP: REM stop clock
 9000 REM SAVE CLOCK
Scroll to Top