cemu-project / cemu_graphic_packs

Community Graphic Packs for Cemu
https://cemu-project.github.io/cemu_graphic_packs/
Creative Commons Zero v1.0 Universal
1.3k stars 585 forks source link

Skylanders: Fix infinite fall softlock at high FPS #639

Open SuperSamus opened 1 month ago

SuperSamus commented 1 month ago

Fixes one of the issues caused by higher framerates in the Skylanders saga: #615.

The reason why the character was respawning during long falls is because of a failsafe meant in case your character is stuck falling between geometry. The game determines whether you are stuck with a simple method: it calculates the squared distance of your character from the position of the previous frame, then checks whether it's lower than 20². If that's true for 3 seconds, then it teleports you. But if the framerate is higher, your distance is going to be lower than normal, and the game will consider you stuck even when falling at top speed. Ironic...

The fix simply consists in overriding the load of 20.0, and load 20×30FPS/targetFPS instead. (Ideally you would multiply by deltaTime instead of dividing by targetFPS, but since it's not already loaded in a register in that part, not bothering.)

Before:

https://github.com/user-attachments/assets/c6215296-79bd-4a04-810e-b9f35508fbd0

After:

https://github.com/user-attachments/assets/74097add-1df3-4f8a-92f8-3463367f13d8

Credits:

This is currently a draft, as this is only one version of one game, so not worth merging now. More games and versions will be added later. I'm leaving this for documentation and for reference.

Other things for reference:

SuperSamus commented 2 weeks ago

Both versions of Swap Force are here!

Crementif commented 2 weeks ago

That's cool! Is this still intended to be a draft pull request, or is it mergeable. I'll trust you to say whatever is better for the users.

SuperSamus commented 2 weeks ago

It's currently missing the other versions of SuperChargers. @WinnerNombre said they'll look into that when they have time. These games luckily have debug symbols, so that should be quick.