dynamically change pixel sprite

SGDK only sub forum

Moderator: Stef

Post Reply
Nainain
Interested
Posts: 14
Joined: Sat Oct 11, 2014 3:34 pm

dynamically change pixel sprite

Post by Nainain » Thu Oct 15, 2015 3:50 pm

Hi all,

To do some effects (sinus deformations, rotate, blur, zoom ... ) i would change dynamically the pixels sprite datas on runtime ...
what method ?
have you a simple sample code ?

Thanks

mikejmoffitt
Very interested
Posts: 86
Joined: Fri Sep 25, 2015 4:16 pm

Re: dynamically change pixel sprite

Post by mikejmoffitt » Thu Oct 15, 2015 11:04 pm

I don't know if SGDK has a function for it, but in the end what you're doing is writing to VRAM, and your sprites will show the relevant tiles.

If you are doing software rendering you should keep a buffer in 68k memory, draw to it, then DMA it to a location in VRAM.

I think SGDK provides bitmap functions (bitmap.h). Because of how memory is organized, by the way, you will want to use multiple 1-cell height sprites instead of any taller ones, because otherwise you're going to have to mangle the arrangement of the tiles in VRAM.

Be sure you aren't doing too many effects like this. All of those effects you described will be extremely slow. If you can pre-calculate them, you should.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: dynamically change pixel sprite

Post by Stef » Fri Oct 16, 2015 8:37 am

When you want to do some pixel based effects (rotation, blur, ...) i highly recommend you to use the SGDK bitmap engine :
https://github.com/Stephane-D/SGDK/blob ... /inc/bmp.h

Everything is done in software as natively the megadrive does not support bitmap mode.
Note that for performance and memory limitation reasons the bitmap resolution is limited to 256x160 and just blitting the bitmap buffer to VRAM will not allow more than 20 FPS on NTSC and 25 FPS on PAL.

Nainain
Interested
Posts: 14
Joined: Sat Oct 11, 2014 3:34 pm

Re: dynamically change pixel sprite

Post by Nainain » Fri Oct 16, 2015 8:54 am

Thx guys

Post Reply