Wednesday, April 25, 2007
I'm Back!!!!
Well it has been a while... but I'm back on the Spectrum XeO3, so many things have intervened in the meantime between work and home, but I'm back looking at the Sprite routines for XeO3 and I'm looking to get them sorted out in the next couple of months (being realistic about the time I can devote to the project).
So major news to date is that I'm going to be a Dad again soon, so we have been preparing for that (and it gives me deadline for sorting out these pesky sprite routines, before changing nappies takes over).
Anyway Mike and I have been talking about the sprite cache system that he has been using on the Plus4 and I think it is the way to go for the Spectrum too, so I've been looking at his routines and seeing what would be the best way to translate them into Z80.
In Pseudo code the DrawSprite routine looks something like this
This uses the sprite stack that I talked about earlier to do the actual rendering, but caches the rotated graphic for each sprite entry, this enables the use of lots of different sprite types without having to store all the possible rotations in memory at once (they are only rotated when required). Usually in the bad old days graphics would all be pre-rotated and restricted at what x coords they could be rendered at (Miner Willy springs to mind, his walk animation required it to move across the screen).
So I'm going to write the general sprite cache routine over the next week or so and then spend a few weeks debugging it properly, so that the game code can just issues a simple DrawSprite call and everything will just work...
So major news to date is that I'm going to be a Dad again soon, so we have been preparing for that (and it gives me deadline for sorting out these pesky sprite routines, before changing nappies takes over).
Anyway Mike and I have been talking about the sprite cache system that he has been using on the Plus4 and I think it is the way to go for the Spectrum too, so I've been looking at his routines and seeing what would be the best way to translate them into Z80.
In Pseudo code the DrawSprite routine looks something like this
Draw Sprite
Calc sprite function to use (could be hard coded to Draw Sprite routine name).
Calc address on screen
if sprite_number+rotation not in cache
[Add to cache]
Get lowest entry on the stack
Remove entry from the cache
Add this sprite to the cache
Rotate the sprite and put it into the cache.
[Get address in cache]
Move this cache entry to the top of the list
retrieve sprite data address
Push information onto sprite stack
This uses the sprite stack that I talked about earlier to do the actual rendering, but caches the rotated graphic for each sprite entry, this enables the use of lots of different sprite types without having to store all the possible rotations in memory at once (they are only rotated when required). Usually in the bad old days graphics would all be pre-rotated and restricted at what x coords they could be rendered at (Miner Willy springs to mind, his walk animation required it to move across the screen).
So I'm going to write the general sprite cache routine over the next week or so and then spend a few weeks debugging it properly, so that the game code can just issues a simple DrawSprite call and everything will just work...