Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001
Page 17
' -----[ Main Code ]------------------------------------------------------------
'
Main:
LCDCMD LCDpin,ClrLCD ' clear the LCD
addr = Prompt
GOSUB Show_Msg ' print prompt
Rollem:
GOSUB Shuffle ' shuffle until button pressed
PAUSE 5
IF (AskBtn = Pressed) THEN Show_Answer
GOTO Rollem
Show_Answer:
' get address of answer message
LOOKUP answer,[Ans0,Ans1,Ans2,Ans3,Ans4,Ans5],addr
LCDCMD LCDpin,ClrLCD
GOSUB Show_Msg
PAUSE 2000 ' give time to read answer
GOTO Main ' do it all over
END
' -----[ Subroutines ]----------------------------------------------------------
'
Show_Msg:
READ addr,char ' read a character
IF (char = 0) THEN Msg_Done ' if 0, message is complete
GOSUB Translate ' fix letters with descenders
LCDOUT LCDpin,NoCmd,[char]
addr = addr + 1 ' point to next character
GOTO Show_Msg
Msg_Done:
RETURN
' convert to descender font
' - does not change other characters
Translate:
LOOKDOWN char,["g","j","q","p","y"],char ' translate decended characters
LOOKUP char,[_g,_j,_q,_p,_y],char
RETURN
Shuffle:
answer = 1 // NumAns ' update answer pointer
clock = clock + 1 // 15 ' update pointer clock
IF (clock > 0) THEN Shuffle_Done ' time to update animation?
LOOKUP pntr,["-+|*"],char ' load animation character
LCDOUT LCDpin,DDRam + 15,[char] ' write it at column 15
pntr = pntr + 1 // 4 ' update animation char
Shuffle_Done:
RETURN