View Single Post
Old 2005-02-21, 18:08   #5
Uncwilly
6809 > 6502
 
Uncwilly's Avatar
 
"""""""""""""""""""
Aug 2003
101×103 Posts

22×5×19×23 Posts
Default

I was just ignorantly using C++ as what I understood to be "advanced/enhnanced C"

What this is is a countdown timer for use in a TV studio. It starts counting down from some number of seconds and displays the time to go. As time elpases the numbers/screen change color to give the host and guest quick visual clues in addition to the actual time. On the fly (or while paused), the timer operator can add or subtract 1 min, 10 sec, or 1 sec at a time. The counter can be stopped and restarted. Since old QBasic is a interpreted, all the defaults can be changed with an edit (like the screen colors and times), I would presume that an .ini file would be needed for a different imp. This runs a 486 laptop (dos/Win 3.11) that is silent in the studio (no fan). Currently it uses crude block letters printed out (and fed to small TV's via a VGA/TV converter). nu$ are the arrays that hold the block numbers and X is purely a counter; unlike my standard code, I have good variable names. Ideally being able to tap into something to use a better font (like an Impact TTF would be nice).

Here is the code (undocumented of course):
Code:
DIM nu$(9, 11)
ON KEY(1) GOSUB Addsecs
ON KEY(2) GOSUB subsecs
ON KEY(3) GOSUB Addsec
ON KEY(4) GOSUB subsec
ON KEY(5) GOSUB Addmin
ON KEY(6) GOSUB Submin
ON KEY(9) GOSUB Pause
KEY(0) ON
Defaulttime = 1660
guesttime1 = 360
guesttime2 = 180
hosttime1 = 60
hosttime2 = 30
hosttime3 = 15
GOSUB Readnum
actualtime = Defaulttime
ON TIMER(1) GOSUB prnttime
TIMER ON
COLOR 10, 0
CLS
starttime = TIMER
timepast = TIMER - starttime
   WHILE timepast < actualtime
      WHILE actualtime - timepast > guesttime1
         timepast = TIMER - starttime
      WEND
      COLOR 14, 0
      CLS
      TIMER OFF
      GOSUB prnttime
      TIMER ON
      WHILE (actualtime - timepast > guesttime2) AND (actualtime - timepast < guesttime1 + 1)
        timepast = TIMER - starttime
      WEND
      COLOR 4, 0
      CLS
      TIMER OFF
      GOSUB prnttime
      TIMER ON
      WHILE (actualtime - timepast > hosttime1) AND (actualtime - timepast < guesttime2 + 1)
        timepast = TIMER - starttime
      WEND
      COLOR 0, 2
      CLS
      TIMER OFF
      GOSUB prnttime
      TIMER ON
      WHILE (actualtime - timepast > hosttime2) AND (actualtime - timepast < hosttime1 + 1)
        timepast = TIMER - starttime
      WEND
      COLOR 0, 14
      CLS
      TIMER OFF
      GOSUB prnttime
      TIMER ON
      WHILE (actualtime - timepast > hosttime3) AND (actualtime - timepast < hosttime2 + 1)
        timepast = TIMER - starttime
      WEND
      COLOR 0, 4
      CLS
      TIMER OFF
      GOSUB prnttime
      TIMER ON
      WHILE (actualtime - timepast > 0) AND (actualtime - timepast < hosttime3 + 1)
        timepast = TIMER - starttime
      WEND
   WEND
END

prnttime:
togo = actualtime - timepast
firstmin = INT(togo / 600)
secondmin = INT(INT(togo / 60) - firstmin * 10)
firstsec = INT(INT(togo / 10) - INT(togo / 60) * 6)
secondsec = INT(togo - INT(togo / 10) * 10)

IF togo > 600 THEN
  FOR x = 1 TO 11
    LOCATE 6 + x, 9: PRINT nu$(firstmin, x);
  NEXT x
ELSE
  FOR x = 1 TO 11
    LOCATE 6 + x, 9: PRINT "          ";
  NEXT x
END IF
IF togo > 60 THEN
  FOR x = 1 TO 11
    LOCATE 6 + x, 23: PRINT nu$(secondmin, x);
  NEXT x
ELSE
  FOR x = 1 TO 11
    LOCATE 6 + x, 23: PRINT "          ";
  NEXT x
END IF
LOCATE 9, 38: PRINT "ÛÛÛÛ"
LOCATE 10, 38: PRINT "ÛÛÛÛ"
LOCATE 13, 38: PRINT "ÛÛÛÛ"
LOCATE 14, 38: PRINT "ÛÛÛÛ"
FOR x = 1 TO 11
  LOCATE 6 + x, 47: PRINT nu$(firstsec, x);
NEXT x
FOR x = 1 TO 11
  LOCATE 6 + x, 61: PRINT nu$(secondsec, x);
NEXT x
LOCATE 24, 1: PRINT TIME$; " F1=+10sec F2=-10sec F3=+1sec F4=-1sec F5=+1min F6=-1min Esc=Go F9=Stop";
RETURN

Addsecs:
actualtime = actualtime + 10
RETURN
Addsec:
actualtime = actualtime + 1
RETURN
subsecs:
actualtime = actualtime - 10
RETURN
subsec:
actualtime = actualtime - 1
RETURN
Addmin:
actualtime = actualtime + 60
RETURN
Submin:
actualtime = actualtime - 60
RETURN

Pause:
stoptime = TIMER
DO
LOOP UNTIL INKEY$ = CHR$(27)
restarttime = TIMER
starttime = starttime + (restarttime - stoptime)
RETURN


Readnum:
nu$(0, 1) = " ÛÛÛÛÛÛÛÛ "
nu$(0, 2) = "ÛÛÛ    ÛÛÛ"
nu$(0, 3) = "ÛÛ      ÛÛ"
nu$(0, 4) = "ÛÛ      ÛÛ"
nu$(0, 5) = "ÛÛ      ÛÛ"
nu$(0, 6) = "ÛÛ      ÛÛ"
nu$(0, 7) = "ÛÛ      ÛÛ"
nu$(0, 8) = "ÛÛ      ÛÛ"
nu$(0, 9) = "ÛÛ      ÛÛ"
nu$(0, 10) = "ÛÛÛ    ÛÛÛ"
nu$(0, 11) = " ÛÛÛÛÛÛÛÛ "


nu$(1, 1) = "    ÛÛÛ   "
nu$(1, 2) = "   ÛÛÛÛ   "
nu$(1, 3) = "  ÞÛÛÛÛ   "
nu$(1, 4) = "    ÛÛÛ   "
nu$(1, 5) = "    ÛÛÛ   "
nu$(1, 6) = "    ÛÛÛ   "
nu$(1, 7) = "    ÛÛÛ   "
nu$(1, 8) = "    ÛÛÛ   "
nu$(1, 9) = "    ÛÛÛ   "
nu$(1, 10) = "    ÛÛÛ   "
nu$(1, 11) = "  ÞÛÛÛÛÛÝ "

nu$(2, 1) = " ÛÛÛÛÛÛÛÛ "
nu$(2, 2) = "ÛÛ      ÛÛ"
nu$(2, 3) = "        ÛÛ"
nu$(2, 4) = "        ÛÛ"
nu$(2, 5) = "      ÛÛÛ "
nu$(2, 6) = "     ÛÛÝ  "
nu$(2, 7) = "   ÛÛÛ    "
nu$(2, 8) = " ÛÛÛ      "
nu$(2, 9) = "ÛÛ        "
nu$(2, 10) = "ÛÛ        "
nu$(2, 11) = "ÛÛÛÛÛÛÛÛÛÛ"

nu$(3, 1) = " ÛÛÛÛÛÛÛÛ "
nu$(3, 2) = "ÛÛ     ÛÛÛ"
nu$(3, 3) = "        ÛÛ"
nu$(3, 4) = "        ÛÛ"
nu$(3, 5) = "       ÛÛ "
nu$(3, 6) = "    ÞÛÛÛ  "
nu$(3, 7) = "       ÛÛ "
nu$(3, 8) = "        ÛÛ"
nu$(3, 9) = "        ÛÛ"
nu$(3, 10) = "ÛÛ     ÛÛÛ"
nu$(3, 11) = " ÛÛÛÛÛÛÛÛ "

nu$(4, 1) = "ÛÛ      ÛÛ"
nu$(4, 2) = "ÛÛ      ÛÛ"
nu$(4, 3) = "ÛÛ      ÛÛ"
nu$(4, 4) = "ÛÛ      ÛÛ"
nu$(4, 5) = "ÛÛ      ÛÛ"
nu$(4, 6) = "ÛÛÛÛÛÛÛÛÛÛ"
nu$(4, 7) = "        ÛÛ"
nu$(4, 8) = "        ÛÛ"
nu$(4, 9) = "        ÛÛ"
nu$(4, 10) = "        ÛÛ"
nu$(4, 11) = "        ÛÛ"

nu$(5, 1) = "ÛÛÛÛÛÛÛÛÛÛ"
nu$(5, 2) = "ÛÛ        "
nu$(5, 3) = "ÛÛ        "
nu$(5, 4) = "ÛÛ        "
nu$(5, 5) = "ÛÛ        "
nu$(5, 6) = "ÛÛÛÛÛÛÛÛÛ "
nu$(5, 7) = "       ÛÛÛ"
nu$(5, 8) = "        ÛÛ"
nu$(5, 9) = "        ÛÛ"
nu$(5, 10) = "ÛÛ     ÛÛÛ"
nu$(5, 11) = " ÛÛÛÛÛÛÛÛ "

nu$(6, 1) = " ÛÛÛÛÛÛÛÛ "
nu$(6, 2) = "ÛÛÛ       "
nu$(6, 3) = "ÛÛ        "
nu$(6, 4) = "ÛÛ        "
nu$(6, 5) = "ÛÛ        "
nu$(6, 6) = "ÛÛÛÛÛÛÛÛÛ "
nu$(6, 7) = "ÛÛ     ÛÛÛ"
nu$(6, 8) = "ÛÛ      ÛÛ"
nu$(6, 9) = "ÛÛ      ÛÛ"
nu$(6, 10) = "ÛÛÛ    ÛÛÛ"
nu$(6, 11) = " ÛÛÛÛÛÛÛÛ "

nu$(7, 1) = "ÛÛÛÛÛÛÛÛÛÛ"
nu$(7, 2) = "Û       ÛÛ"
nu$(7, 3) = "        ÛÛ"
nu$(7, 4) = "       ÛÛ "
nu$(7, 5) = "     ÞÛÛ  "
nu$(7, 6) = "     ÛÛ   "
nu$(7, 7) = "   ÞÛÛ    "
nu$(7, 8) = "   ÛÛ     "
nu$(7, 9) = "   ÛÛ     "
nu$(7, 10) = "   ÛÛ     "
nu$(7, 11) = "   ÛÛ     "

nu$(8, 1) = " ÛÛÛÛÛÛÛÛ "
nu$(8, 2) = "ÛÛÛ    ÛÛÛ"
nu$(8, 3) = "ÛÛ      ÛÛ"
nu$(8, 4) = "ÛÛ      ÛÛ"
nu$(8, 5) = "ÛÛÛ    ÛÛÛ"
nu$(8, 6) = " ÛÛÛÛÛÛÛÛ "
nu$(8, 7) = "ÛÛÛ    ÛÛÛ"
nu$(8, 8) = "ÛÛ      ÛÛ"
nu$(8, 9) = "ÛÛ      ÛÛ"
nu$(8, 10) = "ÛÛÛ    ÛÛÛ"
nu$(8, 11) = " ÛÛÛÛÛÛÛÛ "

nu$(9, 1) = " ÛÛÛÛÛÛÛÛ "
nu$(9, 2) = "ÛÛÛ    ÛÛÛ"
nu$(9, 3) = "ÛÛ      ÛÛ"
nu$(9, 4) = "ÛÛ      ÛÛ"
nu$(9, 5) = "ÛÛÛ    ÛÛÛ"
nu$(9, 6) = " ÛÛÛÛÛÛÛÛÛ"
nu$(9, 7) = "       ÞÛÛ"
nu$(9, 8) = "        ÛÛ"
nu$(9, 9) = "        ÛÛ"
nu$(9, 10) = "ÛÛ     ÛÛÛ"
nu$(9, 11) = " ÛÛÛÛÛÛÛÛ "
RETURN
Uncwilly is online now   Reply With Quote