flyinghead / flycast

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

Sega Driving Simulator (bug report & fix for game controls) #1636

Open CO-Windler opened 2 months ago

CO-Windler commented 2 months ago

I am using Win10 on a Ryzen 2400G with internal graphics on a single 4:3 CRT monitor (at 1280*1024@72Hz) and corded Xbox 360 gamepad. I did a quite detailed analysis of Sega Driving Simulator. This is the summary of bugs I found.

When displaying the 3D part (menus are ok) the emulator crashes (windows disappear) when the Graphics API is not set to OpenGL. In all other games DirectX11 works best. OpenGL is somewhat choppy and Vulkan has glitches (e.g. water in "Soul Surfer"). DirectX9 supports no Naomi2 anyway. If there is no easy fix, make it possible to select this per game.

There seems to be a very bad race condition with semi-random behaviour. This game can lock up when entering the emulator menu because all 3 emulated PCBs run out of sync when restarting. It also crashes if any of its windows is paused or slowed for few seconds (e.g. by dragging it). So when pausing the emulator, the player has to resume it only with gamepad button, because mouse clicking only resumes that window, pushing them out of sync. If he needs to click, always resume first on both slave windows before the main window. But after moving a slave window, also resume by button sometimes only resumes one window.

Flycast should stop all 3 game PCBs while one window is dragged or resized. So long there are sync bugs, slave windows should have manual reset/restart button to exit lockups (else application test mode is difficult to start).

The emulator should permit manual save and restore of different window combinations (size & position) to ease use of 3-screen driving games on a single monitor. Best would be a mode with all 3 virtual screens in one fullscreen window. There should be an optional display of dashboard gauges and pilot lamps (below main window or as a HUD).

The emulator menu only pauses all 3 windows properly when entered by a gamepad button. Apparently PC keyboard or mouse clicks are not properly broadcast to all of them, thus resuming by key or mouse only starts the focussed window, making the emulated PCB run out of sync with risk of lockup.

Some mappings are missing. I have figured out the keyboard matrix and fixed most controls of Sega Driving Simulator to make it playable. See thread below for config and details.

Arcade driving games often have exotic input mappings. The emulator should support individual default mappings at different input ports (A,B,C,D). Coin slot 2 is missing (may be STOP SW). Each digital input should get an optional locking (on/off) mode (add a checkbox) to simulate rocker switches. More complex variants (like in fighting game combos) may be useful to simulate car stick shift.

When selecting on the green screen the rightmost menu (higher training levels?), it boots into a mode with corrupted menu graphics (garbled kanji etc.). This may be a bad rom/disc dump or a memory map problem (too little ram?) of the emulation.

WTF is this? The steering wheel changes sound volume of the driving simulator (very noticeable with speech). Turning left = loud, right = quiet. Obviously 2 DAC channels from a volume potentiometer on the dashboard are miswired. In I/O CHECK the register is labelled "MASTER VOL". Possibly this means that the left 2 digits are "MASTER" and the right 2 digits "VOL" splitted among steering and sound volume, or one of the lower bits selects between both channels and so gets interpreted wrongly. The steering DAC value is "POSITION" in the separate HANDLE SETTING menu.

This is only a summary. For tech details and fixed controller config see my analysis here.

HOW-TO: Sega Driving Simulator (tech & bug report) #1634

flyinghead commented 2 months ago

Simulation crashes when not using OpenGL.

There's no reason why sega driving simulator would crash with DX11 or Vulkan. It's not a general issue with this game or any other one. Make sure to use the latest Flycast build since it might be a bug that's been fixed already. Also, test with default settings to rule out any configuration issue.

Slave PCBs run out of sync and lockup when windows are moved

Sega Driving Simulator is unique in that it's 3 naomi2 boards linked together with an optical fiber token ring network. This means that stopping, pausing or slowing down any of the 3 instances can make the system fail. There's no easy solution to this problem. For the same reason fast forwarding and saving/loading a state is disabled.

Pause/resume fails from mouse or keyboard.

Same reason as above: there are 3 instances of Flycast running, each with its own window, and only the active window receives keyboard and mouse input (for obvious security reasons).

Many controls are unmapped.

