home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 025.lha / Hyper-Typer < prev    next >
Encoding:
Text File  |  1987-04-02  |  11.3 KB  |  405 lines

  1. REM ******  Startup calls to give the test a reality  ****
  2. REM  *****   and a place to call home. !(Phone_Home) *****
  3.  
  4. GOSUB Initize   : REM  ** Call Screen, Window, Colors, and
  5.                   REM  ** Variable initialization Routine.
  6. REM ******   Main Program Driver
  7. Main:   GOSUB Reseed : REM * Reseed Random # Generator ??
  8.         GOSUB Question : REM * Make up a question
  9.         GOSUB Answer   : REM * Get an answer or null
  10.         
  11.         REM ** Handle "NULL" string answer
  12.         IF Answer$ = "" THEN
  13.           GOSUB Wrong
  14.           GOTO Main
  15.         END IF
  16.         
  17.         REM ** Student wishes to pause ??
  18.         IF ASC(Answer$) = 27 THEN
  19.           LOCATE 15,2 : PRINT "                                    "
  20.           GOSUB PauseMode
  21.           LOCATE 15,2: PRINT "Press <ESC> to Pause"
  22.           GOTO Main
  23.         END IF
  24.         
  25.         REM **  Is he right or wrong ??
  26.         IF Answer$ = LEFT$(Character$(Quest),1) THEN
  27.           GOSUB Right
  28.           GOTO Main
  29.         ELSE
  30.           GOSUB Wrong
  31.           GOTO Main
  32.         END IF
  33.         
  34.         GOTO Main  : REM ***  Just in case ***
  35. REM *****  Random Reseeder Routine  ******
  36.  
  37. Reseed: REM *** label  ***
  38.  
  39. Reseed% = Reseed% + 1
  40. IF Reseed% >= 25 THEN
  41.   RANDOMIZE TIMER
  42.   Reseed% = 0
  43. END IF
  44.  
  45. RETURN
  46.  
  47. REM ******   Question generator Routine  ******
  48.  
  49. Question: REM *** label ***
  50.  
  51. QRestart:  Quest = INT((MaxChars+1)*RND(2))
  52.            FOR t = 1 TO 10
  53.            junk$ = INKEY$
  54.            NEXT t
  55.            
  56.            LOCATE 7,16 
  57.            PRINT Character$(Quest);"           "
  58.          
  59.            RETURN
  60.            
  61. REM ***  Get an Answer Routine   *****
  62.  
  63. Answer:
  64. FOR Count = 1 TO Speed
  65.   Answer$ = INKEY$
  66.   IF Answer$ <> "" THEN
  67.     ActualTime = Count
  68.     Count = Speed
  69.   END IF
  70. NEXT Count
  71.  
  72. RETURN 
  73.  
  74. REM *****   Right Answer Handling Routine ******
  75.  
  76. Right:
  77. LOCATE 5,10
  78. PRINT "RIGHT!"
  79. Right = Right + 1
  80. LOCATE 10,2
  81. PRINT "Right : ";Right;"     "
  82. GOSUB Percent
  83. IF Speed <= 200 THEN                         
  84.   Speed = 200
  85. ELSE 
  86.   Speed = Speed - 8
  87. END IF
  88. Points = Points + (10+INT(10*(400/ActualTime)))
  89. LOCATE 2,15
  90. PRINT "Points: ";Points;"      "
  91.  
  92. RETURN
  93.  
  94. REM *****   Wrong Answer Handling Routine
  95.  
  96. Wrong:
  97. BEEP
  98. LOCATE 5,10
  99. PRINT "WRONG!"
  100. Speed = Speed + 40
  101. Wrong = Wrong + 1
  102. LOCATE 11,2
  103. PRINT "Wrong : ";Wrong;"     "      
  104. GOSUB Percent
  105. Points = Points - (5+INT(Speed/200))
  106. LOCATE 2,15
  107. PRINT "Points: ";Points;"     "
  108.  
  109. RETURN
  110.  
  111. REM ******   Percentage Calculation Routine  ******
  112.  
  113. Percent:
  114. Percent = (Right/(Right+Wrong)*100)
  115. LOCATE 12,2
  116. PRINT "Percent Right : ";Percent;"      "
  117.  
  118. RETURN
  119.  
  120. REM **** Pause Mode a la mode ****
  121. PauseMode:
  122.        WINDOW 5,"The Test is now in Pause Mode",(0,131)-(310,180),0,2
  123.        PRINT "Pause Menu:"
  124.        PRINT "Resume Test     - <ESC> Key
  125.        PRINT "Start New Test  - CTRL-R"
  126.        PRINT "Quit Program    - CTRL-Q"
  127. ReChoose: choice$ = INKEY$
  128.           IF choice$ = "" THEN GOTO ReChoose
  129.          REM **** Resume or not ? **** 
  130.           IF ASC(choice$) = 27 THEN 
  131.               ResumeFlag = -1
  132.               GOTO EndPause
  133.           ELSE
  134.               ResumeFlag = 0
  135.           END IF
  136.           REM *****  Restart or not ? *****        
  137.           IF ASC(choice$) = 18 THEN 
  138.               RestartFlag = -1
  139.               GOTO EndPause 
  140.           ELSE
  141.               RestartFlag = 0
  142.           END IF
  143.           
  144.           REM *****   Quit or not ? ****    
  145.           IF ASC(choice$) = 17 THEN 
  146.              QuitFlag = -1
  147.              GOTO EndPause
  148.           ELSE 
  149.              QuitFlag = 0 
  150.              GOTO ReChoose
  151.           END IF
  152.           
  153. EndPause: WINDOW OUTPUT 4  
  154.           WINDOW CLOSE 5
  155.           LOCATE 15,2: PRINT "Press <ESC> to Pause"
  156.          IF ResumeFlag THEN GOTO Main
  157.          IF RestartFlag THEN
  158.          LOCATE 16,2 
  159.          PRINT "Are you sure you want to"
  160.          PRINT " start a NEW test (Y/N) ?"
  161. Wait6:   Resp$ = INKEY$
  162.          IF Resp$ = "" THEN GOTO Wait6
  163.          IF (UCASE$(Resp$)<>"Y" AND UCASE$(Resp$)<>"N") THEN GOTO Wait6
  164.          LOCATE 16,2:
  165.          PRINT "                                            "
  166.          PRINT "                                            "
  167.          IF UCASE$(Resp$) = "N" THEN 
  168.            GOTO Main
  169.          ELSE 
  170.            GOSUB Startup
  171.            GOTO Main
  172.          END IF
  173.        END IF     
  174.        IF QuitFlag THEN  GOTO Quitter
  175.         
  176. RETURN 
  177.  
  178. REM ***** Startup and Restart Menu  *******
  179.  
  180. Startup:
  181. WINDOW 3,"MAIN MENU ",(0,0)-(310,180),0,2
  182. PRINT "    Make Your Selections"
  183. LOCATE 3,1
  184. PRINT " <F1> to take a Lesson"
  185. PRINT " <F2> to play a Game"
  186. PRINT " <F3> to raise the Level"
  187. PRINT " <F4> to lower the Level"
  188. PRINT " Press S to start a new run"
  189. IF FirstStart = 0 THEN  PRINT:PRINT " Press <ESC> to Resume  "
  190. IF ModeFlag = 1 THEN Mode$ = "Lesson"
  191. IF ModeFlag = 2 THEN Mode$ = "Game"
  192. LOCATE 11,2
  193. PRINT "Tutor Mode : ";Mode$;"   ";
  194. LOCATE 12,2
  195. PRINT "Level      : ";Level;"    ";
  196. redo:  Key$ = INKEY$
  197.        IF Key$ = "" THEN GOTO redo
  198.        Askey% = ASC(Key$)
  199.        IF FirstStart = 0 THEN
  200.           IF Askey% = 27 THEN GOTO CloseMainMenu
  201.        END IF
  202.        
  203.        REM **** check for ascii code of F1 ***
  204.        IF Askey% = 129 THEN
  205.          ModeFlag = 1
  206.          LOCATE 11,2: PRINT "Tutor Mode : Lesson";
  207.          GOTO redo
  208.        END IF
  209.        
  210.        REM ***  Check for ascii code of F2 ***
  211.        IF Askey% = 130 THEN
  212.          ModeFlag = 2
  213.          IF Level >= 4 THEN 
  214.            Level = 4
  215.            LOCATE 12,2
  216.            PRINT "Level      : ";Level;"   ";
  217.          END IF  
  218.          LOCATE 11,2: PRINT "Tutor Mode : Game    ";
  219.          GOTO redo
  220.        END IF
  221.        
  222.        REM ****  Check for ascii code of F3 ***
  223.        IF Askey% = 131 THEN
  224.          Level = Level + 1
  225.          IF ModeFlag = 2 THEN
  226.            IF Level >= 4 THEN Level = 4
  227.          END IF
  228.          IF ModeFlag = 1 THEN
  229.            IF Level >= 12 THEN Level = 12
  230.          END IF   
  231.          LOCATE 12,2: PRINT "Level      : ";Level;"   ";
  232.          GOTO redo
  233.        END IF
  234.        
  235.        
  236.        REM ***  check for ascii code of F3  ***
  237.        IF Askey% = 132 THEN
  238.          Level = Level - 1
  239.          IF Level <= 1 THEN Level = 1
  240.          LOCATE 12,2: PRINT "Level      : ";Level;"   ";
  241.          GOTO redo
  242.        END IF
  243.        
  244.        REM **** Don't Start a new game  ****
  245.        IF (Askey% <> 83 AND Askey% <> 115) THEN GOTO redo
  246.        
  247.        REM ****  Start A New Game  ****Redo  
  248.          IF ModeFlag = 1 THEN Mode$ = "Lesson"
  249.          IF ModeFlag = 2 THEN Mode$ = "Game"
  250.          LOCATE 15,1
  251.          PRINT "Start ";Mode$;" at Level#";Level;"(Y/N)?"
  252. Wait5: Resp$ = INKEY$
  253.        IF Resp$ = "" THEN GOTO Wait5
  254.        IF (UCASE$(Resp$)<>"Y" AND UCASE$(Resp$)<>"N") THEN GOTO Wait5 
  255.        IF UCASE$(Resp$) = "N" THEN 
  256.           LOCATE 15,1
  257.           PRINT "                                               "
  258.           GOTO redo
  259.        END IF 
  260.        REM ****   Startup Initialization  ****
  261.        WINDOW CLOSE 3
  262.        WINDOW OUTPUT 4
  263.        Speed = 800: Wrong = 0: Right = 0: Count = 0
  264.        Reseed = 0: Percent = 0: Points = 0: ActualTime = 0
  265.        GOSUB IScreenFill
  266.        FirstStart = 0 : REM **  Only on initial startup flag
  267.        GOSUB ArrayInitize
  268.        RETURN
  269.        
  270. CloseMainMenu: WINDOW CLOSE 3
  271.                WINDOW OUTPUT 4
  272.                RETURN
  273.                        
  274. REM *****  Character Array Initialization Routine  ****
  275.  
  276. ArrayInitize:
  277. REM *** this group of if statements dimensions the array **
  278. REM *** each level automatically knows how many characters 
  279. REM *** it uses  ****
  280. IF ModeFlag = 1 THEN
  281.   IF Level = 1 THEN MaxChars = 8 : REM *** Lesson 1
  282.   IF Level = 2 THEN MaxChars = 12 : REM *** Lesson 2
  283.   IF Level = 3 THEN MaxChars = 16 : REM *** Lesson 3
  284.   IF Level = 4 THEN MaxChars = 25 : REM *** Lesson 4
  285.   IF Level = 5 THEN MaxChars = 33 : REM *** Lesson 5
  286.   IF Level = 6 THEN MaxChars = 42 : REM *** Lesson 6
  287.   IF Level = 7 THEN MaxChars = 51 : REM *** Lesson 7 
  288.   IF Level = 8 THEN MaxChars = 60 : REM *** Lesson 8 
  289.   IF Level = 9 THEN MaxChars = 70 : REM *** Lesson 9 
  290.   IF Level = 10 THEN MaxChars = 79 : REM *** Lesson 10 
  291.   IF Level = 11 THEN MaxChars = 87 : REM *** Lesson 11 
  292.   IF Level = 12 THEN MaxChars = 92 : REM *** Lesson 12
  293.   RESTORE Lessons
  294. END IF
  295. IF ModeFlag = 2 THEN
  296.   IF Level = 1 THEN MaxChars = 36
  297.   IF Level = 2 THEN MaxChars = 72
  298.   IF Level = 3 THEN MaxChars = 81
  299.   IF Level = 4 THEN MaxChars = 89
  300.   RESTORE LCaseCharacters
  301. END IF
  302. MaxChars = MaxChars - 1  
  303. FOR arrayc = 0 TO MaxChars                              
  304.   READ NextChar$
  305.   Character$(arrayc) = NextChar$
  306. NEXT arrayc
  307. RETURN
  308.  
  309. REM  *****   Set the Restore to this label name to take lessons
  310. REM ****   There are 91 chars in all in this data section
  311. Lessons:
  312. DATA "a","s","d","f","j","k","l",";" : REM *** Lesson 1
  313. DATA "e","r","o","h"                 : REM *** Lesson 2
  314. DATA "c","t","i","m"                   : REM *** Lesson 3
  315. DATA "v",". period","A","S","D","F","E","R","C" : REM *** Lesson 4
  316. DATA "w","g","n",", comma","' apostrophe","W","G","V"     : REM *** Lesson 5
  317. DATA "J","K","L",": colon","S","b","u","T","I" : REM *** Lesson 6
  318. DATA "B","U","M","O","H","q","x","p","/ backslash" : REM *** Lesson 7
  319. DATA "z","y","?","Q","P","X","N","Z","Y" : REM *** Lesson 8
  320. DATA ">","<","[","]","{","}","3","4","7","8" :REM *** Lesson 9
  321. DATA "1","2","9","0","#","$","&","*","- hyphen" : REM ** Lesson 10
  322. DATA "5","6","!","@","(",")","_ underscore","=" : REM *** lesson 11
  323. DATA "%","^","+","\ slash","| bar" : REM ***  Lesson 12
  324.  
  325. REM  ***** Set the RESTORE to this label to do just 
  326. REM ****   characters with no shift  game.
  327. LCaseCharacters:
  328. DATA "a","b","c","d","e","f","g","h","i","j","k","l","m"
  329. DATA "n","o","p","q","r","s","t","u","v","w","x","y","z"
  330. DATA "1","2","3","4","5","6","7","8","9","0"
  331. DATA "A","B","C","D","E","F","G","H","I","J","K","L","M"
  332. DATA "N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
  333. DATA "!","@","#","$","%","^","&","*","(",")"
  334. DATA "- hyphen","=","\ slash","[","]","' apostrophe",", comma"
  335. DATA ". period","/ backslash"
  336. DATA "_ underscore","+","| bar","{","}","<",">","?"
  337.  
  338.  
  339.  
  340. REM  ********   Initialization Routine   **********
  341. Initize: REM *** Label ***
  342. SCREEN 2,320,200,2,1
  343. WINDOW 4,"Typing Tutor Window",(0,0)-(310,180),16,2
  344. CLS
  345. REM *****   disable breaks  ***
  346. BREAK ON
  347. ON BREAK GOSUB NoBreak
  348. REM *****   Set up the Palette of colors ***
  349. PALETTE 0,.73,.73,.67
  350. PALETTE 1,0,0,0
  351. PALETTE 2,1,1,1
  352. PALETTE 3,.4,.6,.93
  353. RANDOMIZE TIMER
  354. DIM Character$(256)
  355. FirstStart = 1: Level = 1: ModeFlag = 1
  356. GOSUB EraseMenu
  357. GOSUB Startup
  358. RETURN
  359.  
  360. REM *******  Initial ScreenFill Routine  *******
  361. IScreenFill: REM *** label ***
  362.  
  363. CLS
  364. LOCATE 2,2 : PRINT "Level: ";Level;" ";
  365. LOCATE 7,2 :  PRINT "TYPE THIS ->"
  366. LOCATE 10,2 : PRINT "Right : ";Right;"    ";
  367. LOCATE 11,2 : PRINT "Wrong : ";Wrong;"    ";
  368. LOCATE 2,15: PRINT "Points: ";Points;"       ";
  369. LOCATE 15,2: PRINT "Press <ESC> to Pause"
  370.  
  371. RETURN
  372.  
  373. REM *****   God said to Abraham, Kill me a Menu  *****
  374. REM *****  Abe said to God where d'ya want this killin' done **
  375. REM *****   God said out on Highway 61  ******
  376. REM ****   Program Menu   *****
  377.  
  378. EraseMenu:
  379. MENU 1,0,1,"  Options                       "
  380. MENU 1,1,1,"  Resume Test in Progress       "
  381. MENU 1,2,1,"  Start a New Test              "
  382. MENU 1,3,1,"  Quit this Program             " 
  383. MENU 1,0,1,"" : REM *** Remove This Line to Use Menu  ****
  384. MENU 2,0,0,""                                
  385. MENU 3,0,0,""
  386. MENU 4,0,0,""
  387. RETURN
  388.  
  389. REM **** NoBreak : The Break Handler ***
  390. NoBreak:
  391.         BEEP
  392.         RETURN
  393.          
  394. REM ******  Quitter Cleanup Subroutine   *******
  395.  
  396. Quitter:
  397.  
  398.  
  399. MENU RESET
  400. SCREEN CLOSE 2
  401.  
  402. END
  403.  
  404. RETURN
  405.