The
Kempston Mouse Turbo Interface
by Velesoft and Ben Versteeg
PC Mouse
and Kempston joystick Interface
for the Sinclair ZX Spectrum

The K-Mouse Turbo interface
provides three functions in one for your Sinclair ZX Spectrum home computer:
- Connect a standard Atari compatible joystick
- Connect a standard PS/2 Mouse
- Connect your ZX Spectrum to a Television, using composite video (allthough
a modulator mod for composite video gives you better picture)
The joystick port is compatible with the Kempston Standard, and the mouse
port is also compatible with the Kempston Mouse standard. Programs written
to use either of these standards (or converted to use them) will happily
work with the interface. You can also use the interface as a Fuller joystick
interface, if you have programs which use that interface, by setting the
interface up as a slave interface.
The Interface also has an "Extra" Mode which allows you to change
various default settings to help with some software, such as switching
to a slower mouse response, or to swap over the actions connected to the
left and right hand mouse buttons, in order to emulate the Russian Kempston
Mouse interface, or to suit a left handed person.
The interface is designed with simplicity in mind and plugs into the ZX
Spectrum's expansion port. All you need to do is then plug in a PS/2 compatible
mouse (or a USB mouse with a USB to PS/2 convertor) and/or an (Atari)
standard joystick. You can also connect the composite video lead between
the video connector and your Television to provide a stable picture on
modern televisions. Switch on your ZX Spectrum and the interface is ready
to use.
If you wish, you can even use an Atari/Amiga standard mouse, by plugging
it into the 9 pin joystick port rather than a joystick (although this
will not work if the interface is set up as a second slave device).
Availability
Use the Contact
Me form on my Blog for ordering information.
In
the box
Your K-Mouse Turbo is delivered with this manual and an RCA cable that
can be used for composite video output (see the 'Video output connector'
section for more details).

The K-Mouse Turbo
has a throughput connector so you can use other interfaces together with
the K-Mouse Turbo.

K-Mouse
software
Many (modified) games for the K-Mouse Turbo can be downloaded from Velesoft's
site:
http://velesoft.speccy.cz/kmsoft.htm
See the 'Using the Interface
from Programs' section about how to use the K-Mouse Turbo from your own
software.
Compatibility
The K-Mouse Turbo Interface is compatible with all ZX Spectrum models.
The K-Mouse Turbo Interface
works perfectly together with these devices:
" DivIDE / DivIDE Plus
" MB02 / MB02+IDE *
" PC Keyboard Interface (by Ben Versteeg & Miguel Angel Rodríguez
Jòdar)
" ZX-MMC+
" Other Devices with built in Kempston Joystick port *
* Warning: when another device
with Kempston Joystick port is also connected, you must disable the joystick
port on the K-Mouse Turbo by removing Jumper 'EN31', otherwise you might
damage your ZX Spectrum or connected device!
Supported
mice
Any PS/2 mouse is supported, even a wireless mouse!
You can also use any USB mouse that supports the PS/2 protocol, but you
have to use a USB to PS/2 adapter plug or cable.
For the Extra Mode functions
described in this document, you will need a three button mouse or a two-button
mouse with scroll-wheel that can be used as button.
How
to connect the K-Mouse Turbo Interface
The interface simply plugs into the expansion port on the Sinclair ZX
Spectrum.
You can have other devices between the ZX Spectrum and the K-Mouse Turbo,
provided that they have a through connector, or you can use the through
connector of the K-Mouse Turbo to connect other compatible devices.
Connecting
a Second K-Mouse Turbo Interface
You can actually connect a second K-Mouse Turbo Interface to use as a
slave device, providing access to a second mouse and a second joystick
at the same time. In order to do this, on the second interface, you will
need to remove jumper 'EN31' (disable the joystick Port) and ensure the
Extra Mode switch is in the off position.
The second joystick (or Amiga Mouse) can then be read using Port 127 (which
is the Fuller standard) and the PS/2 mouse can be read using ports 15327,
16351 and 15071.

Video
output connector
The video output connector only works on a ZX Spectrum 16K/48K or ZX Spectrum
+.
Simply use the RCA cable
provided to connect the ZX Spectrum (+) with K-Mouse Turbo to your (lcd)
television.
The signal is composite video.
You can use a scart-adapter when no RCA connector on your tv is available.
Keep in mind that a modified modulator for composite video gives superior
picture.
The
Reset Button
The K-Mouse Turbo Interface also incorporates a small push button on the
side which can be used to force the ZX Spectrum to reset.
Switching
between the Mouse and the Joystick
You can only use the mouse OR the joystick at a time as they both use
the same control port. As soon as you press a mouse button, the mouse
mode is activated and the joystick is disabled. You can switch to the
joystick (and disable the mouse) by pressing the fire button on the joystick.
Disabling
the Joystick Port
If you wish to permanently disable the joystick port on the K-Mouse Turbo
Interface (for example, if you want to use the interface with the MB-02
or with another interface which already has a built in Kempston Joystick
Port), simply remove Jumper 'EN31' (the small black plastic jumper between
the switch and the joystick port on the top of the interface).

