Draws a digital wristwatch, with strap, curved case and “ASEIKO Quartz” face, and runs it as a clock. Before starting you set the hours with H, the minutes with M and the seconds with S (in steps of five), and choose AM or PM with A or P. G starts it; started from zero it works as a stopwatch. Hours run from 1 to 12 and AM and PM change over at twelve o’clock.
REMs credit D. Richardson and ZX Computing, February/March 1984, and note that more accurate time can be kept by changing the PAUSE in line 110.
Program Analysis
Structure
- Lines 30–80: draw the watch (subroutine 250) and take the setting keys.
- Lines 85–200: the running clock.
PAUSE 59makes each second, then seconds, minutes and hours carry over. - Lines 250–750: the drawing. The case sides are
DRAWcommands with an angle argument, which draws arcs; UDG l is a small bracket printed beside the labels.
Notable Techniques
- The positions of the hour, minute, second and AM/PM fields are kept as embedded
ATstrings (CHR$ 22+CHR$ row+CHR$ column) inh$,m$,s$anda$, so each update is a shortPRINT.
Potential Issues
- The clock counts
PAUSE 59plus the time BASIC takes to run each loop, so it drifts. - After 12, line 170 sets the hour to 0 but prints 1. The next hour then shows 1 again, so one o’clock lasts two hours.
This program came from an Oliger (JLO SAFE) disk, a copy of the SNUG library disk 17/18, and was converted to load from tape. No changes were needed. It was tested in ZEsarUX, setting a time and starting the clock.
Source Code
5 REM > DIGITAL WRISTWATCH <
10 REM
15 REM RESET ZX COMPUTING, Feb/Mar 1984
20 REM by D. Richardson
25 REM More accurate time can be kept by changing the pause in line 110
30 CLS : GO SUB 250
45 IF INKEY$<>"" THEN GO TO 45
50 IF INKEY$="" THEN GO TO 50
55 IF INKEY$="h" THEN PRINT AT 10,17;h+1: LET h=h+1: IF h>12 THEN LET h=1: PRINT h$;"1 ": GO TO 45
60 IF INKEY$="m" THEN PRINT m$;m+1: LET m=m+1: IF m>59 THEN LET m=0: PRINT m$;"0 ": GO TO 45
65 IF INKEY$="s" THEN PRINT s$;s+5: LET s=s+5: IF s>59 THEN LET s=0: PRINT s$;"0 ": GO TO 45
70 IF INKEY$="p" THEN LET r$="PM": PRINT a$;r$: GO TO 45
75 IF INKEY$="a" THEN LET r$="AM": PRINT a$;r$: GO TO 45
80 IF INKEY$<>"g" THEN GO TO 45
85 FOR n=0 TO 11: PRINT AT n,0;" ": NEXT n
90 PRINT AT 15,2;"As ""TIME""": PRINT AT 16,5;"goes by"
110 PAUSE 59
120 LET s=s+1
130 IF s<60 THEN PRINT s$;s: GO TO 110
140 LET s=0: PRINT s$;"0 "
145 LET m=m+1: IF m<60 THEN PRINT m$;m: GO TO 110
155 LET m=0: PRINT m$;"0 "
160 LET h=h+1: IF h<12 THEN PRINT h$;h: GO TO 110
165 IF h=12 THEN PRINT h$;h: GO TO 195
170 IF h=13 THEN LET h=0: PRINT h$;" 1": GO TO 110
195 IF r$="AM" THEN LET r$="PM": PRINT a$;r$: GO TO 110
200 IF r$="PM" THEN LET r$="AM": PRINT a$;r$: GO TO 110
250 LET h=0: LET m=0: LET s=0
255 BORDER 0
260 LET h$=CHR$ 22+CHR$ 10+CHR$ 17
270 LET m$=CHR$ 22+CHR$ 10+CHR$ 20
280 LET s$=CHR$ 22+CHR$ 10+CHR$ 23
285 PRINT h$;h,m$;m,s$;s
290 LET r$="AM"
295 LET a$=CHR$ 22+CHR$ 14+CHR$ 17: PRINT a$;r$
300 PRINT AT 0,0;"To set PRESS": PRINT " H for hours": PRINT " M - mins": PRINT " S - secs": PRINT " AorP-AM/PM": PRINT '" To START": PRINT " PRESS 'G'": PRINT ''" (Stopwatch": PRINT " only""G"")"
350 PRINT AT 12,17;"Hr";AT 12,20;"Mn";AT 12,23;"Sc"
400 PRINT AT 14,21;"SA19"
500 PRINT AT 7,18;"ASEIKO"
510 PRINT AT 16,18;"Quartz"
520 PLOT 143,128: DRAW 0,-97,.72*PI
530 PLOT 192,31: DRAW 0,97,.72*PI
540 PLOT 143,175: DRAW 0,-51: DRAW 0,-89,.67*PI: DRAW 0,-35
550 PLOT 192,0: DRAW 0,35: DRAW 0,89,.67*PI: DRAW 0,51
560 FOR y=0 TO 35 STEP 5: PLOT 143,y: DRAW 49,0: NEXT y
570 FOR y=124 TO 175 STEP 5: PLOT 143,y: DRAW 49,0: NEXT y
580 PLOT 203,99: DRAW 0,-15: DRAW -71,0: DRAW 0,15: DRAW 71,0
590 PLOT 128,105: DRAW 79,0: DRAW 0,-51: DRAW -79,0: DRAW 0,51
700 FOR n=0 TO 7
710 READ a
720 POKE USR "l"+n,a: NEXT n
730 PRINT AT 12,28;"l"
740 RETURN
750 DATA 248,8,8,248,0,0,0,0Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

