Login
Back to forumSee the full topicGo to last reply

Posted By

Mad
on 2021-05-23
21:52:11
 Re: Software Sprites

There is some technique called automasking.. Where you don't need a mask. Actually color 0,1,2 are opaque there and color 3 is transparent. But that is a bit more advanced, but it helped in our games to have up to 200 and more sprite frames in ram whilst doing all the rest. With masks it would have been only 100 sprite frames.. And shifting is not a good idea, too if you want much memory.. With masks and preshifts the number of sprite frames would be 1/8 of what is actually possible memory wise (25 sprite frames instead of 200 sprite frames)..

This is the code for applying automasking, where ora automask,x is the interessting part, this table is a bit more complicated to calculate but once you got it everything is easy and you don't need masks anymore whilst keeping the same speed.
lax (ZP_SPRITEDATA),y ; sprite
and (ZP_BACKGROUNDDATA),y ; background and sprite
ora automask,x
sta (ZP_SPRITEDATA),y ; sprite

For non preshifted sprites you may use tables to shift your sprites in realtime..
the shifting code would look like
ldx leftcolumnbyte,y
lda shifttable1,x (for instance this tables shifts in this case by 2 bit to the left)
ldx rightcolumnbyte,y
ora shifttable2,x (in this case this table shifts by 6 bit to the right (thus shifts in 2 bits from above))

you would have to exchange the shifttables by self modifying code.
this is of course optimizable if you do several bytes at once in one row. (ldx rightcolumnbyte,y is ldx leftcolumnbyte,y of the next byte, so no need to load it again)

Selfmodifying code is the key.. And unrolling the innerloops of course! If you target the C16 most probably other people may help you, I think many of these games just shift the sprites when needed, but others know more about that.

Xeo3 uses some sort of sprite caching which is a plus if the same spritegraphic is shown on consecutive frames. So you only shift the graphics once and use it again if needed.


Whats also good is to never save the background of the sprites, instead repaint the graphics from the tilemap behind the sprites.. If you would save the background you would need to draw them one after another but clear them in reverse order, and most of the times this approach is probably slower..

If you do charmode it's good if the sprites only use the 3 frozen colors ($ff15,$ff16,$ff17) so you avoid colorclashes. In bitmap mode sprite painting is a lot of another field, there other rules apply.. But the easy way is of course also possible in bitmap mode, but it gets very slow if you don't use tricks there.

If I remember right Pets Rescues Routine can do 6-8 24x32 sprites in 50Hz.. Xeo3 probably even more.. So actually many big sprites are no problem for this machine.

I don't know anything about what people used in the past like all the other pro people here, most of them know more about "popular techniques". Maybe other people will help you more..

Happy coding!



Back to top


Copyright © Plus/4 World Team, 2001-2024