Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cogmind support #303

Open
aronson opened this issue Jul 8, 2023 · 3 comments
Open

Cogmind support #303

aronson opened this issue Jul 8, 2023 · 3 comments

Comments

@aronson
Copy link

aronson commented Jul 8, 2023

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:

  • The scroll wheel does not function
  • Pressing/holding right shift on macOS CrossOver Wine will not register the keypress

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:

  • The game crashes with heap corruption a few seconds after firing a weapon
    • This specifically crashes in SDL_FreeWAV because of a hack the developer used long ago
    • One can intercept calls to SDL_FreeWAV, find msvcrt.dll!free, and call that to satisfy the game's behavior. I've tried to apply solutions with the developer a few times, but we have not figured out the correct way for his game's source to allocate the buffer.
    • I'm not sure how this could be selectively applied to only this game. I have a solution here in my fork.
  • The game has ear-splitting audio corruption with the default SDL2 audio driver
    • Manually setting the driver to winmm by setting an environment variable before loading the SDL2 library gets around this issue.
    • This also begs the question of is it within the scope of this project to auto configure this for only one game.

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
Copy link
Contributor

sezero commented Jul 8, 2023

Any chance that the SDL_mixer issue you linked is related to the following?
#215 (comment)
libsdl-org/SDL_mixer@4c47f6f
libsdl-org/SDL_mixer@6158823

@icculus
Copy link
Collaborator

icculus commented Jul 9, 2023

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
Copy link
Author

aronson commented Jul 10, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants