/sinclair/zxspectrum/originaldocs.php">Commodore 64/128 Original Documents Commodore 1351 Mouse User Manual v1.1

Commodore 1351 Mouse User Manual v1.1

 

_____
/ ___|___
| / |__/ C o m m o d o r e
| \___|__\ =================
\_____|

1351 MOUSE
User's Manual


FIRST EDITION
NOVEMBER 1986

Copyright (C) 1986 by Commodore Business Machines, Inc.
All rights reserved.

This manual is copyrighted and contains proprietary information.
No part of this publication may be reproduced, stored in a
retrieval system, or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, or otherwise,
without the prior written permission of COMMODORE BUSINESS
MACHINES, Inc.

Commodore 1351 Mouse is registered trademark of
Commodore Business Machines, Inc.

Commodore 64 and Commodore 128(R) are registered trademarks of
Commodore Business Machines, Inc.

GEOS is registered trademark of Berkeley Softworks, Inc.

About this manual

Basically, this manual is divided into two parts. The first part
includes the introduction, mouse cleaning, and tips for general
care of the mouse. That part is for the user with mouse-
compatible software, who wants simply to plug in the mouse and
begin using it. The second part of the manual contains
information needed by those who wish to develop software for
the mouse.

CONTENTS

Introduction
1. USING THE MOUSE
1.1. Mouse Cleaning
1.2. Mouse Tips

2. PROPORTIONAL MOUSE DEVELOPER'S GUIDE
2.1. Introduction
2.2. Joystick Mode
2.3. Proportional Mode
2.4. SID Register Cautions

APPENDICES
A. BASIC AND MACHINE LANGUAGE PROGRAMS FOR 1351 MOUSE AND C64
B. BASIC AND MACHINE LANGUAGE PROGRAMS FOR 1351 MOUSE AND C128
C. 1351 MOUSE PIN-OUT

1. USING THE MOUSE


Introduction

The Commodore 1351 Mouse(TM) is a controller designed for use
with the Commodore 64(R) or Commodore 128(TM) computers. It
features two buttons on the top, and a ball on the underside that
is rolled upon a flat surface to manipulate onscreen activity.

The mouse has two modes of operation -- joystick mode and
proportional mode.

In joystick mode, the mouse emulates a joystick and can be
used with all joystick-compatible software. In this mode, the
left button is the fire button and the right button is usually
ignored.

In proportional mode, the mouse uses a new technique to
communicate mouse movement to the controlling application
software. That requires the software to know the mouse is there
and how to read it. For example, the GEOS(TM) operating system
can use many different input drivers. One of them is the
Commodore Mouse driver, which can be used with the 1351 in
proportional mode.

The 1351 provides a proportional mode so that applications can
have a fast, responsive pointer that moves easily on the screen.
Joystick mode acts as a fallback for those for those applications
that don't have installable device drivers. You can therefore use
the mouse as a joystick for older software, and take advantage of
the benefits provided by proportional mode with newer
applications.

The mouse automatically powers up in proportional mode. To choose
joystick mode, plug the mouse into either joystick port on the
side of the computer and hold down the right button as the
computer is powered up.


1.1. Mouse Cleaning

Since the ball of your mouse roll freely to accurately manipulate
the cursor (or whatever) on the screen, it's important that the
ball remains free of dirt or debris. This is easily accomplished
by sliding out the plastic piece holding the ball in place.

[ Pictures omitted ]

Remove the ball and wipe it off with a soft cloth, such as a
handkerchief.

[ Picture omitted ]

To remove any dirt or dust from the ball area, just blow gently
into the opening. Around the top of the opening, there are three
metal rollers. To clean these, take cotton-tipped swab, moistened
with head cleaning fluid or alcohol, and gently clean the surface
of each roller. Replace the ball inside the controller and snap
the plastic piece back on.

[ Picture omitted ]


1.2. Mouse Tips

Proper care and use of your mouse requires common sense.

Use your mouse on a clean, smooth surface.

Make sure you have adequate desktop space to manipulate your
mouse, so you don't have to constantly pick up and reposition it.

Don't hold the mouse by its cord, or let the body of the mouse
hang off the table.

2. PROPORTIONAL MOUSE DEVELOPER'S GUIDE

This section explains the theory of operation of the Commodore
1351 mouse and suggests ways in which it can be interfaced to
applications or software.


2.1. Introduction

