Log In  

We had some back-and-forth on Discord about row-shifting effects and whether to do them with the CPU or by copying to sprite ram and using sspr. I came up with a pretty good function at the time for the CPU to do it in place, but I've since iterated on that to bring down the token count and also to optimize certain types of shifts.

This is a little demo wrapper built around that function. If anyone's interested in effects like this, I offer this up to them. Take a look at the full-fat version of the function in tab 1, and also at a low-fat version in tab 2, which is a little slower and lacks the edge-clamping feature, but uses about 2/3 of the tokens. You should be able to drop either version as-is into a game or demo and just use it right out of the box.

Performance: The full-fat version can apply a sine wave to the full screen at a cost of about 8-9% of a 30fps frame, while the low-fat version requires about 10-11%.

Token cost: The full-fat version is 155 tokens. The low-fat version is 96 tokens.

Limitations: To reduce token count and because this was written for someone to do a subtle water effect, I have no logic for shifting beyond +/-8 pixels (32 bits). It could be modified pretty easily to do so, it just doesn't right now. It would probably add maybe 1-2 dozen tokens to do so.

Cart #rowshift-0 | 2020-03-01 | Code ▽ | Embed ▽ | No License
4

P#73574 2020-03-01 06:33 ( Edited 2020-03-01 06:33)

:: Munro
4

perfect for underwater!

P#73575 2020-03-01 08:02
:: Felice

@Munro

Hey, nice! The subs are adorable btw. ;)

P#73584 2020-03-01 19:13

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-01-17 15:19 | 0.031s | 4194k | Q:31