@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?
TFMSX rev 2 features & problems
Moderators: terriblefire, Terriblefire Moderator
- arkadiusz.makarenko
- Moderator Team
- Posts: 1193
- Joined: Wed Jun 19, 2019 7:36 am
- Location: Edinburgh
Re: TFMSX rev 2 features & problems
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
~ Stanislaw Lem
Re: TFMSX rev 2 features & problems
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.
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 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.

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?arkadiusz.makarenko wrote: ↑Sun Nov 12, 2023 6:25 pm @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?
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.
- arkadiusz.makarenko
- Moderator Team
- Posts: 1193
- Joined: Wed Jun 19, 2019 7:36 am
- Location: Edinburgh
Re: TFMSX rev 2 features & problems
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.NYYRIKKI wrote: ↑Sun Nov 19, 2023 9:40 pm 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.
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?arkadiusz.makarenko wrote: ↑Sun Nov 12, 2023 6:25 pm @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?
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.
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.
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
~ Stanislaw Lem
Re: TFMSX rev 2 features & problems
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.
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.
- arkadiusz.makarenko
- Moderator Team
- Posts: 1193
- Joined: Wed Jun 19, 2019 7:36 am
- Location: Edinburgh
Re: TFMSX rev 2 features & problems
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.
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.
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
~ Stanislaw Lem
- arkadiusz.makarenko
- Moderator Team
- Posts: 1193
- Joined: Wed Jun 19, 2019 7:36 am
- Location: Edinburgh
Re: TFMSX rev 2 features & problems
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
https://github.com/arkadiuszmakarenko/T ... v2F730.bin
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
~ Stanislaw Lem
Re: TFMSX rev 2 features & problems
Thank you. I tested this version and I can confirm the gamepad works correctly now.
- arkadiusz.makarenko
- Moderator Team
- Posts: 1193
- Joined: Wed Jun 19, 2019 7:36 am
- Location: Edinburgh
Re: TFMSX rev 2 features & problems
Thank you for checking this up.
Now I can revisit mouse support

Do not trust people. They are capable of greatness.
~ Stanislaw Lem
~ Stanislaw Lem