Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PS/2 Mouse support on C64 and VIC20

39 views
Skip to first unread message

David Murray

unread,
Nov 12, 2009, 10:30:30 PM11/12/09
to
I wanted to raise this topic again.. For those who are unfamiliar, a
little refresher.. A couple of years ago I developed a mouse driver
for connecting a PS/2 mouse directly to the userport of a Commodore
DTV without any extra hardware. But the driver didn't work on a real
C64 because I had to disable badlines on the DTV before I could get
reliable operation. However, I had theorized that it might be
possible to use better timing so that the mouse was read during the
screen refresh so that maybe the badlines wouldn't cause timing
issues. However, there wasn't much interest and at the time I was
only interested in working on the DTV so I never pursued the issue.
For a demo of this on the DTV, look here:

http://galaxy22.dyndns.org/dtv/common/ps2mouse/index.html

However, since I'm still highly considering making a real-time
strategy game for the C64, something akin to StarCraft, mouse support
is apparently needed. I could obviously add support for the 1351 but
I don't even own one anymore and I think they are getting pretty
rare. So I was thinking about re-visiting the PS/2 mouse driver
issue and seeing if I could get it to work on a real C64. The
hardware to connect the mouse would be extremely simple and cheap. So
it would be available to everyone at very low cost. Plus you could use
fancy optical mice, cordless mice, etc.

So my question is this.. if I got this working, would anyone else have
any software they've written which could benefit? Or any software
planned to be written which could use it?

Second question.. I hadn't even considered the VIC-20 or Plus/4 at the
time. But do they have badlines? I am thinking not since the VIC-20
does not blank the screen when reading from cassette. In which case,
the mouse driver would probably work as-is on the VIC-20 without any
mods.

Third question.. Would anyone be interested in adding PS/2 mouse
emulation on the userport to VICE or other emulators?

Tom Lake

unread,
Nov 12, 2009, 10:59:56 PM11/12/09
to

"David Murray" <adr...@yahoo.com> wrote in message
news:9e7f5ab2-3223-40be...@a21g2000yqc.googlegroups.com...

> A couple of years ago I developed a mouse driver
> for connecting a PS/2 mouse directly to the userport of a Commodore
> DTV without any extra hardware. But the driver didn't work on a real
> C64 because I had to disable badlines on the DTV before I could get
> reliable operation.

Pardon my ignorance, but what are "badlines"? I tried Google but no luck.

Tom Lake

David Murray

unread,
Nov 12, 2009, 11:16:19 PM11/12/09
to
> Pardon my ignorance, but what are "badlines"?  I tried Google but no luck.
>
> Tom Lake

Umm.. it has something to do with the VIC-II chip and it stops the CPU
like every 8 horizontal lines for just a few cycles in order to fetch
something from RAM.. (please feel free to correct me if I have this
wrong) Unfortunately, this messes up the timing on the PS/2 mouse
because it is bit-banged and once you ask the PS/2 mouse for its
movement info, it feeds it out very quickly and the 1Mhz CPU in the
C64 is just barely fast enough to intercept each bit as it comes in.
If you shut off the CPU for a few cycles, you'll never get a proper
reading.

Vanessa Ezekowitz

unread,
Nov 12, 2009, 11:34:12 PM11/12/09
to

In normal C64 parlance, a "bad" line is any of the 25 raster lines in
which the VIC-II steals 43 cycles from the CPU to fetch character data.
This causes periodic, predictable timing errors in the running program, which
is probably what was preventing his mouse driver from being able to sample
the PS/2 signals accurately. Same reason fast loaders often blank the
screen.

Turning badlines off on a C64 or C128 requires setting a register in the
VIC-II to blank the screen.

--
"There are some things in life worth obsessing over. Most
things aren't, and when you learn that, life improves."
http://starbase.globalpc.net/~ezekowitz
Vanessa E. <vanDEesLEsaTE...@gmail.com>
(Delete the obvious to email me)

Sean Huxter

unread,
Nov 13, 2009, 7:26:35 AM11/13/09
to
I know I'd love to have a hardware adapter that would allow me to use a
regular mouse on my C64.

