EduGateway(TM) "MouseHit" Program


This little program was written in 1995 to teach mouse skills on XT-class computers (pre-windows). The program runs like a game and keeps score of the proper number of hits and misses. A letter will appear at a random position on the screen and the player must take the appropriate action to score points. This table shows the letters, points, and actions:

Letter Value Action
0 1 point Move the mouse onto the 0 - no clicking required
L 1 point Click the LEFT mouse button on the L once quickly
R 1 point Click the RIGHT mouse button on the R once quickly
* 5 points Click BOTH mouse buttons on the * at the same time

The program deducts points for any mistakes.

This program demonstrates how to display non-ASCII characters, pause the computer, play sounds, and read the mouse in text mode. This program has very few comments and may be a bit difficult for beginners to understand. But it is useful for teaching mouse skills (especially on older computers like the XT).



DECLARE SUB WelcomeScreen ()
DEFINT A-Z


DEF SEG = 0

' Set up for the mouse calls

DIM MSEG AS INTEGER, MOUSE AS INTEGER
DIM M1 AS INTEGER, M2 AS INTEGER, M3 AS INTEGER, M4 AS INTEGER
MSEG = 256 * PEEK(51 * 4 + 3) + PEEK(51 * 4 + 2)
MOUSE = 256 * PEEK(51 * 4 + 1) + PEEK(51 * 4) + 2

DIM row AS INTEGER, col AS INTEGER, buttons AS INTEGER
DIM lrow AS INTEGER, lcol AS INTEGER, lbuttons AS INTEGER
lrow = -1: lcol = -1: lbuttons = -1
DIM RandVal AS SINGLE
DIM passnum AS INTEGER
passnum = 1

CLS


IF (MSEG OR (MOUSE - 2)) = 0 THEN
  PRINT "Mouse Driver Not Found"
  END
END IF

DEF SEG = MSEG
IF PEEK(MOUSE - 2) = 207 THEN
  PRINT "Mouse Driver Not Found"
  END
END IF

M1 = 30: M2 = 0: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
M1 = 0: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
M1 = 1: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)

M1 = 2: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
CALL WelcomeScreen
M1 = 1: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)

RANDOMIZE TIMER

Score = 0
lscore = -1
Done = 0
DO
 
  M1 = 2: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
  CLS
  M1 = 1: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)

  IF passnum <= 4 THEN
   
    ' Pick special targets for practice
    SELECT CASE passnum
      CASE IS = 1
        TargButton = 0: TargRow = 10: TargCol = 18
        LOCATE 10, 20: PRINT "<-- Practice: Just move the mouse onto this '0'";
      CASE IS = 2
        TargButton = 1: TargRow = 17: TargCol = 23
        LOCATE 17, 25: PRINT "<-- Practice: Click the Left mouse button on the 'L'";
      CASE IS = 3
        TargButton = 2: TargRow = 2: TargCol = 2
        LOCATE 2, 4: PRINT "<-- Practice: Click the Right mouse button on the 'R'";
      CASE IS = 4
        TargButton = 3: TargRow = 19: TargCol = 10
        LOCATE 19, 12: PRINT "<-- Practice: Click Both mouse button on the '*'";
    END SELECT
    LOCATE 22, 44: PRINT "Your score will change here "; CHR$(196); CHR$(196); CHR$(196); CHR$(196); CHR$(191);
    LOCATE 23, 44: PRINT "                                "; CHR$(179);
    LOCATE 24, 44: PRINT "                                "; CHR$(179);
    passnum = passnum + 1
 
  ELSE
   
    IF passnum = 5 THEN
      passnum = passnum + 1
      Score = 0
    END IF

    ' Pick a random target row, column, and button number
    RandVal = RND
    RandVal = RandVal * RandVal
    TargRow = 1 + (RandVal * 23)
    IF TargRow > 23 THEN
      TargRow = 23
    END IF
    TargCol = 1 + (RND * 79)
    'TargButton = RND * 3
    TargButton = RND * 100
    IF TargButton < 40 THEN
      TargButton = 1 'Left
    ELSEIF TargButton < 40 + 20 THEN
      TargButton = 2 'Right
    ELSEIF TargButton < 60 + 30 THEN
      TargButton = 0 'None
    ELSE
      TargButton = 3 'Both
    END IF
 
  END IF

  LOCATE 25, 1
  PRINT "0=None:+1  L=Left:+1  R=Right:+1  *=Both:+5  Miss:-10   Esc=Quit";
  LOCATE 25, 69
  PRINT "Score="; Score;
 
  LOCATE TargRow, TargCol, 0
  IF TargButton = 1 THEN
    M1 = 2: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
    PRINT "L";
    M1 = 1: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
  ELSEIF TargButton = 2 THEN
    M1 = 2: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
    PRINT "R";
    M1 = 1: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
  ELSEIF TargButton = 3 THEN
    M1 = 2: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
    PRINT "*";
    M1 = 1: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
  ELSE
    TargButton = 0
    M1 = 2: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
    PRINT "0";
    M1 = 1: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
  END IF

  Hit = 0
  DO
    M1 = 3: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)
    col = 1 + (M3 \ 8)
    row = 1 + (M4 \ 8)
    buttons = M2
    IF (row <> lrow) OR (col <> lcol) OR (buttons <> lbuttons) THEN
      REM LOCATE 25, 1
      REM PRINT "Row:"; row; " Column:"; col; " Buttons:"; buttons;
      lrow = row: lcol = col: lbuttons = buttons
    END IF
    IF (row = TargRow) AND (col = TargCol) AND (buttons = TargButton) THEN
      Hit = 1
      PLAY "L50bag"
      IF TargButton = 3 THEN
        PLAY "L8eg"
        Score = Score + 5
      ELSE
        PLAY "P50"
        Score = Score + 1
      END IF
    ELSEIF (buttons <> 0) AND (TargButton <> 3) THEN
      PLAY "L64<>"
      Score = Score - 10
    END IF
    IF Score <> lscore THEN
      LOCATE 25, 69
      PRINT "Score="; Score;
      lscore = Score
    END IF
    IF (INKEY$ = CHR$(27)) THEN
      Done = 1
    END IF
  LOOP UNTIL Done OR Hit
