Mouse Support Over the COM2 Port in PCXT Core

User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

I am moving the question of the Mouse support to a new thread:
spark2k06 wrote: Mon Sep 12, 2022 9:31 am
Mouse support over the COM2 port, based on the great work Antonio has done with the PS/2 to Serial wrapper he has developed:

https://github.com/MiSTer-devel/PCXT_Mi ... com2-mouse

For now, I am using a 1.844262 MHz clock via PLL for clk_uart for both ports, so that it is compatible with the 1200 baudrate required by the serial port. So, the disk image must be set to 115.2Kbps for it to be recognised.

The serial port is working correctly, the problem here seems to be the handling of the PS/2 signal coming from the MiSTer mouse emulator:

mouse_com2.jpg

Although mouse events are detected and generated, the results are not correct because it performs random movements and records mouse button presses when they are not actually taking place.
kitune-san wrote:
@kitune-san, maybe you could give us a clue on this, I would appreciate it... I am stuck on these points.
somhi
Posts: 88
Joined: Mon Jul 18, 2022 4:37 pm
Has thanked: 25 times
Been thanked: 25 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by somhi »

I've been testing for the direct DeMiSTify ports the latests improvements done by Antonio (@thesonders) with the PS/2 to Serial wrapper.

What I've reached so far is that the mouse is recognized well as Microsoft mouse mode and I could test the mouse in Norton Commander, Monkey Island and Arkanoid games, but after a few seconds (sometimes minutes) the mouse stops working.

When I do the tests with Norton Commander I can see that if I don't access any folder the mouse keeps working, but when Serdrive at COM1 starts working it hangs the mouse most of the time.

We are very close to get the mouse working in direct ports (not using MiSTer framework and it's HPS) but there seems to be maybe a synchronism problem or interference with COM1 port. I cannot explain exactly what is going on.

The wrapper's output is at exactly 1200 bps.

COM2 was added here at https://github.com/somhi/PCXT_DeMiSTify ... pherals.sv by the previous work done by @spark2k06.

We need some help by @kitune-san on these to check what is going on with the COM Ports. After we get it working here I thing it will be easier to port to MiSTer.
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by Caldor »

Ahh, that sounds like some good progress :) Once mouse is working I plan on making some more videos of this core. I have been testing several games and found a collection I want to show off that uses CGA and Tandy graphics, but I have a few games that I want to show in those that actually refuse to load if no mouse is detected. Most games do support just moving a cursor around with the arrow keys or something like that, but The Adventures of Robin Hood f.ex. refuses to load without a mouse. But its an action adventure game and without a mouse you would not be able to react fast enough and such. I think there were one or two other games as well, but I do not remember any other specific names right now.
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

Caldor wrote: Tue Oct 04, 2022 8:07 am Ahh, that sounds like some good progress :) Once mouse is working I plan on making some more videos of this core. I have been testing several games and found a collection I want to show off that uses CGA and Tandy graphics, but I have a few games that I want to show in those that actually refuse to load if no mouse is detected. Most games do support just moving a cursor around with the arrow keys or something like that, but The Adventures of Robin Hood f.ex. refuses to load without a mouse. But its an action adventure game and without a mouse you would not be able to react fast enough and such. I think there were one or two other games as well, but I do not remember any other specific names right now.
Fortunately, there are mouse emulators based on keystrokes such as cursors:

https://ftp.sunet.se/mirror/archive/ftp ... dos/mouse/
http://www.lanet.lv/simtel.net/msdos/mouse.html

photo_2022-10-04_11-30-03.jpg
photo_2022-10-04_11-30-03.jpg (121.18 KiB) Viewed 19943 times

Don't let that stop you from making the video ;)
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by Caldor »

Nice, I had thought about looking into finding some mouse emulators like these, but my early googling had fallen short. Thanks :)
somhi
Posts: 88
Joined: Mon Jul 18, 2022 4:37 pm
Has thanked: 25 times
Been thanked: 25 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by somhi »

@kitune-san, some notes of the mouse testing done today by @thesonders:

Well, I'll explain what I do and you can discuss it with whoever you want:
-ctmouse /s2
- Correctly detected with a Microsoft mode
- Open Norton (NC)
- The mouse works correctly
- When I open the Windows directory (it takes a few seconds), the mouse stops responding
- I leave Norton
-ctmouse /u
-ctmouse /s2
- Mouse is not detected well (is detected as mouse systems mode)
- While doing so, the wrapper continues to transmit and function well (output signal redirected to a signal analyser)
- "Flushing" the COM port with command > copy COM2 empty.txt
- CTRL+PAUSE
- Reinstall ctmouse and it works correctly again