The Commodore 1351 mouse for use with the C64/C128 product line
is a small two-button device which is connected to either of the
joystick ports on the C64/C128.

The mouse supports two distinct operating modes:
1) Joystick mode.
2) Proportional mode.

Proportional mode is usable with the C64 or the C128, and
requires a special machine language driver to yield optimum
performance.

Mode selection is determined when the mouse is powered up. If the
user depresses the right mouse button when the device is powered
up, then the mouse will be in joystick mode.

If the user does not depress the right mouse button when the
device is powered up, then the mouse will default to proportional
mode.

Joystick mode allows you to utilize the mouse as a joystick when
using software which does not support proportional mode.


2.2. Joystick Mode

In joystick mode the mouse operates as follows:
1) If the mouse is moved, then the appropriate joystick lines are
activated for a period of 20 ms. Thus moving the mouse is like
pushing the joystick in the appropriate direction.
2) The left mouse button is mapped to what would be the fire
button on a joystick.
3) The right mouse button is mapped into the SID POTX register.
If the button is depressed then the SID POTX register will
contain a number <$80. If the button is not depressed then SID
POTX will contain a number >=$80.
4) See the section on SID Register Cautions.

Software Interface

For most applications, the interface for joystick mode should
be just as any joystick driver, and the right button should be
ignored.


2.3. Proportional Mode

In proportional mode the mouse operates as follows:
1) Mouse movement is tracked internally within the mouse. The
position of the mouse MOD 64 is transmitted to the SID POTX
and POTY registers every 512 microsecond and requires no
software intervention.
The POTX register is used to read X position of the mouse
and the POTY register is used to read Y position of the mouse.
The register contents are as follows:

+-------------------------------+
Bit Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+---+---+---+---+---+---+---+---+
POT Register | X | P5| P4| P3| P2| P1| P0| N |
+-------------------------------+
where:
X ......... is a don't care bit.
P5-P0 ..... is the mouse position MOD 64.
N ......... is a special (noise) bit (keep reading...).

2) The left mouse button is mapped to what would be the fire
button on a joystick.
3) The right mouse button is mapped to what would be that UP
direction on a joystick.

Software Interface

1) Because the left and right buttons appear as joystick lines,
reading them from software is a simple exercise in polling.
Note that as with a joystick, the buttons will interfere with
the keyboard map, and software should make some effort to
distinguish between point short in the keyboard matrix (i.e.,
a key being depressed), and a whole row or column being
grounded (i.e., a joystick type of signal).
2) The position information is not difficult to handle. Ideally
is should be installed as part of the 60 Hz interrupt routine
(preferably at the beginning -- see the section on SID
Register Cautions).
This strategy is as follows:
1) Read the mouse position MOD 64.
2) Determine if the mouse has moved by comparing the current
position with a saved copy of the previous position.
3) If the mouse has moved, then modify your pointer position
appropriately.
You should note, that even if the mouse is still, it is
possible for the POT register to oscillate between $80 and
$7F. This would result in the mouse position as jittering
between two points.

In order to ascertain whether the mouse has moved the software
should read the low order bit of the POT register.

All of this can be seen in the supplied mouse driver code.


2.4. SID Register Cautions

In the C64 & C128, the SID POT lines are connected to both
joystick ports. A 4066 analog switch is used to switch the POT
lines between the two ports based on one of the keyboard scan
lines. This means that the normal keyscan interrupt temporarily
affects the values returned in the POT registers. Therefore, in
order to perform reliable conversions, the POT lines must be
connected to the mouse for a period >1.6 millisecond before the
value in the POT register is valid.

The best way to insure this is to wedge the mouse driver software
into the IRQ handler prior to the polled keyscan. This more-or-
less assures that the keyscan lines have been sufficiently stable
before the POT register is read by the mouse drivers.

APPENDIX A

BASIC AND MACHINE LANGUAGE PROGRAMS FOR 1351 MOUSE AND C64


