GWBasic mouse routine? 
Author Message
 GWBasic mouse routine?


GB> Can anyone point me towards a routine to read the mouse in GWBasic?
  > Or give some help on how to do it? Thanks

Try this...

--- cut here ---------------------------------------------------------------
100 ' MEESCALL.BAS  demonstrates how to call mouse functions in GW-BASIC
110 '
120 '   Author:     Christy Gemmell
130 '   Date:       15/9/1991
140 '
150 ' Load general-purpose interrupt service interface.
160 '
170 DEFINT A-Z: CLS: PRINT: KEY OFF
180 DIM REG.IN(7), REG.OUT(7)
190 AX = 0: BX = 1: CX = 2: DX = 3: SI = 4: DI = 5: DS = 6: ES = 7
200 SYSINT$ = SPACE$(116)
210 FOR X = 1 TO 116
220     READ A$: MID$(SYSINT$, X, 1) = CHR$(VAL("&H" + A$))
230 NEXT
240 '
250 '  Test out some mouse functions with it.
260 '
270 INT.NO = &H33   ' Microsoft Mouse driver interrupt number
280 '
290 '  Reset Mouse and get status
300 '
310 REG.IN(AX) = 0: GOSUB 770
320 IF REG.OUT(AX) = 0 THEN PRINT "Mouse not installed!": BEEP: STOP
330 PRINT "A"; REG.OUT(BX); "- button mouse is available"
340 PRINT "Turning on the Mouse pointer"
350 PRINT: PRINT "Press the <Esc> key to quit"
360 '
370 '  Show Mouse pointer
380 '
390 REG.IN(AX) = 1: GOSUB 770
400 '
410 ' Main control loop
420 '
430 IF INKEY$ = CHR$(27) THEN GOTO 600
440 '
450 '  Get Mouse pointer and button status
460 '
470 REG.IN(AX) = 3: GOSUB 770
480 LOCATE 10, 1: PRINT "X ="; REG.OUT(CX); " "
490 LOCATE 11, 1: PRINT "Y ="; REG.OUT(DX); " "
500 LOCATE 13, 1
510 IF REG.OUT(BX) = 1 THEN PRINT "Left Button Down" ELSE PRINT SPACE$(20)
520 LOCATE 14, 1
530 IF REG.OUT(BX) = 3 THEN PRINT "Centre Button Down" ELSE PRINT SPACE$(20)
540 LOCATE 15, 1
550 IF REG.OUT(BX) = 2 THEN PRINT "Right Button Down" ELSE PRINT SPACE$(20)
560 GOTO 430
570 '
580 '  Hide Mouse pointer
590 '
600 REG.IN(AX) = 2: GOSUB 770
610 END
620 '
630 '  Machine-language opcodes
640 '
650 DATA 55, 8B, EC, 8B, 5E, 0A, 8B, 07, 8B, 5E, 06, 8B, CB
660 DATA 8B, 5E, 08, 06, 1E, E8, 05, 00, 00, 00, CD, 00, C3
670 DATA 5D, 88, 46, 03, 89, 4E, 00, 8B, 4F, 04, 8B, 57, 06
680 DATA 8B, 77, 08, 8B, 7F, 0A, 8B, 47, 0E, 3D, FF, FF, 74
690 DATA 02, 8E, C0, 8B, 47, 0C, 3D, FF, FF, 74, 02, 8E, D8
700 DATA 36, 8B, 07, 36, 8B, 5F, 02, E8, CC, FF, 53, 8B, 5E
710 DATA 00, 36, 89, 07, 36, 8F, 47, 02, 8C, D8, 36, 89, 47
720 DATA 0C, 1F, 8C, C0, 89, 47, 0E, 07, 89, 4F, 04, 89, 57
730 DATA 06, 89, 77, 08, 89, 7F, 0A, 5D, CA, 06, 00, 00
740 '
750 '  Call machine-language routine
760 '
770 X = VARPTR(SYSINT$)
780 SYSINT! = PEEK(X + 1) + 256 * PEEK(X + 2)
790 CALL SYSINT!(INT.NO, REG.IN(0), REG.OUT(0))
800 RETURN
--- and here ---------------------------------------------------------------

The assembly-language routine that loads into SYSINT$ can actually
be used for lots more than just reading the mouse. In fact it is a
general-purpose routine that emulates QuickBASIC's CALL INTERRUPT
and can be used to access any DOS or BIOS interrupt function.

+------------------------+-----------------------------------------------+
|     _/_/_/_/  _/_/_/_/ | Christy Gemmell, Singular Software            |
|    _/        _/        | 11 Abingdon Road, Leicester LE2 1HA, England. |


| _/_/_/_/  _/_/_/_/     | Phone: +44-0116-254-7681                      |
+------------------------+-----------------------------------------------+

 * 1st 2.00o #323 * The British celebrate Thanksgiving on the 4th July.



Tue, 02 Dec 1997 03:00:00 GMT  
 GWBasic mouse routine?
I will try it, many thanks in advance....
J Blessing ASE Master Tech


Wed, 03 Dec 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Examples mouse in gwbasic programs?

2. Mouse in GWBasic?

3. GWBASIC (1/1) - gwbasic.zip [2/2]

4. GWBASIC (1/1) - gwbasic.zip [1/2]

5. Help - routine for mouse input

6. Video / Mouse Routine

7. Mouse Routines

8. Mouse routines/functions in QB4.5?

9. Mouse routines/functiuns in QB4.5?

10. IMPORTANT!: Mouse routines needed...

11. Easy mouse routines demo.

12. Have qbasic mouse routines - help with cursor!

 

 
Powered by phpBB® Forum Software