paulbnl wrote: ↑Sat Jul 18, 2020 3:43 pm
I got it from DB9 module
https://github.com/Miguel-T80c/Genesis_ ... joydb9md.v.
This module is clocked at 50Mhz and it divides the clock by 256 for the joystick state counter which results in 195.3Khz (0.00512ms per state).
The joystick state counter counts from 0-255 and it saves the joystick buttons at state 0-6: 256 x 0.00512ms = 1.31ms.
You are right with the lag time. I have been working improving the instance to reduce the lag at maximum.
Here you have the instance in Verilog with the new code.
Now we read data in all 8 cycles (There is not a counter now until 256, we ready cycling the 8 states).We check it with 6 buttons and 3 buttons Megadrive Joysticks and it is very stable.
The clock we use for pin7 of the DB9 connector (SELECT pin) is based in the HSYNC signal. This value is the same than the real Megadrive machine. So, The lag is the same than real machine, that is means by definition that there is not lag.
So,let's study the lag in RGB mode when the HSYNC signal is 15 Khz and in VGA mode when the HSYNC is 31.5 Khz.
If we take 15 Khz (the worst case in RGB mode), this is the lag for each Joy Signal (the lag it is not the same for all signals of the Joy control as you can see in the Cycle Table)
- Megadrive_8_Cycles.JPG (32.27 KiB) Viewed 5059 times
Code: Select all
Down and up --> 5/8 --> 9.375 Khz --> 0.106 ms
C , B , Start and A --> 1/2 --> 7.5 Khz --> 0.1333 ms
Right and Left --> 3/8 --> 5.625 Khz --> 0.178 ms
Mode, X , Y and Z --> 1/8 --> 1.875 Khz --> 0.534 ms (This is the worst case, only reading in one cycle)
Consider that we are working in NTSC mode 60 Khz --> 16 ms for each frame. Our lag is not as USB lag that is variable, the lag in this case is constant and we read the Mode, X, Y and Z buttons every 0.534 ms, almost 32 times faster than the frame time. As we already knew, there is not lag
If we take 31.5 Khz as HSYNC the lag is exactly the half
We are gonna implement soon this new version in the DB9 cores to improve the lag. Thanks for your advice
Regards