flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.46k stars 174 forks source link

SA2 & 1 Left stick emulation problems #287

Open LlinePoP opened 3 years ago

LlinePoP commented 3 years ago

Platform / OS / Hardware: 64-bit Linux Mint 20.1 Ulyssa

Hardware: 60-key keyboard and average mouse (keyboard detected as 'Generic 105-key PC (intl.)) in Mint's system settings.

Description of the Issue In Sonic Adventure 1 & 2, when I press 'w' on my keyboard (mapped to Left Stick Up in config), Sonic moves not exactly forward but slightly to the left, which makes it really annoying to deal with when you run on high speed. The same thing happens when I press 's' (Left Stick Down), which makes Sonic move back and lean a little to the right. This issue wasn't present when I played these games on Windows about half a year ago. Left and right buttons work just fine.

Some screenshots:

Screenshot_2021-07-04_11-09-28

Screenshot_2021-07-04_11-08-39

ghost commented 3 years ago

I can reproduce this issue on Arch.

flyinghead commented 3 years ago

I checked the joystick values returned to the game and the X axis stays at 0 when Y goes to 127 (up) or -128 (down). Same thing for the Y axis when X changes. Also there hasn't been any recent change in this code.

SA2 is known to have float precision issues. Could that be it?

LlinePoP commented 3 years ago

Perhaps this is an issue with the camera? If camera behind Sonic was to offset to the left for some reason, it could explain this strange behavior.

Or, if the issue is indeed due to float errors, there's nothing that could be done on the emulator's side? I've just fiddled around with the setting that could relate to it in that case (idle skip, safe mode, tried different cpu modes) but nothing's changed. Also tried V-sync and settings related to resolution but saw no success.

LlinePoP commented 3 years ago

I've found this post just now related to this issue, and one of the comments says this:

Screenshot_2021-07-04_17-55-37

Link: https://github.com/p1pkin/demul/issues/392

flyinghead commented 3 years ago

Yup, this certainly is the cause of the problem

LlinePoP commented 3 years ago

Could a stick noise function theoretically be implemented?

flyinghead commented 3 years ago

In theory, yes. But it will probably have adverse effects on other games. So it would need to only be activated for SA 1&2. And we still have to find out what kind of noise would make SA happy.

overlordchaos commented 3 years ago

In theory, yes. But it will probably have adverse effects on other games. So it would need to only be activated for SA 1&2. And we still have to find out what kind of noise would make SA happy.

if i can add my 2 cents: both SA and SA2 where rushed to DC in an attempt by sega to salvage the console apocalypse it was for them. that those game sales would salvage sega corp. it was at the verge of closure. my point to this issue is: on gamecube/other consoles ports/PC this issues are totally solved. my guess its a both games bug + buggy dreamcast joystick hardware that translates into an issue into the emulation. i dont think it can be solved unless someone that ported for example SA2 to other console can tell us if it was a game only, hardware only or both issues combined. this could never be solved.

LlinePoP commented 3 years ago

i dont think it can be solved unless someone that ported for example SA2 to other console can tell us if it was a game only, hardware only or both issues combined. this could never be solved.

Or, maybe, we can fix it by asking a person who still owns a working DC controller to plug it into his PC with some sort of adapter and use some joystick calibration app to look at joysticks' behavior when idle and when moving. We may be able to solve the issue if it shows visible noise or just acts strangely.

overlordchaos commented 3 years ago

i dont think it can be solved unless someone that ported for example SA2 to other console can tell us if it was a game only, hardware only or both issues combined. this could never be solved.

Or, maybe, we can fix it by asking a person who still owns a working DC controller to plug it into his PC with some sort of adapter and use some joystick calibration app to look at joysticks' behavior when idle and when moving. We may be able to solve the issue if it shows visible noise or just acts strangely.

DC joysticks where known for beeing of low quality and buggy. even if some sort of adapter would exist (witch i guess it does not) raw data would not help the emulator since a program should be made to emulate the buggyness of the controller. just for 2 games reported giving issues...

LlinePoP commented 3 years ago

DC joysticks where known for beeing of low quality and buggy. even if some sort of adapter would exist (witch i guess it does not) raw data would not help the emulator since a program should be made to emulate the buggyness of the controller. just for 2 games reported giving issues...

I'm more interested in why these issues are not present on all available platforms. I haven't had any on Reicast when I played on Android (I moved on-screen virtual analog stick straight up without any deviations to the right side which could've countered the problem), nor I had any on Windows a long time ago.

Perhaps a person familiar with coding should look at Reicast's source code relating to controller emulation to see if any fix was implemented? I would've done if myself, but I don't know a bit about programming.

overlordchaos commented 3 years ago

DC joysticks where known for beeing of low quality and buggy. even if some sort of adapter would exist (witch i guess it does not) raw data would not help the emulator since a program should be made to emulate the buggyness of the controller. just for 2 games reported giving issues...

I'm more interested in why these issues are not present on all available platforms. I haven't had any on Reicast when I played on Android (I moved on-screen virtual analog stick straight up without any deviations to the right side which could've countered the problem), nor I had any on Windows a long time ago.

Perhaps a person familiar with coding should look at Reicast's source code relating to controller emulation to see if any fix was implemented? I would've done if myself, but I don't know a bit about programming.

maybe you are right and its this emulator bug. maybe reicast had a work around to emulate the "noise" the real dreamcast controller had. maybe a fix was implemented on SA-SA2 based on the code fix they did when it was re-released for the gamecube.

tails101 commented 1 year ago

i dont think it can be solved unless someone that ported for example SA2 to other console can tell us if it was a game only, hardware only or both issues combined. this could never be solved.

Or, maybe, we can fix it by asking a person who still owns a working DC controller to plug it into his PC with some sort of adapter and use some joystick calibration app to look at joysticks' behavior when idle and when moving. We may be able to solve the issue if it shows visible noise or just acts strangely.

DC joysticks where known for beeing of low quality and buggy. even if some sort of adapter would exist (witch i guess it does not) raw data would not help the emulator since a program should be made to emulate the buggyness of the controller. just for 2 games reported giving issues...

Well now we know it is wrong. We know that the DC was using good quality hall effect stick. And mayflash and some other company make USB adapter for the DC controller.

HyperSonic1999 commented 9 months ago

Hi, just wanted to add that PkR; the creator of the Dreamcast Conversion mod for SADX PC created a CodeBreaker cheat for SA1 v1.005 USA that disables analog interpolation. Not sure if I can post links to his website, but web search "SA1 Drift Fix" and you should find the cheat code pretty quick.

I'm curious if there is a way to implement this in a similar way from the emulator side, so it can be a global fix for all games with the issue. If this is not possible, perhaps add an option for the user to manually rotate the stick and have it be an togglable setting, so it can be easily turned off.

flyinghead commented 8 months ago

There's no need for a global fix since this issue is specific to SA 1&2. However I could integrate the cheat codes for SA1.

flyinghead commented 8 months ago

I tried the cheat code for SA1 and it sometimes work and sometimes make the character uncontrollable. So I'd rather not include it by default but let the user decide.

HyperSonic1999 commented 8 months ago

I figured there might have been some issues with using a cheat code, that's why thought of adding the option to rotate the analog stick instead. If this could be implemented it would fix every variant of SA1 and SA2 in one fell swoop. I made a mockup image to get the general idea.

flycast rotate analog stick example

vlad54rus commented 1 month ago

The Dreamcast Image Builder contains drift fix patches for both games. The only problem is to find compatible GDI rom.