The intend was to spend the Christmas holidays assembling the Gigatron (besides entertaining the wife and family), but impatience got the better of me weeks ago and the Gigatron has been happily blinking its lights ever since. I was about to write "humming along" but it isn't, not even softly, and that's a bit of a letdown really (just kidding). So, I've been doing some BASIC (really basic) stuff on it and reliving my school days, when life was much more simpler and in a time when the Dead Sea merely had an annoying cold... Those were the days of stealing computer time on C64 demo computers at the V&D store in town after school hours (and occasionally during school hours at well, as a matter of fact), hoping you'd be able to finish typing in the code you had jotted down on paper the night before, before someone from the store would pat you on the shoulder and told you to b*gger off! In that unfortunate case you would migrate to the Bijenkorf, another well known store, and try your luck there. Ahhh, if only I had a time machine...
Anyway...before the forum moderators tap me on the shoulder for wasting too many electrons, here's a little BASIC code I made up. When showing off the Gigatron to friends and family, one way of demoing is with the Mandelbroth, which looks nice and complex and has a clock. But non-IT people don't really get it, so I was looking for something simpler. In BASIC. Marcel posted hist Cosinus code a while back and that fitted the bill quite nicely. So I blatantly copied it, randomized it a bit, changed the background, and added a clock in retro-looking red digits. Just for fun.
Now, the clock is of course a bit of a challenge, in a programming language which doesn't keep time, on a computer which doesn't either. Yes I know, the Gigatron does have a clock and a good thing too it does otherwise it wouldn't work at all, but that's besides my point. So what can we do? We cheat of course! Sort of. For we know the Gigatron is a single tasking computer, and therefore it is quite safe to assume that a loop in BASIC code will take exactly the same time every time it is interpreted, as long as the amount of code within each loop iteration is constant (or in other words: not too many jumps). My goal was to have an accuracy of no more than a 1 minute deviation in 24 hours. And that works. For me I clocked and fine tuned this particular loop time to 23.56 seconds, but I am really curious if this number is constant on other Gigatrons as well. Should be... The clock is in 24 hour format, as it should be, but ye Americans can be easily adapted to 12 hour format I guess.
One final word: do NOT use this clock for important time keeping. I do NOT take any responsibility should you miss an appointment or whatever. Just saying

And here's the code. It wont save to Mr. McPlugface so use an Arduino instead. The code is also on Github in Contrib/Crouze.
Code: Select all
10 poke 42,0:poke43,2
20 'Q = loop duration in
30 '1/100s, adjust to
40 'finetune the clock
50 mode1:cls:T=150:Q=2356
60 ?"Set Hour and Minute"
70 input H:if H<0 goto 70
80 if H>23 goto 70
90 input M:if M<0 goto 90
100 if M>59 goto 90
110 cls:C=rnd(23)+1
120 P=(rnd(24)+4)*16
130 U=5000:V=0
140 if T<6000 goto 220
150 M=M+1:T=T-6000
160 if M<60 goto 220
170 M=0:H=H+1
180 If H=24 H=0
190 'unREM line 220 to
200 'show 1/100s for
210 'finetuning clock
220 REM at 2,112:?T;
230 L=rnd(128)+2
240 at L,1:?"0 :0";
250 Z=0:if H<10 Z=6
260 at L+Z,1:?H;
270 Z=0:if M<10 Z=6
280 at L+Z+18,1:?M;
290 for X=0 to 159
300 Y=68-U/100
310 poke Y*256+X,C
320 U=U+V:V=V-U/P
330 next X:T=T+Q
340 if C>500 goto 110
350 C=C+23
360 if C%64=0 goto 350
370 at L,1:?" ";
380 goto 140

Enjoy your holidays (if you have),
Marco