libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
191 stars 40 forks source link

Cogmind support #303

Open aronson opened 1 year ago

aronson commented 1 year ago

Hello, I updated the spreadsheet with my findings, and wanted to chime in on some issues I've faced, and also present some solutions I have that could be adapted to this upstream project.

I have been running the closed-source, MSVC++ Windows 32-bit game Cogmind with sdl12-compat and have run into a few issues. The game ships an old SDL 1.2.14 DLL. It will not accept drop-in replacements of new SDL 1.2 DLLs unless you build with mingw or clang, or apply a manual hack in SDL_FreeWAV.

Issues I've found in sdl12-compat but not fixed:

I've looked into these issues myself, but my ability to debug the scan codes and input hooks is limited and I could use some help.

Issues I've found and fixed with a crude solution:

I maintain an sdl12-compat fork, builds, and install instructions for the Cogmind community at the moment. Your project has breathed new life into the game on Apple Silicon platforms where we saw speedups from sub-30 FPS to over 120 FPS by installing the mod. I can provide a gifted copy of the game to an sdl12-compat maintainer in the interest of fixing bugs if needed. Thank you all for contributing to this project :)

sezero commented 1 year ago

Any chance that the SDL_mixer issue you linked is related to the following? https://github.com/libsdl-org/sdl12-compat/issues/215#issuecomment-1271439552 https://github.com/libsdl-org/SDL_mixer/commit/4c47f6f3eb2fe180c9acefea91cc02ae9ba20e68 https://github.com/libsdl-org/SDL_mixer/commit/615882306946a840a9725eb74e8c247dc43f9518

icculus commented 1 year ago

This also begs the question of is it within the scope of this project to auto configure this for only one game.

We keep a quirks table in sdl12-compat, for workarounds that only a few programs (or one program) need, so yes, this is definitely in scope if we can deal with it.

I wonder if the quirk would be to sniff out the address of the malloc the game uses and call SDL_SetMemoryFunctions during SDL_Init, so SDL uses the same malloc under the hood.

The scroll wheel does not function

I'm surprised it doesn't, but most of our heavy testing has been on Linux, so it's possible this is just broken on Windows atm. I'll take a look.

Pressing/holding right shift on macOS CrossOver Wine will not register the keypress

This I'm less optimistic about fixing. If it works on Windows and not Wine, that's a Wine bug, unless someone wants to find a workaround and the workaround is small and doesn't break real Windows.

The game has ear-splitting audio corruption with the default SDL2 audio driver

I can track this one down.

Your project has breathed new life into the game on Apple Silicon platforms where we saw speedups from sub-30 FPS to over 120 FPS by installing the mod.

That's amazing!

I can provide a gifted copy of the game to an sdl12-compat maintainer in the interest of fixing bugs if needed.

That's a kind offer, but I just bought a copy. It sounds like you've made several important contributions already, I couldn't ask for money on top of it.

I'll dig in and report back later this week!

aronson commented 1 year ago

I very much appreciate the help!

For the scroll wheel issue I wanted to write up a way to test it quickly in-game, and found it's mysteriously... fixed? I tested with the latest codebase again on both Windows and under Wine on macOS and can't reproduce the bug. I received one user report it wasn't working on Windows a year ago and have experienced it myself under macOS Wine for a long time... I did recently rebase my fork with new changes from this project and replace the SDL2.dll I ship with the latest, so it's possible this was fixed somewhere else or is an intermittent bug in the game itself/user error we're just happening to run into. I'm going to try and reproduce it with old builds for my own curiosity but I think it's safe to dismiss.

As for the right shift, I can confirm sdl12-compat works fine in Windows with the game. On macOS we use Karabiner-Elements to remap right_shift to emit left_shift for Cogmind with no impact to gameplay.

I wanted to bring up one more bug we're running into that happens on both Windows and macOS Wine. Pressing space->M to perform a map export can take many minutes, blow up memory (no more than 1GB thankfully), and grind a CPU core. It works fine in sdl12-compat in the starter map, but partially-explored maps larger than the visible area of the screen cause the behavior and end-game maps are large enough to make the export button a "crash my game" button. I've attached a (zipped) save file you can place in the user/ folder under the game's directory before launching to reproduce the behavior. In SDL 1.2 it's almost instant comparatively. save_v75.zip