Background animations the right way

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
amateus
Member
Posts: 46
Joined: Fri Nov 15, 2019 9:13 am

Background animations the right way

Post by amateus »

There are a few ways to animate background tiles. The most common is to just print the characters with PrintAtInv in the same position to achieve it, but this has a lot of overhead.

A more optimized way is to print a tile outside the main loop and inside the main loop change it's correspondent graphic every now and then and invalidate just the specific tile coordinate, or a list of tiles.

Enter sp1_IterateUpdateArr and sp1_IterateUpdateRect realm.

The idea is to print the background only once, outside the main loop, and then just update the graphic tile (sp1_TileEntry) and invalidate the affected tiles (sp1_IterateUpdateArr) to force the draw on the next update

The code is available at https://github.com/antoniocmateus/z88dk ... _animation and is fully commented.

Example (the bigger stars to animate):
Image

Happy animations.
Post Reply