My own 1351 is getting a bit flaky when moving to the right, though moving
in the other 3 directions is fine. It's a bit frustrating, and no amount of
cleaning the ball or the wheels seems to help for very long.

So yeah, as long as one wouldn't need to run some software to get it to
work, I'd love one. I use GEOS, and to have a reliable mouse that I don't
have to hunt down a replacement for one Bay would be a huge win.

I'm not sure what you mean about VICE though. Vice uses a regular PC mouse
as if it was a 1351, so I don't get what you were asking there.

Sean.


"David Murray" <adr...@yahoo.com> wrote in message
news:9e7f5ab2-3223-40be...@a21g2000yqc.googlegroups.com...

David Murray

unread,
Nov 13, 2009, 8:14:35 AM11/13/09
to
> So yeah, as long as one wouldn't need to run some software to get it to
> work, I'd love one. I use GEOS, and to have a reliable mouse that I don't
> have to hunt down a replacement for one Bay would be a huge win.

GEOS would not work with this mouse unless somebody modified GEOS and
added the driver. Neither would any other software that wasn't
written specifically to take advatange of it.

> I'm not sure what you mean about VICE though. Vice uses a regular PC mouse
> as if it was a 1351, so I don't get what you were asking there.

Yes.. but again, the interface to this mouse is totally different. So
if I wrote software designed to use the PS/2 mouse then it would not
work on the emulator because the emulator is only emulating a 1351
mouse.

Obviously.. if I begin to write such a program, I will most likely
design it to work with both a PS/2 and a 1351 mouse. In fact, that
would be a must because I'd be doing all of my development in VICE or
Power64 and so I'd need to have mouse support for testing. But when
using the real system, I'd be using a PS/2.

Lars Haugseth

unread,
Nov 13, 2009, 8:42:53 AM11/13/09
to
* David Murray <adr...@yahoo.com> wrote:
>
> I wanted to raise this topic again.. For those who are unfamiliar, a
> little refresher.. A couple of years ago I developed a mouse driver
> for connecting a PS/2 mouse directly to the userport of a Commodore
> DTV without any extra hardware. But the driver didn't work on a real
> C64 because I had to disable badlines on the DTV before I could get
> reliable operation.

I once worked on a bitmap graphics drawing program on the C64 that used
a regular Amiga mouse connected to one of the joystick ports. The port
had to be polled about 800-1000 times a second (using NMI) for smooth
movement, but badlines was not an issue. So you might consider that as
an option. Amiga mice are not that rare, and there is no hardware
modding needed to get it to work.

--
Lars Haugseth

Andreas Meerbann

unread,
Nov 13, 2009, 10:39:38 AM11/13/09
to
Hi David,

maybe it makes more sense to build an adaptor that converts a PS/2
mouse into a 1531 compatible mouse and plugs into the joystick port.
Maybe you could port your code to a PIC controller which translates
the PS/2 signals to 1531 signals. Half of the job you've already done
and 1531 signals are not very complicated (even though the philosophy
behind is very different from the serial PS/2 approach)

This is of course more hardware (well basically one IC) but would work
with all the existing software.

What do you think?

Andreas

PS: Second version of that device would then allow to connect a USB-
mouse :-)

Gene Buckle

unread,
Nov 13, 2009, 10:30:19 AM11/13/09
to
To: David Murray
Re: PS/2 Mouse support on C64 and VIC20
By: David Murray to comp.sys.cbm on Thu Nov 12 2009 07:30 pm

> I wanted to raise this topic again.. For those who are unfamiliar, a
> little refresher.. A couple of years ago I developed a mouse driver
> for connecting a PS/2 mouse directly to the userport of a Commodore

David, if you're going to develop a bit of hardware in order to connect a PS/2
mouse to the user port, why not go a little bit further and build an adaptor
that would allow a person to connect a PS/2 or USB mouse to the standard 9 pin
joystick port? Having 1351 compatability(sp) would give you the widest
audience and could be done with a few parts and a PIC or AVR uController.

g.

--- Synchronet 3.15a-Win32 NewsLink 1.91
The Retro Archive - telnet://bbs.retroarchive.org

U. v. Bassewitz