Using
the 'Extra Mode'
You can enter the 'Extra Mode' by toggling the switch on the top of the
interface towards the joystick port and then by pressing the left, middle
and right mouse buttons at the same time.
When you enter the Extra Mode,
the LED below the switch will iluminate.
The Extra Mode allows you to
configure various parameters for the mouse as follows:
" Press the Left Button on the mouse to toggle Port 31 on or off
(see below)
" Press the Right Button on the mouse to reverse the actions on the
left and right mouse button - this allows the K-Mouse Turbo Interface
to emulate the Russian Kempston Mouse Interface Clone, or can be useful
for a left handed person.
" Press the Middle Button on the mouse to toggle between slow mouse-movement
(which is compatible with the original Kempston Mouse Interface) and turbo
mouse-movement. Turbo is the default and is approximately 4x the speed
of the original interface for reading the mouse.
" Press the Left, Middle and Right buttons together to reset the
Mouse interface to its defaults
" If you move the mouse wheel by more than 4 clicks in one direction,
this will disable the mouse wheel.
" Press the Left and Right buttons together to exit Extra Mode
NOTE: Once you change any setting, you will leave the Extra Mode
Using
the Interface from Programs
The K-Mouse Turbo Interface can be interrogated from programs by using
the IN command. The standards are in accordance with the Kempston Joystick
Interface standard and the Kempston Mouse Interface standard, and therefore
programs which are written to use either of these will work with the interface
without any changes.
Detecting the Interface
If the K-Mouse Turbo Interface is connected as a master device, IN 65247
(#fedf) will return the value sent to OUT 32765 (#7ffd).
If the interface is connected as a slave device, IN 16095 (#3edf) will
return the value sent to OUT 32765 (#7ffd).
This can be quite useful, as it is possible to see all 8 bits sent to
the #7fdd memory paging port, used on ZX Spectrum 128K machines - ideal
if you want to take snapshots of the memory, so that you know what page
the Spectrum was in at the time.
Reading a PS/2 Mouse
Programs need to interrogate 3 ports to determine the mouse's position
and which buttons have been pressed:
Master Interface
(standard)
PORT Hex Value
64479 FBDF Horizontal Position (X-axis)
65503 FFDF Vertical Position (Y-axis)
64223 FADF This returns 255 if the mouse is stationary and no buttons
are pressed.
Bit 0 (D0) is cleared ('0') to indicate the right mouse button has been
pressed
Bit 1 (D1) is cleared ('0') to indicate the left mouse button has been
pressed
Bit 2 (D2) is cleared ('0') to indicate the middle mouse button has been
pressed
Bit 3 (D3) is cleared ('0') to indicate a fourth mouse button has been
pressed
Bit 4-7 (D4-D7) return the position of the mouse wheel = %1111 is default
If you have the interface set
up as a slave, a second set of ports is used instead:
Slave Interface
PORT Hex Value
15327 3BDF Horizontal Position (X-axis)
16351 3FDF Vertical Position (Y-axis)
15071 3ADF This returns 255 if the mouse is stationary and no buttons
are pressed.
Bit 0 (D0) is cleared ('0') to indicate the right mouse button has been
pressed
Bit 1 (D1) is cleared ('0') to indicate the left mouse button has been
pressed
Bit 2 (D2) is cleared ('0') to indicate the middle mouse button has been
pressed
Bit 3 (D3) is cleared ('0') to indicate a fourth mouse button has been
pressed
Bit 4-7 (D4-D7) return the position of the mouse wheel = %1111 is default
Reading An
Atari/Amiga Mouse
Provided that you have the K-Mouse Turbo Interface as a master, an Atari/Amiga
Mouse can be plugged into the 9 pin joystick port and is read through
Port 31 (as if it were a joystick).
Master Interface
(standard)
PORT Hex Value
31 1F This returns 127 if the mouse is stationary and no buttons are pressed.
Bit 0 (D0) is cleared ('0') to indicate the mouse has moved to the right
(XB)
Bit 1 (D1) is cleared ('0') to indicate the mouse has moved to the left
(YB)
Bit 2 (D2) is cleared ('0') to indicate the mouse has moved down (XA)
Bit 3 (D3) is cleared ('0') to indicate the mouse has moved up (YA)
Bit 4 (D4) is cleared ('0') to indicate the left mouse button has been
pressed
Bit 5 (D5) is cleared ('0') to indicate the right mouse button has been
pressed
Bit 6 (D6) is cleared ('0') to indicate the middle mouse button has been
pressed
Bit 7 (D7) is 0
If you have the interface set
up as a slave, this type of mouse is not supported.
Reading The Joystick
Programs need to interrogate port 31 to determine signals from the joystick.
The joystick port of the master
interface will behave as a Kempston joystick port:
Master Interface (standard)
PORT Hex Value
31 1F This returns 127 if the joystick is stationary and no buttons are
pressed.
Bit 0 (D0) is cleared ('0') to indicate the joystick has moved to the
right
Bit 1 (D1) is cleared ('0') to indicate the joystick has moved to the
left
Bit 2 (D2) is cleared ('0') to indicate the joystick has moved down
Bit 3 (D3) is cleared ('0') to indicate the joystick has moved up
Bit 4 (D4) is cleared ('0') to indicate the left fire button has been
pressed
Bit 5 (D5) is cleared ('0') to indicate the right fire button has been
pressed
Bit 6 (D6) is cleared ('0') to indicate the third fire button has been
pressed
Bit 7 (D7) is 0
If you have the interface set
up as a slave, a second port is used instead, but this will behave as
Fuller joystick port:
Slave Interface
PORT Hex Value
127 7F This returns 255 if the joystick is stationary and no buttons are
pressed.
Bit 0 (D0) is cleared ('0') to indicate the joystick has moved to the
right
Bit 1 (D1) is cleared ('0') to indicate the joystick has moved to the
left
Bit 2 (D2) is cleared ('0') to indicate the joystick has moved down
Bit 3 (D3) is cleared ('0') to indicate the joystick has moved up
Bit 4 (D4) is 1
Bit 5 (D5) is cleared ('0') to indicate the third fire button has been
pressed
Bit 6 (D6) is cleared ('0') to indicate the right fire button has been
pressed
Bit 7 (D7) is cleared ('0') to indicate the left fire button has been
pressed
Disabling the
Mouse
Programs can disable all ports except for Port 31, effectively turning
the interface into a Kempston only compatible joystick interface (presuming
that Jumper 'EN31' is enabled).
To do this, issue the command:
OUT 16095,128
To re-enable the ports, use the command:
OUT 16095,0
K-Mouse
driver
This is the Z80 assembly code listing for reading the Kempston Mouse,
presuming that it is connected to the PS/2 port on a master Interface:
MOUSE |
LD HL,(COORD)
LD BC,#FBDF
LD DE,(OLDCO)
IN A,(C)
LD (OLDCO),A
SUB E
JR Z,NM_X
JP P,MX_PL
ADD A,L
JR C,ZER_X
XOR A
|
ZER_X |
LD
L,A
JR NM_X |
MX_PL
|
ADD
A,L
JR C,BEX_Z
CP #FD ;MAXIMUM X
JR C,BEX_B |
BEX_Z
|
LD
A,#FD ;MAXIMUM X |
BEX_B |
LD L,A |
NM_X |
LD B,#FF
IN A,(C)
LD (OLDCO+1),A
SUB D
JR Z,NM_Y
NEG
JP P,MY_PL
ADD A,H
JR C,ZER_Y
XOR A |
ZER_Y
|
LD
H,A
JR NM_Y |
MY_PL |
ADD A,H
JR C,BEY_Z CP #BE ;MAXIMUM Y
JR C,BEY_B |
BEY_Z |
LD A,#BE ;MAXIMUM Y |
BEY_B |
LD H,A |
NM_Y |
LD A,H
CP #FF
JR C,BIGY
LD H,#FF |
BIGY |
CP #02 ;MINIMUM Y
JR NC,SMALY
LD H,#02 ;MINIMUM Y |
SMALY |
LD A,L
CP #FF
JR C,DIRY
LD L,#FF |
DIRY
|
CP
#02 ;MINIMUM X
JR NC,DIMENS
LD L,#02 ;MINIMUM X |
DIMENS |
LD (COORD),HL
LD BC,#FADF
LD HL,CONTRB
IN A,(C)
CPL
AND 7
RLCA
RLCA
RLCA
RLCA
OR (HL)
LD (HL),A
RET |
COORD |
DEFB 0,0 |
OLDCO |
DEFB 0,0;WORKING |
Alternative drivers can be
found in the K-Mouse Turbo documentation on Velesoft's site.

ZX Spectrum with master
and slave K-Mouse Turbo interfaces and DivIDE

|