How to build a time of day clock on the Commodore 64

- by

In this video I’ll demonstrate how to build a simple clock on the C64. We’ll go through this process step by step, including the built-in TI and TI$ variables, string formatting with LEFT$, RIGHT$ and MID$, as well as screen formatting.

Here’s the code I’m writing – works in Commodore BASIC v2 and above:

5 input "qwhat is the current time (hhmm
ss) ";ti$
10 print chr$(147):print chr$(5)
20 a$ = left$(ti$,2)
25 a$ = a$ +":"
30 a$ = a$ + mid$(ti$,3,2)
35 a$ = a$ +":"
40 a$ = a$ +right$(ti$,2)
50 gosub 200
60 print chr$(19)
70 print "qqqqqqqqqqq]]]]]]]]]]]]]]curre
nt time"
80 print "]]]]]]]]]]]]]]]]";
90 print a$
100 goto 20
200 rem print a box
210 print chr$(19)
220 print "qqqqqqqqqq]]]]]]]]]]]]]UCCCCC
CCCCCCCI"
230 print "]]]]]]]]]]]]]B]]]]]]]]]]]]B"
240 print "]]]]]]]]]]]]]B]]]]]]]]]]]]B"
250 print "]]]]]]]]]]]]]JCCCCCCCCCCCCK"
299 return

Many of the characters that appear in this listing are cursor control characters and appear in reverse in the video. They either position the cursor or print PETSCII graphics.

Inspired by David’s video, in which he connects an LCD screen to his C64’s User Port: https://www.youtube.com/watch?v=vV8FbwobrKY



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.