Campston Mouse Interface - diagram from Spectrophone.

Hacker #07
 Kempston Mouse Interface.                              .IRON 
                                                                
 The following text was cruelly torn from a certain magazine
SPECTR0F0N, since the diagram is drawn really correctly and
ok.                                                      
                                                                
             DD1 DDS                               
         5┌──┬──┬─┐ b 2┌──┬──┬─┐18 D0                       
     ┌────oCa│ST│0├────────┤D1│|>│1├─────╢                      
Хь ─┴─ 15├──┤ │ │11 4│ │ │ │1b D1║                      
 ──┬──────/С │ │1├────────┤D2│ │2├─────╢                      
Ha │ 10│ │ │ │14 b│ │ │ │14 D2║                      
 ───┬─────┤U/D │2├────────┤D3│ │3├─────╢                      
   ││ 9├──┤ │ │2 8│ │ │ │12 D3║                      
   ││ ┌───┤R │ │3├────────┤D4│ │4├─────╢                      
   ││ │ 1│ │ │ │ 11│ │ │ │9 D4║                      
   ││ ├───┤S │ │ │ ┌─────┤D5│ │5├─────╢                      
   ││─┴─ 4│ │ │ │ │ 13│ │ │ │7 D5║                      
   ││ ──┤0 │ │ │ │┌────┤Db│ │b├─────╢                      
   ││ 12│ │ │ │ ││ 15│ │ │ │5 Db║                      
   ││ ──┤1 │ │ │ ││┌───┤D7│ │7├─────╢                      
   ││ 13││  │ │  │││ 17│  │  │ │3  D7║                      
   ││   ──┤2 │  │ │  │││┌──┤D8│  │8├─────╢                      
   ││    3│  │  ├─┤7 ││││19├──┤  │ │     ║                      
   ││   ──┤3 │  │Со─┐││││┌─оЕ2│  │ │     ║                      
   ││     └──┴──┴─┘ ││││││1│  │  │ │     ║                      
   ││  ┌────────────┘││││├─оЕ1│  │ │     ║                      
   ││  │     DD2     │││││ └──┴──┴─┘     ║                      
   ││  │ 5┌──┬──┬─┐б │││││ /XCS          ║                      
   ││  └──оСа│СТ│0├──┘│││└────           ║                      
   ││   15├──┤  │ │11 │││                ║                      
   └──────/С │  │1├───┘││                ║                      
    │   10│  │  │ │14  ││                ║                      
    └─────┤U/D  │2├────┘│                ║                      
         9├──┤  │ │2    │                ║                      
      ┌───┤R │  │3├─────┘                ║                      
      │  1│  │  │ │                      ║                      
      ├───┤S │  │ │                      ║                      
     ─┴─ 4│  │  │ │                      ║                      
        ──┤0 │  │ │                      ║                      
        12│  │  │ │                      ║                      
        ──┤1 │  │ │                      ║                      
        13│  │  │ │║                      
        ──┤2 │  │ │                      ║                      
         3│  │  ├─┤7                     ║                      
        ──┤3 │  │Со──                    ║                      
          └──┴──┴─┘                      ║                      
             DDЗ              DDб        ║                      
         5┌──┬──┬─┐б      2┌──┬──┬─┐18 D0║                      
     ┌────оСа│СТ│0├────────┤D1│|>│1├─────╢                      
Уа  ─┴─ 15├──┤  │ │11     4│  │  │ │1б D1║                      
 ──┬──────/С │  │1├────────┤D2│  │2├─────╢                      
Yb │    10│  │  │ │14     б│  │  │ │14 D2║                      
 ───┬─────┤U/D  │2├────────┤D3│  │3├─────╢                      
   ││    9├──┤  │ │2      8│  │  │ │12 D3║                      
   ││ ┌───┤R │  │3├────────┤D4│  │4├─────╢                      
   ││ │  1│  │  │ │      11│  │  │ │ 9 D4║                      
   ││ ├───┤S │  │ │  ┌─────┤D5│  │5├─────╢                      
   ││─┴─ 4│  │  │ │  │   13│  │  │ │ 7 D5║                      
   ││   ──┤0 │  │ │  │┌────┤Dб│  │б├─────╢                      
   ││   12│  │  │ │  ││  15│  │  │ │ 5 Dб║                      
   ││   ──┤1 │  │ │  ││┌───┤D7│  │7├─────╢                      
   ││   13│  │  │ │  │││ 17│  │  │ │ 3 D7║                      
   ││   ──┤2 │  │ ││││┌──┤D8│  │8├─────╢                      
   ││    3│  │  ├─┤7 ││││19├──┤  │ │     ║                      
   ││   ──┤3 │  │Со─┐││││┌─оЕ2│  │ │     ║                      
   ││     └──┴──┴─┘ ││││││1│  │  │ │     ║                      
   ││ ┌─────────────┘││││├─оЕ1│  │ │     ║                      
   ││ │      DDЧ     │││││ └──┴──┴─┘     ║                      
   ││ │  5┌──┬──┬─┐б │││││  /YCS         ║                      
   ││ └───оСа│СТ│0├──┘│││└──────         ║                      
   ││   15├──┤  │ │11 │││                ║                      
   └──────/С │  │1├───┘││ ╔══════════════╝                      
    │   10│  │  │ │14  ││ ║                                     
    └─────┤U/D  │2├────┘│ ║                                     
         9├──┤  │ │2    │ ║                                     
      ┌───┤R │  │3├─────┘ ║                                     
      │  1│  │  │ │       ║                                     
      ├───┤S │  │ │       ║                                     
     ─┴─ 4│  │  │ │       ║                                     
        ──┤0 │  │ │       ║                                     
        12│  │  │ │       ║                                     
        ──┤1 │  │ │       ║                                     
        13│  │  │ │       ║                                     
        ──┤2 │  │ │       ║3│  │  ├─┤7      ║                                     
        ──┤3 │  │Со──     ║                                     
          └──┴──┴─┘       ║                                     
                     ╔════╝                                     
          DD7.2      ║       DD8                                
 RIGHB   5┌─┬──┐б  D0║А10 1┌─┬──┬─┐15                           
 ─────────┤D│|>├─────╫─────┤1│DC│0о──                           
         4│ │  │     ║А8  2│ │  │ │14                           
       ┌──оЕ│  │     ║─────┤2│  │1о──                           
       │  └─┴──┘     ║А7  3│ │  │ │13                           
       │  DD7.3      ║─────┤4│  │2о──                           
 LEFTB │ 9┌─┬──┐8  D1║/RD 5├─┤  │ │12                           
 ─────────┤D│|>├─────╫─────о&│  │3о──                           
       │10│ │  │     ║А0  б│ │  │ │11 /BCS                      
       ├──оЕ│  │     ║─────┤ │  │4о───────                      
       │  └─┴──┘     ║    4│ │  │ │10                           
       │  DD7.4      ║  ┌──oS│  │5о──                           
 MIDLB │12┌─┬──┐11 D2║  │  │ │  │ │9 /XCS                       
 ─────────┤D│|>├─────╢  │  │ │  │бо───────                      
       │13│ │  │     ║  │  │ │  │ │7 /YCS                       
       ├──оЕ│  │     ║│  │ │  │7о───────                      
       │  └─┴──┘     ║  │  └─┴──┴─┘                             
       │             ║  └────────────┐                          
       │  /BCS       ║       DD7.1   │                          
       └────────     ║/IORQ 2┌─┬──┐3 │                          
                     ║───────┤D│|>├──┘                          
 DD1..DDЧ - КSб1ИЕ11 ║А5    1│ │  │                             
 DDS, DDб - К5SSАПS  ║───────оЕ│  │                             
 DD7  - К1SSЛП8      ║       └─┴──┘                             
 DD8  - К5SSИД7      ║                                          
                                                                