iirc only 2 buttons are missing (STOP and WIPER_HI). I don't think they are required to "play" the game. Now there are like 20+ buttons for this game and this is way more than Flycast supports, so a lot of work is required to make this game plug and play. Given it's more of a curiosity than anything I don't plan on spending more time on this. However patches are welcome.

Higher level menus are corrupted.

Yes, know issue. No idea what the root cause is. It could be due to a bad rom/dump but it's not labeled as such in mame.

Steering wheel is miswired to volume control.

That's a funny one but you're correct. This game uses a force-feedback drive board, which is also used to read the wheel drive position. So there's no JVS axis for the wheel, and axis 0 is used for master audio volume. I pushed a fix on the master branch.

CO-Windler commented 2 months ago

Simulation crashes when not using OpenGL.

There's no reason why sega driving simulator would crash with DX11 or Vulkan. It's not a general issue with this game or any other one. Make sure to use the latest Flycast build since it might be a bug that's been fixed already.

I used v2.3 on Ryzen 2400G. The in-game menus look ok but the windows simply close themselves when the game tries to draw the actual 3D world.

Slave PCBs run out of sync and lockup when windows are moved

Sega Driving Simulator is unique in that it's 3 naomi2 boards linked together with an optical fiber token ring network. This means that stopping, pausing or slowing down any of the 3 instances can make the system fail.

Has the emulator no control to halt all 3 PCBs simultaneously?

Pause/resume fails from mouse or keyboard.

Same reason as above: there are 3 instances of Flycast running, each with its own window, and only the active window receives keyboard and mouse input (for obvious security reasons).

It should detect when one of them is moved/resized and propagate the signal to halt also the other 2 until move/resize has finished. When I manually pause before that (only with gamepad "Guide" button, not key or mouse click) and also resume with gamepad (main window is focussed) I can often avoid the lockup.

Many controls are unmapped.

iirc only 2 buttons are missing (STOP and WIPER_HI).

Now there are like 20+ buttons for this game and this is way more than Flycast supports.

WIPER_HI does work (its on Port B Service). I mapped it and most others (lamps etc., reverse gear) too! Only STOP is not found.

I don't think they are required to "play" the game.

