REM **************************************************** REM * clock program to display the time on * REM * the Tektronix 4010 Graphics Terminal * REM * written by Steve and Jim Forbes 5/2/2003 * REM * for QBASIC to run on a 286 with DOS 5 * REM **************************************************** DECLARE SUB clearscreen () DECLARE SUB graphicsmode () DECLARE SUB movetopoint (xcoord, ycoord) DECLARE SUB splitbytes (hibyte, lobyte) REM open serial port for data transmission to 4010 RS-232C interface OPEN "com1:2400,N,8,1" FOR RANDOM AS #1 clearscreen REM define center of screen origx = 512 origy = 384 centerx = origx centery = origy REM define hand end point radii hourbegin = 0 hourend = 200 minbegin = 50 minend = 350 DO IF minutes <> VAL(MID$(TIME$, 4, 2)) THEN REM check for minutes = seconds = 0 and clear screen if true IF MID$(TIME$, 4, 2) = "00" AND RIGHT$(TIME$, 2) = "00" THEN clearscreen REM calculate hand positions in radians minutes = VAL(MID$(TIME$, 4, 2)) minutedegrees = VAL(MID$(TIME$, 4, 2)) * 6 - 90 minutesradians = minutedegrees * .017453# hoursdegrees = VAL(LEFT$(TIME$, 2)) * 30 + VAL(MID$(TIME$, 4, 2)) * .5 - 90 hoursradians = hoursdegrees * .017453# REM calculate hand end coordinates relative to center hoursx = INT(hourend * COS(hoursradians)) hoursy = INT(-hourend * SIN(hoursradians)) minutesx1 = INT(minbegin * COS(minutesradians)) minutesy1 = INT(-minbegin * SIN(minutesradians)) minutesx2 = INT(minend * COS(minutesradians)) minutesy2 = INT(-minend * SIN(minutesradians)) REM draw minute hand-first set to move mode, then move to center REM then move to outer end of hand graphicsmode movetopoint centerx, centery centerx = origx centery = origy movetopoint hoursx + centerx, hoursy + centery REM draw minute hand graphicsmode centerx = origx centery = origy movetopoint centerx + minutesx1, centery + minutesy1 centerx = origx centery = origy movetopoint centerx + minutesx2, centery + minutesy2 END IF LOOP UNTIL INKEY$ = CHR$(27) CLOSE #1 END SUB clearscreen REM clear screen PRINT #1, CHR$(27); CHR$(12) REM delay loop while clear is executed which takes 1.5 seconds REM will need change for other than 10mhz cpu FOR i = 1 TO 5000 NEXT i END SUB SUB graphicsmode REM send command to enter graphics mode REM may change to pass argument 1 or 0, change ascii REM from 29 to 27 to return to text mode PRINT #1, CHR$(29); END SUB SUB movetopoint (hix, hiy) REM encode and send coordinate high and low bytes to terminal REM added numbers set bit flags for byte status loy = 0 lox = 0 splitbytes hiy, loy splitbytes hix, lox PRINT #1, CHR$(hiy + 32); CHR$(loy + 96); CHR$(hix + 32); CHR$(lox + 64); END SUB SUB splitbytes (hibyte, lobyte) fullnumber = hibyte hibyte = 0 DO IF fullnumber < 32 THEN EXIT DO fullnumber = fullnumber - 32 hibyte = hibyte + 1 LOOP lobyte = fullnumber END SUB