Mouse Routine

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
qbasicfreak
Veteran
Posts: 90
Joined: Wed Oct 22, 2008 3:27 pm
Location: canada

Mouse Routine

Post 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
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post 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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
qbasicfreak
Veteran
Posts: 90
Joined: Wed Oct 22, 2008 3:27 pm
Location: canada

Post by qbasicfreak »

Thanks!
Qbasicfreak
veganaiZe
Newbie
Posts: 1
Joined: Mon Mar 09, 2015 7:00 pm

Re: Mouse Routine

Post 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.
Post Reply