diff options
Diffstat (limited to 'addon/sb_vfd/vfd_4x40_m68_clock.bas')
-rw-r--r-- | addon/sb_vfd/vfd_4x40_m68_clock.bas | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/addon/sb_vfd/vfd_4x40_m68_clock.bas b/addon/sb_vfd/vfd_4x40_m68_clock.bas new file mode 100644 index 0000000..ecc999a --- /dev/null +++ b/addon/sb_vfd/vfd_4x40_m68_clock.bas @@ -0,0 +1,96 @@ +1 REM clock.bas +2 REM by Scott Baker, http://www.smbaker.com/ +3 REM Demonstrates use of BQ4845 RTC on Z80 RC2014 computer +4 REM with VFD display. + +5 REM set 24-hour mode +6 OUT &HCE, 2 + +7 GOSUB 4000 : REM initialize VFD +8 GOSUB 4100 : REM VFD cursor off +9 T$="RC2014 VFD Clock" +10 X=12 : Y=1 : CTRLR=0 : GOSUB 4400 : REM goto line 2 on controller 1 +11 CTRLR=1 : GOSUB 4500 : REM VFD print string on controller 1 + +15 LS=999 +20 GOSUB 1000 : REM get time + +30 if (LS = S) GOTO 100 +40 LS = S +50 GOSUB 2000 +60 X=16 : Y=0 : CTRLR=2 : GOSUB 4400 : REM goto line 1 on controller 2 +70 CTRLR=3 : GOSUB 4500 : REM display time on controller 2 +100 GOTO 20 + +998 REM read the current time from the RTC +999 REM store it in the variables H, M, S. +1000 X=inp(&HC0) +1010 S=(X and 15) + INT(X/16)*10 +1020 X=inp(&HC2) +1030 M=(X and 15) + INT(X/16)*10 +1040 X=inp(&HC4) +1050 H=(X and 15) + (INT(X/16) and 3)*10 +1060 RETURN + +1999 REM format H, M, S into a string T$ +2000 T$="" +2010 if (H>9) GOTO 2030 +2020 T$=T$+"0" +2030 T$=T$+right$(str$(H),len(str$(H))-1) +2040 T$=T$+":" +2050 if (M>9) GOTO 2070 +2060 T$=T$+"0" +2070 T$=T$+right$(str$(M),len(str$(M))-1) +2080 T$=T$+":" +2090 if (S>9) GOTO 2110 +2100 T$=T$+"0" +2110 T$=T$+right$(str$(S),len(str$(S))-1) +2120 RETURN + +2999 REM set the clock using H, M, S +3000 TS=INT(S/10) +3010 OS=S-(TS*10) +3020 OUT &HC0, TS*16 + OS +3030 TM=INT(M/10) +3040 OM=M-(TM*10) +3050 OUT &HC2, TM*16 + OM +3060 TH=INT(H/10) +3070 OH=H-(TH*10) +3080 OUT &HC4, TH*16 + OH +3090 RETURN + +4000 OUT 0, &H30 : REM function set - 8 bit 1st controller +4005 OUT 2, &H30 : REM function set - 8 bit 2nd controller +4010 OUT 1, 3 : REM min brightness 1st controller +4015 OUT 3, 3 : REM min brightness 2nd controller +4020 OUT 0, 1 : REM clear display 1st controller +4025 OUT 2, 1 : REM clear display 2nd controller +4030 OUT 0, &H0F : REM display on, cursor on, blink on 1st controller +4035 OUT 2, &H0F : REM display on, cursor on, blink on 2nd controller +4040 RETURN + +4099 REM turn cursor off +4100 OUT 0, &H0C : REM display on, cursor off 1st controller +4105 OUT 2, &H0C : REM display on, cursor off 2nd controller +4110 RETURN + +4199 REM turn cursor on +4200 OUT 0, &H0F : REM display on, cursor on, blink on 1st controller +4205 OUT 2, &H0F : REM display on, cursor on, blink on 2nd controller +4210 RETURN + +4299 REM clear screen +4300 OUT 0, 1 : REM 1st controller +4305 OUT 2, 1 : REM 2nd controller +4310 RETURN + +4399 REM goto X, Y at Controller (CTRLR) +4400 DA = &H80 + (&H40 * Y) + X +4410 OUT CTRLR, DA +4420 RETURN + +4499 REM print string at Controller (CTRLR) +4500 FOR I=1 to LEN(T$) +4510 OUT CTRLR, ASC(MID$(T$, I, 1)) +4520 NEXT I +4530 RETURN |