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):
Happy animations.