----------------------------------------------------------------
                                                                
   Примечания:                                                  
                                                                
- жирной линией обозначена шина Spectrum;                       
                                                                
- на мышь идут следующие сигналы: Ха, ХЬ, Уа, Yb, RIGHTB, MIDLB,
  LEFTB, +5V, GND;                                              
                                                                
- /BCS,  /XCS,  /YCS  - внутренние сигналы схемы,  соединяются с
  одноименными парными наscheme;                                
                                                                
- the diagram is shown for a passive type mouse (mouse for “Search”
  MMP-9B), for others it is necessary to output the signals Xa, Xb and Ya, 
  Yb, which are taken from optocouplers after the transistor-trigger chain
  Schmidt;                                                       
                                                                
- the computer needs to block the ODFh port;      
                                                                
- it is possible to replace the decryption circuit (DD7.1, DD8) with a PLM type
  55bPTC (RT11), the remaining free output can be used
  to block ports.                                        
                                                                
 If you have any suggestions/complaints, questions/ideas, then you can
contact the author of the scheme, Mikhail Kondratiev.                
                                                                
            Michael Kondratyev: 2:5030/3b2.1@FidoNet            
                                                                
 So, now let's explain how to work with Kempston Mouse
Interface for the programmer.   Nothing difficult to understand
is expected, since the interface is quite simple and clear.
There are three ports, here they areaddresses: #FADF, #FBDF, #FFDF;
The width of each is 8 bits, i.e. byte.                       
                                                                
 #FADF is a button port, the significant three bits in it are:
         0 bit - state of the right button;                       
         1 bit - left button state;                        
         2 bits - state of the middle button.                      
                                                                
 When the buttons are not pressed, all bits are '1'. When you press the button
the corresponding bit is set to '0'.                      
                                                                
 According to ancient tradition, the left button is used as a choice
(Fire), the right one - as cancellation (Cancel). Middle button accepted
use for additional functions.                        
                                                                
 #FBDF - X-coordinate port;                                     
 #FFDF - Y-coordinate port.                                     
                                                                
 As the mouse moves, the values in the ports
change, and also cyclically, i.e. when #FF is reached and
further increase, they become zero again and grow further,
again until #FF. When moving to anotheron the other hand the picture is similar,
only changes occur in the opposite direction.             
                                                                
 The following picture will help to visualize this matter:               
                    y^                                          
                     │.                                         
                     │2                                         
                     │1                                         
 │012..                                     
                     ┼─────────> x                              
                                                                
 Thus, it is necessary to read the port values, and according to
the difference between the current and previous value is determined
direction of mouse movement.                                  
                                                                
 If very precise manipulations are required, the driver is written with
taking this into account, and moving the arrow one point is done
when the value read from port changes to 2, 3, 5, or
more than units.                                                   
                                                                
 Recently, a smarter driver has become fashionable, which
at the beginning waits for a button to be pressed, and the firstmouse button pressed
becomes (for the driver) left.  This only applies to two
extreme buttons, the middle button - it’s the middle button in Africa too. This
useful for people who are used to holding the mouse in their left hand, or on
the case if someone often stepped on your mouse and one of
her buttons work worse than the others.  Such a driver
is considered good manners.  And if you noticed, that's exactly it
The ZX-Format driver arrives.                                  
                                                                
 You can check the operation of the newly assembled interface directly
from Basic, doing PRINT IN from ports: b4479 - X, b5503 - Y - at
As you move the mouse, the values should change cyclically. When
reading from port b4423 - Fire three low bits should be clicked
when pressing buttons.                                           
                                                                
----------------------------------------------------------------

Share your thoughts about the article