Login
Back to forumSee the full topicGo to last reply

Posted By

MMS
on 2016-05-19
17:17:06
 Re: Mouse for Plussy

Yes the two options are right, in fact these two are three happy

1) The NST BSZ SID Card can support in it's latest revision on it's joy port
A) analog Commodore 1351 mouse
B) digital ATARI ST/AMIGA mouse.
There is a proper documentation about that, how you can read the data out.

I try to make PDF out of the original document I received for my SID Card, documenting these registers.


2) With the help of easily available MAX232 circuit on User Port, connected to an RS232 serial PC mouse.
I work on this with BSZGG.
Definitely the HW is ready, and pretty simple and cheap to build (maybe from 6-10 € you have everything, but you can get the mouse free or cheap from local used HW shop)

But I have troubles to compress the driver somewhere useful for the BASIC too (sorry, my lameness, I wanted to use it in my adventure too happy and both projects are waiting to the other one), and also there was a bug inside the driver.

So there is a PDF about HOW to build, and I just started to write about the RS232 protocol, and how to handle it via USER Port.
Today I upload the first draft in PDF (but I am not a HW professional, haha!)

How it will work?
Actually the mouse sends 3 bytes after the IRQ, in a rather strange structure
1) one byte contains the button status and the minority upper bytes of coordinates
2) majority of X coordinates
3) majority of Y coordinates

We did not finish to finalize where we want to store the X, Y coordinates and the mouse Button status

D6 D5 D4 D3 D2 D1 D0
1st byte 1 LB RB Y7 Y6 X7 X6
2nd byte 0 X5 X4 X3 X2 X1 X0
3rd byte 0 Y5 Y4 Y3 Y2 Y1 Y0

http://paulbourke.net/dataformats/serialmouse/

In C the decoding:

void DecodeMouse(unsigned char *s,int *button,int *x,int *y)
{
*button = 'n'; /* No button - should only happen on an error */
if ((s[0] & 0x20) != 0)
*button = 'l';
else if ((s[0] & 0x10) != 0)
*button = 'r';
*x = (s[0] & 0x03) * 64 + (s[1] & 0x3F);
if (*x > 127)
*x = *x - 256;
*y = (s[0] & 0x0C) * 16 + (s[2] & 0x3F);
if (*y > 127)
*y = *y - 256;
}

Or in a little more detailed form from http://www.cpcwiki.eu/index.php/Serial_RS232_Mouse:

"Standard Serial Mouse (most common)

A serial mouse should be read at 1200 bauds, 7 data bits, no parity, 1 stop bit (7N1) with DTR and RTS on. For best compatibility, the mouse should output 2 stop bits (so it could be alternately also read as 7N2 or 8N1).
When the mouse gets moved, or when a button gets pressed/released, the mouse sends 3 or 4 characters:
__First Character____________________
6 First Character Flag (1)
5 Left Button (1=Pressed)
4 Right Button (1=Pressed)
2-3 Upper 2bit of Vertical Motion
0-1 Upper 2bit of Horizontal Motion
__Second Character___________________
6 Non-first Character Flag (0)
5-0 Lower 6bit of Horizontal Motion
__Third Character____________________
6 Non-first Character Flag (0)
5-0 Lower 6bit of Vertical Motion
__Fourth Character (if any)__________
6 Non-first Character Flag (0)
5 Middle Button (1=Pressed)
4 Unused ???
3-0 Wheel ???"



Back to top


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon