BBC Mouse operation

discussion of beeb/electron applications, languages, utils and educational s/w
rharper
Posts: 290
Joined: Sat Sep 01, 2012 5:19 pm
Location: Dunstable
Contact:

BBC Mouse operation

Postby rharper » Fri Jul 28, 2017 4:39 pm

I have written some software to work with a mouse using J.G. Harston's MOUSROM which uses ADVAL, INKEY or OSWORD 64 to retrieve the values and which works fine.
I thought I would try to find out how the mouse worked.
I have set &FE62=0 and read &FE60.
This uses bits 5-7 for the button presses, bits 0 & 2 change with mouse movement, the others appear to be unused.
Looking at the wiring for the user port it looks like bits 0 & 2 are for X and Y direction.
Bits in &FE6A change with mouse movement.
Does anyone know how this ties together to get the up/down/left/right movement?
Thanks,
Ray :)
Raycomp

User avatar
1024MAK
Posts: 6678
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: BBC Mouse operation

Postby 1024MAK » Fri Jul 28, 2017 5:56 pm

The Beeb (and some of the Arcs) use quadrature mice. Also known in the IBM PC world as bus mice. Various other home computers also use them (Atari ST/TT series, Commodore Amiga, and various add on mice interfaces for ZX Spectrum and Amstrad CPC computers).

This article gives an overview of how they work: http://www.lintech.org/comp-per/05MS.pdf

So there are TWO X movement inputs and TWO Y movement inputs. By working out which which changes first, with respect to the other input, the system can work out the direction of movement. By counting the pulses, it can work out the distance.

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
jgharston
Posts: 2658
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: BBC Mouse operation

Postby jgharston » Fri Jul 28, 2017 9:12 pm

A quadrature mouse generates four movement signals "moved horizontally", "horizontal direction", "moved vertically", "vertical direction".

You would normally wire this to generate two interupts "moved horiztonally" and "moved vertically".
When you receive a "moved horiztonally" interupt you check the "horizontal movement" signal to decide which way the mouse has moved horizontally, and when you receive the "moved vertically" interupt you check the "vertical movement" signal to decide which way the mouse has moved vertically.

The actual signals aren't particualrly special, in the mouse circuitry the signals for an axis are just generated from the same motion dectector, offset by 90 degrees, and when the mouse moves in one direction they are offset +90 and when it moves the other they are offset -90, so resulting in that after the pulse of one, the other tells you the direction. So, you use one to generate an interupt and the other is samples by the interupt code to discover the direction.

Something like this:

Code: Select all

     IRQ   IRQ   IRQ   IRQ            IRQ   IRQ   IRQ
      v     v     v     v              v     v     v     v
  +--+  +--+  +--+  +--+           +--+  +--+  +--+  +--+
  |  |  |  |  |  |  |  |           |  |  |  |  |  |  |  |
--+  +--+  +--+  +--+  +--       --+  +--+  +--+  +--+  +--

    +--+  +--+  +--+  +--+        +--+  +--+  +--+  +--+   
    |  |  |  |  |  |  |  |        |  |  |  |  |  |  |  |   
  --+  +--+  +--+  +--+  +--    --+  +--+  +--+  +--+  +--

      ^     ^     ^     ^              ^     ^     ^     ^

If you use the top signal to generate an interupt and sample the bottom signal on the interupt, that tells you which direction the motion is.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

rharper
Posts: 290
Joined: Sat Sep 01, 2012 5:19 pm
Location: Dunstable
Contact:

Re: BBC Mouse operation

Postby rharper » Sat Jul 29, 2017 1:39 pm

Thanks for the replies.
A final Q - Is the data in &FE6A related to the direction and the number of pulses counted?
Ray
Raycomp

User avatar
jgharston
Posts: 2658
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: BBC Mouse operation

Postby jgharston » Sun Jul 30, 2017 6:53 pm

rharper wrote:Thanks for the replies.
A final Q - Is the data in &FE6A related to the direction and the number of pulses counted?
Ray
&FE6A is the Shift Register. It uses pulses on CB1 to shift in bits on CB2. Irrelevant for the quadrature mouse as CB1 and CB2 are the interupts telling the Beeb to look at PB0 and PB2. The shift register will change as every time you move the mouse horizontally the Shift Register will sample the vertical motion. There's nothing you can usefully do with this information. The useful information is in the data register, PB0/2 for the direction, PB5/6/7 for the buttons (or PB0-PB4 on the Compact/Marconi).

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

rharper
Posts: 290
Joined: Sat Sep 01, 2012 5:19 pm
Location: Dunstable
Contact:

Re: BBC Mouse operation

Postby rharper » Mon Jul 31, 2017 11:28 am

Thanks Jonathan
Ray
Raycomp


Return to “software: other”

Who is online

Users browsing this forum: No registered users and 3 guests