LOOP UNTIL Done

M1 = 0: CALL ABSOLUTE(M1, M2, M3, M4, MOUSE)

CLS
LOCATE 1, 1
PRINT "Your final score was"; Score
PRINT ""

SUB WelcomeScreen

  DIM time AS SINGLE

  DIM vv AS STRING * 1: vv = CHR$(179)
  DIM hh AS STRING * 1: hh = CHR$(196)
  DIM tu AS STRING * 1: tu = CHR$(193)
  DIM td AS STRING * 1: td = CHR$(194)
  DIM tl AS STRING * 1: tl = CHR$(180)
  DIM tr AS STRING * 1: tr = CHR$(195)
  DIM ll AS STRING * 1: ll = CHR$(192)
  DIM lr AS STRING * 1: lr = CHR$(217)
  DIM ul AS STRING * 1: ul = CHR$(218)
  DIM ur AS STRING * 1: ur = CHR$(191)
  DIM xx AS STRING * 1: xx = CHR$(197)
  DIM ss AS STRING * 1: ss = " "

  vv = CHR$(186)
  hh = CHR$(205)
  tu = CHR$(202)
  td = CHR$(203)
  tl = CHR$(185)
  tr = CHR$(204)
  ll = CHR$(200)
  lr = CHR$(188)
  ul = CHR$(201)
  ur = CHR$(187)
  xx = CHR$(206)
  ss = " "
 
  CLS

  LOCATE 1, 1, 0
  REM   "              "; W                                   E                       L                       C                       O                       M                           E
  PRINT "              "; ur; ss; ss; ss; ss; ss; ul; ss; ss
  PRINT "              "; vv; ss; ss; ss; ss; ss; vv; ss; ss; ul; hh; hh; ur; ss; ss; ur; ss; ss; ss; ss; ss; ul; hh; hh; ur; ss; ss; ul; hh; hh; ur; ss; ss; ul; hh; td; hh; ur; ss; ss; ul; hh; hh; ur
  PRINT "              "; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; vv; ss; vv; ss; ss; vv
  PRINT "              "; vv; ss; ss; vv; ss; ss; vv; ss; ss; tr; hh; hh; ss; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; vv; ss; vv; ss; ss; tr; hh; hh
  PRINT "              "; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; vv; ss; vv; ss; ss; vv
  PRINT "              "; ll; hh; hh; tu; hh; hh; lr; ss; ss; ll; hh; hh; lr; ss; ss; ll; hh; hh; hh; ss; ss; ll; hh; hh; lr; ss; ss; ll; hh; hh; lr; ss; ss; lr; ss; ss; ss; ll; ss; ss; ll; hh; hh; lr

  LOCATE 9, 1, 0
  REM   "                              "; t                       o
  PRINT "                              "; ss; ss; vv; ss; ss; ss
  PRINT "                              "; hh; hh; xx; hh; hh; ss
  PRINT "                              "; ss; ss; vv; ss; ss; ss; ul; hh; hh; ur
  PRINT "                              "; ss; ss; vv; ss; ss; ss; vv; ss; ss; vv
  PRINT "                              "; ss; ss; ll; ss; ss; ss; ll; hh; hh; lr

  LOCATE 16, 1, 0
  REM   "           "; M                                   O                       U                       S                       E                               H                           I           T
  PRINT "           "; ul; hh; hh; td; hh; hh; ur; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ur; ss; ss; ss; ul; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss; ss
  PRINT "           "; vv; ss; ss; vv; ss; ss; vv; ss; ss; ul; hh; hh; ur; ss; ss; ur; ss; ss; ul; ss; ss; ul; hh; hh; ur; ss; ss; ul; hh; hh; ur; ss; ss; ss; ss; vv; ss; ss; ss; vv; ss; ss; td; ss; ss; ul; hh; td; hh; ur; ss
  PRINT "           "; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; ss; ss; ss; ss; ss; tr; hh; hh; hh; tl; ss; ss; vv; ss; ss; ss; ss; vv; ss; ss; ss
  PRINT "           "; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; ll; hh; hh; ur; ss; ss; tr; hh; hh; ss; ss; ss; ss; ss; vv; ss; ss; ss; vv; ss; ss; vv; ss; ss; ss; ss; vv; ss; ss; ss
  PRINT "           "; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; vv; ss; ss; ss; ss; ss; vv; ss; ss; vv; ss; ss; ss; ss; ss; ss; ss; vv; ss; ss; ss; vv; ss; ss; vv; ss; ss; ss; ss; vv; ss; ss; ss
  PRINT "           "; lr; ss; ss; ss; ss; ss; ll; ss; ss; ll; hh; hh; lr; ss; ss; ll; hh; hh; lr; ss; ss; ll; hh; hh; lr; ss; ss; ll; hh; hh; lr; ss; ss; ss; ss; lr; ss; ss; ss; ll; ss; ss; tu; ss; ss; ss; ss; tu; ss; ss; ss

  LOCATE 24, 6, 0
  PRINT "This program is the Intellectual Property of Robert M. Kuczewski";
  LOCATE 25, 20, 0
  PRINT "Copyright 1995 - All Rights Reserved";

  FOR i% = 440 TO 1000 STEP 5
    SOUND i%, i% / 30000
  NEXT i%

  REM PLAY "MB O1"
  REM PLAY "l4cf.l8fl4fag.l8fl4gaf.l8fl4a>cl2d.l4dc. Just move onto the letter - no clicking required (1 point)"
  PRINT "     L => Click the LEFT mouse button quickly              (1 point)"
  PRINT "     R => Click the RIGHT mouse button quickly             (1 point)"
  PRINT "     * => Click the BOTH mouse buttons at the same time    (5 points)"
  PRINT "  Any mistakes will cost you 10 points - so try to be accurate!"
  PRINT "  Please report any problems and/or suggestions. ---  Thanks for your help!"
  PRINT ""
  PRINT "                      Press the space bar to continue...";


  DO
  LOOP WHILE INKEY$ <> ""
  DO
  LOOP WHILE INKEY$ <> " "

END SUB


You can use your web browser to copy this program to the clipboard (Click and Drag to Select, then Copy). Then paste it into any text editor (like Windows Notepad), and save it in a file called "mousehit.bas". Then use DOS QBASIC to open the file and run it.

Click here to view some example screens from the program.


© 1995-2001 EduGateway(TM)