7800 sprite to display list idea
One of the frustrating aspects of 7800 coding is constructing the display lists. On paper it sounds like a great plan - a list of pointers to sprites with width and horizontal positioning info. Very powerful and flexible, but damn difficult to use in practice.
My balldemo code has, what I thought, to be as efficient way of doing this as possible. The pseudo code goes something like this:
For each sprite determine which display list based on the vertical position. Add sprite pointer etc to the end of the display list and the next display list. (Each display list controls 1-16 rasters, thus sprites which move vertically need to be in more than one list.) Once all the sprites have been added, add a termination flag to the end of every list.
The main problem with this method is the 6502 is an 8 bit processor, so the code has to use indexed indirect ( aka (ZP),Y ) addressing. So there's a lot of data movement steps, copying data from lookup tables, loading the current end of list offset etc. Ugh. The vertical position fiddling is also not pleasant (although probably unavoidable).
Anyway, it occurred to me this morning that a more efficient way might be to flip the order. So:
For each display list, scan the list of sprites to determine whether they need to be added based on vertical position. Add sprite pointer etc to the end of the display list. Once all the sprites have been added, add a termination flag to the end of the current list.
Now, I haven't tried to code this yet (I want to but I'm trying to work on Leprechaun) but this should be somewhat more efficient because a lot of the mucking around with pointers isn't required. You set up the pointer only once for each display list. Now, it does require scanning through the list of sprites multiple times, but that should be simple comparisons. (Although there may still be some vertical position fiddling required.)
The other advantage is it should be possible in this case to compact the display lists so each one follows the other. This would be particularly useful if the game double-buffered the display list updates since it would save RAM. (With the sprite -> display list routine each display list has a fixed length and starts at a fixed position.)
Just thought I'd put it here so I wouldn't forget.
4 Comments
Recommended Comments