unread,
Nov 13, 2009, 11:20:30 AM11/13/09
to
David Murray <adr...@yahoo.com> wrote:
> I wanted to raise this topic again.. For those who are unfamiliar, a
> little refresher.. A couple of years ago I developed a mouse driver
> for connecting a PS/2 mouse directly to the userport of a Commodore
> DTV without any extra hardware. But the driver didn't work on a real
> C64 because I had to disable badlines on the DTV before I could get
> reliable operation.

Here is a small board for the Atari, that - according to the developer -
should also work for the C64 (but this is untested):

http://www.atariage.com/forums/topic/134949-advance-orders-for-cmi08-ps2-mouse-interface/

I have one, but haven't built and tried it until now, so apart from
posting the link I cannot comment ...

Regards


Uz


--
Ullrich von Bassewitz u...@spamtrap.musoftware.de
17:18:04 up 4 days, 1:44, 1 user, load average: 0.08, 0.08, 0.08

RobertB

unread,
Nov 13, 2009, 11:41:49 AM11/13/09
to
The Indivision Micromys PS/2 adapter at

http://amigakit.leamancomputing.com/catalog/product_info.php?products_id=877

Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug
The Other Group of Amigoids
http://www.calweb.com/~rabel1/
Southern California Commodore & Amiga Network
http://www.sccaners.org

David Murray

unread,
Nov 13, 2009, 2:57:30 PM11/13/09
to

> maybe it makes more sense to build an adaptor that converts a PS/2
> mouse into a 1531 compatible mouse and plugs into the joystick port.

