TFMSX rev 2 features & problems

Home for the Terriblefire MSX clone

Moderators: terriblefire, Terriblefire Moderator

User avatar
arkadiusz.makarenko
Moderator Team
Moderator Team
Posts: 1207
Joined: Wed Jun 19, 2019 7:36 am
Location: Edinburgh

Re: TFMSX rev 2 features & problems

Post 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?
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
User avatar
NYYRIKKI
Posts: 25
Joined: Sat Sep 30, 2023 12:20 pm
Location: Helsinki
Contact:

Re: TFMSX rev 2 features & problems

Post 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: 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?
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.
User avatar
arkadiusz.makarenko
Moderator Team
Moderator Team
Posts: 1207
Joined: Wed Jun 19, 2019 7:36 am
Location: Edinburgh

Re: TFMSX rev 2 features & problems

Post by arkadiusz.makarenko »

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. :D
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?
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.
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
User avatar
NYYRIKKI
Posts: 25
Joined: Sat Sep 30, 2023 12:20 pm
Location: Helsinki
Contact:

Re: TFMSX rev 2 features & problems

Post 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.
User avatar
arkadiusz.makarenko
Moderator Team
Moderator Team
Posts: 1207
Joined: Wed Jun 19, 2019 7:36 am
Location: Edinburgh

Re: TFMSX rev 2 features & problems

Post 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.
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
User avatar
arkadiusz.makarenko
Moderator Team
Moderator Team
Posts: 1207
Joined: Wed Jun 19, 2019 7:36 am
Location: Edinburgh

Re: TFMSX rev 2 features & problems

Post 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
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
User avatar
NYYRIKKI
Posts: 25
Joined: Sat Sep 30, 2023 12:20 pm
Location: Helsinki
Contact:

Re: TFMSX rev 2 features & problems

Post by NYYRIKKI »

Thank you. I tested this version and I can confirm the gamepad works correctly now.
User avatar
arkadiusz.makarenko
Moderator Team
Moderator Team
Posts: 1207
Joined: Wed Jun 19, 2019 7:36 am
Location: Edinburgh

Re: TFMSX rev 2 features & problems

Post by arkadiusz.makarenko »

NYYRIKKI wrote: Wed Nov 29, 2023 1:54 pm 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 :)
Do not trust people. They are capable of greatness.
~ Stanislaw Lem
Post Reply

Return to “TFMSX”