My CONCLUSION: when COM1 is accessed (or COM2 get stuck) the UART buffer fills up and ctmouse do not receive data from COM2.
Once COM2 is emptied or flushed, everything works again.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by kitune-san »

Sorry. I have not been able to act on this matter yet.

As I recall, the mouse is a device that generates many interrupts.
It might easily hang up when other interrupt processes are busy.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by kitune-san »

memorandum
- Check that hardware flow control is enabled.
- when unable to accept reception, PS2 CLK signal is set Low.
flynnsbit
Top Contributor
Posts: 552
Joined: Sun May 24, 2020 8:07 pm
Has thanked: 185 times
Been thanked: 310 times
Contact:

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by flynnsbit »

This topic sparked a memory for me with the PCJr and the keyboard issues when running at a higher baud rate when connecting to a BBS, it would cause issues if you had lots of data coming in and pressed a keyboard key at the same time. Could this be happening due to the XTIDE COM data + the mouse data coming in similar to the notes below? Not sure what you all can do with this but maybe it could give you some insights.

From Using a modem section of the FAQ here: https://www.brutman.com/PCjr/pcjr_tips.html

_________________________________________________________________________________________

[Using a Modem]
My PCjr spent a lot of time connected to other machines, via a modem. For many years it was used to dial BBS systems and trade DOS utility programs. When I went to college, it was used to connect to the Unix hosts there.

The best modem to use is an external modem. The internal modem that IBM offered only transferred data at 300bps, and it had a strange command set that was not Hayes compatible. Any old (9600 bps or less) external modem using the Hayes command set is a good choice.

Note: According to the technical reference guide for the PCjr, it is not recommended to drive a modem faster than 1200bps. The PCjr is just too slow. Here is the technical explanation (paraphrased):

The PCjr uses the Non-Maskable Interrupt of the 8088 processor to handle the keyboard, which is a departure from other PCs of the era. Non-Maskable means that the interrupt can't be ignored. At 2400bps data is coming in fast, but the PCjr is fast enough to read it. However, if you press a key on the keyboard, the PCjr will drop what it is doing and decode the key. Keyboard decoding time is too long, which can cause data to be missed at the serial port.

The 8250 UART chip can be programmed to do 4800 baud. The machine is certainly fast enough. You just can't type while it is happening.

Another problem for the PCjr is the lack of a DMA controller. If you are receiving data at any speed from the serial port and the diskette drive is activated, you will lose data from the serial port. The processor will spend all of it's time servicing the disk drive, causing the serial port bits to "drop on the floor."


I used my PCjr for years at 2400bps with few problems. Here is why it worked for me, and how you can make it work for you:

Use a PCjr with expanded memory, and run your program from that memory. Memory accesses above the 128KB mark are faster because the PCjr's video hardware does not intefere. See "The Memory Subsystem" for details. If you do this, you should drop less bytes because the machine has more time to monitor the serial port. Keystrokes may still cause you pain.
Add a NEC V20 to your PCjr to speed the processor up. The extra 5 or 10% performance improvement might allow keyboard decoding to happen and finish between bytes coming in on the serial port.
Don't type while data is coming in. ;-)
Don't use the diskette drive while data is coming in. If you need to download, download files to a ram disk and transfer the files to floppy after the download has completed.
Super Hackers only: The 8250 can be replaced with the 16550 rather easily. The 16550 is capable of buffering up to 16 bytes. With some software to drive it, you can cut the interrupt overhead a lot by processing more than one character at a time.

Faster modems may work with the PCjr, although your risk of data loss increases. You are better off if you just limit the interface speed to 2400bps, even if you have a faster modem.

You will need the serial port adapter to do this. You will also need software, such as Qmodem, Procomm, PC Talk, or any old DOS based program. And finally, you may need the COMSWAP utility to correct the COM port weirdness discussed in the hardware section.

See "The Serial Ports" for a discussion on the PCjr serial port hardware.
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by Caldor »

So... a simple solution might be to boot from a floppy and mouse should work? That is, boot from a floppy and not have any HDD at all, to avoid the HDD from disrupting the mouse?

Amazing how many of the things that seems to be bugs and problems are really just the core acting the way its supposed to :)
somhi
Posts: 88
Joined: Mon Jul 18, 2022 4:37 pm
Has thanked: 25 times
Been thanked: 25 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by somhi »

kitune-san wrote: Wed Oct 05, 2022 12:25 am Sorry. I have not been able to act on this matter yet.

