I was trying to think of a way to handle objects that consist of multiple sprites in patterns like waving sine waves. I didn't want to use linked lists, or having an object control a gazillion other objects, so I was thinking maybe there is a way to organize multiple tables of multiple sizes depending on how many sprites the object needs. Obviously there can't be more than 128 sprites onscreen, and because of that, there can't be more than 128 objects onscreen either, assuming each object has at least one sprite. I thought 32 would be a nice maximum sprites-per-object limit, so 128 lists of 32 sprites would be 4096 entries, which is definitely more space than needed. If I had a list of 128 1-slots, I can have 64 32-slots, which adds up to 2176 entries. If I had 128 2-slots, I can have 42 32-slots, which adds up to 1600 entries.
It then turned out that using 128 4-slots, and 25 32-slots came up the best at 1312 entries, so I subdivided both groups. I got these groups:
9 slots of 32
25 slots of 12
64 slots of 4
128 slots of 1
Then I discovered that one slot of every group can be reduced in size and still work withing the worst case scenario.
8 slots of 32
1 slot of 24
24 slots of 12
1 slot of 8
63 slots of 4
1 slot of 2
128 slots of 1
I got this down to 958 entries total.
edit:
Found out some tweaks can get me to 955:
It then turned out that using 128 4-slots, and 25 32-slots came up the best at 1312 entries, so I subdivided both groups. I got these groups:
9 slots of 32
25 slots of 12
64 slots of 4
128 slots of 1
Then I discovered that one slot of every group can be reduced in size and still work withing the worst case scenario.
8 slots of 32
1 slot of 24
24 slots of 12
1 slot of 8
63 slots of 4
1 slot of 2
128 slots of 1
I got this down to 958 entries total.
edit:
Found out some tweaks can get me to 955:
Code:
//minimum
8 slots of 32 //13
1 slot of 24 //12
23 slots of 12 //5
1 slot of 11 //5
1 slot of 8 //4
62 slots of 4 //2
1 slot of 3 //2
1 slot of 2 //1
127 slots of 1 //1
8 slots of 32 //13
1 slot of 24 //12
23 slots of 12 //5
1 slot of 11 //5
1 slot of 8 //4
62 slots of 4 //2
1 slot of 3 //2
1 slot of 2 //1
127 slots of 1 //1