' Public Domain by Erik Olson ' MOUSE routines for graphics screens. See remarks in code for text mode 'FUNCTION MouseInitialize% ' Initialize the mouse with this function. Returns TRUE if successful 'SUB MouseShowCursor ' Make the cursor visible with this procedure 'SUB MouseHideCursor ' Hide the cursor (do this before any screen writes in your program) 'SUB MouseInformation (Rgt%, Lft%, Row%, Col%) ' Returns the current position and button status of the mouse 'SUB MouseMoveCursor (Row%, Col%) ' Move the cursor to this position 'SUB MouseTimesPressed (Button%, NumberTimes%, Row%, Col%) ' Returns the number of times a button was pressed since last call 'SUB MouseHorizontalRange (Rgt%, Lft%) ' Adjust the allowed screen area for the mouse cursor 'SUB MouseVerticalRange (Top%, Bottom%) ' Adjust the allowed screen area for the mouse cursor '=======DRAW: Sample Mouse Program======================================= IF NOT MouseInitialize% THEN PRINT "No mouse...":END SCREEN 12 CALL MouseShowCursor CALL MouseVerticalRange(5,400) CALL MouseHorizontalRange(5,634) LOCATE 27,1:PRINT " Left Button = Draw lines"; LOCATE 28,1:PRINT "Right Button = Draw Pixels"; LOCATE 30,75:PRINT "DRAW!"; LINE (0,0)-(4,405),2,BF LINE (0,0)-(639,4),2,BF LINE (635,0)- (639,405),2,BF LINE (0,401)-(639,405),2,BF DO CALL MouseInformation(Rgt%, Lft%, Row%, Col%) LOCATE 27,40:PRINT Row%;" ";Col%; IF Rgt% THEN PSET(Col%, Row%) If Lft% THEN IF Pcol% > 0 and Prow% > 0 THEN CALL MouseHideCursor LINE (Pcol%, Prow%)-(col%, Row%) CALL MouseShowCursor END IF Pcol%=col%:Prow%=Row% END IF a$=inkey$: if a$=chr$(27) THEN EXIT LOOP LOOP ' ======== [ MOUSE CONTROL ROUTINES BEGIN HERE ] ========================== FUNCTION MouseInitialize% REG 1,0 CALL INTERRUPT &H33 MouseInitialize%=REG(1) END FUNCTION SUB MouseShowCursor REG 1,1 CALL INTERRUPT &H33 END SUB SUB MouseHideCursor REG 1,2 CALL INTERRUPT &H33 END SUB SUB MouseInformation (Rgt%, Lft%, Row%, Col%) Rgt%=0: Lft%=0 REG 1,3 CALL INTERRUPT &H33 SELECT CASE REG(2) CASE 1 Lft%=1 CASE 2 Rgt%=1 CASE 3 Lft%=1 Rgt%=1 END SELECT Row%=REG(4) '\ 8 + 1 ' <------- Unremark for text mode Col%=REG(3) '\ 8 + 1 ' END SUB SUB MouseMoveCursor (Row%, Col%) REG 4, 8 * (Row% - 1) REG 3, 8 * (Col% - 1) REG 1, 4 CALL INTERRUPT &H33 END SUB SUB MouseTimesPressed (Button%, NumberTimes%, Row%, Col%) REM Button% should be 0 to return left button info, 1 for right REG 2, Button% REG 1, 5 CALL INTERRUPT &H33 NumberTimes% = REG(2) Row% = REG(4) '\ 8 + 1 '<-----------unremark for text mode Col% = REG(3) '\ 8 + 1 END SUB SUB MouseHorizontalRange (Rgt%, Lft%) REG 3, Rgt% REG 4, lft% REG 1, 7 CALL INTERRUPT &H33 END SUB SUB MouseVerticalRange (Top%, Bottom%) REG 3, Top% REG 4, Bottom% REG 1, 8 CALL INTERRUPT &H33 END SUB