start tok64 data64.prg
100 GOSUB 140:GOSUB 330
110 V=13*4096:POKE V+21,1:POKE V+39,1:POKEV+0,100:POKE V+1,100:\
POKE V+16,0
120 POKE 2040,56:SYS 12*4096+256
130 END
140 FOR X=0 TO 129:READ A$:GOSUB 430:POKE 49408+X,Y:NEXT X:RETURN
150 DATA AD,15,03,C9,C1,F0,19,08
160 DATA 78,AD,14,03,8D,00,C0,AD
170 DATA 15,03,8D,01,C0,A9,21,8D
180 DATA 14,03,A9,C1,8D,15,03,28
190 DATA 60,D8,AD,19,D4,AC,02,C0
200 DATA 20,58,C1,8C,02,C0,18,6D
210 DATA 00,D0,8D,00,D0,8A,69,00
220 DATA 29,01,4D,10,D0,8D,10,D0
230 DATA AD,1A,D4,AC,03,C0,20,58
240 DATA C1,8C,03,C0,38,49,FF,6D
250 DATA 01,D0,8D,01,D0,6C,00,C0
260 DATA 8C,05,C0,8D,04,C0,A2,00
270 DATA 38,ED,05,C0,29,7F,C9,40
280 DATA B0,07,4A,F0,12,AC,04,C0
290 DATA 60,09,C0,C9,FF,F0,08,38
300 DATA 6A,A2,FF,AC,04,C0,60,A9
310 DATA 00,60
320 REM ------------------------
330 FOR X=0 TO 63:READ A$:GOSUB 430:POKE 3584+X,Y:NEXT X:RETURN
340 DATA F8,00,00,90,00,00,B8,00
350 DATA 00,DC,00,00,8E,00,00,07
360 DATA 00,00,02,00,00,00,00,00
370 DATA 00,00,00,00,00,00,00,00
380 DATA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; BIT 0 IS HIGH ORDER X POSITION
;
*=$C000
IIRQ2 *=*+2
OPOTX *=*+1
OPOTY *=*+1
NEWVALUE *=*+1
OLDVALUE *=*+1
;
* = $C100
;
INSTALL LDA IIRQ+1
CMP #>MIRQ
BEQ L90
PHP
SEI
LDA IIRQ
STA IIRQ2
LDA IIRQ+1
STA IIRQ2+1

LDA #<MIRQ
STA IIRQ
LDA #>MIRQ
STA IIRQ+1
;
PLP
L90 RTS
;
MIRQ CLD ; JUST IN CASE.....
LDA POTX ; GET DELTA VALUES FOR X
LDY OPOTX
JSR MOVCHK
STY OPOTX
;
CLC ; MODIFY LOW ORDER X POSITION
ADC XPOS
STA XPOS
TXA
ADC #$00
AND #%00000001
EOR XPOSMSB
STA XPOSMSB
;
LDA POTY ; GET DELTA VALUE FOR Y
LDY OPOTY
JSR MOVCHK
STY OPOTY
;
SEC ; MODIFY Y POSITION ( DECREASE Y FOR
; INCREASE IN POT )
EOR #$FF
ADC YPOS
STA YPOS
;
JMP (IIRQ2) ; CONTINUE W/ IRQ OPERATION
;
; MOVCHK
; ENTRY Y = OLD VALUE OF POT REGISTER
; A = CURRENT VALUE OF POT REGISTER
; EXIT Y = VALUE TO USE FOR OLD VALUE
; X, A = DELTA VALUE FOR POSITION
;
MOVCHK STY OLDVALUE ; SAVE OLD & NEW VALUES
STA NEWVALUE
LDX #0 ; PRELOAD X W/ 0
;
SEC ; A <= MOD64( NEW-OLD )
SBC OLDVALUE
AND #%01111111
CMP #%01000000 ; IF > 0
BCS L50
LSR A ; A <= A/2
BEQ L80 ; IF <> 0
LDY NEWVALUE ; Y <= NEWVALUE
RTS ; RETURN
;
L50 ORA #%11000000 ; ELSE OR IN HIGH ORDER BITS
CMP #$FF ; IF <> -1
BEQ L80
SEC ; A <= A/2
ROR A
LDX #$FF ; X <= -1
LDY NEWVALUE ; Y <= NEWVALUE
RTS ; RETURN
;
L80 LDA #0 ; A <= 0
RTS ; RETURN W/ Y = OLD VALUE
;

APPENDIX B

BASIC AND MACHINE LANGUAGE PROGRAMS FOR 1351 MOUSE AND C128


