[net.micro.cbm] Commodore 128 Mouse Interface

corbin@encore.UUCP (Steve Corbin) (05/06/86)

I have just purchased a Commodore 128 mouse with the hopes of connecting
it to my Z80/CPM machine.  The only documentation supplied in the package
is the connector pinout.  Does anyone know where I can get the full
technical details for this device?  Items of interest would be schematics,
electrical and timing characteristics, suggested hardware interfaces, and
software drivers.


The connector is laid out as follows:

	PIN	SIGNAL
	 1	UP
	 2	DOWN
	 3	LEFT
	 4	RIGHT
	 5	nc
	 6	BUTTON 1 (left)
	 7	VCC (+5v)
	 8	GND
	 9	BUTTON 2 (right)


The little I could tell about these signals is:

BUTTON #1, BUTTON #2

These lines are connected to one contact of the pushbuttons with the other
contacts to GND.  No pull-up or debounce circuitry.

UP, DOWN, LEFT, RIGHT

Active low signals indicating direction(s) of movement.  UP/LEFT, UP/RIGHT,
DOWN/LEFT and DOWN/RIGHT may be simultaneous and asynchronous with respect
to each other.  Questions are:

	1.  Are these lines pulsed for each 'step' of movement?

	2.  What is the resolution of movement? (i.e. steps/inch)

	3.  What is the minimum/maximum pulse width?

	4.  What is the minimum/maximum high time between pulses?

	5.  What is the output voltage levels?


Thanks in advance,
Steve Corbin

Usenet: corbin@encore
        {ihnp4, allegra, linus}!encore!corbin

daveh@cbmvax.cbm.UUCP (Dave Haynie) (05/07/86)

In article <290@encore.UUCP> corbin@encore.UUCP (Steve Corbin) writes:
>I have just purchased a Commodore 128 mouse with the hopes of connecting
>it to my Z80/CPM machine.  The only documentation supplied in the package
>is the connector pinout.  Does anyone know where I can get the full
>technical details for this device?  Items of interest would be schematics,
>electrical and timing characteristics, suggested hardware interfaces, and
>software drivers.
>
>....
>
>The little I could tell about these signals is:
>
>BUTTON #1, BUTTON #2
>
>These lines are connected to one contact of the pushbuttons with the other
>contacts to GND.  No pull-up or debounce circuitry.

On the C128, one of the buttons is sensed though a 6526 CIA, the other 
though a port on the SID chip.  Essentially what happens is that one bit
of a parallel output port is used to read in each button press.  Bouncing
has not been a problem, as the port device has a degree of internal pullup,
and scanning this at a 250KHz rate, or thereabouts, at most, we've found
no need for debouncing.  Also, the first button is completely compatible
with the C128/C64 joystick fire button; a large portion of the total
design is based on necessary compatibility with the joystick.

>UP, DOWN, LEFT, RIGHT

These pins emulate the four switches in the standard C128/C64 digital
joystick.

>Active low signals indicating direction(s) of movement.  UP/LEFT, UP/RIGHT,
>DOWN/LEFT and DOWN/RIGHT may be simultaneous and asynchronous with respect
>to each other.  Questions are:
>
>	1.  Are these lines pulsed for each 'step' of movement?

Yes, the lines are pulsed; faster movement results in greater "active" time.
There's a tiny, dedicated microprocessor in the mouse that does the "vane"
pulse to joystick pulse conversion.  These lines are attached to the same
parallel port in the C128/C64 as is the fire button.  

>	2.  What is the resolution of movement? (i.e. steps/inch)
>	3.  What is the minimum/maximum pulse width?

Not sure about these.

>	4.  What is the minimum/maximum high time between pulses?

I think you can "saturate" the pulsing, i.e., if you move it fast enough,
you can get a continuous active output.

>	5.  What is the output voltage levels?

The voltage level into the mouse should be 5v +/- 5% regulated DC, the 
output will be standard TTL levels.

>Thanks in advance,
>Steve Corbin
>
>Usenet: corbin@encore
>        {ihnp4, allegra, linus}!encore!corbin

As for programming it, there's a short machine program (6502 code of course)
in the C64 Programmer's Reference Guide, intended for joysticks, which could
be modified for optimal mouse performance.  In the example, $DC00 is the
location of the memory-mapped port.

	;Program to read the direction change from a joystick or mouse.

	DX = $C110		;X direction
	DY = $C111		;Y direction

DJRR	LDA $DC00		;Read port
DJRRB	LDY #$00		;Decode it, buy shifting values right
	LDX #$00		;and testing for the carry bit.
	LSR A			;Bits 0 and 1 modify the Y direction
	BCS DJR0
	DEY
DJR0	LSR A
	BCS DJR1
	INY
DJR1	LSR A			;Bits 2 and 3 modify the X direction
	BCS DJR2
	DEX
DJR2	LSR A
	BCS DJR3
	INX
DJR3	LSR A			;Bit 4 is the fire button.

	STX DX			;Exit here with X,Y directions stored, and
	STY DY			;the fire button status in the carry bit.
	RTS

-- 

Dave Haynie    {caip,inhp4,allegra,seismo}!cbmvax!daveh
               "There, beyond the bounds of your weak imagination
                Lie the noble towers of my city, bright and gold"
								-Genesis