They definitely are. Lessons with night or bad weather require these to be used. There needs to be an abort lesson button to quit, because currently it is impossible unless the player figures out how to successfully solve the exercise (which returns to the menu). Likely this would be either STOP hi or setting IG-ON or BELT lo. If the supported count of buttons is limited (why can't it be increased??) perhaps map this to game reset or coin button (which seems unused) to make it possible to exit a level without rebooting the entire thing by closing and restarting the emulator (which is lengthy and severely crash prone). Else it becomes even more troublesome to try out and compare the different skill levels/exercises of the game. And particularly when reverse gear was not mapped (I figured it out), the car could easily get stuck between fences with no chance of escaping.

Given it's more of a curiosity than anything I don't plan on spending more time on this. However patches are welcome.

Others consider emulated mahjong games useless, and these do have fandom too and a key mapping in Flycast.

Most of the inputs do already work. (Mapping see https://github.com/flyinghead/flycast/discussions/1634 ) Only locking switch behaviour is absent. I mapped the gamepad in a way that it can be used, although a little awkward (holding buttons down to keep lamps, wiper and gears on).

Steering wheel is miswired to volume control.

That's a funny one but you're correct.

Thanks. The racket was annoying with the alarm basedrum noise booming like earthquake through my tube amp with 1m high TML bass boxes. May it be that this tone was even supposed to be played through the steering wheel motor instead of the speakers?

CO-Windler commented 2 months ago

I have tried out the recent Flycast versions. In the main version the steering wheel volume control bug is gone, in the dev version its still there.

I have rechecked that Sega Driving Simulator works only in OpenGL mode. My AMD graphics driver is an unofficial version because on Ryzen 2400G APU the official driver runs jerky and (even worse) disabled the game recorder (falsely claiming 2400G would not meet hardware requirements, because so they attempt to sell expensive premium hardware). My driver is

WHQL-AMD-Software-Hybrid-Edition-23.9.3-23.30.01.02-PVNFlex-Omega-RemiX-DCH.7z

and identifies itself as

AMD Software: Creator Edition Version 2023.1003.1527.2005

All other Flycast games I tested (mainly arcade driving things and "Soul Surfer") work correctly in DirectX 11 mode. (But that is to say, MAME in DX11 mode does lockup Win10 when I exit 3D games; i.e. e.g. Ridge Racer runs very nicely, but when in fullscreen I press ESC, the screen freezes and keyboard does not respond anymore (sound hangs in a loop, HDD lamp still flickers, indicating that other tasks (antivirus?) are still alive.) Thus in MAME I need to select OpenGL too. Also some ancient games like the 1st Sybex "3D Fahrschule" lockup in native fullscreen mode.)

Sgdrivesim in DX11 terminates itself (closes all windows) when it starts the 3D part. The end of flycast.log complains about a null pointer.

02:26:541 rend/dx11/dx11_shaders.cpp:680 E[RENDERER]: Pixel shader creation failed
02:26:542 ui/gui.cpp:3696 E[COMMON]: Verify Failed  : shader != nullptr
 in getShader -> D:/a/flycast/flycast/core/rend/dx11/dx11_shaders.cpp : 553
02:17:158 rend/dx11/dx11_shaders.cpp:680 E[RENDERER]: Pixel shader creation failed
02:17:158 ui/gui.cpp:3696 E[COMMON]: Verify Failed  : shader != nullptr
 in getShader -> D:/a/flycast/flycast/core/rend/dx11/dx11_shaders.cpp : 553
02:17:186 rend/dx11/dx11_shaders.cpp:680 E[RENDERER]: Pixel shader creation failed
02:17:186 ui/gui.cpp:3696 E[COMMON]: Verify Failed  : shader != nullptr
 in getShader -> D:/a/flycast/flycast/core/rend/dx11/dx11_shaders.cpp : 553

The quite similar 3-screen game F355 runs fine on DX11. To compare flycast.log (from main and dev) see attachments.

flycast.log_sgdrvsim_OpenGl.txt flycast.log_sgdrvsim_DX11.txt flycast.log_f355_DX11.txt flycastDev.log_sgdrvsim_OpenGl.txt flycastDev_sgdrvsim_DX11.log

flyinghead commented 2 months ago

The GPU driver is failing when creating the pixel shader compiled by Flycast. The Naomi 2 shaders are different (and more complex) than dreamcast/naomi1 ones so this could explain why it's working with naomi 1 games (like F355). However I would expect Soul Surfer to crash as well. Now Naomi 2 shaders produced by Flycast are valid afaik, or they would crash on all platforms. I did a quick test with DX11 (Win10 with Intel Iris+ 640) and no issue there. So this looks like an issue with your driver.

CO-Windler commented 2 months ago

Nope, its not Naomi 2 in general. Soul Surfer ran perfectly on DX11. Only on Vulkan I had some rectangular pixel garbage areas floating on the water.

CO-Windler commented 2 months ago

Serious driving simulators (for training or research) may appear a nerdy topic, but they have an exciting history and (even less than arcade machines) barely survive nor get preserved through emulation once their purpose is finished. As an utilitarian thing, nobody considers them anything like art, although they are often unintentionally ridiculous. (Did you know that the world first electronic drivesim was invented in Germany, and became the origin of all 3D racing videogames?) I try to collect info and youtube videos about their cultural history, which is far less documented than videogames and barely written down.

first driving simulators https://www.youtube.com/playlist?list=PLCMrVbN84CCYZgKJQFp7m3fgpODPbb1i7

driving simulator & flight sim history https://www.youtube.com/playlist?list=PLCMrVbN84CCaUZOEUPiO362OtCB04EqDg

This makes it so important to keep sgdrvsim playable. I now downloaded the newest Flycast and compared it again. Soul Surfer indeed needs "Full Framebuffer Emulation" enabled to run on DX11 or Vulkan (also earlier Flycast version did), and glitches go away by selecting effect rendering "per pixel". With Vulkan it even seems to run smoothest, although the start of the demo mode still stutters a bit. (Does it cache something during the first minutes after starting the game?)

The strange thing is, Sega Driving Simulator apparently also depends on enabling "Full Framebuffer Emulation" to work in DX11 and Vulkan mode, but when I disable it again the drivesim keeps working. (Selecting textures "per pixel" only turns it slow/choppy.) Does it render things into the "data" directory (shader/pipeline cache?) and only depend on existence of that file even when "Full Framebuffer Emulation" is off again? Or does it write that parameter in a per game config? (I saw nothing obvious in flycast.cfg.)