Thursday, 18 January 2018

Repairing an Amiga Mouse, and then using it on the MEGA65

As anticipated earlier, I have added transparent support for Amiga mouses to the MEGA65, so that people don't have to find a 1351, and can use the existing USB to Amiga mouse adapters, to allow use of newer mouses.

To get that working, I put out an appeal on Facebook for anyone who had an Amiga mouse to spare (not necessarily 100% working, just enough so that I could test with), and a kind person from Tasmania sent me one with a problem with the X axis.  Nonetheless, it was enough for me to do what I needed to do, and as a result the MEGA65 works very nicely indeed when an Amiga mouse is plugged in, and can automatically detect an Amiga mouse, 1351 mouse, paddles and joystick -- in real time -- and switch modes on the joystick port as required, so that no user fiddling is required.

This all works by looking at what the digital and analog lines are doing on each joystick port, to see whether the behaviour matches one or the other type of device.  It all turned out to be relatively simple in the end, requiring only a modest amount of fiddling to get it stable.

However, as I mentioned, the Amiga mouse that was donated was a bit sick, and I would really like it fully working, as I can use it with the MEGA65 r1 PCB without any funny adapters to route the POT lines, as I currently do for the 1351 mouse (this will of course be fixed on the r2 PCB).  So I started poking around in the mouse today to find out what is wrong, exactly.

It didn't take long with the multi-meter to work out that the voltage output of one of the infra-red light sensors on the mouse was a bit lower than it should be. The mouse shows signs of having been physically repaired around that part of the assembly, so it isn't too surprising, really.  A bit of looking at Amiga mouse schematics I could see that the mouse sensors are fed through a LM339 type comparator to produce a nice 5V square-wave output from the fuzzy light sensor readings. 

Each light sensor is paired with a reference voltage that is used to determine whether to output 5V or 0V, depending whether the sensor voltage exceeds the reference voltage or not.  Since the problem was the sensor voltage was a bit low, I figured the easy solution was to put a bit of extra bias towards 0V on the reference voltage, so that the sensor voltage would again be correct.  It looked like there was about 1.5K resistance between the reference voltage and ground, so I thought I would start by adding a 2K Ohm resistor between the reference voltage and ground, like this:

Only I realised when testing that I had put the bias on the sensor voltage instead, i.e., making the problem worse, rather than better.  So then I though, well, why don't I just put the bias towards 5V on the sensor voltage, like this:

Only it turns out that that doesn't work. I didn't bother exploring why.  So, back to Plan A, only this time with the correct pins:

The astute observer will notice that the above picture shows a 1K not 2K resistor. This was because in testing I found a 1K resistor provided the correct bias correction.

Then it was time to test on the MEGA65 using the Mouse Test 2 program, which as we can see below I was able to use to move the 1351 mouse indicator, with the others staying put -- even though I was using an Amiga mouse:

 However, that is all a bit dull to look at, so I made a short video showing it in action, with me turning on and off the 1351 emulation mode on and off in real-time:

So now the mouse all works very nicely, and I can work on software that uses the mouse.


  1. Hi Paul,

    i have a question regarding the mouse support.
    Do you know, by any chance, if the micromys v4 would work on the MEGA65 (
    This is the mouseadapter, i am using with my c64 for quite a while now, because i can use a standard USB/PS2 lasermouse with it.

    1. I don't have one here to test with, but given how we have almost exactly replicated how the POT lines work on the MEGA65, I would be quite surprised if the micromys didn't work.


  2. How about supporting emulation of NEOS mouse? Some c64 games use it but don't work with 1351.

    1. I haven't added it at this stage, but it should be possible to do. It won't be able to happen until the next revision of the MEGA65 PCB, however, as it requires that the joystick lines be bidirectional, from what I can see at

    2. ... sorry, I have just confused myself: To use a real NEOS mouse, will require the r2 PCB. However, NEOS emulation should be possible. Having an actual mouse here or detailed technical information on the NEOS mouse would help in doing so. I can find the decompiled source for what looks like a GEOS driver for it, but that's all so far.

  3. How about supporting NEOS mouse emulation? Some c64 games use it and they don't support 1351.

  4. Is it possible to support NEOS mouse emulation? Some c64 games use it and they don't support 1351.

  5. Is it possible to support NEOS mouse emulation? Some c64 games use it and they don't support 1351.