start tok64 /128 data128.prg
100 GOSUB 230:GOSUB 420:SYS 6144
120 BA=DEC("0a04"):POKE BA,1 OR PEEK(BA)
130 SPRITE 1,1,2:MOVSPR 1,100,100
140 GRAPHIC 1,1:CHAR 1,8,1,"1351 mouse paint"
150 DO:IF (JOY(1) AND 128) THEN GOSUB 180
160 IF (JOY(1) AND 1) THEN GRAPHIC 1,1:\
CHAR 1,8,1,"1351 mouse paint"
170 LOOP
180 X=RSPOS(1,0)-25:Y=RSPOS(1,1)-51:X=-X*(X>0):Y=-Y*(Y>0)
190 LOCATE X,Y:C=1-RDOT(2):DRAW C,X,Y
200 DO:X=RSPOS(1,0)-25:Y=RSPOS(1,1)-51:X=-X*(X>0):Y=-Y*(Y>0)
210 DRAW C TO X,Y:LOOP WHILE JOY(1) AND 128:RETURN
220 REM ------------------------
230 FOR X=0 TO 135:READ A$:POKE 6144+X,DEC(A$):NEXT X:RETURN
240 DATA AD,15,03,C9,18,F0,19,08
250 DATA 78,AD,14,03,8D,F0,18,AD
260 DATA 15,03,8D,F1,18,A9,21,8D
270 DATA 14,03,A9,18,8D,15,03,28
280 DATA 60,D8,AD,7E,11,D0,33,AD
290 DATA 19,D4,AC,F2,18,20,5D,18
300 DATA 8C,F2,18,18,6D,D6,11,8D
310 DATA D6,11,8A,69,00,29,01,4D
320 DATA E6,11,8D,E6,11,AD,1A,D4
330 DATA AC,F3,18,20,5D,18,8C,F3
340 DATA 18,38,49,FF,6D,D7,11,8D
350 DATA D7,11,6C,F0,18,8C,F5,18
360 DATA 8D,F4,18,A2,00,38,ED,F5
370 DATA 18,29,7F,C9,40,B0,07,4A
380 DATA F0,12,AC,F4,18,60,09,C0
390 DATA C9,FF,F0,08,38,6A,A2,FF
400 DATA AC,F4,18,60,A9,00,60,00
410 REM ------------------------
420 FOR X=0 TO 63:READA$:POKE DEC("0e00")+X,DEC(A$):NEXT X:\
RETURN
430 DATA F8,00,00,90,00,00,B8,00
440 DATA 00,DC,00,00,8E,00,00,07
450 DATA 00,00,02,00,00,00,00,00
460 DATA 00,00,00,00,00,00,00,00
470 DATA 00,00,00,00,00,00,00,00
480 DATA 00,00,00,00,00,00,00,00
490 DATA 00,00,00,00,00,00,00,00
500 DATA 00,00,00,00,00,00,00,00
stop tok64

