Mouse Control
Pascal, being a language that is
now reaching several decades in its incarnation
as Pascal 6.0, is a language that has no basic
facility for mouse control. In the modern computing
world the mouse is all important, and surplants
the keyboard whereever the more simple visual
input device can be used appropriately. It is
therefore necessary, particularly when writing
application program in pascal, to include mouse
control in order to avoid the severe frustration
of a user that is forced to learn a serious of
tedious and laborious keyboard shortcuts. Fortunately,
with these units, adding mouse control is not
as difficult as it may seem to the beginner. Although
to read and recognise movements of the mouse an
interupt must be set up, that runs every time
the mouse is manipulated, once this is established
the actual code for the drawing of the pointer
is remarkably simple, and only slightly more complex
in SVGA. Even this is not necessary, however:
there are numerous high quality mouse units available
accross the internet, and I present two of the
best of them here for your experimentation. The
first, designed for use with MCGA, was my mouse
unit of choice when writing many of my early applications
such as Canvas 2.4 and the Trooper II
level editor, and was originally part of the excellent
graphical units by Kevin A. Lee. The second, scripted
purely by myself, uses assembler routines coded
into the interupt to provide a very rapid, entirely
reliable mouse pointer for much with SVGA. In
my unit, the pointer can be changed at will to
any configuration by assigning variables to arrays
of bytes representing the pointer. In both the
units, the mouse can be shown and hidden (vital
for drawing processes - if the mouse is drawn
on top of then the drawn section will be disturbed
when the mouse is next moved), confined to a certain
bounded region on the screen, moved around automatically,
and all importantly, its position on the screen
detected as well as the state of any of its buttons.
Both the units are totally compatible with the
existing MCGA and SVGA graphics libraries, and
can simply can added to programs by invoking the
initialize routines after the graphics engine
has been started. All mouse pointers are drawn
in palette colour 15, so the colour of the mouse
can also be changed without disturbing the mouse
unit. The MCGA download contains an exemplar program
that demonstrates the basics (which is effectively
everything) of mouse control, but since the program
isn't actually mine I've omitted the source code.
The SVGA unit has no exemplar program, but has
full and completely transparent source. Both of
these mouse units are desgined for use with the
corresponding graphics engines. Have fun, Jon
Download
the mouse unit for MCGA (7 Kb, zipped) | Back
to Tools & Units
Download the mouse unit for SVGA (4 Kb, zipped)