EasyManua.ls Logo

Commodore Amiga - Page 229

Commodore Amiga
321 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Readiug
tke
COunters
The
mouse/trackball counter contents can be accessed by reading register addresses
named JOYODAT and JOYIDAT. These contain the counts for the left
(0)
and the
right
(1)
controller ports.
The
contents of each of these 16-bit registers are as follows:
Bits 15-8
Bits 7-0
Mouse/trackball vertical count
Mouse/trackball horizontal count
Counter
Limitations
These counters will "wrap around" in either the positive or negative direction.
If
you
wish
to
use the mouse to control something
that
is happening on the screen, you must
read the counters once each vertical blanking period and save the previous contents of
the registers. Then you can subtract
to
determine direction of movement and speed.
The
counter contents must be read once each vertical blanking time to find
out
if the
user moved the mouse since counters were last read.
The
mouse produces about
200
count pulses per inch of movement in either a horizontal
or vertical direction. Vertical blanking happens once each
1/60th
of a second.
If
you
read the mouse once each vertical blanking period, you will most likely find a count
difference (from the previous count) of less than 127. (Only if a user moves the mouse
at
a speed of more than
72
inches per second will
it
exceed this
count-an
unlikely hap-
pening).
If
you
subtract
the current count from the previous count, the absolute value of the
difference will represent the speed. The sign of the difference (positive or negative),
along with the sign of the previous and current values, lets you determine which direc-
tion the mouse is traveling.
The
example shown in table
8-1
treats both counts as unsigned values, ranging from 0 to
255.
A count of 100 pulses is measured in each case.
218
Interface Hardware

Table of Contents

Other manuals for Commodore Amiga

Related product manuals