As I recall, the mouse is a device that generates many interrupts.
It might easily hang up when other interrupt processes are busy.
Yes, but if the mouse doesn't move, uart2's buffer shouldn't be filled, so it shouldn't generate interrupts.
When the ps2 mouse doesn't move, the wrapper doesn't even output the serial start bit. There is no transmission.
kitune-san wrote: Wed Oct 05, 2022 12:25 am memorandum
- Check that hardware flow control is enabled.
- when unable to accept reception, PS2 CLK signal is set Low.
I have RTS/CTS enabled on COM1 for serdrive.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by kitune-san »

Could you confirm that the irq signal on the uart goes low each time one byte of data is read?
Or could you check if the irq signal goes low when the mouse hangs up?

I remember that pcxt bios was set to accept interrupts on the rising edge.
If irq does not go low until fifo is empty, then there may be a problem with uart interrupt.
somhi
Posts: 88
Joined: Mon Jul 18, 2022 4:37 pm
Has thanked: 25 times
Been thanked: 25 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by somhi »

Thanks kitune-san, we will check it.

One thing to notice is that I was able to check a direct PS2 mouse attached to external pins of the Sockit fpga with the same Core and MiSTer framework as De10-nano with only FDD (no using Serdrive at all) and I could see the mouse cursor moving in Norton Commander but it hanged after a few seconds of moving the mouse.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by kitune-san »

somhi wrote: Sat Oct 08, 2022 9:06 am Thanks kitune-san, we will check it.

One thing to notice is that I was able to check a direct PS2 mouse attached to external pins of the Sockit fpga with the same Core and MiSTer framework as De10-nano with only FDD (no using Serdrive at all) and I could see the mouse cursor moving in Norton Commander but it hanged after a few seconds of moving the mouse.
Now I am reading the wrapper code....
The PS/2 data and the ByteSync signal may not be synchronized.
2022-10-09 214337.png
2022-10-09 214337.png (55.61 KiB) Viewed 19538 times
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

kitune-san wrote: Sun Oct 09, 2022 12:47 pm
Now I am reading the wrapper code....
The PS/2 data and the ByteSync signal may not be synchronized.
I have updated the exp-com2-mouse branch with the latest release, which has FDD support and also has the new UART 16750:

https://github.com/MiSTer-devel/PCXT_Mi ... com2-mouse

On the other hand, you will notice that I have made a small change suggested by Antonio, author of the MouseWrapper:

https://github.com/MiSTer-devel/PCXT_Mi ... 8721226a80

20221010_094905-screen.png
20221010_094905-screen.png (164.48 KiB) Viewed 19451 times
20221010_095007-screen.png
20221010_095007-screen.png (165.16 KiB) Viewed 19451 times
Despite these changes, the stream version needed for MiSTer still doesn't work, it doesn't respond to PS/2 events, however, as you can see, it has recognised the 4Dh byte corresponding to the Microsoft mode mouse protocol, so that's where we are.

I have passed your query on to Antonio, and what he tells me is as follows:
In the stream version, in the screenshot you have sent, line 275 is the one in charge of synchronisation
sync.png
sync.png (6.73 KiB) Viewed 19451 times
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by kitune-san »

Attachments
PCXT.zip
(1.34 MiB) Downloaded 257 times
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

kitune-san wrote: Mon Oct 10, 2022 8:46 am Could you try this?

https://github.com/kitune-san/PCXT_MiST ... ture-mouse
It is too sensitive, but it works!



The mouse must move very very slowly, but apart from that, it is very stable :-)
Mills
Posts: 90
Joined: Mon Jun 08, 2020 2:52 pm
Has thanked: 15 times
Been thanked: 32 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by Mills »

kitune-san wrote: Mon Oct 10, 2022 8:46 am Could you try this?

https://github.com/kitune-san/PCXT_MiST ... ture-mouse
Thanks!.

Y axis looks ok, X axis has issues, cursor gets stuck at the borders.
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

Mills wrote: Mon Oct 10, 2022 11:21 am
kitune-san wrote: Mon Oct 10, 2022 8:46 am Could you try this?

https://github.com/kitune-san/PCXT_MiST ... ture-mouse
Thanks!.

Y axis looks ok, X axis has issues, cursor gets stuck at the borders.
I with both axes... the Y immediately overflows too if you move a bit too fast when it should reach each end and that should be its limit.
kitune-san
Top Contributor
Posts: 401
Joined: Wed May 18, 2022 11:20 am
Has thanked: 127 times
Been thanked: 412 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by kitune-san »

Maybe following modifications are needed
2022-10-10 223225.png
2022-10-10 223225.png (9.54 KiB) Viewed 19312 times
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

