Skip to content

Optimized sprite rotation routines #614

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

Merged
merged 1 commit into from
Jun 8, 2025
Merged

Conversation

ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Jun 8, 2025

This is in its own commit due to the complexity of gfx_RotateScaleSprite and gfx_RotatedScaledSprite(Transparent)_NoClip.

The inner loop of gfx_RotatedScaledSpriteTransparent_NoClip is 8F faster when a pixel is drawn. I also believe that creating a clipped variant of this routine is possible with a constant performance penalty.

I have fixed most of the issues outlined in #612. There are a few limitations to note:

  • The sprite will render incorrectly if the output is larger than 255x255. This is not worth fixing however, since a 256x256 sprite doesn't fit onto a 320x240 screen anyways.
  • input sprites larger than 210x210 (255 * (sqrt(8) - 2) or ~211.2489) may experience texture wrapping. This should be harmless, as shown below with a 254x254 sprite
    image

@mateoconlechuga mateoconlechuga merged commit 6bebb17 into master Jun 8, 2025
9 checks passed
@mateoconlechuga mateoconlechuga deleted the optimize_rotate_sprite branch June 8, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants