Page 1 of 1

Mouse Routine

Posted: Thu Feb 25, 2010 3:19 pm
by qbasicfreak
I'm looking for a mouse routine for my qmunication program. What is the best, and preferably easiest mouse routine to set up and use?

Thanks
Qbasicfreak

Posted: Thu Feb 25, 2010 3:36 pm
by burger2227
Use an ABSOLUTE routine if you want compatiblity with QBASIC. Quickbasic can use Interrupt also, but programs must use the library.

QB64 offers a simple mouse routine, but does not allow some functions that Absolute or Interrupt can offer like moving the mouse cursor or limiting the mouse area.

Here is a simpler way to use Absolute mouse:

Code: Select all

DEFINT A-Z
DIM a(10) AS LONG, x1 AS SINGLE
a(0) = &H8BE58955
a(1) = &H33CD0C46
a(2) = &H890A768B
a(3) = &H8768B1C
a(4) = &H768B0C89
a(5) = &H5D148906
a(6) = &H8CA
a(7) = &H8EA800B8
a(8) = &H31FF31C0
a(9) = &H36B0B9C0
a(10) = &HCBABF3
DEF SEG = VARSEG(a(0))
k = 1
SCREEN 9, , 1, 0
CALL absolute(BYVAL 2, mb, mx, my, VARPTR(a(0)))
DO
t! = TIMER + .04
CALL absolute(BYVAL 3, mb, mx, my, VARPTR(a(0)))
x1 = (mx - 320) * .01 - .4
CALL absolute(VARPTR(a(7)))
k = k XOR 3
m1! = SIN(l * .001) * 1000
FOR j = 3 TO 50 STEP 2
z = 700 \ (j - k)
FOR i = 0 TO 8
IF l < 32767 THEN l = l + 1 ELSE l = 0
m! = SIN(l * .001) * 1000 - m1!
x = COS(i * .4 + x1 - m! * .007) * z
y = SIN(i * .4 + x1 - m! * .007) * z
LINE -(x + 300 + m!, y + 100 + m!), i <> 0 * -15
NEXT
NEXT
PCOPY 1, 0
1 IF TIMER < t! THEN 1
LOOP UNTIL INP(&H60) = 1
SYSTEM                       'code by Ben
Ted

Posted: Sat Feb 27, 2010 7:03 am
by qbasicfreak
Thanks!
Qbasicfreak

Re: Mouse Routine

Posted: Mon Mar 09, 2015 7:14 pm
by veganaiZe
I have made a QBasic SUB called "mouse" that I consider to be "the best and easiest mouse routine to setup and use". It is documented here:
http://staticchaos.awardspace.com/basic/qbmouse.php

It sets up a minimal block of machine language (fully commented) and is accessed via CALL ABSOLUTE(ax, bx, cx, dx, offset%). It mimics the first 4 sub-functions of DOS INT 33h and is a good resource for anyone who wants a simple, yet effective mouse routine for QBasic or QuickBasic. I think it is especially valuable for someone who wants to be able to actually understand what the code is doing as well.