kitune-san wrote: Mon Oct 10, 2022 1:11 pm Maybe following modifications are needed

2022-10-10 223225.png
That was the reason, thank you very much!



I attach it here, but it will be available in the next release.
Attachments
PCXT_mouse-feature.zip
(1.33 MiB) Downloaded 258 times
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

@kitune-san, I'll pull request myself on the prerelease branch with your changes.

Thanks for everything!
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by Caldor »

Awesome :) Time to try some mouse games :D
suww37
Posts: 173
Joined: Sun Apr 17, 2022 2:24 am
Has thanked: 7 times
Been thanked: 15 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by suww37 »

spark2k06 wrote: Mon Oct 10, 2022 2:20 pm @kitune-san, I'll pull request myself on the prerelease branch with your changes.

Thanks for everything!
Great! Now all that's left is a Hercules garphic module transplant? The "ski or die" game is not running normally yet, and I hope this will be resolved too. Thank you.
jordi
Posts: 282
Joined: Thu Jun 11, 2020 10:11 am
Has thanked: 112 times
Been thanked: 87 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by jordi »

suww37 wrote: Mon Oct 10, 2022 10:03 pm
spark2k06 wrote: Mon Oct 10, 2022 2:20 pm @kitune-san, I'll pull request myself on the prerelease branch with your changes.

Thanks for everything!
Great! Now all that's left is a Hercules garphic module transplant? The "ski or die" game is not running normally yet, and I hope this will be resolved too. Thank you.
have you tried as tandy or cga modes?
Mills
Posts: 90
Joined: Mon Jun 08, 2020 2:52 pm
Has thanked: 15 times
Been thanked: 32 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by Mills »

Mouse is working fine now:

Cartooners:
20221011_090745-screen.png
20221011_090745-screen.png (264.63 KiB) Viewed 19018 times
GEM desktop (install microsoft mouse):
20221011_090924-screen.png
20221011_090924-screen.png (104.94 KiB) Viewed 19018 times
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

suww37 wrote: Mon Oct 10, 2022 10:03 pm
Great! Now all that's left is a Hercules garphic module transplant? The "ski or die" game is not running normally yet, and I hope this will be resolved too. Thank you.
The problem is that there is no Hercules module, someone has to make it from scratch.

Regarding the ski or die game, there must be some versions that crash more than others, and it also happens in PCem, as far as I have been able to check. It's a matter of finding the right version of the game,
suww37
Posts: 173
Joined: Sun Apr 17, 2022 2:24 am
Has thanked: 7 times
Been thanked: 15 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by suww37 »

spark2k06 wrote: Tue Oct 11, 2022 9:31 am
suww37 wrote: Mon Oct 10, 2022 10:03 pm
Great! Now all that's left is a Hercules garphic module transplant? The "ski or die" game is not running normally yet, and I hope this will be resolved too. Thank you.
The problem is that there is no Hercules module, someone has to make it from scratch.

Regarding the ski or die game, there must be some versions that crash more than others, and it also happens in PCem, as far as I have been able to check. It's a matter of finding the right version of the game,
I know it. I think the hercules mode is not very interested in Westerners, I know that hercules graphic adaptor was developed to express the language of Asians. I just want someone to develop it, but it's a pity that it's not possible. And "ski or die" ran all versions with "google search" but I failed to work, other XT machine versions with pcem I remember this game was running on it.
User avatar
spark2k06
Core Developer
Posts: 876
Joined: Sat Jun 06, 2020 9:05 am
Has thanked: 409 times
Been thanked: 969 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by spark2k06 »

suww37 wrote: Tue Oct 11, 2022 9:44 am I know it. I think the hercules mode is not very interested in Westerners, I know that hercules graphic adaptor was developed to express the language of Asians. I just want someone to develop it, but it's a pity that it's not possible. And "ski or die" ran all versions with "google search" but I failed to work, other XT machine versions with pcem I remember this game was running on it.
It would be more interesting to have a real 8-bit IDE to avoid serdrive and we are still in the situation we are in. It's not that it's impossible, it's that the developer who does it has to have a lot of interest in it and that it's really worthwhile compared to other projects.

Regarding ski or die, don't you remember.... then check it out, and if it works but not here in the core, give us the link and maybe we can find out why ;)
User avatar
Hodor
Posts: 142
Joined: Mon May 25, 2020 8:29 am
Has thanked: 378 times
Been thanked: 30 times

Re: Mouse Support Over the COM2 Port in PCXT Core

Unread post by Hodor »

Does the mouse work out of the box or need some driver installation? Sorry for asking, but core´s readme doesn´t show any info yet.
Post Reply