# http://www.ex-parrot.com/~tom/calcs/calcs/encyc/progs/src/hangman.ctf # ======================================================================== # Program name: Hangman # # Version: 1.0 # Author: Tom Lynn # Date: 1995-1997 # Models: 9700, 9800 # # # Description: # # The first player enters a word (15 letters max IIRC) letter-by-letter # by either pressing [ALPHA] followed by the letter key or by giving the # position of the letter in the alphabet (eg 5 for "E"). When they have # finished entering the word, they enter 0. When they have confirmed that # the word is correct, the calc clears the screen and they hand the calc # to the other player who then tries to guess the word, again entering # one letter at a time in a similar fashion. If they run out of guesses, # the man is hanged. That's about it. Enjoy. # # # # Global subroutines: # # This program uses the +TEXT55 (5-by-5 pixel text) program and its # subroutines, which should be in tlglobal.ctf. Warning - it's long. # It also uses +ALPHASET from the same library. @@ Program "~HANGMAN" # Main routine " \*\*\* HANGMAN \*\*\*" Mcl Defm 20 Prog "+ALPHASET" Lbl 3 1->A 2->B 24->X 25->Y "Enter word, pressing EXE after each letter [0 to finish]" ; 4 spcs 0->Z[1] Lbl 0 1->A Isz Z[1] ?->A Int A->A A->Z[Z[1]+2] A>0=>A<27=>Goto 0 A=0=>Goto 8 " Text only, please!" Dsz Z[1] Goto 0 Lbl 8 Z[1]<4=>" Word must have at least 3 letters. " ; spcs: 2, 4, 2 Z[1]<4=>Goto 3 2->\th Range 1,127,0,1,63,0 Lbl 2 6\th-6->A 57->B Z[\th+1]->\r Prog "+TEXT55" Isz \th \th<=Z[1]=>Goto 2 Plot 0,0_ "OK [Y\/N]" ?->A A=N=>Goto 3 Prog "HASCRINIT" 8->A Lbl 1 " " Dsz A Goto 1 Isz A Lbl 5 Plot 0,0_ Lbl 4 Prog "+ALPHASET" "Enter guess or press" "0 to view screen:" ?->\th Int \th->\th \th=0=>Goto 5 \th>26=>" Text only, please! " \th>26=>Goto 4 \th<0=>" Text only, please! " \th<0=>Goto 4 \th->E Prog "HAGUESSCHECK" 0->\th C=0=>Prog "HAHANG" Prog "+ALPHASET" Prog "HACHECK4WIN" \th>0=>Goto 9 Goto 5 Lbl 9 " " \th=1=>" You lose!" ; 6 spcs \th=2=>" You win!" ; 6 spcs " " " Press EXE to" ; 4 spcs " play again" ; 5 spcs " " @@ Program "HACHECK4WIN" # Checks for a win 2->A 0->B Lbl 0 B+Z[A+1]->B Isz A A<=Z[1]=>Goto 0 B=0=>2->\th @@ Program "HAGUESSCHECK" # Checks if guess is correct Prog "+ALPHASET" \th->E 2->D 0->C Lbl 0 Z[D+1]=\th=>Goto 1 Lbl 2 Isz D DGoto 0 Goto 9 Lbl 1 7D-9->A 55->B Z[D+1]->\r Prog "+TEXT55" 0->Z[D+1] 1->C Goto 2 Lbl 9 @@ Program "HAHANG" # Hang the man a bit more 0->F 47->B 5->A Z[2]=0=>Goto 0 Z[2]=1=>Goto 1 Z[2]=2=>Goto 2 Z[2]=3=>Goto 3 Z[2]=4=>Goto 4 Z[2]=5=>Goto 5 Z[2]=6=>Goto 6 Z[2]=7=>Goto 7 Z[2]=8=>Goto 8 Z[2]=9=>Goto 9 Lbl 1 Plot 30,12 Plot X,44 Line Goto 0 Lbl 3 Plot 30,44 Plot 50,Y Line Goto 0 Lbl 2 Plot 25,12 Plot 30,17 Line Plot 35,12 Line Goto 0 Lbl 4 Plot 30,39 Plot 35,44 Line Goto 0 Lbl 5 Plot 45,44 Plot X,36 Line Goto 0 Lbl 6 Plot 45,36 Plot 48,33 Line Plot 45,30 Line Plot 42,33 Line Plot 45,36 Line Goto 0 Lbl 8 Plot 42,27 Plot 45,30 Line Plot 48,27 Line Goto 0 Lbl 7 Plot 45,30 Plot X,24 Line Goto 0 Lbl 9 Plot 42,21 Plot 45,24 Line Plot 48,21 Line Z[F+3]->\r Z[F+3]<>0=>Prog "+TEXT55" Isz F A+7->A F+2<=Z[1]=>Goto 9 1->\th Lbl 0 Z[2]=0=>Plot 23,12 Z[2]=0=>Plot 37,Y Z[2]=0=>Line 6Z[2]+60->A 3->B E->\r Prog "+TEXT55" Isz Z[2] @@ Program "HASCRINIT" # Set up screen Cls Plot 1,63 Plot 127,63 Line Plot 127,1 Line Plot 1,1 Line Plot 1,63 Line 53->B 5->A Lbl 0 Plot A,B Plot A+4,B Line A+7->A (A+2)/7Goto 0 5->A 7->\r 3->B 1->C Lbl 1 Prog "+TEXT55" Isz C C=2=>21->\r Frac (C/3=0=>5->\r C>=4=>C<=5=>19->\r C=7=>4->\r C=8=>36->\r A+6->A C<9=>Goto 1 # ======================================================================== # CTF compliant. See http://www.york.ac.uk/~tw104/casio/ for details. # # More programs and information at: # http://www.ex-parrot.com/~tom/calcs/calcs/encyc/ # # This file last compiled: Friday, 30 April, 1999 # ========================================================================