I would like to get a sprite engine that à saw on youtube :
Is there anyone who knows or owns the source code ?
I think its very interessant to make an Isometric Game or a platform game.
Re: double buffered sprite engine ?
Posted: Sat Aug 22, 2020 7:38 pm
by Iapetus
Hello,
Unfortunately I have not published any code of mine yet.
The sprite engine does this basically:
- restore background for each sprite
- save background for each sprite
- paint the masked sprites (pixel data and masks are already pre-shifted in RAM)
- copy buffer to screen
- calculate sprite data(where to paint sprite, which gfx and mask to use etc)
- repeat
You can make it faster by having an extra buffer with the background and then you don't need the "save background" step. Also in my latest version of the sprite engine which is quite faster than this one I copy only what moved on the buffer so I don't need to copy the whole buffer to the screen every time.
I hope this helps.
Re: double buffered sprite engine ?
Posted: Sat Aug 22, 2020 8:43 pm
by ibisum
Looks pretty smooth .. what did you mean by this, though?
>- paint the masked sprites (pixel data and masks are pre-shifted)
to 6-bits, or .. ?
Re: double buffered sprite engine ?
Posted: Sat Aug 22, 2020 9:12 pm
by Iapetus
ibisum wrote: ↑Sat Aug 22, 2020 8:43 pm
Looks pretty smooth .. what did you mean by this, though?
>- paint the masked sprites (pixel data and masks are pre-shifted)
to 6-bits, or .. ?
For each sprite I need to store in RAM the gfx and mask for 6 possible positions as we have 6 pixels per byte on the Oric (this allows the sprite to move at one pixel precision, if your sprites move at 2 pixel steps you need to store only 3 possible positions).
I am sorry I don't understand all of your response bc i don't speak very well in english. Do you speak french ?
If I understand, you precalculate all of 6 sprites position for each sprite before put in the sprite buffer ?. It must take much memory ?
In my example(joint file) i dont precalculate the sprite position but i use many tables of shift. That is generic for all graphic sprite.
I would like to understand and find the complete flowchart process of double buffering technical. I dont see on internet any technical information of this subjet.
Is it for one buffer of a sprite ? :
(1) clear the buffer -> (2) [put background in the buffer] -> (3) [put the mask in the buffer] -> (4) [put the sprite in the buffer] ->
(5) [copy the buffer to the visible screen at the sprite position(byte) ]
Re: double buffered sprite engine ?
Posted: Sun Aug 23, 2020 8:05 pm
by Iapetus
I am sorry although I can understand written formal French I can't explain this stuff en Français
I am not using a buffer for each sprite, I use a big buffer where I paint the game screen, with tiles, sprites, objects etc. And then I copy the the buffer to screen after finishing updating the buffer once per game loop. (The buffer in that video is a buffer bigger than the play area so it allows for sprite clipping and in that case I only copy the visible area)
I have written quite a lot about this in the forums... I am quite sure I even put some code in the SkoolDaze and OASIS (the engine I made to program Blake's7) dev forums.
For newer games, I moved to pre-rotated graphics. If your Sprite has different animation frames, you ar not wasting too much memory and it is faster.
I used tables for mirroring, but never for rotations.
Hope this helps. Keep us informed of your progress!
Re: double buffered sprite engine ?
Posted: Mon Aug 24, 2020 5:44 pm
by goyo
thank you all for this information
And Chema, do you generate automatically the mask of sprite with an specific algorithm? for example to convex or concave shape ...? infos store in 2 left bits ?
Re: double buffered sprite engine ?
Posted: Mon Aug 24, 2020 6:26 pm
by Dbug
goyo wrote: ↑Mon Aug 24, 2020 5:44 pm
thank you all for this information
And Chema, do you generate automatically the mask of sprite with an specific algorithm? for example to convex or concave shape ...? infos store in 2 left bits ?
Twilighte actually did some tests with that in his Times of Lore prototype, using the two unused bits to provide some crude masking information, but that did work well enough I believe.
Re: double buffered sprite engine ?
Posted: Mon Aug 24, 2020 11:15 pm
by Chema
goyo wrote: ↑Mon Aug 24, 2020 5:44 pm
thank you all for this information
And Chema, do you generate automatically the mask of sprite with an specific algorithm? for example to convex or concave shape ...? infos store in 2 left bits ?
Not really. I create both the graphic and mask manually (with some pixel paint program) and convert them to data to include in my sources.
Re: double buffered sprite engine ?
Posted: Wed Aug 26, 2020 10:54 am
by goyo
Iapetus wrote: ↑Sun Aug 23, 2020 8:05 pm
I am sorry although I can understand written formal French I can't explain this stuff en Français
I am not using a buffer for each sprite, I use a big buffer where I paint the game screen, with tiles, sprites, objects etc. And then I copy the the buffer to screen after finishing updating the buffer once per game loop. (The buffer in that video is a buffer bigger than the play area so it allows for sprite clipping and in that case I only copy the visible area)
Mmmm I'd say it depends. Using a screen size buffer will make rendering there faster (no coordinate adjustment or clipping needed), but you need more memory. Of course that is true only if you clear/draw/dump the areas that need updating.. This must be done with care to make it as fast as possible. Separate buffers may also.work well if done with care and avoid updating intersection areas more than once. Aome sort of dirty rectangles algorithm may do.
I used a single small buffer in Space:1999, but it was far from an optimal solution, as I failed to update the same area twice when sprites overlap.
In 1337 the whole play area is updated as everything changes, and it is a performance bottleneck.
In SkoolDaze, Oricium and Blake's7 I took a different approach, based on small tiles. The backbuffer in this case is just one tile, but they are updated only once and when really needed.
Re: double buffered sprite engine ?
Posted: Wed Aug 26, 2020 3:58 pm
by Iapetus
goyo wrote: ↑Wed Aug 26, 2020 10:54 am
Which is the fastest ? use a one screen size buffer for all sprites or many buffer of sprite size
I never used many small buffers I always use the big buffer and then I have two options, 1. I copy all the buffer to the screen at each game look iteration OR 2. I just copy what changed since the last game loop iteration. I find that the second option is faster BUT it depends of course, on the number and size of sprites, bullets(particles), objects, the speed(in pixels) the objects/sprites can move etc. You always have to assess which option will work the best, when coding for these old computers we must always make concessions.
Re: double buffered sprite engine ?
Posted: Mon Aug 31, 2020 6:07 pm
by goyo
In this following link i created an image to try to understand the display sprite process, is it the good algorithm that you used ? :