Page 6 of 10

Re: TFMSX rev 2 features & problems

Posted: 12 Nov 2023 18:25
by arkadiusz.makarenko
@NYYRIKKI
Could you confirm that MSX mouse works as expected over normal gameport on TFMSX?
I am getting random readings and I am not sure why?

Re: TFMSX rev 2 features & problems

Posted: 19 Nov 2023 21:40
by NYYRIKKI
Hi again!

I did some more testing today, and I have some new test results:

USB-Joypad: I did test it today for the first time and it puzzled me a moment, what is wrong with it, until I realized that you got all the directions wrong... With that I mean that now UP is DOWN, DOWN is UP, LEFT is RIGHT, RIGHT is LEFT, direction pushed is direction lifted and direction lifted is direction pushed. So... Now if you see your character moving to the right, it is not because right was pressed, but because left was lifted. :D
arkadiusz.makarenko wrote: 12 Nov 2023 18:25 @NYYRIKKI
Could you confirm that MSX mouse works as expected over normal gameport on TFMSX?
I am getting random readings and I am not sure why?
Yes, I today tested the BASIC test program I posted here with real MSX mouse & TFMSX, and it worked flawlessly. Could this be also caused by the previous mistake of mixing values of zeros and ones?

I also understand you timing problem. I remember I had similar with the PS/2 adapter I made. I solved it by reading value from PS/2 right after sending value to MSX while keeping the MSX side pins in "0"-value to prevent mouse from moving if for some reason read happens immediately again while Arduino is busy. There was anyway another problem as MSX may not always read mouse coordinates, but it may still expect button to be pushed in style of "press fire to start" or "hold button 1 while loading to...". This I solved by having something like 25ms timeout value so that if MSX mouse is not read by then, the adapter will anyway read PS/2 mouse status and update the mouse buttons & direction counters... It might not be the most elegant way to handle the issue, but it did work ok for me.

Last I want to add that I tried FM-PAC in slot expander with external power input and it worked great! This proves that the sound part works perfectly and my problem was indeed only the missing voltages.

Re: TFMSX rev 2 features & problems

Posted: 20 Nov 2023 21:49
by arkadiusz.makarenko
NYYRIKKI wrote: 19 Nov 2023 21:40 Hi again!

I did some more testing today, and I have some new test results:

USB-Joypad: I did test it today for the first time and it puzzled me a moment, what is wrong with it, until I realized that you got all the directions wrong... With that I mean that now UP is DOWN, DOWN is UP, LEFT is RIGHT, RIGHT is LEFT, direction pushed is direction lifted and direction lifted is direction pushed. So... Now if you see your character moving to the right, it is not because right was pressed, but because left was lifted. :D
arkadiusz.makarenko wrote: 12 Nov 2023 18:25 @NYYRIKKI
Could you confirm that MSX mouse works as expected over normal gameport on TFMSX?
I am getting random readings and I am not sure why?
Yes, I today tested the BASIC test program I posted here with real MSX mouse & TFMSX, and it worked flawlessly. Could this be also caused by the previous mistake of mixing values of zeros and ones?

I also understand you timing problem. I remember I had similar with the PS/2 adapter I made. I solved it by reading value from PS/2 right after sending value to MSX while keeping the MSX side pins in "0"-value to prevent mouse from moving if for some reason read happens immediately again while Arduino is busy. There was anyway another problem as MSX may not always read mouse coordinates, but it may still expect button to be pushed in style of "press fire to start" or "hold button 1 while loading to...". This I solved by having something like 25ms timeout value so that if MSX mouse is not read by then, the adapter will anyway read PS/2 mouse status and update the mouse buttons & direction counters... It might not be the most elegant way to handle the issue, but it did work ok for me.

Last I want to add that I tried FM-PAC in slot expander with external power input and it worked great! This proves that the sound part works perfectly and my problem was indeed only the missing voltages.
I will invert signals and directions this week. I have noticed that there is something not right with gamepad few days when using hid test.

My issue with mouse is that I cannot wait for MSX pin8 as mpu has to do many other tasks like USB stack, keyboard etc, so I cannot use blocking code, need to use exti (Interrupts),.I need to wait for both edge rising and falling, and I don't have clue how to sync this with MSX.

I am building some PCB (USB to db9 adapter) for MSX to allow me to learn in isolation first then hopefully I will be able to port it directly to TFMSX. It may take me a while.

Re: TFMSX rev 2 features & problems

Posted: 21 Nov 2023 14:29
by NYYRIKKI
Nice!

One more question about the USB-joypad... I quickly tried to use it on Joystick port 2 by swapping the keyboard and Joypad ports, but my keyboard stopped working completely. How this is supposed to work ATM? The thing is that on many MSX games player 1 can play either on keyboard or on Joystick 1, but player 2 needs to have joystick connected to port 2.

Handling mouse with interrupts sounds like a good idea. The interrupt handler just needs to be quite fast as there are not that many Z80 clock cycles to return a value, but as you have managed to solve this problem on PPI keyboard poll, I'm sure you can get it working here as well. If you need more exact timing details, let me know.

Re: TFMSX rev 2 features & problems

Posted: 21 Nov 2023 19:58
by arkadiusz.makarenko
Currently there is no port 2 support as I don't think there is enough pins left?
I have two USB ports HS and FS.
With keyboard I had state shared between HS and FS, so firmware got confused when anything was disconnected. I still think I might have some cross talk between HS and FS somewhere... Those are very deeply changed stm32 USB libraries, they are massive and complex.
On top of it there is USB hub support which complicates stuff even more.

I am looking to solve those issues just now.

Edit:
I solved above gamepad issues, still have few small bits to fix, but nothing serious. Eg. After disconnecting USB gamepad you can't use real joystick. (It did work before, so by fixing one thing I had to break another one)

About speed of IRQ, those are not the greatest, but fast enough as keyboard routines do work, so it should be fast enough for mouse.

Edit2:
Lunchtime programming resulted in fixing release of joystick port when USB is disconnected.

Only USB LED handle to do.

Re: TFMSX rev 2 features & problems

Posted: 22 Nov 2023 20:29
by arkadiusz.makarenko
I think I addressed most issues in new firmware. I will test it more over the weekend. But all initial issues have been addressed.
https://github.com/arkadiuszmakarenko/T ... v2F730.bin

Re: TFMSX rev 2 features & problems

Posted: 29 Nov 2023 13:54
by NYYRIKKI
Thank you. I tested this version and I can confirm the gamepad works correctly now.

Re: TFMSX rev 2 features & problems

Posted: 29 Nov 2023 17:26
by arkadiusz.makarenko
NYYRIKKI wrote: 29 Nov 2023 13:54 Thank you. I tested this version and I can confirm the gamepad works correctly now.
Thank you for checking this up.

Now I can revisit mouse support :)

Re: TFMSX rev 2 features & problems

Posted: 15 Mar 2024 15:51
by NYYRIKKI
arkadiusz.makarenko wrote: 30 Oct 2023 17:43 As of mouse support I will add this to my todo list for this firmware, I am a little bit snowed in at work just now, but winters are long in Scotland.
Is there still enough winter left?

Re: TFMSX rev 2 features & problems

Posted: 19 Mar 2024 20:47
by arkadiusz.makarenko
NYYRIKKI wrote: 15 Mar 2024 15:51
arkadiusz.makarenko wrote: 30 Oct 2023 17:43 As of mouse support I will add this to my todo list for this firmware, I am a little bit snowed in at work just now, but winters are long in Scotland.
Is there still enough winter left?
I got sidetracked by other project.
I have equipment ready , need to get to it :)