Hmm.. Seems we have a concensus.. Everybody wants to plug it into
their existing joystick port. Okay, I understand the benefit of
this. But I should point out that the hardware to do this is much
more expensive. A good example is the device already being sold for
this purpose which costs around $40. My design would cost only $1.49
for the cost of a Mini-DIN connector or could even be done for no cost
at all if the person wanted to solder the cables from the mouse
directly to the userport connector (I wouldn't recommend) but you get
the idea. Also I believe direct interaction with the PS/2 mouse would
give more reliable and accurate results. granted, I've never tried
this converter device, but I have tried my own design and the mouse
movements are just as natural as you would expect on a modern PC. And
it would leave the joystick ports free for other stuff.

As for software compatibility. I'm sure that is important to some of
you. But I really do not currently use any software on the 8-bit
platform that uses a mouse. The only software I ever did use was GEOS
128 and I have no need for that in this modern world. Even my
favorite drawing program of the time, Doodle, only used a joystick.

So.. My reasoning is that the direct connection of the PS/2 mouse is
the best way to go into the future.

Mark McDougall

unread,
Nov 13, 2009, 5:47:17 PM11/13/09
to
David Murray wrote:

> Hmm.. Seems we have a concensus.. Everybody wants to plug it into
> their existing joystick port. Okay, I understand the benefit of
> this. But I should point out that the hardware to do this is much
> more expensive. A good example is the device already being sold for
> this purpose which costs around $40.

IMHO this is by _far_ the best option, as it gives instant compatibility
with all exsiting mouse software. I don't think $40 is unreasonable given
the nature of the product either - I made a small batch of Amiga PS/2
adapters and it cost just about that to manufacture each one.

> Also I believe direct interaction with the PS/2 mouse would
> give more reliable and accurate results.

I've never used a C64 mouse, but I gather you're implying that the mouse is
_not_ as smooth & accurate as the PS/2 version - yes??? Then perhaps the
inaccuracies are inherent in the original mouse itself, rather than the
protocol and/or frequency at which the mouse is sampled? In that case, using
a PS/2 adapter would alleviate those problems.

Regards,

--
| Mark McDougall | "Electrical Engineers do it
| <http://members.iinet.net.au/~msmcdoug> | with less resistance!"

Jim Brain

unread,
Nov 13, 2009, 8:26:56 PM11/13/09
to David Murray
David Murray wrote:
>> maybe it makes more sense to build an adaptor that converts a PS/2
>> mouse into a 1531 compatible mouse and plugs into the joystick port.
>
> Hmm.. Seems we have a concensus.. Everybody wants to plug it into
> their existing joystick port. Okay, I understand the benefit of
> this. But I should point out that the hardware to do this is much
> more expensive. A good example is the device already being sold for
> this purpose which costs around $40. My design would cost only $1.49

I might be able to offer a design for $10-$15... If Nick can tell me
where he gets that low profile DE-9 connector for 64JPX.

Would that be of interest?

Jim

Tom

unread,
Nov 14, 2009, 12:19:43 AM11/14/09
to
In article <p-mdnQSo2dRffWDX...@westnet.com.au>, Mark McDougall <msmc...@no.spam.iinet> wrote:
>David Murray wrote:
>
>> Hmm.. Seems we have a concensus.. Everybody wants to plug it into
>> their existing joystick port. Okay, I understand the benefit of
>> this. But I should point out that the hardware to do this is much
>> more expensive. A good example is the device already being sold for
>> this purpose which costs around $40.
>
>IMHO this is by _far_ the best option, as it gives instant compatibility
>with all exsiting mouse software. I don't think $40 is unreasonable given
>the nature of the product either - I made a small batch of Amiga PS/2
>adapters and it cost just about that to manufacture each one.
>
>> Also I believe direct interaction with the PS/2 mouse would
>> give more reliable and accurate results.
>
>I've never used a C64 mouse, but I gather you're implying that the mouse is
>_not_ as smooth & accurate as the PS/2 version - yes??? Then perhaps the
>inaccuracies are inherent in the original mouse itself, rather than the
>protocol and/or frequency at which the mouse is sampled? In that case, using
>a PS/2 adapter would alleviate those problems.

I included a PS/2 to 1531 converter in my keyboard adapter:
http://www.divshare.com/download/3749836-3fa
and I've found the smoothness and accuracy to be very good using the stock
1531 driver that comes with GEOS. In terms of cost, if you only want the mouse
adapter without the keyboard adapter, then a single chip solution would work.
Total parts cost should be under $10 in low quantities.

Connecting directly to the user port should be OK as well. If you use the
built-in serial port in the CIA then you shouldn't need to worry about bad
scan lines since you'll have around 600 us between interrupts. The only two
issues are the inverted clock polarity and the fact that the mouse sends 11
bits per byte while it CIA receives 8 bits per byte. The latter is not a
problem if you set up the mouse to use the 4-byte Intellimouse mode and simply
ignore the Z-values.

Jim Brain

unread,
Nov 14, 2009, 5:05:36 PM11/14/09
to

Nick @ 64HDD

unread,
Nov 15, 2009, 9:24:18 AM11/15/09
to
> http://galaxy22.dyndns.org/dtv/common/ps2mouse/index.html

>
> So my question is this.. if I got this working, would anyone else have
> any software they've written which could benefit?  Or any software
> planned to be written which could use it?

Hi David,
This project of yours always sounded interesting - but never got
around to trying as not applicable to a real C64.

The obvious candidate is GEOS, but depends on the coding footprint to
create a driver. From what I've worked out, you have around ~330bytes
of space to play in for a GEOS input driver (not including pointer
sprite shape definition).

Cheers,
Nick

Groepaz

unread,
Nov 15, 2009, 12:38:18 PM11/15/09
to
David Murray wrote:

> However, since I'm still highly considering making a real-time
> strategy game for the C64, something akin to StarCraft, mouse support
> is apparently needed. I could obviously add support for the 1351 but
> I don't even own one anymore and I think they are getting pretty
> rare. So I was thinking about re-visiting the PS/2 mouse driver
> issue and seeing if I could get it to work on a real C64. The
> hardware to connect the mouse would be extremely simple and cheap. So
> it would be available to everyone at very low cost. Plus you could use
> fancy optical mice, cordless mice, etc.
>
> So my question is this.. if I got this working, would anyone else have
> any software they've written which could benefit? Or any software
> planned to be written which could use it?

i seriously dont see the point on using a custom interface for this... 1351
mice are not rare at all, and everyone who ever wants to use a mouse at his
c64 probably has one by now. also there are cheap interfaces to connect any
ps/2 mouse.

if you use your own interface, your target audience is: 1 - you

--

http://www.hitmen-console.org http://magicdisk.untergrund.net
http://www.pokefinder.org http://ftp.pokefinder.org

Man kann garnicht so dumm denken wie es manchmal kommt.


Jim Brain

unread,
Nov 22, 2009, 3:38:35 PM11/22/09
to
David Murray wrote:

Sorry to resurrect an older thread, but things take time to process.

> Hmm.. Seems we have a concensus.. Everybody wants to plug it into
> their existing joystick port. Okay, I understand the benefit of
> this. But I should point out that the hardware to do this is much
> more expensive. A good example is the device already being sold for
> this purpose which costs around $40. My design would cost only $1.49
> for the cost of a Mini-DIN connector or could even be done for no cost
> at all if the person wanted to solder the cables from the mouse
> directly to the userport connector (I wouldn't recommend) but you get
> the idea.

As I see it, it will cost $3.00 or so for your design, assuming folks
build it themselves. If a unit is sold pre-assembled, that would be
around $7-$10. It's a very attractive price point.

> Also I believe direct interaction with the PS/2 mouse would
> give more reliable and accurate results. granted, I've never tried

I am not sure about that.

> this converter device, but I have tried my own design and the mouse
> movements are just as natural as you would expect on a modern PC. And
> it would leave the joystick ports free for other stuff.

I think cost is the only true advantage.

* PS/2 interface mouse movements are natural as well (not sure what you
were implying with this statement)
* PS/2 CLK signals come in at 80-100uS intervals. I assume your user
port code hooks CLK to an IRQ and then reads all 11 bits of a PS/2 byte
as a single loop. That's 1100uS where you can't service another IRQ.
I don't know if there is a way to force the reading to occur when
desired. PS/2 joystick port interfaces only require only CPU every
16000uS and requires only 3 PEEKs and the same amount of math as with
user port solutions (assuming no mousewheel requirements. Mousewheel
requirements require checking the joystick buttons every 45mS, but
that's better than 80uS.
* The joystick port is unavailable, but the user port is left free for
interfacing. If you truly need a joystick and mouse on the VIC-20,
there is a way to interface a second joystick to the VIC-20 via the user
port that has been available for some time.
* The user port is not very friendly to open-drain IO requirements of
the PS/2 mouse. The VIA does not have software pullups, so pullup
resistors are needed.

> So.. My reasoning is that the direct connection of the PS/2 mouse is
> the best way to go into the future.

Although most VIC mouse apps would not require IRQs, those that do might
have issues.

It is true the normal 1351 does not appear to work on the VIC-20. But,
there is no reason an aftermarket interface cannot be engineering to
work. Such a device would be $4-$8 for the hobbyist, or $15.00
pre-assembled.

Jim


David Murray

unread,
Nov 22, 2009, 9:18:37 PM11/22/09
to
On Nov 22, 2:38 pm, Jim Brain <br...@jbrain.com> wrote:
> David Murray wrote:
>
> Sorry to resurrect an older thread, but things take time to process.

Well, based on the opinions I've seen here, I've decided not to bother
with it anyway. I am not even 100% sure it would work, although I
highly suspect it would since I got it working so nicely on the DTV.
I think a few mods to run the mouse poll during the screen refresh to
eliminate bad-lines would be the only needed change.

My original line of thinking is that there aren't that many apps
available that even have mouse support on the C64 and there are a
total of zero apps that I use these days on the C64 which have mouse
support, so I didn't know that backwards compatibility would be such
an important issue for people. But I guess it is. The only app I
ever used on the C64 or 128 that used a mouse was GEOS and I have no
use for that these days.

Groepaz

unread,
Dec 6, 2009, 3:49:12 PM12/6/09
to
David Murray wrote:

> My original line of thinking is that there aren't that many apps
> available that even have mouse support on the C64 and there are a
> total of zero apps that I use these days on the C64 which have mouse
> support, so I didn't know that backwards compatibility would be such
> an important issue for people. But I guess it is. The only app I
> ever used on the C64 or 128 that used a mouse was GEOS and I have no
> use for that these days.

backwards compatibility is THE issue for any kind of new hardware for the
c64. as you say there are already only few apps that supports exisiting
mouse solutions. and these apps are what whatever new mouse interface must
work with, because noone will come around and patch existing software, or
even write new one from scratch.

--

Die [weiber] wollen entweder a) ficken oder b) sich darᅵber beschweren, dass
mᅵnner nur ans ficken denken
<Graham/Oxyron>


0 new messages