Big Digit Clock

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Clock

Clock asks for the hour and minute, sets the computer’s frame counter to match, and then shows the time as four large digits filling the middle of the screen. Each digit is drawn 8 × 8 character cells, one cell for each pixel of the ordinary ROM character, so the display can be read across a room.

Program Analysis

Lines 30–70 convert the time to frames (×60 per second on the TS2068) and poke the three bytes of the FRAMES system variable at 23672–23674. The main loop (100–190) reads FRAMES back, works out hours, minutes and seconds, and builds a four-character string t$. The drawing routine at 200 finds each digit’s bitmap through the CHARS system variable (23606), takes the eight rows, splits each byte into bits with repeated division by 2, and prints CHR$ 144 or CHR$ 143 for each bit. Line 203 defines user-defined graphic A as a blank cell from the DATA at line 300.

Notable Techniques

  • The FRAMES counter used as a real-time clock.
  • Large characters drawn from the ROM font, with CHR$ (144-BIT) choosing between a blank graphic and a solid block.

Potential Issues

  • The display is redrawn only when the seconds reach 47 (line 180), so the time first appears up to a minute after it is set and then changes once a minute.
  • Hour 13 becomes 1, but hour 0 is shown as 00, and the clock does not wrap after 24 hours.

This copy came from a Larken disk; only the disk save and menu lines were removed. Tested in ZEsarUX.

Related Content

Image Gallery

Source Code

    1 BORDER 7: PAPER 7: INK 0: CLS 
    5 DIM t$(4)
   10 INPUT "Hour ? ";h
   20 INPUT "Minute ? ";m
   30 LET a=(h*3600+m*60)*60
   40 LET b=INT (a/65536): POKE 23674,b
   50 LET c=a-b*65536
   60 LET a=INT (c/256): POKE 23673,a
   70 LET b=c-a*256: POKE 23672,b
  100 LET t=INT ((65536*PEEK 23674+256*PEEK 23673+PEEK 23672)/60)
  110 LET h=INT (t/3600)
  120 LET b=t-h*3600
  130 LET m=INT (b/60)
  140 LET s=b-m*60: IF h=13 THEN LET h=1
  150 LET t$( TO 2)=STR$ h: IF LEN STR$ h=1 THEN LET t$( TO 2)="0"+STR$ h
  160 LET t$(3 TO 4)=STR$ m: IF LEN STR$ m=1 THEN LET t$(3 TO 4)="0"+STR$ m
  180 IF s=47 THEN GO SUB 200
  190 GO TO 100
  200 FOR Z=1 TO 4
  203 RESTORE : FOR J=0 TO 7: READ a: POKE USR CHR$ 144+J,a: NEXT J
  205 LET J=CODE t$(Z)-33
  210 LET C=PEEK 23606+256*PEEK 23607+256
  220 FOR P=7 TO 14
  225 LET BYTE=PEEK (C+P+J*8)
  235 FOR L=Z*8-1 TO (Z-1)*8 STEP -1
  240 LET X=INT (BYTE/2): LET BIT=BYTE-2*X: LET BYTE=X
  245 PRINT AT P,L;CHR$ (144-BIT)
  250 NEXT L
  255 NEXT P
  260 NEXT Z
  270 RETURN 
  300 DATA 0,0,0,0,0,0,0,0
 9000 SAVE "CLOCK" LINE 0
 9992 REM  removed (LKDOS-only)
 9998 REM  removed (LKDOS-only)

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.