I am trying to design a kernel where I can have x amount of sprites that can appear anywhere on the screen.
What I want to do is split the screen into rows and then dynamically assign software sprites (player/enemy/item/whatever) to hardware sprites (GRP0,GRP1) depending on how many software sprites appear in a row.
If 1 sprite appears in a row then I just use GRP0 to display it.
If 2 sprites appear in the row then I would use GRP0 and GRP1 to display them.
If more than 2 sprites are in a row then I would flicker between them.. For example if 4 sprites are in the same row then I would do:
1st frame:
GRP0 = sprite1
GRP1 = sprite2
(GRP0 = GRP1, GRP1 = next sprite)
2nd frame
GRP0 = sprite2
GRP1 = sprite3
3rd frame
GRP0 = sprite3
GRP1 = sprite4
(GRP0 = GRP1, GRP1 = first sprite)
4th frame
GRP0 = sprite4
GRP1 = sprite1
5th frame
GRP0 = sprite1
GRP1 = sprite2
...for each row
I have a kernel that splits the screen into sectors/rows of 24 scanlines, and checks if a sector has a sprite in it. If the sector contains no sprite then the next 24 scanlines are free to do whatever. If the sector does contain a sprite then the usual checking takes place.
So what I want to do is extend what I have to draw 2 sprites per sector (which is simple enough), and have some code during vblank or overscan (or during empy sectors!) that does this sorting.
I just can't quite get my head around how to implement this idea assembly.. I've noticed that a few games must use a similar system (dig dug for example) so was hoping that someone here has coded something like this before and could give a few pointers.
One problem is RAM.
I figure that I'd need 2 "arrays", one byte per sector to hold what GRP0 should display in each sector and what GRP1 should display per sector.
Then I would need another array to keep track of what the last item would be (how I would know when to loop around back to "sprite1" in the above example).
It seems like a lot of RAM really.. Then the actual code to do it all might be a bit heavy too.. Just how do games like Dig Dug do this?? (trying to code for the VCS makes you really appreciate the coding behind these games, even though they do often look really primitive like Dig Dug does).














