rage1
rage1 copied to clipboard
btile: animated background btiles
Allow for animated btiles.
- Intended mainly for short and sporadic animation sequences
- This does not replaces sprites, btiles do not move
- An animated btile has N frames
- An animated btile has an animation sequence, which repeats over and over, governed by a repetition delay
- An animation sequence is a sequence of frame numbers (minimum 2, maximum 16), governed by animation delay
- This would very well benefit from #85 since there is the potential of reusing several 8x8 tiles between BTILE frames
- This would also benefit from #106 for better efficiency
- Reuse the sprite animation sequence code
Tasks:
- [x] Factor out sprite animation data structure for reuse
- [x] Factor out code for animation sequence state-machine for reuse (
enemy.c
) - [ ] DATAGEN: add support for defining btiles with multiple frames (special case: normal btile with 1 frame)
- [ ] Add a new table to a screen which contains the animated btiles (btiles with a frame count > 1 and an animation sequence with >1 steps). Since the number of btiles in a screen can be big, the list needs to be precomputed.
- [ ] Modify game loop main function to call
btile_animate_all
function, which animates only animated btiles, extracted from the table indicated in the previous step - [ ] Conditional compilation: btile definition with more than 1 frame activates build feature ANIMATED_BTILES
- [ ] Code related to animated btiles must be conditionally compiled wrt that build feature
Notes:
- According to https://worldofspectrum.org/forums/discussion/11729/ann-sp1-for-z88dk-aka-splib3-sprite-pack-v3-0/p2 , function sp1_PutTilesInv can be used for better efficiency.
- This function needs the data in a specific format (struct sp1_tp), but I think we can rearrange the BTile data layout to match that, and use that function instead.
- The point of that function is that the loop for all the N cells of a BTile is done fully in assembler, so it would be just one call to sp1_PutTilesInv instead of N calls to sp1_PrintAtInv. Also, calculations for indexes would be saved.