| Posted By
MMS on 2016-12-25 09:07:45
| PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
Hello Folks,
I just uploaded a PDF with the documentation of BSZGG and my project "RS232 PC serial mouse for Commodore Plus/4". This explains the hardware how to build to get a cheap RS232 interface working with Plus/4, how you can link it with a PC RS232 serial mouse, and what is the protocol behind. (That small adapeter may also communicate with standard RS232 modems (later) or even developed further to "go Wifi". Certainly we will need a proper terminal program managing it )
Merry Christmas to you, this is our gift for the scene. From my point of view, it was one of the "Holy Grails with no real solution" on our platform.
During my work I found, that in the past similar c64 models were implemented and posted from time to time, the most recent and similar one linked in the project document too they work almost identical to ours. Even more surprising it seems that even Commodore VIC-1011A could do the job without (major) modification, unfortunately rather rare and expensive (but this need to be checked with a real piece yet). The connection to Data0 on c64 made to speed up data transfer, it is a question how plus/4 could manage it.
Still the weakest part is the SW support need to work on. As the speed is essential, and a lot of bit banging happens to get the coordinates and button status from the 3 bytes sent by the mouse , the calculation on zero page code would be more than beneficial. Unfortunately the resident driver code (originally programmed for $6000) could not be reduced in it's original form to fit into the zero page free areas. It also have a nasty overflow bug I could not solve yet, but I am not a great programmer. ;-)
Based on the C code maybe the scene can create something useful and efficient in the zero page. After that a Basic code can use the coordinates to demonstrate it's working, and want to hack Botticelli to able to use it.
No standard place defined yet for the final mouse data, maybe it should be in the zero page speech area. X coordinate (2 bytes) Y coordinate (1 byte) Left and Right Button status (1 byte's lower and upper half first 1 bit, with value of 0, 1 (right button active) and 16(left button is active ) )
|
|
Posted By
JamesC on 2016-12-25 11:27:56
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
Just for clarification -- have you built a RS232 interface, or are you suggesting how others might build one (and program for it)?
The Plussy has the 6551, which can do up to 19,400 bps. Does your project utilize it? If we can read RS232 data from the 6551 directly (at $FD00-$FD0F) then we might save precious CPU cycles that would otherwise be spent "decoding" (64/128 term: "bit banging") it. Which may free us to use non-zeropage memory and not worry so much about system speed.
My two cents/pence/fractional Euro: please don't reassign Speech memory for other purposes. While there aren't any 364s in common use, YAPE supports it. YAPE also supports a lightpen and SID cards, so we should allow for the possibility of YAPE supporting an RS232 interface at some point. If I could use a mouse within YAPE *and* retain Speech, I would appreciate it.
If you are willing to use non-zeropage memory, function key memory is rarely utilized to its potential. You could reassign a few bytes ($05DF-$05E6) and the system would never know.
|
|
Posted By
MMS on 2016-12-26 11:09:39
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
Hi JamesC,
-Actually when the PDF will be readible, it will be all clear for your. In short: I have the HW on my desk.
-Thank you for your comments and suggestions related to the speech mem area! I will consider it in the final version, though I calculated with speech area as 141 byte free mem. I want to make the driver positioned at an area do not collide with any program (including BASIC). It could be positioned on the upper (>60K) RAM area too, as we do not have such huge utility programs, except of very few cases.
-Thank you for the hint on the Function key mem area.
-Corr: Yeah I made a mistake: in the zero page area there is no space for the code, just for the mouse position value stored there. It can make the code shorter due to shorter addresses and faster code. There is an zero page area I can use 00D8-00E8, supposed NOT to be used by the speech module (as per SVS map) I meant for the resident code the below $1000 area, but without speech area it is only ~200 bytes long (even with tapy buffer)
Some answers: -Yes, the original code happens with ACIA too. Without it, most of the CPU time would be spend just looking for the data come in via User port.
-When the byte comes in (change in mouse status), it generates an IQR at ACIA and we store the first byte. Then the second byte does the same, and the third too. After that we start the decoding.
-As my PDF still not visible in my post, I show you why we need a fast routine: The RS232 mouse sends 3 bytes (but only 7 bit long) in the form like this: D7 D6 D5 D4 D3 D2 D1 D0 1. x 1 LB RB Y7 Y6 X7 X6 2. x 0 X5 X4 X3 X2 X1 X0 3. x 0 Y5 Y4 Y3 Y2 Y1 Y0
The X and Y values are the movement of the mouse comperated to previous state.
Positive is right direction, format is in two's complement for to able to give negative result too, highest 7. bit means -128 and all the rest is positive number. Mouse+protocol" target="_blank" rel="nofollow">http://everything2.com/title/Mouse+protocol
As you can see, it a lot of bit rotation and some calculations needed just to get eg total Y movement. And certainly it sould be added to the previous position too. That's why I called it bitbanging (BTW the serial mouse position change value seems too high for Plussy, so we may need to divide the incoming value by two, just a single rotation)
So with the use of ACIA getting the 3 bytes is not a real issue, but ACIA cannot help to create from these received 3 bytes useful data, it is a CPU "wood cutting" task.
|
|
Posted By
JamesC on 2016-12-26 14:25:34
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
If you only seek 3 bytes in ZP, consider the odds of someone RENUMBERing a program while using a mouse. Practically zero, since entering or modifying a program is a keyboard activity. This frees $03-$06 for your mouse pointer data.
Will your interface only support one RS232 device at a time? If so, we cannot use a mouse and a modem at the same time. If we give up tape support too, this frees $0332-$0472 (320 bytes) for your mouse driver. (The RS232 buffer is in this area, which is why I ask about modem and mouse together.)
We don't have a list of programs known to use the application ZP area at $D8-E8. You would not be happy to write your code to use that area, then later discover that your graphics program (or flight simulator, or word processor) is overwriting your mouse data.
Similarly, we don't know with certainty that someone hasn't already appropriated the Speech areas for their own program(s).
At least we know what uses a modem or a tape drive.
|
|
Posted By
MMS on 2016-12-26 18:33:09
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
OFF
1) you are right. it has zero chance.
2) The circuit in this current form only utilizes only the TXD line of the TTL converter circuit (as I need only incoming signals from the mouse), but it takes only a small additional soldering joint to link it to the Pin M of the User Port to the RXD line to get a full scale RS232 I/O device.
(BTW I was thinking, why the C64 equivalents connecting the TXD to both B and C lines, while I found C only sufficient enough?)
(As nobody wants to print anything with a Commodore Plus/4 (in real life), especially not with an EPSON RS232 printer and we do not have yet a terminal program to reach BBS (?) the major task of the project still to realize the mouse as an input device, but with some future potentials)
The next steps could be with some additonal circuitry: MODEM: as you mentioned, by connecting RXD to Pin M it will be possible. (I have no analogue telephone line in my house any more to test it (though I still have a working RS232 modem) )
USB: RS232 to USB with a converter (I have such a circuit). As I read, on PC side the Striketerm can do the job.
In fact I am more interested (as you already know) the 8bit Covox like digital sound output card via User Port and to make my SFD-1001 work properly with Plussy. (I have the IEC2IEE adapter, but have no QD floppies and have a probably dirty disc drive head)
Thinking how I can make the best use of both in a single card (and user port connector), making somehow modular or what...
|
|
Posted By
JamesC on 2016-12-26 19:49:13
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
The 64 and Plus/4 userports *are* different. Could the B line be necessary on the 64 to gain the 6526's attention?
I don't know of many people who use a modem to call a BBS anymore. There are very few BBSses in the US these days, most have moved to web pages. So, to me, modem support is not essential. (Plus I have a Commodore modem packed away, in case I ever want to be 16 again. )
My interest in this project is mostly for compatibility with other programs now, possibly with YAPE at some point. Do as you desire, don't let me hold you to any particular idea.
|
|
Posted By
MMS on 2016-12-27 09:34:46
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
OFFs (it is nice feeling to make my own topic offtopic, haha ) -Actually the two userports are different, but it seems for serial port (RS232 style in TTL) communication they are *almost* pin equivalent.
Question remains: What will the connection to B line cause in Plussy? (I checked the circuit diagram of the VIC-1011A, it happens) On C64 B is the Flag bit for CIA, and the C is the Data0 (of the 8 paralell data bits). Hm. In our case B is the Data0 (will be not used for serial transfer) but as a ACIA manages an IRQ when data (level) appears on pin C (Receive data). Seem they will behave the same way, even if a C64 RS232 or modem card connected to Plus/4. It could happen, that C64 Commodore modems and RS232 interfaces are 100% Plus/4 compatible?
-In the V3 version of the document I will add the RXD connection to userport, and the MAX232 IC pin layout too, in case somone wants to built his/her own. By this, the interface will be a full I/O RS232 device (from hardware point of view).
|
|
Posted By
Litwr on 2016-12-27 10:30:56
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
I've just written some codes to translate ACIA 3 bytes to X and Y current coordinates.
LDA ACIA1 and #$0c asl asl asl asl sta label1+1 lda ACIA3 and #$3f label1 ora #0 adc current_Y ;we may add some checks here to prevent cursor from leaving the screen sta current_Y lda ACIA1 and #3 clc ror ror ror sta label2+1 lda ACIA2 and #$3f label2 ora #0 adc current_X ;possible checks sta current_X
It looks easy. There is also problem how to distinguish TED and ACIA IRQs?
|
|
Posted By
MMS on 2016-12-27 11:21:22
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
Hi,
thanks! That's great! our code looked much much longer and more complex, I dunno why
1) BTW how did you manage the negative value movements? I tried to follow your code, but missed that point. My bad... The highest 7. bit of the X7-X0 and Y7-Y0 means -128, this is the maximum left /up movement at once, and +127 is the maximum right /down one. We could manage it only with a lot of jumps in the code.
2) Actually, no. What we checked in Multibotticelli that it does not use IQRs, so ACIA could be the only one. In case of Graphic3 mode in BASIC, could cause some troubles. Otherwise no IRQs expected, at least in BASIC.
|
|
|
Posted By
Litwr on 2016-12-27 11:38:14
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
>1) BTW how did you manage the negative value movements? The same as the positive because it is two's complement. For example, -1 = $ff, 5-1=5+$ff.
2) What we checked in Multibotticelli that it does not use IQRs, so ACIA could be the only one. The raster interrupts provide timer and should not be disabled even by Multibotticelli.
|
|
Posted By
bszggg on 2016-12-27 13:25:05
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
Hi!
I noticed this post... I'm writing my problems with this. (Though I haven't worked on it for years.)
My once problem was the limit. Because the 320 (320 × 200) is better than 255. So we need the set the limit. It is need if lower than 0, and need the upper limit if over then 320. And it is necessary to set the upper limit, because...
-My idea was a mouse driver for operating systems. Because we can count the cursor position to mouse in the screen, and it is setted to char background color. If we click on the mouse, we can set the normal cursor position with mouse position. It is help me to navigate on the screen. But I couldn't make the cursor position. (and the screenroll make my mousepointer color to wrong. It is need to clear the color screen, but my program was too slow to solve it.)
-Other useful option, if we can read the counted mouse position for BASIC programs, But my problem was the different speed of basic and asm. If I try to read the position from basic, the upper and lower number changed.. And the basic program wasn't good.
So the problem of me not the read from ACIA... My problem was these informations built to a useful solution.
|
|
Posted By
MMS on 2016-12-27 14:05:22
| Re: PC RS232 Mouse project for Plus/4 User port_a cheap and working one :-)
Maybe the resident driver shoould store the position for the GFX mode and the character mode independently, as in assembly it takes only a 3 ROR commands do divide by 8 to get the position in character mode. (omg, we did not speak about multicolor and hire mode differences...)
XHires (2 bytes): 0 - 319 YHires (1 byte): 0 - 200
XChar (1 byte): 0 - 39 YChar (1 byte): 0 - 24
Maybe we try to reinvent the wheel now, but there could be available mouse drivers for C64? Because they had the RS232 cartridge. Just asking.
OK, update: at least we have a mouse driver for the SID+1351 mouse :-) http://www.creators.no/dokuwiki/doku.php?id=ctr_mouse_driver
|
|
| |
Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon |