DECLARE SUB CloseProg () DECLARE SUB Center (y%, prnt$) DECLARE FUNCTION Initialize% () 'Req'd for Mouse DECLARE SUB MouseDriver (ax%, bx%, cx%, dx%) 'Req'd for Mouse DECLARE SUB CursorOff () 'Req'd for Mouse DECLARE SUB CursorOn () 'Req'd for Mouse DECLARE SUB Getmouse (lb%, rb%, xmouse%, ymouse%) 'Req'd for Mouse DIM SHARED Mouse$, lb%, rb%, xmouse%, ymouse% ' Fill up the mouse's Mouse$ = SPACE$(57) ' init string FOR i% = 1 TO 57 READ a$ H$ = CHR$(VAL("&H" + a$)) MID$(Mouse$, i%, 1) = H$ NEXT i% DATA 55,89,E5,8B,5E,0C,8B,07,50,8B,5E,0A,8B,07,50,8B 'Mouse Data DATA 5E,08,8B,0F,8B,5E,06,8B,17,5B,58,1E,07,CD,33,53 DATA 8B,5E,0C,89,07,58,8B,5E,0A,89,07,8B,5E,08,89,0F DATA 8B,5E,06,89,17,5D,CA,08,00 MakeMenu: CLS ' END the program if ms% = Initialize% ' there's no mouse. IF NOT ms% THEN SCREEN 0 Center 13, "Mouse not found. Cannot execute test." END END IF a = 1 LOCATE 1, 80: PRINT "X" LOCATE 1, 25: PRINT "(-1 means the button is clicked)" LOCATE 2, 25: PRINT "(0 means the button is not clicked)" Center 9, "Patz QuickBasic Creatioms - Mouse Test Proogram" Center 11, "This tests the status of your mouse in DOS." Center 12, "The status is displayed in the upper-left corner." Center 15, "Click the X in the upper-right corner to quit." Center 13, "You can use the mouse and center routines included in this program" Center 14, "in your own programs as long as PQBC and UWLabs get credit." Center 19, "Color tests:" CursorOn WHILE a < 16 LOCATE 20, a * 5: COLOR 7, a: PRINT " " LOCATE 21, a * 5: COLOR a, 0: PRINT "PQBC" a = a + 1 WEND COLOR 7, 0 Center 23, "Special thanks to UWLabs." WHILE poop$ <> CHR$(de) looper: CALL Getmouse(lb%, rb%, xmouse%, ymouse%) LOCATE 1, 2: PRINT "Left button: "; lb% LOCATE 2, 2: PRINT "Right Button: "; rb% LOCATE 3, 2: PRINT "X-Position: "; xmouse% LOCATE 4, 2: PRINT "Y-Position: "; ymouse% one = lb% two = rb% thr = xmouse% fou = ymouse% WHILE one = lb% AND two = rb% AND thr = xmouse% AND fou = ymouse% CALL Getmouse(lb%, rb%, xmouse%, ymouse%) WEND IF lb% = -1 AND xmouse% = 80 AND ymouse% = 1 THEN CloseProg IF rb% = -1 AND xmouse% = 80 AND ymouse% = 1 THEN CloseProg GOTO looper WEND SUB Center (y%, prnt$) LET centervar = LEN(prnt$) / 2 LET centervar = INT(centervar) LET centervar = 40 - centervar LOCATE y%, centervar: PRINT prnt$ END SUB SUB CenterWFill (txt%, bkg%, y%, prnt$) LET centervar = LEN(prnt$) / 2 LET centervar = 40 - centervar COLOR txt%, bkg%: LOCATE y%, 1: PRINT SPACE$(centervar); prnt$; LET red = centervar PRINT SPACE$(centervar) END SUB SUB CloseProg CALL CursorOff CLS END END SUB SUB CursorOff ' Turns OFF the mouse Cursor ' NOTE: Turning it OFF twice will make it STAY that way! ax% = 2 MouseDriver ax%, 0, 0, 0 END SUB SUB CursorOn ' Turns the Mouse Cursor back ON. ax% = 1 MouseDriver ax%, 0, 0, 0 END SUB SUB Getmouse (lb%, rb%, xmouse%, ymouse%) ' ' "gets" the mouse coodinates and button clicks. ' Place this sub in all your loops. ' ' A button press returns a value of -1 ' ax% = 3 MouseDriver ax%, bx%, cx%, dx% lb% = ((bx% AND 1) <> 0) rb% = ((bx% AND 2) <> 0) xmouse% = (cx% / 8) + 1 'If you decide to use the mouse in GRAPHICS mode, ymouse% = (dx% / 8) + 1 'comment these two lines, ' xmouse% = cx% + 1 ' --\___ and un-comment out these. 'ymouse% = dx% + 1 ' --/ END SUB FUNCTION Initialize% ' Init's the mouse driver - needed only once. ax% = 0 MouseDriver ax%, 0, 0, 0 Initialize% = ax% END FUNCTION SUB Limits (x1%, y1%, x2%, y2%) ' ' Sets up limits for the mouse on the screen, restricting ' cursor movement. ' (For GRAPHICS mode, rem out the "* 8" multipliers.) ' ax% = 7 cx% = (x1% - 1) * 8 dx% = (x2% - 1) * 8 MouseDriver ax%, 0, cx%, dx% ax% = 8 cx% = (y1% - 1) * 8 dx% = (y2% - 1) * 8 MouseDriver ax%, 0, cx%, dx% END SUB SUB MouseDriver (ax%, bx%, cx%, dx%) ' ' Defines the mouse driver, used once at program start. ' DEF SEG = VARSEG(Mouse$) Mouse% = SADD(Mouse$) CALL Absolute(ax%, bx%, cx%, dx%, Mouse%) END SUB