Micromys Protocol

From IndividualComputers
Jump to: navigation, search

Micromys provides support for additional buttons and features on some computers.

Contents

C64

The current mouse position can be taken from the SID registers $D419 (X-value) and $D41A (y-value). However, these values are not absolute, but relative movements of the mouse. You need to store the current state of the register, delay a certain amount of time and re-read the register. This is preferrably done in an IRQ routine. The difference between the two values gives an indication of the mouse movement during the delay interval. We won't go into detail about this here, as there's other literature available about 1351 mouse programming that applies 100% to Micromys as well.

additional signals in 1351 mode

Micromys will not only translate the left and right mouse buttons, but also wheel movements and the middle mouse button to the C64. This is done using the joystick direction lines that are normally not used by the original 1351 mouse. If the wheel is not moved or pressed, the nomally-unused signals remain untouched, so full compatibility to the original 1351 mouse is still given. The following description gives some idea from a programmer's point of view.

Bit 7 6 5 4 3 2 1 0
Function -- -- -- LMB DN UP MMB RMB

This bit layout is valid for both control ports. Port 1 is located at CIA address $DC01, and port 2 is located at CIA address $DC00. Bits 7, 6 and 5 are unused and should be masked out. All five signals are active-low:

LMB stands for left mouse button

RMB stands for right mouse button

MMB stands for middle mouse button

UP is the scrollwheel-flag for up-movements

DN is the scrollwheel-flag for down-movments

If a button is pressed, it will be represented as a 0 in the corresponding bit. If it is released, the corresponding bit will be 1.

If the wheel is moved up or down, a sequence of pulses appears on the UP or DN bits of the above port registers. The number of pulses is exactly the number of increments that the wheel has been moved. The following picture illustrates two pulses for a wheel movement of two clicks:

Micromys Wheel pulses.png

The idle state of the UP and DN bits is 1, and the pulses bring the bit to zero for a period of 50ms. The time between two pulses is also about 50ms. The time may vary by about 4%, mainly caused by different timings between PAL and NTSC machines (Micromys V3 takes a timebase from the potentiometer conversion rate, which is affected by the different clock speeds of the different C64 video norms). This also means that you don't need to tweak your code to run on NTSC and PAL - with changing C64 timing, the Micromys V3 timing will automatically adapt. The number of CPU cycles between low-pulses is the same on PAL and NTSC machines.

Sampling the UP and DN bits should be done at a rate of at least 45ms in order not to miss a pulse. You should count the number of high-to-low changes, but not the static signal in the UP and DN bits. If you link your wheel-routine with the system timer interrupt (Jiffy IRQ), the sampling rate will be high enough, as the interrupt occurs every 17ms (60Hz). Other interrupt sources like a raster-IRQ are also possible, as even a PAL raster IRQ comes at a rate of 50Hz (20ms).

This part of the manual also applies to the old Micromys, originally developed by Marko Herold, who sold the design to us. The difference to the older hardware is the absence of DIP switches and therefore the absence of Amiga- and Atari modes. The C64 / 1351 emulation mode is identical to Micromys V1, so any software that you write for the C64 will also work with the existing customer base. We're happy to answer any support questions, including code review and cross-testing with the old Micromys model and the original 1351 mouse. Let us know if we should update the list of programs on this site with a link to your software!

Amiga

Wheel and middle mouse button data is transferred through the potentiomenter input (PotX). Although this is an analog input, it's two digital units talking to each other, and the protocol nulls any error in transmission. The protocol for transporting the data into the Amiga aims at the least possible CPU usage, and it's making smart use of the Amiga's hardware.

First of all, set the PotX line into potentiometer mode and make sure that the operating system does not change this setting back to "digital input" in the VBlank IRQ. Note that the Amiga requires the software to start each and every measurement. The fact that every measurement is a discrete process is used by Micromys, as two values are transferred to the Amiga for a single set of wheel data: One calibration value and a data value that includes four valid bits of data. The calibration value is required, because values change with different screenmodes.

Read two consecutive values from the PotX register, doing two measurements. It does not matter in what order you actually read the two values, as the calibration value is always the same. The calibration value is always bigger than the data value, so the two are easily distinguished. The following assumes that you have put the calibration value (the larger one) into variable A, and the data value into variable B. Variable C is a working-variable.

C=(B*127/A) - 9 

Reduce variable C to an unsigned byte by cutting off any fractions. This really means cutting off fractions, not mathematical rounding! The data word C now contains the middle mouse button in bit 6. In other words: If C is larger or equal to 64, then the middle mouse button (or wheel) is pressed. If the MMB is pressed, subtract 64 from C and continue:

C=2*C/3 

This time, do not just cut off fractions, but round mathematically correct. Bits 4,3 and 2 now contain the lower three bits of the scroll-counter, where bit 4 is the LSB:

Bit 7 6 5 4 3 2 1 0
Function 0 0 0 SCRL0 SCRL1 SCRL2 0 0

Should bit 0 and 1 of C not be 0, they can be used to identify and correct any measurement errors. In addition to that, the order of the bits allows you to reduce the number of valid bits to two, in case an extremely low HSync frequency introduces more error than the protocol can balance.

Links

  • VICE mouse test/example code for 1351 and NEOS mouse on C-64 and VIC-20

Download

  • Amiga driver for 68020 and higher processors; install script: Micromys.lha (June 2009)
  • Amiga driver only, re-compiled for 68000 processor (binary only): Micromys_68000.lha (March 2013)
Personal tools
Namespaces

Variants
Actions
Navigation
Icomp
Print/export
Administration