begin 644 data128.prg
M`1P8'&0`C2`R,S`ZC2`T,C`ZGB`V,30T`#@<>`!"0;+1*"(P03`T(BDZER!"
M02PQ(+`@PBA"02D`4AR"`/X'(#$L,2PR.OX&(#$L,3`P+#$P,`!W'(P`WB`Q
M+#$ZX"`Q+#@L,2PB,3,U,2!-3U5312!004E.5"(`E!R6`.LZBR`HSR@Q*2"O
M(#$R."D@IR"-(#$X,`#('*``BR`HSR@Q*2"O(#$I(*<@WB`Q+#$ZX"`Q+#@L
M,2PB,3,U,2!-3U5312!004E.5"(`SARJ`.P``AVT`%BRS@4H,2PP*:LR-3I9
MLLX%*#$L,2FK-3$Z6+*K6*PH6+$P*3I9LJM9K"A9L3`I`!T=O@#F(%@L63I#
MLC&KT"@R*3KE($,L6"Q9`%,=R`#K.EBRS@4H,2PP*:LR-3I9LLX%*#$L,2FK
M-3$Z6+*K6*PH6+$P*3I9LJM9K"A9L3`I`'(=T@#E($,@I"!8+%DZ["#](,\H
M,2D@KR`Q,C@ZC@"1'=P`CR`M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2T`NQWF
M`($@6+(P(*0@,3,U.H<@020ZER`V,30TJE@LT2A!)"DZ@B!8.HX`V1WP`(,@
M040L,34L,#,L0SDL,3@L1C`L,3DL,#@`]QWZ`(,@-S@L040L,30L,#,L.$0L
M1C`L,3@L040`%1X$`8,@,34L,#,L.$0L1C$L,3@L03DL,C$L.$0`,QX.`8,@
M,30L,#,L03DL,3@L.$0L,34L,#,L,C@`41X8`8,@-C`L1#@L040L-T4L,3$L
M1#`L,S,L040`;QXB`8,@,3DL1#0L04,L1C(L,3@L,C`L-40L,3@`C1XL`8,@
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00 ; LOW ORDER X POSITION
YPOS = VIC+$01 ; Y POSITION
XPOSMSB = VIC+$10 ; BIT 0 IS HIGH ORDER X POSITION
;
*=$18F0
IIRQ2 *=*+2
OPOTX *=*+1
OPOTY *=*+1
NEWVALUE *=*+1
OLDVALUE *=*+1
;
* = $1800
;
INSTALL LDA IIRQ+1
CMP #>MIRQ
BEQ L90
PHP
SEI
LDA IIRQ
STA IIRQ2
LDA IIRQ+1
STA IIRQ2+1

LDA #<MIRQ
STA IIRQ
LDA #>MIRQ
STA IIRQ+1
;
PLP
L90 RTS
;
MIRQ CLD ; JUST IN CASE.....
LDA ACTIVE ; IF BASIC IS MOVING SPRITE
BNE L90 ; LET BASIC HAVE IT ( WHY NOT ? )
LDA POTX ; GET DELTA VALUES FOR X
LDY OPOTX
JSR MOVCHK
STY OPOTX
;
CLC ; MODIFY LOW ORDER X POSITION
ADC XPOS
STA XPOS
TXA
ADC #$00
AND #%00000001
EOR XPOSMSB
STA XPOSMSB
;
LDA POTY ; GET DELTA VALUE FOR Y
LDY OPOTY
JSR MOVCHK
STY OPOTY
;
SEC ; MODIFY Y POSITION ( DECREASE Y FOR
; INCRESE IN POT )
EOR #$FF
ADC YPOS
STA YPOS
;
JMP (IIRQ2) ; CONTINUE W/ IRQ OPERATION
;
; MOVCHK
; ENTRY Y = OLD VALUE OF POT REGISTER
; A = CURRENT VALUE OF POT REGISTER
; EXIT Y = VALUE TO USE FOR OLD VALUE
; X, A = DELTA VALUE FOR POSITION
;
MOVCHK STY OLDVALUE ; SAVE OLD & NEW VALUES
STA NEWVALUE
LDX #0 ; PRELOAD X W/ 0
;
SEC ; A <= MOD64( NEW-OLD )
SBC OLDVALUE
AND #%01111111
CMP #%01000000 ; IF > 0
BCS L50
LSR A ; A <= A/2
BEQ L80 ; IF <> 0
LDY NEWVALUE ; Y <= NEWVALUE
RTS ; RETURN
;
L50 ORA #%11000000 ; ELSE OR IN HIGH ORDER BITS
CMP #$FF ; IF <> -1
BEQ L80
SEC ; A <= A/2
ROR A
LDX #$FF ; X <= -1
LDY NEWVALUE ; Y <= NEWVALUE
RTS ; RETURN
;
L80 LDA #0 ; A <= 0
RTS ; RETURN W/ Y = OLD VALUE
;

APPENDIX C

1351 MOUSE PIN-OUT


/-------------------\
| 5 4 3 2 1 |
| o o o o o |
\ /
\ o o o o /
\ 9 8 7 6 /
\_______________/


+-------------------------------------------------------+
| CONNECTION TABLE |
+-------------------------------------------------------+
| FUNCTION |
+--------------------------------+----------------------+
| PIN NO. | JOYSTICK MODE | PROPORTIONAL MODE |
+---------+----------------------+----------------------+
| 1 | UP | RIGHT BUTTON |
+---------+----------------------+----------------------+
| 2 | DOWN | UNUSED |
+---------+----------------------+----------------------+
| 3 | LEFT | UNUSED |
+---------+----------------------+----------------------+
| 4 | RIGHT | UNUSED |
+---------+----------------------+----------------------+
| 5 | UNUSED | Y-POSITION |
+---------+----------------------+----------------------+
| 6 | LEFT BUTTON | LEFT BUTTON |
+---------+----------------------+----------------------+
| 7 | + 5 V | + 5 V |
+---------+----------------------+----------------------+
| 8 | GND | GND |
+---------+----------------------+----------------------+
| 9 | RIGHT BUTTON | X-POSITION |
+---------+----------------------+----------------------+


_____
/ ___|___
|