Last modified on 9 July 2013, at 06:13

Kempston Mouse

Revision as of 06:13, 9 July 2013 by Phi2x (Talk | contribs)

This mouse is supported by The OCP Art Studio, The Advanced OCP Art Studio and Carrier Command.

It appears that this mouse is also called the Genius mouse, as both claim to be compatible with The Advanced OCP Art Studio.

Technical

Position:

Port FBEEh READ: Kempston Mouse 8 bit X position
Port FBEFh READ: Kempston Mouse 8 bit Y position
Note: The position values aren't reset after reading.
To calculated the distance since last read:
  dist=new-old, old=new
whereas,
  dist=00h : no move
  dist=+01h..+7Fh moved right/up
  dist=-01h..-80h moved left/down

Buttons:

Port FAEFh READ: Kempston Mouse Buttons
bit 0: Left Button (active low)
bit 1: Right Button (active low)
bit 2..7: unknown


Review (German)

From an article about the "Amstrad Consumer Show" in german magazine "Happy Computer 12/1986":

  • "Bewundern Sie auch die Maussteuerung eines Atari ST oder eines Schneider PC? Bei Kempston gibt es für 69,95 Pfund auch für Ihren CPC oder Joyce so eine komfortable Benutzeroberfläche. Die Maus entspricht dabei völlig dem Standard mit zwei unabhängigen Tasten. Das mitgelieferte Desktop-Programm braucht sich vor den Brüdern auf 16-Bit-Computern nicht zu verstecken."


Get mouse position on screen

Calculating the mouse position from the information given on the Kempston mouse ports is easy.

We will proceed in 2 steps:

1. Calculate mouse pointer location on a virtual screen that has a 640*400 resolution.
2. Translate position from the virtual screen to the current CPC screen mode.

Here is the algorithm in pseudo-code:

// initMouse initializes variables and centers the mouse pointer on screen
function initMouse() {
 maxX = 639;
 maxY = 399;
 // centering the mouse pointer on the screen
 virtualX = maxX >> 1; // virtualX = maxX/2
 virtualY = maxY >> 1; // virtualY = maxY/2
 // store raw mouse values
 oldX = inp(&FBEE);
 oldY = inp(&FBEF);
 // get mouse pointer position
 refreshMouse();
}
// refreshMouse has to be called before you redraw the mouse pointer (and ideally on every frame)
function refreshMouse() {
 // get raw mouse values
 rawX = inp(&FBEE);
 rawY = inp(&FBEF);
 // get the relative mouse displacement since last call
 deltaX = rawX - oldX;
 deltaY = rawY - oldY;
 // store raw mouse values
 oldX = rawX;
 oldY = rawY;
 // calculate new unclipped virtual position
 virtualX = virtualX + deltaX;
 virtualY = virtualY - deltaY; // Kempston mouse Y-axis is inverted compared to screen coordinates!
 // perform clipping
 if (virtualX < 0) then virtualX = 0;
 else if (virtualX > maxX) then virtualX = maxX;
 if (virtualY < 0) then virtualY = 0;
 else if (virtualY > maxY) then virtualY = maxY;
 // now we translate position from the virtual screen to the current CPC screen mode
 mouseY = virtualY >> 1; // mouseY = virtualY/2
 if (mode2) then mouseX = virtualX;
 else if (mode1) then mouseX = virtualX >> 1; // mouseX = virtualX/2
 else if (mode0) then mouseX = virtualX >> 2; // mouseX = virtualX/4
}